Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 915ec9805147dbecc174c96c0dc32b166333c2df (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
/*
   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"
#include "ui/paint.h"
#include "ui/ui.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::~Container()
{
}

void Container::resize()
{
	float w = UI::elementsize.width() * 1.5f;
	float h = children().size() * (UI::elementsize.height() + UI::elementmargin) + UI::elementsize.height();
	set_size(w, h);

	const float x = UI::elementsize.width() * 0.25f;
	float y = UI::elementsize.height() * 0.5f;

	// reposition all children within the container
	for (Children::iterator it = children().begin(); it != children().end(); it++) {
		Widget *w = (*it);
		w->set_size(UI::elementsize);
		w->set_location(x, y);
		y += UI::elementsize.height() + UI::elementmargin;
	}
}


void Container::draw_border()
{
	if(focus()) {
		paint::color(palette()->foreground());
	} else {
		paint::color(palette()->border());
	}
	paint::border(global_location(), size());
}

}