mail[Wesnoth-commits] r28770 - in /trunk/src/gui/widgets: container.cpp container.hpp grid.cpp grid.hpp widget.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by koraq on August 19, 2008 - 17:58:
Author: mordante
Date: Tue Aug 19 17:58:20 2008
New Revision: 28770

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28770&view=rev
Log:
Added some extra set_dirty() defintions in inherited classes.  
set_dirty(false)
for a container should also clear the dirty flag of it's children. Before the
window was redrawn every frame causing an increased CPU usage, which has been
gone with this change.

Modified:
    trunk/src/gui/widgets/container.cpp
    trunk/src/gui/widgets/container.hpp
    trunk/src/gui/widgets/grid.cpp
    trunk/src/gui/widgets/grid.hpp
    trunk/src/gui/widgets/widget.hpp

Modified: trunk/src/gui/widgets/container.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/container.cpp?rev=28770&r1=28769&r2=28770&view=diff
==============================================================================
--- trunk/src/gui/widgets/container.cpp (original)
+++ trunk/src/gui/widgets/container.cpp Tue Aug 19 17:58:20 2008
@@ -135,5 +135,15 @@
        set_self_active(active);
 }
 
+void tcontainer_::set_dirty(const bool dirty)
+{
+       // Inherited.
+       twidget::set_dirty(dirty);
+
+       if(!dirty) {
+               grid_.set_dirty(dirty);
+       }
+}
+
 } // namespace gui2
 

Modified: trunk/src/gui/widgets/container.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/container.hpp?rev=28770&r1=28769&r2=28770&view=diff
==============================================================================
--- trunk/src/gui/widgets/container.hpp (original)
+++ trunk/src/gui/widgets/container.hpp Tue Aug 19 17:58:20 2008
@@ -139,8 +139,11 @@
        /** FIXME see whether needed to be exported. */
        void set_client_size(const SDL_Rect& rect) { grid_.set_size(rect); }
 
+
+       /** Inherited from twidget. */
+       void set_dirty(const bool dirty = true);
+
 protected:
-
        /***** ***** ***** setters / getters for members ***** ****** *****/
 
        const tgrid& grid() const { return grid_; }

Modified: trunk/src/gui/widgets/grid.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/grid.cpp?rev=28770&r1=28769&r2=28770&view=diff
==============================================================================
--- trunk/src/gui/widgets/grid.cpp (original)
+++ trunk/src/gui/widgets/grid.cpp Tue Aug 19 17:58:20 2008
@@ -529,6 +529,22 @@
        col_grow_factor_.resize(cols);
        children_.resize(rows_ * cols_);
        clear_cache();
+}
+
+void tgrid::set_dirty(const bool dirty)
+{
+       // Inherited.
+       twidget::set_dirty(dirty);
+
+       if(!dirty) {
+               for(std::vector<tchild>::iterator itor = children_.begin();
+                               itor != children_.end(); ++itor) {
+
+                       if(itor->widget()) {
+                               itor->widget()->set_dirty(dirty);
+                       }
+               }
+       }
 }
 
 tpoint tgrid::tchild::get_best_size() const

Modified: trunk/src/gui/widgets/grid.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/grid.hpp?rev=28770&r1=28769&r2=28770&view=diff
==============================================================================
--- trunk/src/gui/widgets/grid.hpp (original)
+++ trunk/src/gui/widgets/grid.hpp Tue Aug 19 17:58:20 2008
@@ -206,6 +206,9 @@
         * @param cols                Parameter to call set_cols with.
         */
        void set_rows_cols(const unsigned rows, const unsigned cols);
+
+       /** Inherited from twidget. */
+       void set_dirty(const bool dirty = true);
 
 private:
        /** Child item of the grid. */

Modified: trunk/src/gui/widgets/widget.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/widget.hpp?rev=28770&r1=28769&r2=28770&view=diff
==============================================================================
--- trunk/src/gui/widgets/widget.hpp (original)
+++ trunk/src/gui/widgets/widget.hpp Tue Aug 19 17:58:20 2008
@@ -535,14 +535,20 @@
        unsigned get_width() const { return w_; }
        unsigned get_height() const { return h_; }
 
-protected:     
+       /**
+        * Sets the widgets dirty state.
+        *
+        * When set to dirty it should also mark it's parents as dirty so 
that the
+        * window easily test for it's dirty state.
+        * When set to not dirty it should also mark it's childeren as not 
dirty.
+        * (Obviously only for container classes).
+        */
        virtual void set_dirty(const bool dirty = true) 
        { 
                dirty_ = dirty; 
                if(parent_ && dirty) parent_->set_dirty(true);
        }
 
-public:        
        virtual bool is_dirty() const { return dirty_; }
 
 private:




Related Messages


Powered by MHonArc, Updated Tue Aug 19 21:21:16 2008