Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorStijn Buys <ingar@telenet.be>2020-07-18 17:20:32 +0200
committerStijn Buys <ingar@telenet.be>2020-07-18 17:20:32 +0200
commit41ec4ed68571091f2e2500344a7aeb527a91dc92 (patch)
tree29584f1f2f949e73da749d2e2504799519a1c21a /src/ui
parentb19afea9427dde861c990236ab11e23edfeb267c (diff)
Added standard close button widget class, added tooltips where approriate.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/iconbutton.cc7
-rw-r--r--src/ui/iconbutton.h4
-rw-r--r--src/ui/tooltip.cc9
-rw-r--r--src/ui/tooltip.h7
4 files changed, 20 insertions, 7 deletions
diff --git a/src/ui/iconbutton.cc b/src/ui/iconbutton.cc
index 18bfb5a..c23ed66 100644
--- a/src/ui/iconbutton.cc
+++ b/src/ui/iconbutton.cc
@@ -18,14 +18,15 @@
namespace ui
{
-IconButton::IconButton(Widget *parent, const char *icon, const char *command) : Widget(parent)
+IconButton::IconButton(Widget *parent, const char *icon, const char *tooltip, const char *command) : Widget(parent)
{
set_label("iconbutton");
set_background(false);
set_border(false);
- set_command(command);
- set_icon(icon);
set_highlight(false);
+ set_icon(icon);
+ set_tooltip(tooltip);
+ set_command(command);
}
IconButton::~IconButton()
diff --git a/src/ui/iconbutton.h b/src/ui/iconbutton.h
index 92e73ee..0382e1a 100644
--- a/src/ui/iconbutton.h
+++ b/src/ui/iconbutton.h
@@ -15,8 +15,8 @@ namespace ui
class IconButton : public Widget
{
public:
- IconButton(Widget *parent, const char *icon = 0, const char *command = 0);
- ~IconButton();
+ IconButton(Widget *parent, const char *icon = 0, const char *tooltip = 0, const char *command = 0);
+ virtual ~IconButton();
/// the command this button executes
inline const std::string & command() const {
diff --git a/src/ui/tooltip.cc b/src/ui/tooltip.cc
index 95f1ac8..b1e8c3c 100644
--- a/src/ui/tooltip.cc
+++ b/src/ui/tooltip.cc
@@ -6,6 +6,7 @@
#include "ui/tooltip.h"
#include "ui/ui.h"
+#include "ui/paint.h"
#include <cassert>
@@ -32,9 +33,15 @@ void Tooltip::resize()
set_location((parent()->width() - width()) * 0.5f, parent()->height());
}
+void Tooltip::draw_background()
+{
+ Paint::draw_material(global_location(), size(), "ui/window");
+}
+
void Tooltip::draw()
{
- if (tooltip_global != this) {
+ if (tooltip_global != this)
+ {
hide();
} else {
Label::draw();
diff --git a/src/ui/tooltip.h b/src/ui/tooltip.h
index 2345973..0cfa12d 100644
--- a/src/ui/tooltip.h
+++ b/src/ui/tooltip.h
@@ -19,7 +19,7 @@ class Tooltip : public Label
{
public:
Tooltip(Widget *parent);
- ~Tooltip();
+ virtual ~Tooltip();
/**
* @brief resize the tooltip
@@ -51,6 +51,11 @@ class Tooltip : public Label
*/
virtual void draw();
+ /**
+ * @brief draw the tooltip background
+ */
+ virtual void draw_background();
+
private:
static Tooltip *tooltip_global;