Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2016-07-29 18:32:55 +0200
committerStijn Buys <ingar@osirion.org>2016-07-29 18:32:55 +0200
commit6f58c083caf6a14bccd708c73eaa0b4d66178ff1 (patch)
treea866465bdb428e0978b105cc0c1a938635bc0436 /src
parentc94e93337b778db7e024483f3f261dcef4bd19c5 (diff)
Minor code cleanups.
Diffstat (limited to 'src')
-rw-r--r--src/ui/iconbutton.cc26
-rw-r--r--src/ui/iconbutton.h13
2 files changed, 28 insertions, 11 deletions
diff --git a/src/ui/iconbutton.cc b/src/ui/iconbutton.cc
index 944ae6c..18bfb5a 100644
--- a/src/ui/iconbutton.cc
+++ b/src/ui/iconbutton.cc
@@ -41,9 +41,13 @@ void IconButton::print(const size_t indent) const
void IconButton::set_command(const char *command)
{
if (command)
+ {
iconbutton_command.assign(command);
+ }
else
+ {
iconbutton_command.clear();
+ }
}
void IconButton::set_command(const std::string &command)
@@ -54,9 +58,13 @@ void IconButton::set_command(const std::string &command)
void IconButton::set_icon(const char *icon)
{
if (icon)
+ {
iconbutton_icon.assign(icon);
+ }
else
+ {
iconbutton_icon.clear();
+ }
}
void IconButton::set_highlight(const bool highlight)
@@ -93,7 +101,9 @@ void IconButton::draw()
void IconButton::draw_border()
{
- if (enabled() && 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);
@@ -101,15 +111,21 @@ void IconButton::draw_border()
t = 1 - t;
color.a = 0.5f + t;
Paint::set_color(color);
- Paint::draw_border(global_location(), size());
+ } else {
+ Paint::set_color(palette()->border());
}
+
+ Paint::draw_border(global_location(), size());
}
bool IconButton::on_mousepress(const unsigned int button)
{
- if (button == SDL_BUTTON_LEFT) {
- if (enabled()) {
- if (iconbutton_command.size()) {
+ if (button == SDL_BUTTON_LEFT)
+ {
+ if (enabled())
+ {
+ if (iconbutton_command.size())
+ {
core::cmd() << iconbutton_command << std::endl;
}
audio::play("ui/clicked");
diff --git a/src/ui/iconbutton.h b/src/ui/iconbutton.h
index a7aee39..92e73ee 100644
--- a/src/ui/iconbutton.h
+++ b/src/ui/iconbutton.h
@@ -51,6 +51,13 @@ public:
/// print button description
virtual void print(const size_t indent) const;
+protected:
+ /// draw the button border
+ virtual void draw_border();
+
+ /// draw the button
+ virtual void draw();
+
/**
* @brief mouse over event handler
* */
@@ -61,12 +68,6 @@ public:
* */
virtual bool on_mousepress(const unsigned int button);
-protected:
- /// draw the button border
- virtual void draw_border();
-
- /// draw the button
- virtual void draw();
private:
std::string iconbutton_command;