Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/widget.cc')
-rw-r--r--src/ui/widget.cc40
1 files changed, 29 insertions, 11 deletions
diff --git a/src/ui/widget.cc b/src/ui/widget.cc
index 982b792..73c454a 100644
--- a/src/ui/widget.cc
+++ b/src/ui/widget.cc
@@ -9,6 +9,7 @@
#include "ui/paint.h"
#include "ui/ui.h"
#include "ui/widget.h"
+#include "ui/tooltip.h"
#include <cassert>
@@ -22,8 +23,9 @@ Widget::Widget(Widget *parent)
widget_border = true;
widget_background = false;
widget_enabled = true;
- widget_palette = 0;
- widget_font = 0;
+ widget_palette = nullptr;
+ widget_font = nullptr;
+ widget_tooltip = nullptr;
widget_label.assign("widget");
if (!parent) {
@@ -228,17 +230,33 @@ void Widget::set_label(const std::string & label)
widget_label.assign(label);
aux::to_label(widget_label);
}
-
+
void Widget::set_label(const char *label)
{
- if (label) {
+ if (label == nullptr)
+ {
+ widget_label.clear();
+ } else {
widget_label.assign(label);
aux::to_label(widget_label);
- } else {
- widget_label.clear();
}
}
+
+void Widget::set_tooltip(const std::string &tooltip_text)
+{
+ set_tooltip(tooltip_text.c_str());
+}
+
+void Widget::set_tooltip(const char *tooltip_text)
+{
+ if (widget_tooltip == nullptr)
+ {
+ widget_tooltip = new Tooltip(this);
+ }
+ widget_tooltip->set_text(tooltip_text);
+}
+
void Widget::set_palette(const Palette *palette)
{
widget_palette = palette;
@@ -300,7 +318,7 @@ Widget *Widget::next_sibling()
// find this widget in the parent's children
Children::iterator it = parent()->children().begin();
while (it != parent()->children().end() && ((*it) != this)) {
- it++;
+ it++;
}
// assert this widget is a child of its parent
@@ -384,17 +402,17 @@ Widget *Widget::find_visible_child(const Widget *widget)
return 0;
}
-Widget *Widget::find_mouse_focus(const math::Vector2f & pos)
+Widget *Widget::find_widget_in_location(const math::Vector2f & location)
{
// this widget is not visible
- if (!visible() || !size().contains(pos))
- return 0;
+ if (!visible() || !size().contains(location))
+ return nullptr;
// reverse-iterate children
for (Children::reverse_iterator rit = widget_children.rbegin(); rit != widget_children.rend(); ++rit) {
Widget *w = (*rit);
if (w->visible() && w->enabled()) {
- Widget *f = w->find_mouse_focus(pos - w->location());
+ Widget *f = w->find_widget_in_location(location - w->location());
if (f)
return f;
}