Author: mordante
Date: Tue Aug 19 08:07:43 2008
New Revision: 28754
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28754&view=rev
Log:
Before we create a toplevel twindow the screen size needs to be reevaluated,
the user might have resized the main window, when no twindow was active.
Modified:
trunk/src/gui/widgets/settings.cpp
trunk/src/gui/widgets/window.cpp
trunk/src/gui/widgets/window.hpp
Modified: trunk/src/gui/widgets/settings.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.cpp?rev=28754&r1=28753&r2=28754&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.cpp (original)
+++ trunk/src/gui/widgets/settings.cpp Tue Aug 19 08:07:43 2008
@@ -20,6 +20,7 @@
#include "filesystem.hpp"
#include "gettext.hpp"
#include "gui/widgets/helper.hpp"
+#include "gui/widgets/window.hpp"
#include "log.hpp"
#include "serialization/parser.hpp"
#include "serialization/preprocessor.hpp"
@@ -109,9 +110,7 @@
// Init.
fill_window_types();
- const SDL_Rect rect = screen_area();
- settings::screen_width = rect.w;
- settings::screen_height = rect.h;
+ twindow::update_screen_size();
// Read file.
config cfg;
@@ -1105,6 +1104,8 @@
std::vector<twindow_builder::tresolution>::const_iterator
get_window_builder(const std::string& type)
{
+ twindow::update_screen_size();
+
std::map<std::string, twindow_builder>::const_iterator
window = current_gui->second.window_types.find(type);
Modified: trunk/src/gui/widgets/window.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.cpp?rev=28754&r1=28753&r2=28754&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.cpp (original)
+++ trunk/src/gui/widgets/window.cpp Tue Aug 19 08:07:43 2008
@@ -121,6 +121,7 @@
h_(h)
{
// We load the config in here as exception.
+ // Our caller did update the screen size so no need for us to do that
again.
set_definition(definition);
load_config();
@@ -129,6 +130,17 @@
help_popup_.set_definition("default");
help_popup_.set_visible(false);
+}
+
+void twindow::update_screen_size()
+{
+ // Only if we're the toplevel window we need to update the size,
otherwise
+ // it's done in the resize event.
+ if(draw_interval == 0) {
+ const SDL_Rect rect = screen_area();
+ settings::screen_width = rect.w;
+ settings::screen_height = rect.h;
+ }
}
twindow::tretval twindow::get_retval_by_id(const std::string& id)
@@ -163,6 +175,10 @@
if(top_level_) {
draw_interval = 30;
SDL_AddTimer(draw_interval, draw_timer, NULL);
+
+ // There might be some time between creation and showing so
reupdate
+ // the sizes.
+ update_screen_size();
}
suspend_drawing_ = false;
Modified: trunk/src/gui/widgets/window.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.hpp?rev=28754&r1=28753&r2=28754&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.hpp (original)
+++ trunk/src/gui/widgets/window.hpp Tue Aug 19 08:07:43 2008
@@ -57,6 +57,16 @@
const std::string& definition);
/**
+ * Update the size of the screen variables in settings.
+ *
+ * Before a window gets build the screen sizes need to be updates. This
+ * function does that. It's only done when no other window is active, if
+ * another window is active it already updates the sizes with it's
resize
+ * event.
+ */
+ static void update_screen_size();
+
+ /**
* Default return values.
*
* These values are named return values and most are assigned to a
widget
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits