]> git.tdb.fi Git - libs/gltk.git/blob - source/row.cpp
Replace the derived layout classes with a more flexible design
[libs/gltk.git] / source / row.cpp
1 #include "row.h"
2
3 namespace Msp {
4 namespace GLtk {
5
6 Row::Row(Layout &l):
7         Arrangement(l),
8         first(true),
9         split_here(false),
10         gravity(-1)
11 { }
12
13 void Row::split()
14 {
15         split_here = true;
16         gravity = 1;
17 }
18
19 void Row::process_widget(Widget &wdg, Side side, bool aligned)
20 {
21         if(side==LEFT)
22         {
23                 bool snug = (edges[RIGHT].aligned && aligned && !split_here);
24                 add_constraint(wdg, (snug ? Layout::RIGHT_OF : Layout::FAR_RIGHT_OF), RIGHT);
25                 if(first)
26                         edges[LEFT].add(wdg, aligned);
27         }
28         else if(side==RIGHT)
29                 next_right.add(wdg, (aligned && gravity>0));
30         else
31         {
32                 if(edges[side].aligned && aligned)
33                         add_constraint(wdg, (side==TOP ? Layout::ALIGN_TOP : Layout::ALIGN_BOTTOM), side);
34                 edges[side].add(wdg, aligned);
35         }
36 }
37
38 void Row::finish_widget(Widget &wdg)
39 {
40         layout.set_gravity(wdg, gravity, 1);
41 }
42
43 void Row::finish_slot()
44 {
45         edges[RIGHT] = next_right;
46         next_right.clear();
47         split_here = false;
48         first = false;
49 }
50
51 } // namespace GLtk
52 } // namespace Msp