Author: sapient
Date: Sun May 27 03:47:12 2007
New Revision: 17890

URL: http://svn.gna.org/viewcvs/wesnoth?rev=17890&view=rev
Log:
make dimension_measurements part of dialog state instead of passing it

Modified:
    trunk/src/construct_dialog.cpp
    trunk/src/construct_dialog.hpp

Modified: trunk/src/construct_dialog.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/construct_dialog.cpp?rev=17890&r1=17889&r2=17890&view=diff
==============================================================================
--- trunk/src/construct_dialog.cpp (original)
+++ trunk/src/construct_dialog.cpp Sun May 27 03:47:12 2007
@@ -264,6 +264,7 @@
        }
 
        LOG_DP << "showing dialog '" << title_ << "' '" << message_->get_text() 
<< "'\n";
+       dim_ = dim;
 
        //create the event context, remember to instruct any passed-in widgets 
to join it
        const events::event_context dialog_events_context;
@@ -274,9 +275,9 @@
        hotkey::basic_handler help_dispatcher(&disp_,&helper);
 
        //draw
-       draw_frame(dim);
-       update_widget_positions(dim);
-       draw_contents(dim);
+       draw_frame();
+       update_widget_positions();
+       draw_contents();
 
        //process
        dialog_process_info dp_info;
@@ -293,7 +294,7 @@
        return result();
 }
 
-void dialog::draw_contents(const dimension_measurements & /*dim*/)
+void dialog::draw_contents()
 {
        if(!preview_panes_.empty()) {
                for(pp_iterator i = preview_panes_.begin(); i != 
preview_panes_.end(); ++i) {
@@ -311,7 +312,7 @@
        disp_.invalidate_all();
 }
 
-void dialog::draw_frame(const dimension_measurements &dim)
+void dialog::draw_frame()
 {
        CVideo& screen = disp_.video();
        std::vector<button*> frame_buttons;
@@ -320,46 +321,46 @@
                frame_buttons.push_back(*b);
        }
        bg_restore_ = new surface_restorer;
-       draw_dialog(dim.frame.x, dim.frame.y, dim.frame.w, dim.frame.h,
+       draw_dialog(dim_.frame.x, dim_.frame.y, dim_.frame.w, dim_.frame.h,
                screen, title_, &style_, &frame_buttons, bg_restore_,
                help_button_.topic().empty() ? NULL : &help_button_);
 }
 
-void dialog::update_widget_positions(const dimension_measurements &dim)
+void dialog::update_widget_positions()
 {
        if(!preview_panes_.empty()) {
                for(pp_iterator i = preview_panes_.begin(); i != 
preview_panes_.end(); ++i) {
                        preview_pane *pane = *i;
                        pane->join();
-                       pane->set_location(dim.panes.find(pane)->second);
+                       pane->set_location(dim_.panes.find(pane)->second);
                }
        }
        if(text_widget_) {
                text_widget_->join();
-               text_widget_->set_location(dim.textbox);
+               text_widget_->set_location(dim_.textbox);
                if(text_widget_->get_label()) {
-                       text_widget_->get_label()->set_location(dim.label_x, 
dim.label_y);
+                       text_widget_->get_label()->set_location(dim_.label_x, 
dim_.label_y);
                }
        }
        if(get_menu().height() > 0) {
                menu_->join();
                menu_->set_numeric_keypress_selection(text_widget_ == NULL);
-               menu_->set_width( dim.menu_width );
-               menu_->set_max_width( dim.menu_width ); //lock the menu width
-               menu_->set_location( dim.menu_x, dim.menu_y );
+               menu_->set_width( dim_.menu_width );
+               menu_->set_max_width( dim_.menu_width ); //lock the menu width
+               menu_->set_location( dim_.menu_x, dim_.menu_y );
        }
        if(image_) {
                image_->join();
-               image_->set_location(dim.image_x, dim.image_y);
+               image_->set_location(dim_.image_x, dim_.image_y);
                if(image_->caption()) {
-                       image_->caption()->set_location(dim.caption_x, 
dim.caption_y);
+                       image_->caption()->set_location(dim_.caption_x, 
dim_.caption_y);
                }
        }
        button_iterator b;
        for(b = extra_buttons_.begin(); b != extra_buttons_.end(); ++b) {
                dialog_button *btn = *b;
                btn->join();
-               std::pair<int,int> coords = dim.buttons.find(btn)->second;
+               std::pair<int,int> coords = dim_.buttons.find(btn)->second;
                btn->set_location(coords.first, coords.second);
        }
        for(b = standard_buttons_.begin(); b != standard_buttons_.end(); ++b) {
@@ -368,9 +369,8 @@
        }
        help_button_.join();
 
-       message_->set_location(dim.message);
+       message_->set_location(dim_.message);
        message_->join();
-       last_dimension_= dim;
 }
 
 void dialog::refresh()
@@ -694,7 +694,8 @@
        //except if there is options and only an OK button
        if (new_right_button && !info.right_button) {
                if( standard_buttons_.empty() ||
-                   (!point_in_rect(mousex,mousey,last_dimension_.frame) && 
!(type_ == OK_ONLY && use_menu)) ) 
+                   (!point_in_rect(mousex,mousey,dim_.frame) && !(type_ == 
OK_ONLY && use_menu)) ) 
+                       //FIXME: should check dim_.outer_frame instead of 
dim_.frame
                        return CLOSE_DIALOG;
        }
 

Modified: trunk/src/construct_dialog.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/construct_dialog.hpp?rev=17890&r1=17889&r2=17890&view=diff
==============================================================================
--- trunk/src/construct_dialog.hpp (original)
+++ trunk/src/construct_dialog.hpp Sun May 27 03:47:12 2007
@@ -220,9 +220,9 @@
 private:
 //     enum INIT_STATE { STATE_UNINIT, STATE_CONTEXT_STARTED, 
STATE_FRAME_DRAWN, STATE_WIDGETS_JOINED, STATE_READY };
 //     void start_context();
-       void draw_frame(const dimension_measurements &dim);
-       void update_widget_positions(const dimension_measurements &dim);
-       void draw_contents(const dimension_measurements &dim);
+       void draw_frame();
+       void update_widget_positions();
+       void draw_contents();
 
        //process - execute a single dialog processing loop and return the 
result
        int process(dialog_process_info &info);
@@ -252,7 +252,7 @@
        dialog_textbox *text_widget_;
        dialog_action *action_;
        surface_restorer *bg_restore_;
-       dimension_measurements last_dimension_;
+       dimension_measurements dim_;
        int result_;
 //     INIT_STATE state_;
 };


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

Reply via email to