Author: mordante
Date: Sun May 18 09:14:57 2008
New Revision: 26682

URL: http://svn.gna.org/viewcvs/wesnoth?rev=26682&view=rev
Log:
set_active() now only changes the state if changed.

Modified:
    trunk/src/gui/widgets/button.cpp
    trunk/src/gui/widgets/button.hpp
    trunk/src/gui/widgets/label.hpp
    trunk/src/gui/widgets/listbox.hpp
    trunk/src/gui/widgets/scrollbar.hpp

Modified: trunk/src/gui/widgets/button.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/button.cpp?rev=26682&r1=26681&r2=26682&view=diff
==============================================================================
--- trunk/src/gui/widgets/button.cpp (original)
+++ trunk/src/gui/widgets/button.cpp Sun May 18 09:14:57 2008
@@ -110,20 +110,6 @@
        }
 }
 
-void tbutton::set_active(const bool active)
-{
-       if(active && state_ == DISABLED) {
-               set_state(ENABLED);
-       } else if(!active && state_ != DISABLED) {
-               set_state(DISABLED);
-       }
-}
-
-bool tbutton::get_active() const
-{
-       return state_ != DISABLED;
-}
-
 void tbutton::set_state(tstate state)
 {
        if(state != state_) {

Modified: trunk/src/gui/widgets/button.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/button.hpp?rev=26682&r1=26681&r2=26682&view=diff
==============================================================================
--- trunk/src/gui/widgets/button.hpp (original)
+++ trunk/src/gui/widgets/button.hpp Sun May 18 09:14:57 2008
@@ -56,8 +56,10 @@
        //! Gets the retval for the default buttons.
        static RETVAL get_retval_by_id(const std::string& id);
 
-       void set_active(const bool active);
-       bool get_active() const;
+       //! Inherited from tcontrol.
+       void set_active(const bool active) 
+               { if(get_active() != active) set_state(active ? ENABLED : 
DISABLED); };
+       bool get_active() const { return state_ != DISABLED; }
        unsigned get_state() const { return state_; }
 
        void set_callback_mouse_left_click(void (*callback) (twidget*))

Modified: trunk/src/gui/widgets/label.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/label.hpp?rev=26682&r1=26681&r2=26682&view=diff
==============================================================================
--- trunk/src/gui/widgets/label.hpp (original)
+++ trunk/src/gui/widgets/label.hpp Sun May 18 09:14:57 2008
@@ -29,7 +29,9 @@
        {
        }
 
-       void set_active(const bool active) { set_state(active ? ENABLED : 
DISABLED); };
+       //! Inherited from tcontrol.
+       void set_active(const bool active) 
+               { if(get_active() != active) set_state(active ? ENABLED : 
DISABLED); };
        bool get_active() const { return state_ != DISABLED; }
        unsigned get_state() const { return state_; }
 

Modified: trunk/src/gui/widgets/listbox.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/listbox.hpp?rev=26682&r1=26681&r2=26682&view=diff
==============================================================================
--- trunk/src/gui/widgets/listbox.hpp (original)
+++ trunk/src/gui/widgets/listbox.hpp Sun May 18 09:14:57 2008
@@ -37,6 +37,7 @@
        
        tlistbox();
 
+       // FIXME this might not the right thing to do.
        void set_active(const bool active) { set_state(active ? ENABLED : 
DISABLED); };
        bool get_active() const { return state_ != DISABLED; }
        unsigned get_state() const { return state_; }

Modified: trunk/src/gui/widgets/scrollbar.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/scrollbar.hpp?rev=26682&r1=26681&r2=26682&view=diff
==============================================================================
--- trunk/src/gui/widgets/scrollbar.hpp (original)
+++ trunk/src/gui/widgets/scrollbar.hpp Sun May 18 09:14:57 2008
@@ -66,7 +66,8 @@
        void mouse_left_button_up(tevent_handler& event);
 
        //! Inherited from tcontrol.
-       void set_active(const bool active) { set_state(active ? ENABLED : 
DISABLED); };
+       void set_active(const bool active) 
+               { if(get_active() != active) set_state(active ? ENABLED : 
DISABLED); };
 
        //! Inherited from tcontrol.
        bool get_active() const { return state_ != DISABLED; }


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to