From aeef4449ce3c1bdc531fb90699fef68bd48ca644 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 25 Sep 2010 13:01:26 +0000 Subject: trading bugfixes: corrects client side screen update issues --- src/ui/button.cc | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src/ui') diff --git a/src/ui/button.cc b/src/ui/button.cc index 95158a2..ddcc72d 100644 --- a/src/ui/button.cc +++ b/src/ui/button.cc @@ -49,7 +49,9 @@ void Button::set_command(const std::string &command) void Button::draw_border() { - if (has_mouse_focus()) { + if (disabled()) { + Paint::set_color(palette()->disabled()); + } else if (has_mouse_focus()) { math::Color color(palette()->foreground()); float t = core::application()->time(); t = t - floorf(t); @@ -57,8 +59,9 @@ void Button::draw_border() t = 1 - t; color.a = 0.5f + t; Paint::set_color(color); - } else + } else { Paint::set_color(palette()->border()); + } Paint::draw_border(global_location(), size()); } @@ -68,22 +71,25 @@ void Button::draw() if (!text().size()) return; - if (has_mouse_focus()) + if (disabled()) { + Paint::set_color(palette()->disabled()); + } else if (has_mouse_focus()) { Paint::set_color(palette()->highlight()); - else + } else { Paint::set_color(palette()->foreground()); - + } Paint::draw_label(global_location(), size(), font(), text(), alignment()); } bool Button::on_keypress(const int key, const unsigned int modifier) { if (key == 512 + SDL_BUTTON_LEFT) { - core::cmd() << button_command << std::endl; - audio::play("ui/button"); - - emit(EventButtonClicked); + if (enabled()) { + core::cmd() << button_command << std::endl; + audio::play("ui/button"); + emit(EventButtonClicked); + } return true; } @@ -97,7 +103,9 @@ bool Button::on_keyrelease(const int key, const unsigned int modifier) void Button::on_mouseover(const math::Vector2f &cursor) { - audio::play("ui/select"); + if (enabled()) { + audio::play("ui/select"); + } } } -- cgit v1.2.3