Author: mordante
Date: Tue Sep  2 20:04:15 2008
New Revision: 29202

URL: http://svn.gna.org/viewcvs/wesnoth?rev=29202&view=rev
Log:
Make sure the arrow keys don't select inactive rows.

Modified:
    trunk/src/gui/widgets/listbox.cpp
    trunk/src/gui/widgets/listbox.hpp

Modified: trunk/src/gui/widgets/listbox.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/listbox.cpp?rev=29202&r1=29201&r2=29202&view=diff
==============================================================================
--- trunk/src/gui/widgets/listbox.cpp (original)
+++ trunk/src/gui/widgets/listbox.cpp Tue Sep  2 20:04:15 2008
@@ -231,6 +231,7 @@
        assert(row < get_item_count());
        assert(rows_[row].grid());
        rows_[row].grid()->set_active(active);
+       rows_[row].set_active(active);
 }
 
 const tgrid* tlistbox::get_row_grid(const unsigned row) const
@@ -266,6 +267,9 @@
                case SDLK_UP : {
 
                        int i = get_selected_row() - 1;
+                       while(i >= 0 && !rows_[i].get_active()) {
+                               --i;
+                       }
                        if(i >= 0) {
                                select_row(i);
                                handled = true;
@@ -276,6 +280,9 @@
                case SDLK_DOWN : {
 
                        int i = get_selected_row() + 1;
+                       while(i <  rows_.size() && !rows_[i].get_active()) {
+                               ++i;
+                       }
                        if(i < rows_.size()) {
                                select_row(i);
                                handled = true;
@@ -740,7 +747,8 @@
        grid_(dynamic_cast<tgrid*>(list_builder_.build())),
        height_(0),
        canvas_(),
-       selected_(false)
+       selected_(false),
+       active_(true)
 {
        assert(grid_);
        init_in_grid(grid_, data);

Modified: trunk/src/gui/widgets/listbox.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/listbox.hpp?rev=29202&r1=29201&r2=29202&view=diff
==============================================================================
--- trunk/src/gui/widgets/listbox.hpp (original)
+++ trunk/src/gui/widgets/listbox.hpp Tue Sep  2 20:04:15 2008
@@ -353,6 +353,9 @@
 
                void set_selected(const bool selected = true);
                bool get_selected() const { return selected_; }
+
+               void  set_active(const bool active) { active_ = active; }
+               bool get_active() const { return active_; }
        private:
 
                /** The grid containing the widgets in the row. */
@@ -366,6 +369,15 @@
 
                /** Is the row currently selected or not. */
                bool selected_;
+
+               /** 
+                * Is the row active or not?
+                *
+                * This value is used to store the status setting it doesn't 
change the
+                * status, so the function that changes the active status 
should also
+                * update this value.
+                */
+               bool active_;
 
                /** Initializes all widgets in the grid. */
                void init_in_grid(tgrid* grid, 


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

Reply via email to