mail[Wesnoth-commits] r36853 - /trunk/src/gui/auxiliary/window_builder/helper.cpp


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

Header


Content

Posted by kailoran on July 12, 2009 - 19:11:
Author: ilor
Date: Sun Jul 12 19:11:53 2009
New Revision: 36853

URL: http://svn.gna.org/viewcvs/wesnoth?rev=36853&view=rev
Log:
fix border handling in gui2 to allow selective border types like "top,left"

Modified:
    trunk/src/gui/auxiliary/window_builder/helper.cpp

Modified: trunk/src/gui/auxiliary/window_builder/helper.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/auxiliary/window_builder/helper.cpp?rev=36853&r1=36852&r2=36853&view=diff
==============================================================================
--- trunk/src/gui/auxiliary/window_builder/helper.cpp (original)
+++ trunk/src/gui/auxiliary/window_builder/helper.cpp Sun Jul 12 19:11:53 2009
@@ -17,6 +17,7 @@
 #include "gui/auxiliary/window_builder/helper.hpp"
 
 #include "config.hpp"
+#include "foreach.hpp"
 #include "gui/auxiliary/log.hpp"
 #include "gui/widgets/grid.hpp"
 #include "gui/widgets/window.hpp"
@@ -57,35 +58,21 @@
 
 unsigned get_border(const std::vector<std::string>& border)
 {
-       if(std::find(border.begin(), border.end(), std::string("all"))
-                               != border.end()) {
-
-               return tgrid::BORDER_TOP
-                       | tgrid::BORDER_BOTTOM | tgrid::BORDER_LEFT | 
tgrid::BORDER_RIGHT;
-       } else {
-               if(std::find(border.begin(), border.end(), std::string("top"))
-                               != border.end()) {
-
-                       return tgrid::BORDER_TOP;
-               }
-               if(std::find(border.begin(), border.end(), 
std::string("bottom"))
-                               != border.end()) {
-
-                       return tgrid::BORDER_BOTTOM;
-               }
-               if(std::find(border.begin(), border.end(), 
std::string("left"))
-                               != border.end()) {
-
-                       return tgrid::BORDER_LEFT;
-               }
-               if(std::find(border.begin(), border.end(), 
std::string("right"))
-                               != border.end()) {
-
-                       return tgrid::BORDER_RIGHT;
+       unsigned result = 0;
+       foreach (const std::string& s, border) {
+               if (s == "all") {
+                       return tgrid::BORDER_ALL;
+               } else if (s == "top") {
+                       result |= tgrid::BORDER_TOP;
+               } else if (s == "bottom") {
+                       result |= tgrid::BORDER_BOTTOM;
+               } else if (s == "left") {
+                       result |= tgrid::BORDER_LEFT;
+               } else if (s == "right") {
+                       result |= tgrid::BORDER_RIGHT;
                }
        }
-
-       return 0;
+       return result;
 }
 
 unsigned read_flags(const config& cfg)




Related Messages


Powered by MHonArc, Updated Sun Jul 12 19:20:39 2009