Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-10-10 16:41:38 +0000
committerStijn Buys <ingar@osirion.org>2008-10-10 16:41:38 +0000
commit02fcd22d8cde355aa898a8c6bb4773d9434b8e9a (patch)
tree9397f1f5b61a0978acadc4c15fd330ee7138c59b /src/ui/widget.cc
parent4331f5c17901f46693dcb5c2df96276f6851be25 (diff)
adds KeyPress, DevInfo and Stats widgets
Diffstat (limited to 'src/ui/widget.cc')
-rw-r--r--src/ui/widget.cc92
1 files changed, 60 insertions, 32 deletions
diff --git a/src/ui/widget.cc b/src/ui/widget.cc
index 4ff577c..b2c436d 100644
--- a/src/ui/widget.cc
+++ b/src/ui/widget.cc
@@ -71,6 +71,30 @@ Font const *Widget::font() const {
}
}
+void Widget::lower()
+{
+ if (!parent())
+ return;
+
+ Children::iterator it = parent()->find_child(this);
+ if (it != parent()->children().end()) {
+ parent()->children().erase(it);
+ parent()->children().push_front(this);
+ }
+}
+
+void Widget::raise()
+{
+ if (!parent())
+ return;
+
+ Children::iterator it = parent()->find_child(this);
+ if (it != parent()->children().end()) {
+ parent()->children().erase(it);
+ parent()->children().push_back(this);
+ }
+}
+
void Widget::show()
{
widget_visible = true;
@@ -81,6 +105,12 @@ void Widget::hide()
widget_visible = false;
}
+
+void Widget::set_visible(bool visible)
+{
+ widget_visible = visible;
+}
+
void Widget::set_border(bool border)
{
widget_border = border;
@@ -122,6 +152,11 @@ void Widget::set_size(float const w, float const h)
widget_size.assign(w, h);
}
+void Widget::set_size(math::Vector2f const &size)
+{
+ widget_size.assign(size);
+}
+
void Widget::set_width(float const w)
{
widget_size.x = w;
@@ -159,30 +194,6 @@ void Widget::remove_child(Widget *child)
}
}
-void Widget::raise()
-{
- if (!parent())
- return;
-
- Children::iterator it = find_child(this);
- if (it != parent()->children().end()) {
- parent()->children().erase(it);
- parent()->children().push_front(this);
- }
-}
-
-void Widget::lower()
-{
- if (!parent())
- return;
-
- Children::iterator it = find_child(this);
- if (it != parent()->children().end()) {
- parent()->children().erase(it);
- parent()->children().push_back(this);
- }
-}
-
void Widget::event_resize()
{
resize();
@@ -231,7 +242,7 @@ void Widget::draw_border()
paint::border(global_location(), size());
}
-Widget *Widget::find_focus(math::Vector2f const & pos)
+Widget *Widget::event_focus(math::Vector2f const & pos)
{
// this widget is not visible
if (!visible())
@@ -245,7 +256,7 @@ Widget *Widget::find_focus(math::Vector2f const & pos)
for (Children::reverse_iterator rit = widget_children.rbegin(); rit != widget_children.rend(); ++rit) {
Widget *w = (*rit);
if (w->visible()) {
- Widget *f = w->find_focus(pos - w->location());
+ Widget *f = w->event_focus(pos - w->location());
if (f)
return f;
}
@@ -261,13 +272,30 @@ bool Widget::has_focus() const
return (root()->focus() == this);
}
-void Widget::mousemove(float x, float y)
-{}
+bool Widget::event_key(bool pressed, unsigned int key, unsigned int modifier)
+{
+ bool handled;
+
+ if (pressed) {
+ handled = keypress(key, modifier);
+ } else {
+ handled = keyrelease(key, modifier);
+ }
-void Widget::keypress(unsigned int key, unsigned int modifier)
-{}
+ if (!handled && parent())
+ handled = parent()->event_key(pressed, key, modifier);
-void Widget::keyrelease(unsigned int key, unsigned int modifier)
-{}
+ return handled;
+}
+
+bool Widget::keypress(unsigned int key, unsigned int modifier)
+{
+ return false;
+}
+
+bool Widget::keyrelease(unsigned int key, unsigned int modifier)
+{
+ return false;
+}
}