summaryrefslogtreecommitdiff
path: root/gui.cpp
blob: 72275c8f2a50953dccc08bb496601e7a1bab7dc4 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "gui.h"
#include "video.h"

#include <boost/format.hpp>
#include <RendererModules/OpenGL/CEGUIOpenGLRenderer.h>

using namespace CEGUI;

CEGUI::Window *GUI::root = NULL;
void GUI::init() {
	OpenGLRenderer::bootstrapSystem();

	DefaultResourceProvider* rp = static_cast<DefaultResourceProvider*>
		(System::getSingleton().getResourceProvider());

	rp->setResourceGroupDirectory("schemes", "GUI/");
	rp->setResourceGroupDirectory("imagesets", "GUI/");
	rp->setResourceGroupDirectory("fonts", "fonts/");
	rp->setResourceGroupDirectory("layouts", "GUI/layouts/");
	rp->setResourceGroupDirectory("looknfeels", "GUI/");

	Imageset::setDefaultResourceGroup("imagesets");
	Font::setDefaultResourceGroup("fonts");
	Scheme::setDefaultResourceGroup("schemes");
	WidgetLookManager::setDefaultResourceGroup("looknfeels");
	WindowManager::setDefaultResourceGroup("layouts");

	SchemeManager::getSingleton().create( "VanillaSkin.scheme" );

	FontManager::getSingleton().create("VeraMono.font");

	System::getSingleton().setDefaultFont( "VeraMono" );
	System::getSingleton().setDefaultMouseCursor( "Vanilla-Images", "MouseArrow" );

	WindowManager& wmgr(WindowManager::getSingleton());

	root = wmgr.createWindow("DefaultWindow", "root");
	System::getSingleton().setGUISheet(root);
}

void GUI::render() {
	/* Disable depth testing to avoid cursor bugginess. */
	glDisable(GL_DEPTH_TEST);
	System::getSingleton().renderGUI();
	glEnable(GL_DEPTH_TEST);
}

/* RaiseWindow */

/* default values */
float RaiseWindow::radius = 5;
float RaiseWindow::focus = .8;
float RaiseWindow::strength = .3;

RaiseWindow::RaiseWindow() {
	WindowManager& wmgr(WindowManager::getSingleton());

	wnd = static_cast<FrameWindow*>(wmgr.loadWindowLayout("raisewnd.layout"));
	root->addChildWindow(wnd);

	radius_sb = static_cast<Scrollbar*>(wmgr.getWindow("radius_sb"));
	radius_sb_lbl = wmgr.getWindow("radius_sb_lbl");
	focus_sb = static_cast<Scrollbar*>(wmgr.getWindow("focus_sb"));
	focus_sb_lbl = wmgr.getWindow("focus_sb_lbl");
	strength_sb = static_cast<Scrollbar*>(wmgr.getWindow("strength_sb"));
	strength_sb_lbl = wmgr.getWindow("strength_sb_lbl");

	/* load default/last used values */
	radius_sb->setScrollPosition(radius);
	focus_sb->setScrollPosition(focus);
	strength_sb->setScrollPosition(strength);
}

RaiseWindow::~RaiseWindow() {
	/* store current values */
	radius = get_radius();
	focus = get_focus();
	strength = get_strength();

	WindowManager& wmgr(WindowManager::getSingleton());
	wmgr.destroyWindow(wnd);
	wmgr.cleanDeadPool();
}

void RaiseWindow::render() {
	radius_sb_lbl->setText((boost::format("%.2f") % radius_sb->getScrollPosition()).str().c_str());
	focus_sb_lbl->setText((boost::format("%.2f") % focus_sb->getScrollPosition()).str().c_str());
	strength_sb_lbl->setText((boost::format("%.2f") % strength_sb->getScrollPosition()).str().c_str());

	GUI::render();
}

float RaiseWindow::get_radius() {
	return radius_sb->getScrollPosition();
}

float RaiseWindow::get_focus() {
	return focus_sb->getScrollPosition();
}

float RaiseWindow::get_strength() {
	return strength_sb->getScrollPosition();
}