]> icculus.org git repositories - divverent/nexuiz.git/blob - data/menuqc/control/window/layout.qc
give menu source its own directory
[divverent/nexuiz.git] / data / menuqc / control / window / layout.qc
1 // DP/Nex Menu
2 // control/window/layout.qc
3
4 ////////////////
5 // Item_Layout
6 ///
7
8 /*
9 ===================
10 Item_Layout_Update
11 ===================
12 */
13 void() Item_Layout_Update =
14 {
15         local entity lChild;
16         local vector lCurrent;
17
18         lCurrent = '0.0 0.0 0.0';
19         for( lChild = self._child ; lChild ; lChild = lChild._next ) {
20                 if( Menu_HasRunFlag( lChild, RUNFLAG_HIDDEN ) )
21                         continue;
22
23                 if( self.direction_y ) {
24                         if( self.alignment == ITEM_ALIGN_FIRST && lChild._child )
25                                 lChild.pos_x = lCurrent_x - lChild._child.size_x;
26                         else if( self.alignment == ITEM_ALIGN_LEFT )
27                                 lChild.pos_x = lCurrent_x;
28                         else if( self.alignment == ITEM_ALIGN_CENTER )
29                                 lChild.pos_x = lCurrent_x - lChild.size_x / 2;
30                         else
31                                 lChild.pos_x = lCurrent_x - lChild.size_x;
32                 } else
33                         lChild.pos_x = lCurrent_x;
34
35                 if( self.direction_x ) {
36                         if( self.alignment == ITEM_ALIGN_LEFT )
37                                 lChild.pos_y = lCurrent_y;
38                         else if( self.alignment == ITEM_ALIGN_CENTER )
39                                 lChild.pos_y = lCurrent_y - lChild.size_y / 2;
40                         else if( self.alignment == ITEM_ALIGN_FIRST && lChild._child )
41                                 lChild.pos_y = lCurrent_y - lChild._child.size_y;
42                         else
43                                 lChild.pos_y = lCurrent_y - lChild.size_y;
44                 } else
45                         lChild.pos_y = lCurrent_y;
46
47                 if( self.direction_x )
48                         lCurrent_x += lChild.size_x + self.direction_x;
49                 else if( self.direction_y )
50                         lCurrent_y += lChild.size_y + self.direction_y;
51         }
52 };
53
54 /*
55 ===================
56 Item_Layout_Spawn
57 ===================
58 */
59 void() Item_Layout_Spawn =
60 {
61         Item_Window_Spawn();
62
63         Item_Layout_Update();
64
65         self._update = Item_Layout_Update;
66 };