Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-10-12 14:55:10 +0000
committerStijn Buys <ingar@osirion.org>2008-10-12 14:55:10 +0000
commitb417df720584c101f3799874a0c836a543a8d0a8 (patch)
treefb7105ed662f13753a6ab8d3efb047bad04f2316 /src/ui/button.cc
parent18383a5fc596bf9546f14d7393ee66c57720b116 (diff)
user interface updates, work-in-progress
Diffstat (limited to 'src/ui/button.cc')
-rw-r--r--src/ui/button.cc32
1 files changed, 19 insertions, 13 deletions
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");
+}
+
}