]> git.tdb.fi Git - libs/gltk.git/blob - source/mixedrows.cpp
Cache widget parts in meshes
[libs/gltk.git] / source / mixedrows.cpp
1 #include "mixedrows.h"
2
3 namespace Msp {
4 namespace GLtk {
5
6 MixedRows::MixedRows(bool u):
7         uniform_rows(u),
8         uniform_cols(false),
9         hgravity(-1),
10         hsplit(false),
11         vgravity(1),
12         vsplit(false),
13         first(true)
14 { }
15
16 void MixedRows::start_row(bool u)
17 {
18         uniform_cols = u;
19         first = true;
20         hgravity = -1;
21         hsplit = false;
22 }
23
24 void MixedRows::split_rows()
25 {
26         vgravity = -1;
27         vsplit = true;
28 }
29
30 void MixedRows::split_columns()
31 {
32         hgravity = 1;
33         hsplit = true;
34 }
35
36 Layout::Slot *MixedRows::create_slot(Widget &wdg)
37 {
38         Slot *slot = new Slot(*this, wdg);
39
40         slot->horiz_pack.gravity = hgravity;
41         slot->vert_pack.gravity = vgravity;
42
43         if(!first)
44         {
45                 Slot *prev = slots.back();
46                 if(!hsplit)
47                         slot->constraints.push_back(Constraint(RIGHT_OF, *prev));
48                 slot->constraints.push_back(Constraint(ALIGN_TOP, *prev));
49                 slot->constraints.push_back(Constraint(ALIGN_BOTTOM, *prev));
50                 if(uniform_cols)
51                         slot->constraints.push_back(Constraint(COPY_WIDTH, *prev));
52         }
53         else if(!slots.empty())
54         {
55                 Slot *prev = slots.back();
56                 if(!vsplit)
57                         slot->constraints.push_back(Constraint(BELOW, *prev));
58                 if(uniform_rows)
59                         slot->constraints.push_back(Constraint(COPY_HEIGHT, *prev));
60         }
61
62         first = false;
63         hsplit = false;
64         vsplit = false;
65
66         return slot;
67 }
68
69 } // namespace GLtk
70 } // namespace Msp