From 2ccf933af280efc249b47728b3b3fd6cf1beb90f Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 31 Aug 2013 17:04:24 +0000 Subject: Use a different cursor for clickable ui elements. --- src/client/galaxymapwidget.cc | 2 +- src/client/mapwidget.cc | 2 +- src/ui/button.cc | 6 ++++++ src/ui/iconbutton.cc | 8 +++++++- src/ui/listitem.cc | 9 ++++++++- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/client/galaxymapwidget.cc b/src/client/galaxymapwidget.cc index 0cc04af..2a95c61 100644 --- a/src/client/galaxymapwidget.cc +++ b/src/client/galaxymapwidget.cc @@ -161,7 +161,7 @@ void GalaxyMapWidget::draw() if (has_mouse_focus()) { if (galaxymapwidget_hover_id) - ui::root()->set_pointer("target", ui::Palette::Active, true); + ui::root()->set_pointer("action", ui::Palette::Highlight); } } diff --git a/src/client/mapwidget.cc b/src/client/mapwidget.cc index 0a4ec72..c7d986b 100644 --- a/src/client/mapwidget.cc +++ b/src/client/mapwidget.cc @@ -226,7 +226,7 @@ void MapWidget::draw() if (has_mouse_focus()) { if (mapwidget_hover_id) - ui::root()->set_pointer("target", ui::Palette::Active, true); + ui::root()->set_pointer("action", ui::Palette::Highlight); } } diff --git a/src/ui/button.cc b/src/ui/button.cc index cba7732..e9a40b9 100644 --- a/src/ui/button.cc +++ b/src/ui/button.cc @@ -11,6 +11,7 @@ #include "core/application.h" #include "core/commandbuffer.h" #include "sys/sys.h" +#include "ui/ui.h" #include "ui/paint.h" #include "ui/button.h" @@ -84,7 +85,12 @@ void Button::draw() } else { Paint::set_color(palette()->foreground()); } + Paint::draw_label(global_location(), size(), font(), text(), alignment()); + + if (enabled() && has_mouse_focus()) { + root()->set_pointer("action", Palette::Highlight); + } } bool Button::on_keypress(const int key, const unsigned int modifier) diff --git a/src/ui/iconbutton.cc b/src/ui/iconbutton.cc index 22a7c14..066f5fa 100644 --- a/src/ui/iconbutton.cc +++ b/src/ui/iconbutton.cc @@ -11,6 +11,7 @@ #include "core/application.h" #include "core/commandbuffer.h" #include "sys/sys.h" +#include "ui/ui.h" #include "ui/paint.h" #include "ui/iconbutton.h" @@ -83,6 +84,11 @@ void IconButton::draw() } Paint::draw_bitmap(global_location(), size(), color, icon()); + + if (enabled() && has_mouse_focus()) { + root()->set_pointer("action", Palette::Highlight); + } + } void IconButton::draw_border() @@ -95,7 +101,7 @@ void IconButton::draw_border() t = 1 - t; color.a = 0.5f + t; Paint::set_color(color); - Paint::draw_border(global_location(), size()); + Paint::draw_border(global_location(), size()); } } diff --git a/src/ui/listitem.cc b/src/ui/listitem.cc index a5d033a..634cbaf 100644 --- a/src/ui/listitem.cc +++ b/src/ui/listitem.cc @@ -7,6 +7,7 @@ #include "audio/audio.h" #include "core/application.h" #include "ui/listitem.h" +#include "ui/ui.h" #include "ui/paint.h" namespace ui { @@ -25,7 +26,7 @@ ListItem::~ListItem() { void ListItem::draw_border() { - if (has_mouse_focus()) { + if (enabled() && has_mouse_focus()) { math::Color color(palette()->foreground()); float t = core::application()->time(); t = t - floorf(t); @@ -54,7 +55,13 @@ void ListItem::draw() } else { Paint::set_color(palette()->foreground()); } + Paint::draw_label(global_location(), size(), font(), text(), alignment()); + + if (enabled() && has_mouse_focus()) { + root()->set_pointer("action", Palette::Highlight); + } + } void ListItem::on_mouseover(const math::Vector2f &cursor) -- cgit v1.2.3