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>2009-05-10 15:33:16 +0000
committerStijn Buys <ingar@osirion.org>2009-05-10 15:33:16 +0000
commitb3083a4fe57cc99c6972180a40091001cb209ad7 (patch)
tree52552b1fc62ff361867a7171404e5c5bd9e52917 /src/ui/iconbutton.cc
parent3dde787b2546958072e8a98350335b2bab6d1c17 (diff)
added disabled ui palette color, added dock and launch buttons
Diffstat (limited to 'src/ui/iconbutton.cc')
-rw-r--r--src/ui/iconbutton.cc29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/ui/iconbutton.cc b/src/ui/iconbutton.cc
index 1999072..2c4661e 100644
--- a/src/ui/iconbutton.cc
+++ b/src/ui/iconbutton.cc
@@ -21,9 +21,10 @@ IconButton::IconButton(Widget *parent, const char *icon, const char *command) :
{
set_label("iconbutton");
set_background(false);
- set_border(true);
+ set_border(false);
set_command(command);
set_icon(icon);
+ iconbutton_enabled = true;
}
IconButton::~IconButton()
@@ -62,22 +63,35 @@ void IconButton::set_icon(const std::string &icon)
iconbutton_icon.assign(icon);
}
+void IconButton::enable(bool enabled)
+{
+ iconbutton_enabled = enabled;
+}
+
+void IconButton::disable(bool disabled)
+{
+ iconbutton_enabled = !disabled;
+}
+
void IconButton::draw()
{
if (!icon().size())
return;
-
- if (has_mouse_focus())
+
+ if (disabled()) {
+ paint::color(palette()->disabled());
+ } else if (has_mouse_focus()) {
paint::color(palette()->highlight());
- else
+ } else {
paint::color(palette()->foreground());
+ }
paint::bitmap(location(), size(), icon());
}
void IconButton::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);
@@ -92,7 +106,7 @@ void IconButton::draw_border()
bool IconButton::on_keypress(const int key, const unsigned int modifier)
{
if (key == 512 + SDL_BUTTON_LEFT) {
- if (iconbutton_command.size()) {
+ if (enabled() && iconbutton_command.size()) {
core::cmd() << iconbutton_command << std::endl;
audio::play("ui/button");
}
@@ -109,7 +123,8 @@ bool IconButton::on_keyrelease(const int key, const unsigned int modifier)
void IconButton::on_mouseover(const math::Vector2f &cursor)
{
- audio::play("ui/select");
+ if (enabled())
+ audio::play("ui/select");
}
}