Fix GUI1 layering and redraws.

These changes ensure that GUI1 elements are properly respecting the
draw layering and are redrawed on the appropriate window events. It
has been tested with both one and multiple overlapping dialogs.
This commit is contained in:
Andreas Löf 2016-02-03 22:25:12 +13:00
parent a02a8da7ea
commit b73cc895ae
4 changed files with 28 additions and 6 deletions

View file

@ -332,7 +332,7 @@ bool resize_comparer(SDL_Event a, SDL_Event b) {
}
bool remove_on_resize(const SDL_Event &a) {
if (a.type == DRAW_EVENT) {
if (a.type == DRAW_EVENT || a.type == DRAW_ALL_EVENT) {
return true;
}
if (a.type == SHOW_HELPTIP_EVENT) {
@ -520,8 +520,8 @@ void pump()
/* iterate backwards as the most recent things will be at the top */
for( std::deque<context>::iterator i = event_contexts.begin() ; i != event_contexts.end(); i++) {
const std::vector<sdl_handler*>& event_handlers = (*i).handlers;
for(size_t i1 = 0, i2 = event_handlers.size(); i1 != i2 && i1 < event_handlers.size(); ++i1) {
event_handlers[i1]->handle_event(event);
for( std::vector<sdl_handler*>::const_iterator i1 = event_handlers.begin(); i1 != event_handlers.end(); i1++) {
(*i1)->handle_event(event);
//event_handlers[i1]->draw();
}
}

View file

@ -153,13 +153,23 @@ void dialog_frame::set_dirty(bool dirty) {
void dialog_frame::handle_window_event(const SDL_Event& event) {
if (event.type == SDL_WINDOWEVENT) {
dirty_ = true;
switch (event.window.event) {
case SDL_WINDOWEVENT_RESIZED:
case SDL_WINDOWEVENT_RESTORED:
case SDL_WINDOWEVENT_SHOWN:
case SDL_WINDOWEVENT_EXPOSED:
set_dirty();
}
}
}
#endif
void dialog_frame::handle_event(const SDL_Event& event) {
if (event.type == DRAW_ALL_EVENT) {
set_dirty();
}
if (event.type == DRAW_EVENT || event.type == DRAW_ALL_EVENT) {
draw();
}

View file

@ -342,10 +342,22 @@ void widget::process_tooltip_string(int mousex, int mousey)
}
}
void widget::handle_event(SDL_Event const &event) {
if (event.type == DRAW_ALL_EVENT) {
set_dirty();
}
}
#if SDL_VERSION_ATLEAST(2, 0, 0)
void widget::handle_window_event(SDL_Event const &event) {
if (event.type == SDL_WINDOWEVENT) {
set_dirty();
switch (event.window.event) {
case SDL_WINDOWEVENT_RESIZED:
case SDL_WINDOWEVENT_RESTORED:
case SDL_WINDOWEVENT_SHOWN:
case SDL_WINDOWEVENT_EXPOSED:
set_dirty();
}
}
}
#endif

View file

@ -90,7 +90,7 @@ protected:
const SDL_Rect* clip_rect() const;
virtual sdl_handler_vector member_handlers() { return sdl_handler::handler_members(); }
virtual void handle_event(SDL_Event const &) {};
virtual void handle_event(SDL_Event const &);
#if SDL_VERSION_ATLEAST(2, 0, 0)
virtual void handle_window_event(SDL_Event const &event);
#endif