diff options
author | Stijn Buys <ingar@osirion.org> | 2010-09-25 13:01:26 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2010-09-25 13:01:26 +0000 |
commit | aeef4449ce3c1bdc531fb90699fef68bd48ca644 (patch) | |
tree | 969c2ec24f382a6a75e01b1b3315dd9fe8f26d46 /src/ui | |
parent | 158706fac974527436a3167cfa94a7ea82070d41 (diff) |
trading bugfixes: corrects client side screen update issues
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/button.cc | 28 |
1 files changed, 18 insertions, 10 deletions
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"); + } } } |