]> git.tdb.fi Git - libs/gltk.git/blob - source/column.cpp
d31544ab2627ed88c5fc529c733651257e49caf9
[libs/gltk.git] / source / column.cpp
1 #include "column.h"
2
3 namespace Msp {
4 namespace GLtk {
5
6 Column::Column(Layout &l):
7         Arrangement(l),
8         first(true),
9         split_here(false),
10         gravity(1)
11 { }
12
13 void Column::split()
14 {
15         split_here = true;
16         gravity = -1;
17 }
18
19 void Column::process_widget(Widget &wdg, Side side, bool aligned)
20 {
21         if(side==TOP)
22         {
23                 bool snug = (edges[BOTTOM].aligned && aligned && !split_here);
24                 add_constraint(wdg, (snug ? Layout::BELOW : Layout::FAR_BELOW), BOTTOM);
25                 if(first)
26                         edges[TOP].add(wdg, aligned);
27         }
28         else if(side==BOTTOM)
29                 next_bottom.add(wdg, (aligned && gravity<0));
30         else
31         {
32                 if(edges[side].aligned && aligned)
33                         add_constraint(wdg, (side==LEFT ? Layout::ALIGN_LEFT : Layout::ALIGN_RIGHT), side);
34                 edges[side].add(wdg, aligned);
35         }
36 }
37
38 void Column::finish_widget(Widget &wdg)
39 {
40         layout.set_gravity(wdg, -1, gravity);
41 }
42
43 void Column::finish_slot()
44 {
45         edges[BOTTOM] = next_bottom;
46         next_bottom.clear();
47         split_here = false;
48         first = false;
49 }
50
51
52 Column::Loader::Loader(Column &c):
53         DataFile::ObjectLoader<Column>(c)
54 {
55         add("split", &Loader::split);
56 }
57
58 void Column::Loader::split()
59 {
60         obj.split();
61 }
62
63 } // namespace GLtk
64 } // namespace Msp