]> icculus.org git repositories - divverent/nexuiz.git/blob - data/menuqc/control/window/arrangement.qc
rename menu directories
[divverent/nexuiz.git] / data / menuqc / control / window / arrangement.qc
1 // DP/Nex Menu
2 // control/window/composition.qc
3
4 /*
5 ===================
6 Item_Arrangement_CalculateSize
7 ===================
8 */
9 void() Item_Arrangement_CalculateSize =
10 {
11         local vector lMin;
12         local vector lMax;
13         local entity lChild;
14
15         // TODO: this is garbage, fix this
16         lMax = '0 0 0';
17         lMin_x = INFINITY;
18         lMin_y = INFINITY;
19         for( lChild = self._child ; lChild ; lChild = lChild._next ) {
20                 if( Menu_HasRunFlag( lChild, RUNFLAG_HIDDEN ) )
21                         continue;
22
23                 lMin_x = min( lMin_x, lChild.pos_x );
24                 lMin_y = min( lMin_y, lChild.pos_y );
25                 lMax_x = max( lMax_x, lChild.pos_x + lChild.size_x );
26                 lMax_y = max( lMax_y, lChild.pos_y + lChild.size_y );
27         }
28         self.size = lMax - lMin;
29 };
30
31 /*
32 ===================
33 Item_Arrangement_Update
34 ===================
35 */
36 void() Item_Arrangement_Update =
37 {
38         Item_Layout_Update();
39
40         Item_Arrangement_CalculateSize();
41
42         if( self.direction_x ) {
43                 if( self.alignment == ITEM_ALIGN_LEFT )
44                         self.origin_y = 0;
45                 else if( self.alignment == ITEM_ALIGN_CENTER || self.alignment == ITEM_ALIGN_FIRST )
46                         self.origin_y = self.size_y / 2;
47                 else
48                         self.origin_y = self.size_y;
49         } else
50                 self.origin_y = 0;
51         if( self.direction_y ) {
52                 if( self.alignment == ITEM_ALIGN_LEFT )
53                         self.origin_x = 0;
54                 else if( self.alignment == ITEM_ALIGN_CENTER || self.alignment == ITEM_ALIGN_FIRST )
55                         self.origin_x = self.size_x / 2;
56                 else
57                         self.origin_x = self.size_x;
58         } else
59                 self.origin_x = 0;
60 };
61
62 /*
63 ===================
64 Item_Arrangement_Spawn
65 ===================
66 */
67 void() Item_Arrangement_Spawn =
68 {
69         Item_Layout_Spawn();
70
71         Item_Arrangement_Update();
72
73         self._update = Item_Arrangement_Update;
74 };
75
76