From b417df720584c101f3799874a0c836a543a8d0a8 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 12 Oct 2008 14:55:10 +0000 Subject: user interface updates, work-in-progress --- src/ui/button.cc | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'src/ui/button.cc') diff --git a/src/ui/button.cc b/src/ui/button.cc index 1ac5fd8..08fd0e9 100644 --- a/src/ui/button.cc +++ b/src/ui/button.cc @@ -11,9 +11,10 @@ #include "ui/button.h" #include "core/commandbuffer.h" -namespace ui { +namespace ui +{ -Button::Button (Widget *parent, const char *text, const char *command) : Label(parent, text) +Button::Button(Widget *parent, const char *text, const char *command) : Label(parent, text) { set_label("button"); set_command(command); @@ -24,7 +25,7 @@ Button::~Button() { } -void Button::print(size_t indent) +void Button::print(const size_t indent) const { std::string marker(""); con_print << aux::pad_left(marker, indent*2) << label() << " \"" << text() << "\" \"" << command() << "\"" << std::endl; @@ -38,7 +39,7 @@ void Button::set_command(const char *command) button_command.clear(); } -void Button::set_command(std::string const &command) +void Button::set_command(const std::string &command) { button_command.assign(command); } @@ -47,12 +48,12 @@ void Button::draw_border() { if (!border()) return; - - if (has_focus()) + + if (has_mouse_focus()) paint::color(palette()->foreground()); else paint::color(palette()->border()); - + paint::border(global_location(), size()); } @@ -60,29 +61,34 @@ void Button::draw_text() { if (!text().size()) return; - - if (has_focus()) + + if (has_mouse_focus()) paint::color(palette()->highlight()); else paint::color(palette()->foreground()); - + paint::text(global_location(), size(), font(), text(), alignment()); } -bool Button::keypress(unsigned int key, unsigned int modifier) +bool Button::on_keypress(const int key, const unsigned int modifier) { return false; } -bool Button::keyrelease(unsigned int key, unsigned int modifier) +bool Button::on_keyrelease(const int key, const unsigned int modifier) { if (key == 512 + SDL_BUTTON_LEFT) { core::cmd() << button_command << std::endl; audio::play("ui/button"); return true; } - + return false; } +void Button::on_mouseover(const math::Vector2f &cursor) +{ + audio::play("ui/select"); +} + } -- cgit v1.2.3