xref: /haiku/src/kits/interface/Alignment.cpp (revision 55b40aa53a835472ec7952b138ae4256203d02e4)
1 /*
2  * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 
6 #include <Alignment.h>
7 
8 // RelativeHorizontal
9 float
10 BAlignment::RelativeHorizontal() const
11 {
12 	switch (horizontal) {
13 		case B_ALIGN_LEFT:
14 			return 0;
15 		case B_ALIGN_RIGHT:
16 			return 1;
17 		case B_ALIGN_HORIZONTAL_CENTER:
18 			return 0.5f;
19 
20 		default:
21 			return (float)horizontal;
22 	}
23 }
24 
25 // RelativeVertical
26 float
27 BAlignment::RelativeVertical() const
28 {
29 	switch (vertical) {
30 		case B_ALIGN_TOP:
31 			return 0;
32 		case B_ALIGN_BOTTOM:
33 			return 1;
34 		case B_ALIGN_VERTICAL_CENTER:
35 			return 0.5f;
36 
37 		default:
38 			return (float)vertical;
39 	}
40 }
41