From 75906b43ecb9a04fdab365bd8b1a00fbdbc66918 Mon Sep 17 00:00:00 2001
From: Stijn Buys <ingar@osirion.org>
Date: Sun, 3 Oct 2010 19:57:17 +0000
Subject: ui updates, removed impulse and jumpgte g_devel conditions, jumpdrive
 crash bugfix

---
 src/ui/iconbutton.cc | 17 ++++++-----------
 src/ui/iconbutton.h  | 24 ++++++++----------------
 src/ui/widget.cc     |  1 +
 src/ui/widget.h      | 34 +++++++++++++++++-----------------
 4 files changed, 32 insertions(+), 44 deletions(-)

(limited to 'src/ui')

diff --git a/src/ui/iconbutton.cc b/src/ui/iconbutton.cc
index 87203ee..204918e 100644
--- a/src/ui/iconbutton.cc
+++ b/src/ui/iconbutton.cc
@@ -24,7 +24,7 @@ IconButton::IconButton(Widget *parent, const char *icon, const char *command) :
 	set_border(false);
 	set_command(command);
 	set_icon(icon);
-	iconbutton_enabled = true;
+	set_highlight(false);
 }
 
 IconButton::~IconButton()
@@ -58,19 +58,14 @@ void IconButton::set_icon(const char *icon)
 		iconbutton_icon.clear();
 }
 
-void IconButton::set_icon(const std::string &icon)
+void IconButton::set_highlight(const bool highlight)
 {
-	iconbutton_icon.assign(icon);
+	iconbutton_highlight = highlight;
 }
 
-void IconButton::enable(bool enabled)
-{
-	iconbutton_enabled = enabled;
-}
-
-void IconButton::disable(bool disabled)
+void IconButton::set_icon(const std::string &icon)
 {
-	iconbutton_enabled = !disabled;
+	iconbutton_icon.assign(icon);
 }
 
 void IconButton::draw()
@@ -80,7 +75,7 @@ void IconButton::draw()
 
 	if (disabled()) {
 		Paint::set_color(palette()->disabled());
-	} else if (has_mouse_focus()) {
+	} else if (highlight() || has_mouse_focus()) {
 		Paint::set_color(palette()->highlight());
 	} else {
 		Paint::set_color(palette()->foreground());
diff --git a/src/ui/iconbutton.h b/src/ui/iconbutton.h
index 37d1c7b..c9a7c5b 100644
--- a/src/ui/iconbutton.h
+++ b/src/ui/iconbutton.h
@@ -28,22 +28,11 @@ public:
 		return iconbutton_icon;
 	}
 
-	/// enabled or disabled
-	inline const bool enabled() const {
-		return iconbutton_enabled;
+	/// highlight state
+	inline const bool highlight() const {
+		return iconbutton_highlight;
 	}
-
-	/// enabled or disabled
-	inline const bool disabled() const {
-		return !iconbutton_enabled;
-	}
-
-	/// enable or disable the button
-	void enable(bool enabled = true);
-
-	/// enable or disable the button
-	void disable(bool disabled = true);
-
+	
 	/// set the command this button will execute
 	void set_command(const std::string &command);
 
@@ -56,6 +45,9 @@ public:
 	/// set the icon texture
 	void set_icon(const char *icon);
 
+	/// set the highlight state
+	void set_highlight(const bool highlight);
+	
 	/// print button description
 	virtual void print(const size_t indent) const;
 
@@ -78,7 +70,7 @@ protected:
 private:
 	std::string	iconbutton_command;
 	std::string	iconbutton_icon;
-	bool		iconbutton_enabled;
+	bool		iconbutton_highlight;
 };
 
 }
diff --git a/src/ui/widget.cc b/src/ui/widget.cc
index 2f35185..f663cc6 100644
--- a/src/ui/widget.cc
+++ b/src/ui/widget.cc
@@ -188,6 +188,7 @@ void Widget::set_enabled(const bool enabled)
 	else
 		disable();
 }
+
 void Widget::set_border(const bool border)
 {
 	widget_border = border;
diff --git a/src/ui/widget.h b/src/ui/widget.h
index 8b61bc1..530af05 100644
--- a/src/ui/widget.h
+++ b/src/ui/widget.h
@@ -57,7 +57,7 @@ public:
 	/**
 	 * @see location()
 	 */
-	inline float left() const {
+	inline const float left() const {
 		return widget_location.x();
 	}
 
@@ -66,7 +66,7 @@ public:
 	 * @see location()
 	 * @see size()
 	 */
-	inline float right() const {
+	inline const float right() const {
 		return widget_location.x() + widget_size.width();
 	}
 
@@ -74,7 +74,7 @@ public:
 	/**
 	 *  @see location()
 	 */
-	inline float top() const {
+	inline const float top() const {
 		return widget_location.y();
 	}
 
@@ -83,7 +83,7 @@ public:
 	 * @see location()
 	 * @see size()
 	 */
-	inline float bottom() const {
+	inline const float bottom() const {
 		return widget_location.y() + widget_size.height();
 	}
 
@@ -91,7 +91,7 @@ public:
 	/**
 	 *  @see size()
 	 */
-	inline float width() const {
+	inline const float width() const {
 		return widget_size.width();
 	}
 
@@ -99,7 +99,7 @@ public:
 	/**
 	 *  @see size()
 	 */
-	inline float height() const {
+	inline const float height() const {
 		return widget_size.height();
 	}
 
@@ -109,32 +109,32 @@ public:
 	}
 
 	/// true if this widget will draw a background
-	inline bool background() const {
+	inline const bool background() const {
 		return widget_background;
 	}
 
 	/// true if this widget will draw a border
-	inline bool border() const {
+	inline const bool border() const {
 		return widget_border;
 	}
 
 	/// true if this widget is visible
-	inline bool visible() const {
+	inline const bool visible() const {
 		return widget_visible;
 	}
 
 	/// true if this widget is not visible
-	inline bool hidden() const {
+	inline const bool hidden() const {
 		return !widget_visible;
 	}
 
 	/// true if the widget is enabled
-	inline bool enabled() const {
+	inline const bool enabled() const {
 		return widget_enabled;
 	}
 	
 	/// true if the widget is disabled
-	inline bool disabled() const {
+	inline const bool disabled() const {
 		return !widget_enabled;
 	}
 	
@@ -170,12 +170,12 @@ public:
 	/// set visibility
 	void set_visible(const bool visible = true);
 
-	///  disable the widget
-	virtual void disable();
-	
-	/// enable the widget
+	/// enable or disable the widget
 	virtual void enable();
-	
+
+	/// enable or disable the widget
+	virtual void disable();
+
 	///set enabled or disabled state
 	void set_enabled(const bool enabled = true);
 
-- 
cgit v1.2.3