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-07 17:14:27 +0000
committerStijn Buys <ingar@osirion.org>2008-10-07 17:14:27 +0000
commitf54bd48a884e4e3c95818f042a4b2418a6e070a4 (patch)
tree73e82729a2f97b58e94ffd6944ac1ad47bf8314e /src/ui/widget.cc
parentf8d1ee921c83b7b148883b3ee16e4ec9c776d6db (diff)
working button click
Diffstat (limited to 'src/ui/widget.cc')
-rw-r--r--src/ui/widget.cc48
1 files changed, 44 insertions, 4 deletions
diff --git a/src/ui/widget.cc b/src/ui/widget.cc
index 068d60f..506d1e7 100644
--- a/src/ui/widget.cc
+++ b/src/ui/widget.cc
@@ -7,6 +7,7 @@
#include "auxiliary/functions.h"
#include "render/primitives.h"
#include "sys/sys.h"
+#include "ui/ui.h"
#include "ui/widget.h"
namespace ui {
@@ -134,11 +135,11 @@ void Widget::remove_child(Widget *child)
}
}
-void Widget::resize_event()
+void Widget::event_resize()
{
resize();
for (Children::iterator it = widget_children.begin(); it != widget_children.end(); it++) {
- (*it)->resize_event();
+ (*it)->event_resize();
}
}
@@ -146,7 +147,7 @@ void Widget::resize()
{
}
-void Widget::draw_event()
+void Widget::event_draw()
{
if (!widget_visible)
return;
@@ -154,7 +155,7 @@ void Widget::draw_event()
draw();
for (Children::iterator it = widget_children.begin(); it != widget_children.end(); it++) {
if ((*it)->visible())
- (*it)->draw_event();
+ (*it)->event_draw();
}
}
@@ -184,4 +185,43 @@ void Widget::draw_border()
render::primitives::border(global_location(), size());
}
+Widget *Widget::find_focus(math::Vector2f const & pos)
+{
+ // this widget is not visible
+ if (!visible())
+ return 0;
+
+ // pos is outside this
+ if ((pos.x < 0) || (pos.y < 0) || (pos.x > size().x) || (pos.y > size().y))
+ return 0;
+
+ // reverse-iterate children
+ 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());
+ if (f)
+ return f;
+ }
+
+ }
+
+ // no child has focus
+ return this;
+}
+
+bool Widget::has_focus() const
+{
+ return (root()->focus() == this);
+}
+
+void Widget::event_mousecursor(float x, float y)
+{}
+
+void Widget::event_keypress(unsigned int key, unsigned int modifier)
+{}
+
+void Widget::event_keyrelease(unsigned int key, unsigned int modifier)
+{}
+
}