From 514aa409f5cd3ed8be71375896292b232bf6b470 Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Wed, 31 May 2017 00:23:10 +1100 Subject: [PATCH] GUI2: removed dirty widget interface This is no longer needed since we redraw everything every frame. The dirty flag in the canvas remains as that controls whether the cached texture is used or recreated. --- src/gui/core/event/handler.cpp | 25 ----------- src/gui/dialogs/debug_clock.cpp | 1 - src/gui/dialogs/editor/custom_tod.cpp | 3 -- src/gui/dialogs/lua_interpreter.cpp | 4 -- src/gui/dialogs/outro.cpp | 2 - src/gui/dialogs/story_viewer.cpp | 12 ------ src/gui/dialogs/story_viewer.hpp | 2 - src/gui/dialogs/title_screen.cpp | 9 ---- src/gui/widgets/button.cpp | 1 - src/gui/widgets/container_base.cpp | 10 ----- src/gui/widgets/container_base.hpp | 5 --- src/gui/widgets/generator.hpp | 8 ---- src/gui/widgets/generator_private.hpp | 13 ------ src/gui/widgets/grid.cpp | 17 -------- src/gui/widgets/grid.hpp | 7 --- src/gui/widgets/label.cpp | 5 --- src/gui/widgets/list.cpp | 8 +--- src/gui/widgets/listbox.cpp | 22 +--------- src/gui/widgets/listbox.hpp | 5 --- src/gui/widgets/matrix.cpp | 7 --- src/gui/widgets/matrix.hpp | 5 --- src/gui/widgets/menu_button.cpp | 9 ---- src/gui/widgets/minimap.hpp | 1 - src/gui/widgets/multimenu_button.cpp | 3 -- src/gui/widgets/pane.cpp | 10 ----- src/gui/widgets/pane.hpp | 5 --- src/gui/widgets/progress_bar.cpp | 2 - src/gui/widgets/repeating_button.cpp | 1 - src/gui/widgets/scrollbar.cpp | 2 - src/gui/widgets/scrollbar_container.cpp | 12 ------ src/gui/widgets/scrollbar_container.hpp | 6 --- src/gui/widgets/slider.hpp | 1 - src/gui/widgets/styled_widget.cpp | 4 -- src/gui/widgets/text_box.cpp | 1 - src/gui/widgets/text_box_base.cpp | 18 ++------ src/gui/widgets/toggle_button.cpp | 4 -- src/gui/widgets/toggle_panel.cpp | 2 - src/gui/widgets/tree_view.cpp | 16 +------ src/gui/widgets/tree_view.hpp | 5 --- src/gui/widgets/tree_view_node.cpp | 15 ------- src/gui/widgets/tree_view_node.hpp | 8 ---- src/gui/widgets/viewport.cpp | 9 ---- src/gui/widgets/viewport.hpp | 5 --- src/gui/widgets/widget.cpp | 48 --------------------- src/gui/widgets/widget.hpp | 57 +------------------------ src/gui/widgets/window.hpp | 2 +- src/scripting/lua_gui2.cpp | 1 - 47 files changed, 8 insertions(+), 410 deletions(-) diff --git a/src/gui/core/event/handler.cpp b/src/gui/core/event/handler.cpp index c4c45652f313..45d54d343c05 100644 --- a/src/gui/core/event/handler.cpp +++ b/src/gui/core/event/handler.cpp @@ -501,12 +501,6 @@ void sdl_event_handler::disconnect(dispatcher* disp) keyboard_focus_ = nullptr; } - /***** Set proper state for the other dispatchers. *****/ - for(auto d : dispatchers_) - { - dynamic_cast(*d).set_is_dirty(true); - } - activate(); /***** Validate post conditions. *****/ @@ -548,13 +542,6 @@ void sdl_event_handler::draw(const bool force) SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); SDL_RenderClear(renderer); - /* - * In normal draw mode the first window in not forced to be drawn the - * others are. So for forced mode we only need to force the first window to - * be drawn the others are already handled. - */ - bool first = !force; - /** * @todo Need to evaluate which windows really to redraw. * @@ -562,18 +549,6 @@ void sdl_event_handler::draw(const bool force) */ for(auto dispatcher : dispatchers_) { - if(!first) { - /* - * This leaves glitches on window borders if the window beneath it - * has changed, on the other hand invalidating twindown::restorer_ - * causes black borders around the window. So there's the choice - * between two evils. - */ - dynamic_cast(*dispatcher).set_is_dirty(true); - } else { - first = false; - } - dispatcher->fire(DRAW, dynamic_cast(*dispatcher)); } diff --git a/src/gui/dialogs/debug_clock.cpp b/src/gui/dialogs/debug_clock.cpp index ad2cc762f612..4daa4b1b92b2 100644 --- a/src/gui/dialogs/debug_clock.cpp +++ b/src/gui/dialogs/debug_clock.cpp @@ -155,7 +155,6 @@ void debug_clock::update_time(const bool force) canvas.set_variable("minute", wfl::variant(minute_stamp)); canvas.set_variable("second", wfl::variant(second_stamp)); } - clock_->set_is_dirty(true); } const std::map tags; diff --git a/src/gui/dialogs/editor/custom_tod.cpp b/src/gui/dialogs/editor/custom_tod.cpp index 69b507a8bcbf..a94f099dff39 100644 --- a/src/gui/dialogs/editor/custom_tod.cpp +++ b/src/gui/dialogs/editor/custom_tod.cpp @@ -301,9 +301,6 @@ void custom_tod::update_tod_display(window& window) // redraw tiles disp->draw(false); - - // NOTE: revert to invalidate_layout if necessary to display the ToD mask image. - window.set_is_dirty(true); } void custom_tod::update_lawful_bonus(window& window) diff --git a/src/gui/dialogs/lua_interpreter.cpp b/src/gui/dialogs/lua_interpreter.cpp index 2020b45563d8..c1d1c25d220f 100644 --- a/src/gui/dialogs/lua_interpreter.cpp +++ b/src/gui/dialogs/lua_interpreter.cpp @@ -518,10 +518,6 @@ void lua_interpreter::controller::input_keypress_callback(bool& handled, handled = true; halt = true; - // Commands such as `wesnoth.zoom` might cause the display to redraw and leave the window half-drawn. - // This preempts that. - window.set_is_dirty(true); - LOG_LUA << "finished executing\n"; } else if(key == SDLK_TAB) { // handle tab completion tab(); diff --git a/src/gui/dialogs/outro.cpp b/src/gui/dialogs/outro.cpp index 6200d57cd4ff..1c14bbf4e515 100644 --- a/src/gui/dialogs/outro.cpp +++ b/src/gui/dialogs/outro.cpp @@ -98,8 +98,6 @@ void outro::draw_callback(window& window) window_canvas.set_variable("fade_step", wfl::variant(fade_step_)); window_canvas.set_is_dirty(true); - window.set_is_dirty(true); - if(fading_in_) { fade_step_ ++; } else { diff --git a/src/gui/dialogs/story_viewer.cpp b/src/gui/dialogs/story_viewer.cpp index 56a60927b480..3ddcf0425d86 100644 --- a/src/gui/dialogs/story_viewer.cpp +++ b/src/gui/dialogs/story_viewer.cpp @@ -199,7 +199,6 @@ void story_viewer::display_part(window& window) // Needed to make the background redraw correctly. window_canvas.set_is_dirty(true); - window.set_is_dirty(true); // // Title @@ -336,8 +335,6 @@ void story_viewer::draw_floating_image(window& window, floating_image_list::cons window_canvas.append_cfg(cfg); window_canvas.set_is_dirty(true); - window.set_is_dirty(true); - ++image_iter; // If a delay is specified, schedule the next image draw. This *must* be a non-repeating timer! @@ -361,7 +358,6 @@ void story_viewer::nav_button_callback(window& window, NAV_DIRECTION direction) // Only set full alpha if Forward was pressed. if(direction == DIR_FORWARD) { find_widget(&window, "part_text", false).set_text_alpha(ALPHA_OPAQUE); - flag_stack_as_dirty(window); return; } } @@ -457,9 +453,6 @@ void story_viewer::draw_callback(window& window) unsigned short new_alpha = utils::clamp(fade_step_ * 25.5, 0, ALPHA_OPAQUE); find_widget(&window, "part_text", false).set_text_alpha(new_alpha); - // The text stack also needs to be marked dirty so the background panel redraws correctly. - flag_stack_as_dirty(window); - if(fade_state_ == FADING_IN) { fade_step_ ++; } else if(fade_state_ == FADING_OUT) { @@ -469,10 +462,5 @@ void story_viewer::draw_callback(window& window) set_next_draw(); } -void story_viewer::flag_stack_as_dirty(window& window) -{ - find_widget(&window, "text_and_control_stack", false).set_is_dirty(true); -} - } // namespace dialogs } // namespace gui2 diff --git a/src/gui/dialogs/story_viewer.hpp b/src/gui/dialogs/story_viewer.hpp index 9d6377efab8b..892ceb7a8c23 100644 --- a/src/gui/dialogs/story_viewer.hpp +++ b/src/gui/dialogs/story_viewer.hpp @@ -74,8 +74,6 @@ class story_viewer : public modal_dialog void draw_callback(window& window); - void flag_stack_as_dirty(window& window); - storyscreen::controller controller_; int part_index_; diff --git a/src/gui/dialogs/title_screen.cpp b/src/gui/dialogs/title_screen.cpp index 3c51212f0d36..926822b14518 100644 --- a/src/gui/dialogs/title_screen.cpp +++ b/src/gui/dialogs/title_screen.cpp @@ -512,15 +512,6 @@ void title_screen::update_tip(window& win, const bool previous) } tips.select_page(page); - - /** - * @todo Look for a proper fix. - * - * This dirtying is required to avoid the blurring to be rendered wrong. - * Not entirely sure why, but since we plan to move to SDL2 that change - * will probably fix this issue automatically. - */ - win.set_is_dirty(true); } void title_screen::show_debug_clock_window(CVideo& video) diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 59d305b06698..8029b50cad0b 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -76,7 +76,6 @@ void button::set_state(const state_t state) { if(state != state_) { state_ = state; - set_is_dirty(true); } } diff --git a/src/gui/widgets/container_base.cpp b/src/gui/widgets/container_base.cpp index 07c9243a2a8c..d14a2ee04676 100644 --- a/src/gui/widgets/container_base.cpp +++ b/src/gui/widgets/container_base.cpp @@ -208,14 +208,6 @@ void container_base::layout_children() grid_.layout_children(); } -void -container_base::child_populate_dirty_list(window& caller, - const std::vector& call_stack) -{ - std::vector child_call_stack = call_stack; - grid_.populate_dirty_list(caller, child_call_stack); -} - widget* container_base::find_at(const point& coordinate, const bool must_be_active) { @@ -251,8 +243,6 @@ void container_base::set_active(const bool active) return; } - set_is_dirty(true); - set_self_active(active); } diff --git a/src/gui/widgets/container_base.hpp b/src/gui/widgets/container_base.hpp index f75c8b81bb8d..67276dc72b1b 100644 --- a/src/gui/widgets/container_base.hpp +++ b/src/gui/widgets/container_base.hpp @@ -111,11 +111,6 @@ class container_base : public styled_widget /** See @ref widget::layout_children. */ virtual void layout_children() override; - /** See @ref widget::child_populate_dirty_list. */ - virtual void - child_populate_dirty_list(window& caller, - const std::vector& call_stack) override; - public: /** See @ref widget::find_at. */ virtual widget* find_at(const point& coordinate, diff --git a/src/gui/widgets/generator.hpp b/src/gui/widgets/generator.hpp index dd640ca9d5ea..b02f8a522c6b 100644 --- a/src/gui/widgets/generator.hpp +++ b/src/gui/widgets/generator.hpp @@ -286,14 +286,6 @@ class generator_base : public widget int x_offset, int y_offset) override = 0; -protected: - /** See @ref widget::child_populate_dirty_list. */ - virtual void - child_populate_dirty_list(window& caller, - const std::vector& call_stack) override - = 0; - -public: /** See @ref widget::find_at. */ virtual widget* find_at(const point& coordinate, const bool must_be_active) override = 0; diff --git a/src/gui/widgets/generator_private.hpp b/src/gui/widgets/generator_private.hpp index a703ce9e7566..f02aef9f588c 100644 --- a/src/gui/widgets/generator_private.hpp +++ b/src/gui/widgets/generator_private.hpp @@ -859,18 +859,6 @@ class generator : public minimum_selection, } } - /** See @ref widget::child_populate_dirty_list. */ - virtual void - child_populate_dirty_list(window& caller, - const std::vector& call_stack) override - { - for(auto& item : items_) - { - std::vector child_call_stack = call_stack; - item->child_grid.populate_dirty_list(caller, child_call_stack); - } - } - /** See @ref widget::find_at. */ virtual widget* find_at(const point& coordinate, const bool must_be_active) override @@ -1004,7 +992,6 @@ class generator : public minimum_selection, { order_func_ = order; order_dirty_ = true; - this->set_is_dirty(true); } struct calculate_order_helper diff --git a/src/gui/widgets/grid.cpp b/src/gui/widgets/grid.cpp index 72fb98862368..59b6fa8a016c 100644 --- a/src/gui/widgets/grid.cpp +++ b/src/gui/widgets/grid.cpp @@ -636,21 +636,6 @@ void grid::layout_children() } } -void grid::child_populate_dirty_list(window& caller, - const std::vector& call_stack) -{ - assert(!call_stack.empty() && call_stack.back() == this); - - for(auto & child : children_) - { - - assert(child.get_widget()); - - std::vector child_call_stack = call_stack; - child.get_widget()->populate_dirty_list(caller, child_call_stack); - } -} - widget* grid::find_at(const point& coordinate, const bool must_be_active) { return grid_implementation::find_at( @@ -1015,7 +1000,6 @@ void grid::impl_draw_children(surface& frame_buffer, int x_offset, int y_offset) */ assert(get_visible() == widget::visibility::visible); - set_is_dirty(false); for(auto & child : children_) { @@ -1034,7 +1018,6 @@ void grid::impl_draw_children(surface& frame_buffer, int x_offset, int y_offset) widget->draw_background(frame_buffer, x_offset, y_offset); widget->draw_children(frame_buffer, x_offset, y_offset); widget->draw_foreground(frame_buffer, x_offset, y_offset); - widget->set_is_dirty(false); } } diff --git a/src/gui/widgets/grid.hpp b/src/gui/widgets/grid.hpp index 497556389bd0..93b90413e73e 100644 --- a/src/gui/widgets/grid.hpp +++ b/src/gui/widgets/grid.hpp @@ -79,7 +79,6 @@ class grid : public widget { assert(row < row_grow_factor_.size()); row_grow_factor_[row] = factor; - set_is_dirty(true); } /** @@ -94,7 +93,6 @@ class grid : public widget { assert(column < col_grow_factor_.size()); col_grow_factor_[column] = factor; - set_is_dirty(true); } /***** ***** ***** ***** CHILD MANIPULATION ***** ***** ***** *****/ @@ -264,11 +262,6 @@ class grid : public widget /** See @ref widget::layout_children. */ virtual void layout_children() override; - /** See @ref widget::child_populate_dirty_list. */ - virtual void - child_populate_dirty_list(window& caller, - const std::vector& call_stack) override; - /** See @ref widget::find_at. */ virtual widget* find_at(const point& coordinate, const bool must_be_active) override; diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index fd0616954fbf..68a280a8f2c7 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -81,8 +81,6 @@ void label::set_text_alpha(unsigned short alpha) for(auto& tmp : get_canvases()) { tmp.set_variable("text_alpha", wfl::variant(text_alpha_)); } - - set_is_dirty(true); } void label::set_active(const bool active) @@ -120,7 +118,6 @@ void label::set_link_aware(bool link_aware) link_aware_ = link_aware; update_canvas(); - set_is_dirty(true); } void label::set_link_color(const color_t& color) @@ -130,14 +127,12 @@ void label::set_link_color(const color_t& color) } link_color_ = color; update_canvas(); - set_is_dirty(true); } void label::set_state(const state_t state) { if(state != state_) { state_ = state; - set_is_dirty(true); } } diff --git a/src/gui/widgets/list.cpp b/src/gui/widgets/list.cpp index b2e8ab3c0c3d..513b9604a2c0 100644 --- a/src/gui/widgets/list.cpp +++ b/src/gui/widgets/list.cpp @@ -193,7 +193,6 @@ void list_view::set_row_shown(const unsigned row, const bool shown) window->invalidate_layout(); } else { // get_grid().set_visible_rectangle(content_visible_rectangle()); - set_is_dirty(true); } if(selected_row != get_selected_row()) { @@ -227,7 +226,6 @@ void list_view::set_row_shown(const boost::dynamic_bitset<>& shown) window->invalidate_layout(); } else { // content_grid_->set_visible_rectangle(content_visible_rectangle()); - set_is_dirty(true); } if(selected_row != get_selected_row()) { @@ -312,10 +310,7 @@ void list_view::resize_content( // Set status. need_layout_ = true; - // If the content grows assume it "overwrites" the old content. - if(width_modification < 0 || height_modification < 0) { - set_is_dirty(true); - } + DBG_GUI_L << LOG_HEADER << " succeeded.\n"; } else { DBG_GUI_L << LOG_HEADER << " failed.\n"; @@ -370,7 +365,6 @@ void list_view::layout_children(const bool force) get_grid().set_visible_rectangle(content_visible_area_); */ need_layout_ = false; - set_is_dirty(true); } } diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index a0835c3e0fb9..35f9d0c827a3 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -175,7 +175,6 @@ void listbox::set_row_shown(const unsigned row, const bool shown) window->invalidate_layout(); } else { content_grid_->set_visible_rectangle(content_visible_area()); - set_is_dirty(true); } if(selected_row != get_selected_row() && callback_value_changed_) { @@ -215,7 +214,6 @@ void listbox::set_row_shown(const boost::dynamic_bitset<>& shown) window->invalidate_layout(); } else { content_grid_->set_visible_rectangle(content_visible_area()); - set_is_dirty(true); } if(selected_row != get_selected_row() && callback_value_changed_) { @@ -328,7 +326,6 @@ bool listbox::update_content_size() if(content_resize_request(true)) { content_grid_->set_visible_rectangle(content_visible_area()); - set_is_dirty(true); return true; } @@ -401,10 +398,7 @@ void listbox::resize_content(const int width_modification, // Set status. need_layout_ = true; - // If the content grows assume it "overwrites" the old content. - if(width_modification < 0 || height_modification < 0) { - set_is_dirty(true); - } + DBG_GUI_L << LOG_HEADER << " succeeded.\n"; } else { DBG_GUI_L << LOG_HEADER << " failed.\n"; @@ -436,18 +430,6 @@ void listbox::layout_children() layout_children(false); } -void -listbox::child_populate_dirty_list(window& caller, - const std::vector& call_stack) -{ - // Inherited. - scrollbar_container::child_populate_dirty_list(caller, call_stack); - - assert(generator_); - std::vector child_call_stack = call_stack; - generator_->populate_dirty_list(caller, child_call_stack); -} - void listbox::handle_key_up_arrow(SDL_Keymod modifier, bool& handled) { assert(generator_); @@ -620,7 +602,6 @@ void listbox::order_by(const generator_base::torder_func& func) { generator_->set_order(func); - set_is_dirty(true); need_layout_ = true; } @@ -695,7 +676,6 @@ void listbox::layout_children(const bool force) } need_layout_ = false; - set_is_dirty(true); } } diff --git a/src/gui/widgets/listbox.hpp b/src/gui/widgets/listbox.hpp index 4cee882801c5..fb9853897261 100644 --- a/src/gui/widgets/listbox.hpp +++ b/src/gui/widgets/listbox.hpp @@ -246,11 +246,6 @@ class listbox : public scrollbar_container /** See @ref widget::layout_children. */ virtual void layout_children() override; - /** See @ref widget::child_populate_dirty_list. */ - virtual void - child_populate_dirty_list(window& caller, - const std::vector& call_stack) override; - /***** ***** ***** setters / getters for members ***** ****** *****/ void set_callback_item_change(const std::function& callback) diff --git a/src/gui/widgets/matrix.cpp b/src/gui/widgets/matrix.cpp index 78d8a79c8380..201aac56d8fb 100644 --- a/src/gui/widgets/matrix.cpp +++ b/src/gui/widgets/matrix.cpp @@ -124,13 +124,6 @@ void matrix::layout_children() content_.layout_children(); } -void matrix::child_populate_dirty_list(window& caller, - const std::vector& call_stack) -{ - std::vector child_call_stack = call_stack; - content_.populate_dirty_list(caller, child_call_stack); -} - void matrix::request_reduce_width(const unsigned /*maximum_width*/) { } diff --git a/src/gui/widgets/matrix.hpp b/src/gui/widgets/matrix.hpp index dca5c07fa863..d1e4680744d0 100644 --- a/src/gui/widgets/matrix.hpp +++ b/src/gui/widgets/matrix.hpp @@ -128,11 +128,6 @@ class matrix : public tbase /** See @ref widget::layout_children. */ virtual void layout_children() override; - /** See @ref widget::child_populate_dirty_list. */ - virtual void - child_populate_dirty_list(window& caller, - const std::vector& call_stack) override; - /** See @ref widget::request_reduce_width. */ virtual void request_reduce_width(const unsigned maximum_width) override; diff --git a/src/gui/widgets/menu_button.cpp b/src/gui/widgets/menu_button.cpp index 586b2cee9ee1..0cdb0b5bbf4a 100644 --- a/src/gui/widgets/menu_button.cpp +++ b/src/gui/widgets/menu_button.cpp @@ -83,7 +83,6 @@ void menu_button::set_state(const state_t state) { if(state != state_) { state_ = state; - set_is_dirty(true); } } @@ -182,10 +181,6 @@ void menu_button::set_values(const std::vector<::config>& values, int selected) assert(static_cast(selected) < values.size()); assert(static_cast(selected_) < values_.size()); - if(values[selected]["label"] != values_[selected_]["label"]) { - set_is_dirty(true); - } - values_ = values; selected_ = selected; @@ -197,10 +192,6 @@ void menu_button::set_selected(int selected) assert(static_cast(selected) < values_.size()); assert(static_cast(selected_) < values_.size()); - if(selected != selected_) { - set_is_dirty(true); - } - selected_ = selected; set_label(values_[selected_]["label"]); diff --git a/src/gui/widgets/minimap.hpp b/src/gui/widgets/minimap.hpp index 63e0a6260aaf..81c97b622b43 100644 --- a/src/gui/widgets/minimap.hpp +++ b/src/gui/widgets/minimap.hpp @@ -59,7 +59,6 @@ class minimap : public styled_widget { if(map_data != map_data_) { map_data_ = map_data; - set_is_dirty(true); } } diff --git a/src/gui/widgets/multimenu_button.cpp b/src/gui/widgets/multimenu_button.cpp index 60695faead0d..4fe129a01ed0 100644 --- a/src/gui/widgets/multimenu_button.cpp +++ b/src/gui/widgets/multimenu_button.cpp @@ -83,7 +83,6 @@ void multimenu_button::set_state(const state_t state) { if(state != state_) { state_ = state; - set_is_dirty(true); } } @@ -239,8 +238,6 @@ void multimenu_button::select_options(boost::dynamic_bitset<> states) void multimenu_button::set_values(const std::vector<::config>& values) { - set_is_dirty(true); - values_ = values; toggle_states_.resize(values_.size(), false); toggle_states_.reset(); diff --git a/src/gui/widgets/pane.cpp b/src/gui/widgets/pane.cpp index 18464574cd8e..f9b03daa52b2 100644 --- a/src/gui/widgets/pane.cpp +++ b/src/gui/widgets/pane.cpp @@ -201,16 +201,6 @@ pane::impl_draw_children(surface& frame_buffer, int x_offset, int y_offset) } } -void pane::child_populate_dirty_list(window& caller, - const std::vector& call_stack) -{ - for(auto & item : items_) - { - std::vector child_call_stack = call_stack; - item.item_grid->populate_dirty_list(caller, child_call_stack); - } -} - void pane::sort(const tcompare_functor& compare_functor) { items_.sort(compare_functor); diff --git a/src/gui/widgets/pane.hpp b/src/gui/widgets/pane.hpp index c48a4081ba8c..071d71a16693 100644 --- a/src/gui/widgets/pane.hpp +++ b/src/gui/widgets/pane.hpp @@ -80,11 +80,6 @@ class pane : public widget int x_offset, int y_offset) override; - /** See @ref widget::child_populate_dirty_list. */ - virtual void - child_populate_dirty_list(window& caller, - const std::vector& call_stack) override; - /** See @ref widget::request_reduce_width. */ virtual void request_reduce_width(const unsigned maximum_width) override; diff --git a/src/gui/widgets/progress_bar.cpp b/src/gui/widgets/progress_bar.cpp index e0e505de1340..c3f9ce219ffc 100644 --- a/src/gui/widgets/progress_bar.cpp +++ b/src/gui/widgets/progress_bar.cpp @@ -58,8 +58,6 @@ void progress_bar::set_percentage(unsigned percentage) { c.set_variable("percentage", wfl::variant(percentage)); } - - set_is_dirty(true); } } diff --git a/src/gui/widgets/repeating_button.cpp b/src/gui/widgets/repeating_button.cpp index 4a473c0e8aa4..619d937b20e7 100644 --- a/src/gui/widgets/repeating_button.cpp +++ b/src/gui/widgets/repeating_button.cpp @@ -89,7 +89,6 @@ void repeating_button::set_state(const state_t state) { if(state != state_) { state_ = state; - set_is_dirty(true); if(state_ == DISABLED && repeat_timer_) { remove_timer(repeat_timer_); diff --git a/src/gui/widgets/scrollbar.cpp b/src/gui/widgets/scrollbar.cpp index 2e7ff0363640..b05538c14bb7 100644 --- a/src/gui/widgets/scrollbar.cpp +++ b/src/gui/widgets/scrollbar.cpp @@ -154,14 +154,12 @@ void scrollbar_base::update_canvas() tmp.set_variable("positioner_offset", wfl::variant(positioner_offset_)); tmp.set_variable("positioner_length", wfl::variant(positioner_length_)); } - set_is_dirty(true); } void scrollbar_base::set_state(const state_t state) { if(state != state_) { state_ = state; - set_is_dirty(true); } } diff --git a/src/gui/widgets/scrollbar_container.cpp b/src/gui/widgets/scrollbar_container.cpp index 4dfa78318706..87fba4e08077 100644 --- a/src/gui/widgets/scrollbar_container.cpp +++ b/src/gui/widgets/scrollbar_container.cpp @@ -876,17 +876,6 @@ void scrollbar_container::layout_children() content_grid_->layout_children(); } -void scrollbar_container::child_populate_dirty_list( - window& caller, const std::vector& call_stack) -{ - // Inherited. - container_base::child_populate_dirty_list(caller, call_stack); - - assert(content_grid_); - std::vector child_call_stack(call_stack); - content_grid_->populate_dirty_list(caller, child_call_stack); -} - void scrollbar_container::set_content_size(const point& origin, const point& size) { @@ -1168,7 +1157,6 @@ void scrollbar_container::scrollbar_moved() content_grid_->set_origin(content_origin); content_grid_->set_visible_rectangle(content_visible_area_); - content_grid_->set_is_dirty(true); // Update scrollbar. set_scrollbar_button_status(); diff --git a/src/gui/widgets/scrollbar_container.hpp b/src/gui/widgets/scrollbar_container.hpp index f72b2c4edd82..95cad5d67430 100644 --- a/src/gui/widgets/scrollbar_container.hpp +++ b/src/gui/widgets/scrollbar_container.hpp @@ -511,12 +511,6 @@ class scrollbar_container : public container_base virtual void impl_draw_children(surface& frame_buffer, int x_offset, int y_offset) override; - - /** See @ref widget::child_populate_dirty_list. */ - virtual void - child_populate_dirty_list(window& caller, - const std::vector& call_stack) override; - /** * Sets the size of the content grid. * diff --git a/src/gui/widgets/slider.hpp b/src/gui/widgets/slider.hpp index ce76e72db097..5732079f44a8 100644 --- a/src/gui/widgets/slider.hpp +++ b/src/gui/widgets/slider.hpp @@ -73,7 +73,6 @@ class slider : public scrollbar_base, public integer_selector void set_best_slider_length(const unsigned length) { best_slider_length_ = length; - set_is_dirty(true); } void set_minimum_value_label(const t_string& minimum_value_label) diff --git a/src/gui/widgets/styled_widget.cpp b/src/gui/widgets/styled_widget.cpp index 2cd231c529ac..482f4771c492 100644 --- a/src/gui/widgets/styled_widget.cpp +++ b/src/gui/widgets/styled_widget.cpp @@ -359,7 +359,6 @@ void styled_widget::set_label(const t_string& label) label_ = label; set_layout_size(point()); update_canvas(); - set_is_dirty(true); } void styled_widget::set_use_markup(bool use_markup) @@ -370,7 +369,6 @@ void styled_widget::set_use_markup(bool use_markup) use_markup_ = use_markup; update_canvas(); - set_is_dirty(true); } void styled_widget::set_text_alignment(const PangoAlignment text_alignment) @@ -381,7 +379,6 @@ void styled_widget::set_text_alignment(const PangoAlignment text_alignment) text_alignment_ = text_alignment; update_canvas(); - set_is_dirty(true); } void styled_widget::set_text_ellipse_mode(const PangoEllipsizeMode ellipse_mode) @@ -392,7 +389,6 @@ void styled_widget::set_text_ellipse_mode(const PangoEllipsizeMode ellipse_mode) text_ellipse_mode_ = ellipse_mode; update_canvas(); - set_is_dirty(true); } void styled_widget::update_canvas() diff --git a/src/gui/widgets/text_box.cpp b/src/gui/widgets/text_box.cpp index b5f46e804bfb..f4b4bbdf898c 100644 --- a/src/gui/widgets/text_box.cpp +++ b/src/gui/widgets/text_box.cpp @@ -256,7 +256,6 @@ void text_box::handle_mouse_selection(point mouse, const bool start_selection) set_cursor(offset, !start_selection); update_canvas(); - set_is_dirty(true); dragging_ |= start_selection; } diff --git a/src/gui/widgets/text_box_base.cpp b/src/gui/widgets/text_box_base.cpp index 487caf7e64e1..b3cd8efd6cb2 100644 --- a/src/gui/widgets/text_box_base.cpp +++ b/src/gui/widgets/text_box_base.cpp @@ -55,7 +55,7 @@ text_box_base::text_box_base() &text_box_base::signal_handler_sdl_key_down, this, _2, _3, _5, _6)); connect_signal(std::bind(&text_box_base::handle_commit, this, _3, _5)); connect_signal(std::bind(&text_box_base::handle_editing, this, _3, _5, _6, _7)); - + connect_signal(std::bind( &text_box_base::signal_handler_receive_keyboard_focus, this, _2)); connect_signal( @@ -104,7 +104,6 @@ void text_box_base::set_maximum_length(const size_t maximum_length) selection_length_ = maximum_length - selection_start_; } update_canvas(); - set_is_dirty(true); } } @@ -117,7 +116,6 @@ void text_box_base::set_value(const std::string& text) selection_start_ = text_.get_length(); selection_length_ = 0; update_canvas(); - set_is_dirty(true); } } @@ -138,7 +136,6 @@ void text_box_base::set_cursor(const size_t offset, const bool select) copy_selection(true); #endif update_canvas(); - set_is_dirty(true); } else { assert(offset <= text_.get_length()); @@ -146,7 +143,6 @@ void text_box_base::set_cursor(const size_t offset, const bool select) selection_length_ = 0; update_canvas(); - set_is_dirty(true); } } @@ -159,7 +155,6 @@ void text_box_base::insert_char(const utf8::string& unicode) // Update status set_cursor(selection_start_ + utf8::size(unicode), false); update_canvas(); - set_is_dirty(true); } } @@ -204,7 +199,6 @@ void text_box_base::paste_selection(const bool mouse) selection_start_ += text_.insert_text(selection_start_, text); update_canvas(); - set_is_dirty(true); fire(event::NOTIFY_MODIFIED, *this, nullptr); } @@ -212,7 +206,6 @@ void text_box_base::set_selection_start(const size_t selection_start) { if(selection_start != selection_start_) { selection_start_ = selection_start; - set_is_dirty(true); } } @@ -220,7 +213,6 @@ void text_box_base::set_selection_length(const int selection_length) { if(selection_length != selection_length_) { selection_length_ = selection_length; - set_is_dirty(true); } } @@ -260,7 +252,6 @@ void text_box_base::set_state(const state_t state) { if(state != state_) { state_ = state; - set_is_dirty(true); } } @@ -304,8 +295,6 @@ void text_box_base::cursor_timer_callback() for(auto& tmp : get_canvases()) { tmp.set_variable("cursor_alpha", wfl::variant(cursor_alpha_)); } - - set_is_dirty(true); } void text_box_base::reset_cursor_state() @@ -451,7 +440,6 @@ void text_box_base::handle_editing(bool& handled, const utf8::string& unicode, i set_cursor(ime_start_point_ + ime_cursor_ + len, true); } update_canvas(); - set_is_dirty(true); } } @@ -587,7 +575,7 @@ void text_box_base::signal_handler_sdl_key_down(const event::ui_event event, // The IME will handle it, we just need to make sure nothing else handles it too. handled = true; break; - + case SDLK_ESCAPE: if(!ime_in_progress_ || (modifier & (KMOD_CTRL | KMOD_ALT | KMOD_GUI | KMOD_SHIFT))) { return; @@ -595,7 +583,7 @@ void text_box_base::signal_handler_sdl_key_down(const event::ui_event event, interrupt_composition(); handled = true; break; - + default: // Don't call the text changed callback if nothing happened. return; diff --git a/src/gui/widgets/toggle_button.cpp b/src/gui/widgets/toggle_button.cpp index b5e57c556c5e..293cdb53f2f6 100644 --- a/src/gui/widgets/toggle_button.cpp +++ b/src/gui/widgets/toggle_button.cpp @@ -107,8 +107,6 @@ void toggle_button::update_canvas() { canvas.set_variable("icon", wfl::variant(icon_name_)); } - - set_is_dirty(true); } void toggle_button::set_value(const unsigned selected) @@ -117,7 +115,6 @@ void toggle_button::set_value(const unsigned selected) return; } state_num_ = selected % num_states(); - set_is_dirty(true); // Check for get_window() is here to prevent the callback from // being called when the initial value is set. @@ -140,7 +137,6 @@ void toggle_button::set_state(const state_t state) { if(state != state_) { state_ = state; - set_is_dirty(true); } } diff --git a/src/gui/widgets/toggle_panel.cpp b/src/gui/widgets/toggle_panel.cpp index cfc21ba49083..59ee3eca56a8 100644 --- a/src/gui/widgets/toggle_panel.cpp +++ b/src/gui/widgets/toggle_panel.cpp @@ -171,7 +171,6 @@ void toggle_panel::set_value(const unsigned selected) return; } state_num_ = selected % num_states(); - set_is_dirty(true); } void toggle_panel::set_retval(const int retval) @@ -186,7 +185,6 @@ void toggle_panel::set_state(const state_t state) } state_ = state; - set_is_dirty(true); std::shared_ptr conf = std::static_pointer_castget_size().y); } -void -tree_view::child_populate_dirty_list(window& caller, - const std::vector& call_stack) -{ - // Inherited. - scrollbar_container::child_populate_dirty_list(caller, call_stack); - - assert(root_node_); - root_node_->impl_populate_dirty_list(caller, call_stack); -} - void tree_view::set_self_active(const bool /*active*/) { /* DO NOTHING */ @@ -142,10 +131,7 @@ void tree_view::resize_content(const int width_modification, // Set status. need_layout_ = true; - // If the content grows assume it "overwrites" the old content. - if(width_modification < 0 || height_modification < 0) { - set_is_dirty(true); - } + horizontal_scrollbar_moved(); DBG_GUI_L << LOG_HEADER << " succeeded.\n"; } else { diff --git a/src/gui/widgets/tree_view.hpp b/src/gui/widgets/tree_view.hpp index abd0035d47ca..600bb19ae1f7 100644 --- a/src/gui/widgets/tree_view.hpp +++ b/src/gui/widgets/tree_view.hpp @@ -63,11 +63,6 @@ class tree_view : public scrollbar_container void clear(); - /** See @ref widget::child_populate_dirty_list. */ - virtual void - child_populate_dirty_list(window& caller, - const std::vector& call_stack) override; - /** See @ref container_base::set_self_active. */ virtual void set_self_active(const bool active) override; diff --git a/src/gui/widgets/tree_view_node.cpp b/src/gui/widgets/tree_view_node.cpp index d374e7232f9e..c908f9312904 100644 --- a/src/gui/widgets/tree_view_node.cpp +++ b/src/gui/widgets/tree_view_node.cpp @@ -393,21 +393,6 @@ const widget* tree_view_node::find(const std::string& id, const bool must_be_act return nullptr; } -void tree_view_node::impl_populate_dirty_list(window& caller, const std::vector& call_stack) -{ - std::vector my_call_stack = call_stack; - grid_.populate_dirty_list(caller, my_call_stack); - - if(is_folded()) { - return; - } - - for(auto& node : children_) { - std::vector child_call_stack = call_stack; - node.impl_populate_dirty_list(caller, child_call_stack); - } -} - point tree_view_node::calculate_best_size() const { return calculate_best_size(-1, get_tree_view().indentation_step_size_); diff --git a/src/gui/widgets/tree_view_node.hpp b/src/gui/widgets/tree_view_node.hpp index 5820eb305b16..d4b34d619c0d 100644 --- a/src/gui/widgets/tree_view_node.hpp +++ b/src/gui/widgets/tree_view_node.hpp @@ -282,14 +282,6 @@ class tree_view_node : public widget void fold_internal(); void unfold_internal(); - /** - * "Inherited" from widget. - * - * This version needs to call its children, which are it's child nodes. - */ - void impl_populate_dirty_list(window& caller, - const std::vector& call_stack); - /** See @ref widget::calculate_best_size. */ virtual point calculate_best_size() const override; diff --git a/src/gui/widgets/viewport.cpp b/src/gui/widgets/viewport.cpp index 73ec51a59118..594a0ecc04d9 100644 --- a/src/gui/widgets/viewport.cpp +++ b/src/gui/widgets/viewport.cpp @@ -130,18 +130,9 @@ viewport::impl_draw_children(surface& frame_buffer, int x_offset, int y_offset) widget_.draw_background(frame_buffer, x_offset, y_offset); widget_.draw_children(frame_buffer, x_offset, y_offset); widget_.draw_foreground(frame_buffer, x_offset, y_offset); - widget_.set_is_dirty(false); } } -void -viewport::child_populate_dirty_list(window& caller, - const std::vector& call_stack) -{ - std::vector child_call_stack = call_stack; - widget_.populate_dirty_list(caller, child_call_stack); -} - void viewport::request_reduce_width(const unsigned /*maximum_width*/) { } diff --git a/src/gui/widgets/viewport.hpp b/src/gui/widgets/viewport.hpp index b807f8a82ec8..f05e3e7f8876 100644 --- a/src/gui/widgets/viewport.hpp +++ b/src/gui/widgets/viewport.hpp @@ -58,11 +58,6 @@ class viewport : public widget int x_offset, int y_offset) override; - /** See @ref widget::child_populate_dirty_list. */ - virtual void - child_populate_dirty_list(window& caller, - const std::vector& call_stack) override; - /** See @ref widget::request_reduce_width. */ virtual void request_reduce_width(const unsigned maximum_width) override; diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp index 8d7cf2af425b..9810446761b6 100644 --- a/src/gui/widgets/widget.cpp +++ b/src/gui/widgets/widget.cpp @@ -39,7 +39,6 @@ widget::widget() , last_best_size_() #endif , linked_group_() - , is_dirty_(true) , visible_(visibility::visible) , redraw_action_(redraw_action::full) , clipping_rectangle_() @@ -61,7 +60,6 @@ widget::widget(const builder_widget& builder) , last_best_size_() #endif , linked_group_(builder.linked_group) - , is_dirty_(true) , visible_(visibility::visible) , redraw_action_(redraw_action::full) , clipping_rectangle_() @@ -234,8 +232,6 @@ void widget::set_size(const point& size) width_ = size.x; height_ = size.y; - - set_is_dirty(true); } void widget::place(const point& origin, const point& size) @@ -259,8 +255,6 @@ void widget::place(const point& origin, const point& size) << " screen origin " << x_ << ',' << y_ << ".\n"; #endif - - set_is_dirty(true); } void widget::move(const int x_offset, const int y_offset) @@ -417,36 +411,6 @@ void widget::draw_foreground(surface& frame_buffer, int x_offset, int y_offset) } } -void widget::populate_dirty_list(window& caller, - std::vector& call_stack) -{ - assert(call_stack.empty() || call_stack.back() != this); - - if(visible_ != visibility::visible) { - return; - } - - if(get_drawing_action() == redraw_action::none) { - return; - } - - call_stack.push_back(this); - //if(is_dirty_) { - caller.add_to_dirty_list(call_stack); - //} else { - // virtual function which only does something for container items. - // child_populate_dirty_list(caller, call_stack); - //} -} - -void -widget::child_populate_dirty_list(window& /*caller*/ - , - const std::vector& /*call_stack*/) -{ - /* DO NOTHING */ -} - SDL_Rect widget::get_dirty_rectangle() const { return redraw_action_ == redraw_action::full ? get_rectangle() @@ -466,16 +430,6 @@ void widget::set_visible_rectangle(const SDL_Rect& rectangle) } } -void widget::set_is_dirty(const bool is_dirty) -{ - is_dirty_ = is_dirty; -} - -bool widget::get_is_dirty() const -{ - return is_dirty_; -} - void widget::set_visible(const visibility visible) { if(visible == visible_) { @@ -498,8 +452,6 @@ void widget::set_visible(const visibility visible) window->invalidate_layout(); } } - } else { - set_is_dirty(true); } } diff --git a/src/gui/widgets/widget.hpp b/src/gui/widgets/widget.hpp index 07772a66581e..8b752d166258 100644 --- a/src/gui/widgets/widget.hpp +++ b/src/gui/widgets/widget.hpp @@ -64,8 +64,7 @@ class widget : public event_executor, public event::dispatcher * tested later). * * The widget (if active) handles events (and sends events to * its children). - * * The widget is drawn (and sends the call to - * @ref populate_dirty_list to children). + * * The widget is drawn. */ visible, @@ -75,9 +74,6 @@ class widget : public event_executor, public event::dispatcher * * @ref find_at 'sees' the widget if active is @c false. * * The widget doesn't handle events (and doesn't send events to * its children). - * * The widget doesn't add itself @ref window::dirty_list_ when - * @ref populate_dirty_list is called (nor does it send the - * request to its children). */ hidden, @@ -87,9 +83,6 @@ class widget : public event_executor, public event::dispatcher * * @ref find_at never 'sees' the widget. * * The widget doesn't handle events (and doesn't send events to * its children). - * * The widget doesn't add itself @ref window::dirty_list_ when - * @ref populate_dirty_list is called (nor does it send the - * request to its children). */ invisible }; @@ -633,40 +626,6 @@ class widget : public event_executor, public event::dispatcher { } -public: - /** - * Adds a widget to the dirty list if it is dirty. - * - * See @ref window::dirty_list_ for more information regarding the dirty - * list. - * - * If the widget is not dirty and has children it should add itself to the - * call_stack and call child_populate_dirty_list with the new call_stack. - * - * @param caller The parent window, if dirty it should - * register itself to this window. - * @param call_stack The call-stack of widgets traversed to reach - * this function. - */ - void populate_dirty_list(window& caller, - std::vector& call_stack); - -private: - /** - * Tries to add all children of a container to the dirty list. - * - * @note The function is private since everybody should call - * @ref populate_dirty_list instead. - * - * @param caller The parent window, if dirty it should - * register itself to this window. - * @param call_stack The call-stack of widgets traversed to reach - * this function. - */ - virtual void - child_populate_dirty_list(window& caller, - const std::vector& call_stack); - public: /** * Gets the dirty rectangle of the widget. @@ -690,9 +649,6 @@ class widget : public event_executor, public event::dispatcher /*** *** *** *** *** *** Setters and getters. *** *** *** *** *** ***/ - void set_is_dirty(const bool is_dirty); - bool get_is_dirty() const; - void set_visible(const visibility visible); visibility get_visible() const; @@ -705,17 +661,6 @@ class widget : public event_executor, public event::dispatcher /*** *** *** *** *** *** *** *** Members. *** *** *** *** *** *** *** ***/ private: - /** - * Is the widget dirty? - * - * When a widget is dirty it needs to be redrawn at the next drawing cycle. - * - * The top-level window will use @ref populate_dirty_list and - * @ref child_populate_dirty_list to find al dirty widgets, so the widget - * doesn't need to inform its parent regarding it being marked dirty. - */ - bool is_dirty_; - /** Field for the status of the visibility. */ visibility visible_; diff --git a/src/gui/widgets/window.hpp b/src/gui/widgets/window.hpp index 1b56025ac988..d7782e100380 100644 --- a/src/gui/widgets/window.hpp +++ b/src/gui/widgets/window.hpp @@ -443,8 +443,8 @@ class window : public panel, public cursor::setter void set_variable(const std::string& key, const wfl::variant& value) { variables_.add(key, value); - set_is_dirty(true); } + point get_linked_size(const std::string& linked_group_id) const { std::map::const_iterator it = linked_size_.find(linked_group_id); diff --git a/src/scripting/lua_gui2.cpp b/src/scripting/lua_gui2.cpp index eb7b7fbe6793..f29e179684ad 100644 --- a/src/scripting/lua_gui2.cpp +++ b/src/scripting/lua_gui2.cpp @@ -853,7 +853,6 @@ int intf_set_dialog_canvas(lua_State* L) config cfg = luaW_checkconfig(L, 2); cv[i - 1].set_cfg(cfg); - c->set_is_dirty(true); return 0; }