wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src playturn.cpp playturn.hpp


From: Philippe Plantier
Subject: [Wesnoth-cvs-commits] wesnoth/src playturn.cpp playturn.hpp
Date: Sat, 27 Aug 2005 18:52:54 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Philippe Plantier <address@hidden>      05/08/27 22:52:54

Modified files:
        src            : playturn.cpp playturn.hpp 

Log message:
        Fixed #12466 - text input field not changing its position when changing 
the resolution.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playturn.cpp.diff?tr1=1.394&tr2=1.395&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playturn.hpp.diff?tr1=1.70&tr2=1.71&r1=text&r2=text

Patches:
Index: wesnoth/src/playturn.cpp
diff -u wesnoth/src/playturn.cpp:1.394 wesnoth/src/playturn.cpp:1.395
--- wesnoth/src/playturn.cpp:1.394      Sat Aug 27 22:24:10 2005
+++ wesnoth/src/playturn.cpp    Sat Aug 27 22:52:54 2005
@@ -1,4 +1,4 @@
-/* $Id: playturn.cpp,v 1.394 2005/08/27 22:24:10 gruikya Exp $ */
+/* $Id: playturn.cpp,v 1.395 2005/08/27 22:52:54 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
@@ -164,16 +164,9 @@
 {
        events::pump();
        events::raise_process_event();
-
-       const int border_size = 10;
 
        if (gui_.video().modeChanged()) {
-               if (textbox_.box != NULL) {
-                       const SDL_Rect& area = gui_.map_area();
-                       const SDL_Rect& label_area = 
font::get_floating_label_rect(textbox_.label);
-                       const int ypos = area.y+area.h-30 - (textbox_.check != 
NULL ? textbox_.check->height() + border_size : 0);
-                       textbox_.box->set_location(area.x + label_area.w + 
border_size*2,ypos);
-               }
+               update_textbox_location();
        }
 
        events::raise_draw_event();
@@ -2878,27 +2871,25 @@
        return turn_end ? PROCESS_END_TURN : PROCESS_CONTINUE;
 }
 
-void turn_info::create_textbox(floating_textbox::MODE mode, const std::string& 
label, const std::string& check_label, bool checked)
+void turn_info::update_textbox_location()
 {
-       close_textbox();
-
-       textbox_.mode = mode;
-
-       if(check_label != "") {
-               textbox_.check.assign(new 
gui::button(gui_.video(),check_label,gui::button::TYPE_CHECK));
-               textbox_.check->set_check(checked);
-       }
+       if (textbox_.box == NULL)
+               return;
 
        const SDL_Rect& area = gui_.map_area();
 
        const int border_size = 10;
 
        const int ypos = area.y+area.h-30 - (textbox_.check != NULL ? 
textbox_.check->height() + border_size : 0);
-       textbox_.label = 
font::add_floating_label(label,font::SIZE_NORMAL,font::YELLOW_COLOUR,area.x+border_size,ypos,0,0,-1,
-               area,font::LEFT_ALIGN);
-       if(textbox_.label == 0) {
+
+       if (textbox_.label != 0)
+               font::remove_floating_label(textbox_.label);
+
+       textbox_.label = 
font::add_floating_label(textbox_.label_string,font::SIZE_NORMAL,
+                       font::YELLOW_COLOUR,area.x+border_size,ypos,0,0,-1, 
area,font::LEFT_ALIGN);
+
+       if (textbox_.label == 0)
                return;
-       }
 
        const SDL_Rect& label_area = 
font::get_floating_label_rect(textbox_.label);
        const int textbox_width = area.w - label_area.w - border_size*3;
@@ -2908,14 +2899,37 @@
                return;
        }
 
-       textbox_.box.assign(new 
gui::textbox(gui_.video(),textbox_width,"",true,256,0.8,0.6));
-       textbox_.box->set_volatile(true);
-       textbox_.box->set_location(area.x + label_area.w + border_size*2,ypos);
+       if(textbox_.box != NULL) {
+               textbox_.box->set_volatile(true);
+               const SDL_Rect rect = { 
+                       area.x + label_area.w + border_size*2, ypos, 
+                       textbox_width, textbox_.box->height() 
+               };
+               textbox_.box->set_location(rect);
+       }
 
        if(textbox_.check != NULL) {
                textbox_.check->set_volatile(true);
                
textbox_.check->set_location(textbox_.box->location().x,textbox_.box->location().y
 + textbox_.box->location().h + border_size);
        }
+}
+
+void turn_info::create_textbox(floating_textbox::MODE mode, const std::string& 
label, const std::string& check_label, bool checked)
+{
+       close_textbox();
+
+       textbox_.label_string = label;
+       textbox_.mode = mode;
+
+       if(check_label != "") {
+               textbox_.check.assign(new 
gui::button(gui_.video(),check_label,gui::button::TYPE_CHECK));
+               textbox_.check->set_check(checked);
+       }
+
+
+       textbox_.box.assign(new 
gui::textbox(gui_.video(),100,"",true,256,0.8,0.6));
+
+       update_textbox_location();
 }
 
 void turn_info::close_textbox()
Index: wesnoth/src/playturn.hpp
diff -u wesnoth/src/playturn.hpp:1.70 wesnoth/src/playturn.hpp:1.71
--- wesnoth/src/playturn.hpp:1.70       Sat Jul  2 21:37:19 2005
+++ wesnoth/src/playturn.hpp    Sat Aug 27 22:52:54 2005
@@ -1,4 +1,4 @@
-/* $Id: playturn.hpp,v 1.70 2005/07/02 21:37:19 ott Exp $ */
+/* $Id: playturn.hpp,v 1.71 2005/08/27 22:52:54 gruikya Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
@@ -69,6 +69,7 @@
                            TEXTBOX_COMMAND };
                MODE mode;
 
+               std::string label_string;
                int label;
 
                floating_textbox() : box(NULL), check(NULL), 
mode(TEXTBOX_NONE), label(0)
@@ -248,6 +249,7 @@
 
        floating_textbox& textbox_;
 
+       void update_textbox_location();
        void create_textbox(floating_textbox::MODE mode, const std::string& 
label, const std::string& check_label="", bool checked=false);
        void close_textbox();
        void enter_textbox();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]