Author: mordante
Date: Sat Apr 5 14:35:31 2008
New Revision: 25569
URL: http://svn.gna.org/viewcvs/wesnoth?rev=25569&view=rev
Log:
Add an extra funtion to set the rows an columns in one call. This avoids a
resize warning. Also convert the caller to use the new way.
Modified:
trunk/src/gui/widgets/grid.cpp
trunk/src/gui/widgets/grid.hpp
trunk/src/gui/widgets/window_builder.cpp
Modified: trunk/src/gui/widgets/grid.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/grid.cpp?rev=25569&r1=25568&r2=25569&view=diff
==============================================================================
--- trunk/src/gui/widgets/grid.cpp (original)
+++ trunk/src/gui/widgets/grid.cpp Sat Apr 5 14:35:31 2008
@@ -97,24 +97,30 @@
return;
}
+ set_rows_cols(rows, cols_);
+}
+
+void tgrid::set_cols(const unsigned cols)
+{
+ if(cols == cols_) {
+ return;
+ }
+
+ set_rows_cols(rows_, cols);
+}
+
+void tgrid::set_rows_cols(const unsigned rows, const unsigned cols)
+{
+
+ if(rows == rows_ && cols == cols_) {
+ return;
+ }
+
if(!children_.empty()) {
WRN_G << "Grid: resizing a non-empty grid may give unexpected
problems.\n";
}
rows_ = rows;
- children_.resize(rows_ * cols_);
-}
-
-void tgrid::set_cols(const unsigned cols)
-{
- if(cols == cols_) {
- return;
- }
-
- if(!children_.empty()) {
- WRN_G << "Grid: resizing a non-empty grid may give unexpected
problems.\n";
- }
-
cols_ = cols;
children_.resize(rows_ * cols_);
}
Modified: trunk/src/gui/widgets/grid.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/grid.hpp?rev=25569&r1=25568&r2=25569&view=diff
==============================================================================
--- trunk/src/gui/widgets/grid.hpp (original)
+++ trunk/src/gui/widgets/grid.hpp Sat Apr 5 14:35:31 2008
@@ -69,6 +69,8 @@
void set_cols(const unsigned cols);
unsigned int get_cols() const { return cols_; }
+
+ void set_rows_cols(const unsigned rows, const unsigned cols);
void remove_child(const unsigned row, const unsigned col);
void remove_child(const std::string& id, const bool find_all = false);
Modified: trunk/src/gui/widgets/window_builder.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window_builder.cpp?rev=25569&r1=25568&r2=25569&view=diff
==============================================================================
--- trunk/src/gui/widgets/window_builder.cpp (original)
+++ trunk/src/gui/widgets/window_builder.cpp Sat Apr 5 14:35:31 2008
@@ -109,8 +109,7 @@
const unsigned rows = definition->grid.rows;
const unsigned cols = definition->grid.cols;
- window.set_rows(rows);
- window.set_cols(cols);
+ window.set_rows_cols(rows, cols);
for(unsigned x = 0; x < rows; ++x) {
for(unsigned y = 0; y < cols; ++y) {
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits