diff options
author | Stijn Buys <ingar@telenet.be> | 2020-07-18 14:49:13 +0200 |
---|---|---|
committer | Stijn Buys <ingar@telenet.be> | 2020-07-18 14:49:13 +0200 |
commit | b19afea9427dde861c990236ab11e23edfeb267c (patch) | |
tree | 6f87e57196649ebe8ba6e2945a82f48bcee1c3d1 /src/ui/widget.cc | |
parent | 094ac735e16ad94c12bc1d866253f1c1d84a9af6 (diff) |
Completed ui library tooltip implementation.
Diffstat (limited to 'src/ui/widget.cc')
-rw-r--r-- | src/ui/widget.cc | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/ui/widget.cc b/src/ui/widget.cc index 8c40c04..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) { @@ -241,19 +243,18 @@ void Widget::set_label(const char *label) } -void Widget::set_tooltip(const std::string &tooltip) +void Widget::set_tooltip(const std::string &tooltip_text) { - widget_tooltip.assign(tooltip); + set_tooltip(tooltip_text.c_str()); } -void Widget::set_tooltip(const char *tooltip) +void Widget::set_tooltip(const char *tooltip_text) { - if (tooltip == nullptr) + if (widget_tooltip == nullptr) { - widget_tooltip.clear(); - } else { - widget_label.assign(tooltip); + widget_tooltip = new Tooltip(this); } + widget_tooltip->set_text(tooltip_text); } void Widget::set_palette(const Palette *palette) |