mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-06 10:03:29 +00:00
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.
This commit is contained in:
parent
9501be8910
commit
ab7cefafb6
@ -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 @@ void load_settings()
|
||||
// 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 @@ tresolution_definition_ptr get_control(
|
||||
|
||||
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);
|
||||
|
||||
|
@ -121,6 +121,7 @@ twindow::twindow(CVideo& video,
|
||||
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();
|
||||
|
||||
@ -131,6 +132,17 @@ twindow::twindow(CVideo& video,
|
||||
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)
|
||||
{
|
||||
/*WIKI
|
||||
@ -163,6 +175,10 @@ int twindow::show(const bool restore, void* /*flip_function*/)
|
||||
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;
|
||||
|
@ -56,6 +56,16 @@ public:
|
||||
const unsigned vertical_placement,
|
||||
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.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user