blob: d5442444964672427a9cff1677b217a149699fa7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/*
ui/container.cc
This file is part of the Osirion project and is distributed under
the terms of the GNU General Public License version 2
*/
#include "ui/container.h"
namespace ui
{
// TODO Container::direction
Container::Container(Widget *parent) : Window(parent)
{
set_label("container");
set_border(false);
set_border(true);
set_background(true);
container_childsize.assign(256, 48);
container_margin = 24;
}
Container::~Container()
{
}
void Container::resize()
{
float w = container_childsize.width() * 1.5f;
float h = children().size() * container_childsize.height() + (children().size()+1) * container_margin;
set_size(w, h);
const float x = container_childsize.width() * 0.25f;
float y = container_margin;
// reposition all children within the container
for (Children::iterator it = children().begin(); it != children().end(); it++) {
Widget *w = (*it);
w->set_size(container_childsize);
w->set_location(x, y);
y += container_childsize.height() + container_margin;
}
}
void Container::set_childsize(const float w, const float h)
{
container_childsize.assign(w, h);
}
void Container::set_margin(const float margin)
{
container_margin = margin;
}
}
|