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.
This commit is contained in:
Charles Dang 2017-05-31 00:23:10 +11:00
parent 7632004979
commit c6ed3f018e
49 changed files with 7 additions and 421 deletions

View file

@ -505,12 +505,6 @@ void sdl_event_handler::disconnect(dispatcher* disp)
keyboard_focus_ = nullptr;
}
/***** Set proper state for the other dispatchers. *****/
for(auto d : dispatchers_)
{
dynamic_cast<widget&>(*d).set_is_dirty(true);
}
activate();
/***** Validate post conditions. *****/

View file

@ -153,7 +153,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<std::string, std::string> tags;

View file

@ -299,9 +299,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)

View file

@ -402,8 +402,7 @@ public:
void input_keypress_callback(bool& handled,
bool& halt,
const SDL_Keycode key,
window& window);
const SDL_Keycode key);
void update_view(); ///< Update the view based on the model
@ -468,8 +467,7 @@ void lua_interpreter::controller::bind(window& window)
this,
_3,
_4,
_5,
std::ref(window)));
_5));
copy_button = find_widget<button>(&window, "copy", false, true);
connect_signal_mouse_left_click(
@ -512,8 +510,7 @@ void lua_interpreter::controller::handle_clear_button_clicked(window & /*window*
/** Handle return key (execute) or tab key (tab completion) */
void lua_interpreter::controller::input_keypress_callback(bool& handled,
bool& halt,
const SDL_Keycode key,
window& window)
const SDL_Keycode key)
{
assert(lua_model_);
assert(text_entry);
@ -525,10 +522,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();

View file

@ -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 {

View file

@ -219,7 +219,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
@ -356,8 +355,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!
@ -381,7 +378,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<scroll_label>(&window, "part_text", false).set_text_alpha(ALPHA_OPAQUE);
flag_stack_as_dirty(window);
return;
}
}
@ -477,9 +473,6 @@ void story_viewer::draw_callback(window& window)
unsigned short new_alpha = utils::clamp<short>(fade_step_ * 25.5, 0, ALPHA_OPAQUE);
find_widget<scroll_label>(&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) {
@ -489,10 +482,5 @@ void story_viewer::draw_callback(window& window)
set_next_draw();
}
void story_viewer::flag_stack_as_dirty(window& window)
{
find_widget<stacked_widget>(&window, "text_and_control_stack", false).set_is_dirty(true);
}
} // namespace dialogs
} // namespace gui2

View file

@ -74,8 +74,6 @@ private:
void draw_callback(window& window);
void flag_stack_as_dirty(window& window);
storyscreen::controller controller_;
int part_index_;

View file

@ -427,15 +427,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()

View file

@ -80,7 +80,6 @@ void button::set_state(const state_t state)
{
if(state != state_) {
state_ = state;
set_is_dirty(true);
}
}

View file

@ -209,14 +209,6 @@ void container_base::layout_children()
grid_.layout_children();
}
void
container_base::child_populate_dirty_list(window& caller,
const std::vector<widget*>& call_stack)
{
std::vector<widget*> 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)
{
@ -252,8 +244,6 @@ void container_base::set_active(const bool active)
return;
}
set_is_dirty(true);
set_self_active(active);
}

View file

@ -115,11 +115,6 @@ protected:
/** 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<widget*>& call_stack) override;
public:
/** See @ref widget::find_at. */
virtual widget* find_at(const point& coordinate,

View file

@ -283,14 +283,6 @@ public:
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<widget*>& call_stack) override
= 0;
public:
/** See @ref widget::find_at. */
virtual widget* find_at(const point& coordinate,
const bool must_be_active) override = 0;

View file

@ -841,15 +841,6 @@ public:
}
}
/** See @ref widget::child_populate_dirty_list. */
virtual void child_populate_dirty_list(window& caller, const std::vector<widget*>& call_stack) override
{
for(auto& item : items_) {
std::vector<widget*> 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
{
@ -983,7 +974,6 @@ private:
{
order_func_ = order;
order_dirty_ = true;
this->set_is_dirty(true);
}
struct calculate_order_helper

View file

@ -624,21 +624,6 @@ void grid::layout_children()
}
}
void grid::child_populate_dirty_list(window& caller,
const std::vector<widget*>& call_stack)
{
assert(!call_stack.empty() && call_stack.back() == this);
for(auto & child : children_)
{
assert(child.get_widget());
std::vector<widget*> 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<widget>(
@ -1003,7 +988,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_)
{
@ -1022,7 +1006,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);
}
}

View file

@ -87,7 +87,6 @@ public:
{
assert(row < row_grow_factor_.size());
row_grow_factor_[row] = factor;
set_is_dirty(true);
}
/**
@ -102,7 +101,6 @@ public:
{
assert(column < col_grow_factor_.size());
col_grow_factor_[column] = factor;
set_is_dirty(true);
}
/***** ***** ***** ***** CHILD MANIPULATION ***** ***** ***** *****/
@ -272,11 +270,6 @@ public:
/** 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<widget*>& call_stack) override;
/** See @ref widget::find_at. */
virtual widget* find_at(const point& coordinate,
const bool must_be_active) override;

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -169,7 +169,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()) {
@ -212,7 +211,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()) {
@ -340,7 +338,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,6 @@ 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 {
@ -438,16 +431,6 @@ void listbox::layout_children()
layout_children(false);
}
void listbox::child_populate_dirty_list(window& caller, const std::vector<widget*>& call_stack)
{
// Inherited.
scrollbar_container::child_populate_dirty_list(caller, call_stack);
assert(generator_);
std::vector<widget*> child_call_stack = call_stack;
generator_->populate_dirty_list(caller, child_call_stack);
}
point listbox::calculate_best_size() const
{
// Get the size from the base class, then add any extra space for the header and footer.
@ -618,7 +601,6 @@ void listbox::order_by(const generator_base::order_func& func)
{
generator_->set_order(func);
set_is_dirty(true);
need_layout_ = true;
}
@ -714,7 +696,6 @@ void listbox::layout_children(const bool force)
}
need_layout_ = false;
set_is_dirty(true);
}
}

View file

@ -258,9 +258,6 @@ public:
/** 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<widget*>& call_stack) override;
/***** ***** ***** setters / getters for members ***** ****** *****/
void order_by(const generator_base::order_func& func);

View file

@ -122,13 +122,6 @@ void matrix::layout_children()
content_.layout_children();
}
void matrix::child_populate_dirty_list(window& caller,
const std::vector<widget*>& call_stack)
{
std::vector<widget*> child_call_stack = call_stack;
content_.populate_dirty_list(caller, child_call_stack);
}
void matrix::request_reduce_width(const unsigned /*maximum_width*/)
{
}

View file

@ -128,11 +128,6 @@ public:
/** 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<widget*>& call_stack) override;
/** See @ref widget::request_reduce_width. */
virtual void request_reduce_width(const unsigned maximum_width) override;

View file

@ -82,7 +82,6 @@ void menu_button::set_state(const state_t state)
{
if(state != state_) {
state_ = state;
set_is_dirty(true);
}
}
@ -161,10 +160,6 @@ void menu_button::set_values(const std::vector<::config>& values, int selected)
assert(static_cast<size_t>(selected) < values.size());
assert(static_cast<size_t>(selected_) < values_.size());
if(values[selected]["label"] != values_[selected_]["label"]) {
set_is_dirty(true);
}
values_ = values;
selected_ = selected;
@ -176,10 +171,6 @@ void menu_button::set_selected(int selected, bool fire_event)
assert(static_cast<size_t>(selected) < values_.size());
assert(static_cast<size_t>(selected_) < values_.size());
if(selected != selected_) {
set_is_dirty(true);
}
selected_ = selected;
set_label(values_[selected_]["label"]);

View file

@ -61,7 +61,6 @@ public:
{
if(map_data != map_data_) {
map_data_ = map_data;
set_is_dirty(true);
}
}

View file

@ -84,7 +84,6 @@ void multimenu_button::set_state(const state_t state)
{
if(state != state_) {
state_ = state;
set_is_dirty(true);
}
}
@ -230,8 +229,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();

View file

@ -198,16 +198,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<widget*>& call_stack)
{
for(auto & item : items_)
{
std::vector<widget*> 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);

View file

@ -78,11 +78,6 @@ public:
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<widget*>& call_stack) override;
/** See @ref widget::request_reduce_width. */
virtual void request_reduce_width(const unsigned maximum_width) override;

View file

@ -66,8 +66,6 @@ void progress_bar::set_percentage(unsigned percentage)
{
c.set_variable("percentage", wfl::variant(percentage));
}
set_is_dirty(true);
}
}

View file

@ -92,7 +92,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_);

View file

@ -175,14 +175,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);
}
}

View file

@ -804,16 +804,6 @@ void scrollbar_container::layout_children()
content_grid_->layout_children();
}
void scrollbar_container::child_populate_dirty_list(window& caller, const std::vector<widget*>& call_stack)
{
// Inherited.
container_base::child_populate_dirty_list(caller, call_stack);
assert(content_grid_);
std::vector<widget*> 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)
{
content_grid_->place(origin, size);
@ -1066,7 +1056,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();

View file

@ -508,9 +508,6 @@ private:
/** See @ref widget::impl_draw_children. */
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<widget*>& call_stack) override;
/**
* Sets the size of the content grid.
*

View file

@ -85,7 +85,6 @@ public:
void set_best_slider_length(const unsigned length)
{
best_slider_length_ = length;
set_is_dirty(true);
}
void set_value_range(int min_value, int max_value);

View file

@ -146,15 +146,12 @@ void slider_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 slider_base::set_state(const state_t state)
{
if(state != state_) {
state_ = state;
set_is_dirty(true);
}
}

View file

@ -329,7 +329,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)
@ -340,7 +339,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)
@ -351,7 +349,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)
@ -362,7 +359,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()

View file

@ -264,7 +264,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;
}

View file

@ -105,7 +105,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);
}
}
@ -118,7 +117,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);
}
}
@ -139,7 +137,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());
@ -147,7 +144,6 @@ void text_box_base::set_cursor(const size_t offset, const bool select)
selection_length_ = 0;
update_canvas();
set_is_dirty(true);
}
}
@ -160,7 +156,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);
}
}
@ -205,7 +200,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);
}
@ -213,7 +207,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);
}
}
@ -221,7 +214,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);
}
}
@ -261,7 +253,6 @@ void text_box_base::set_state(const state_t state)
{
if(state != state_) {
state_ = state;
set_is_dirty(true);
}
}
@ -305,8 +296,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()
@ -459,7 +448,6 @@ void text_box_base::handle_editing(bool& handled, const utf8::string& unicode, i
set_cursor(cursor_end, true);
}
update_canvas();
set_is_dirty(true);
}
}

View file

@ -105,8 +105,6 @@ void toggle_button::update_canvas()
{
canvas.set_variable("icon", wfl::variant(icon_name_));
}
set_is_dirty(true);
}
void toggle_button::set_value(unsigned selected, bool fire_event)
@ -116,7 +114,6 @@ void toggle_button::set_value(unsigned selected, bool fire_event)
return;
}
state_num_ = selected;
set_is_dirty(true);
// Check for get_window() is here to prevent the callback from
// being called when the initial value is set.
@ -142,7 +139,6 @@ void toggle_button::set_state(const state_t state)
{
if(state != state_) {
state_ = state;
set_is_dirty(true);
}
}

View file

@ -166,7 +166,6 @@ void toggle_panel::set_value(unsigned selected, bool fire_event)
return;
}
state_num_ = selected;
set_is_dirty(true);
// Check for get_window() is here to prevent the callback from
// being called when the initial value is set.
@ -187,7 +186,6 @@ void toggle_panel::set_state(const state_t state)
}
state_ = state;
set_is_dirty(true);
const auto conf = cast_config_to<toggle_panel_definition>();
assert(conf);

View file

@ -98,17 +98,6 @@ void tree_view::clear()
resize_content(0, -content_grid()->get_size().y);
}
void
tree_view::child_populate_dirty_list(window& caller,
const std::vector<widget*>& 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 */
@ -145,10 +134,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 {

View file

@ -63,11 +63,6 @@ public:
void clear();
/** See @ref widget::child_populate_dirty_list. */
virtual void
child_populate_dirty_list(window& caller,
const std::vector<widget*>& call_stack) override;
/** See @ref container_base::set_self_active. */
virtual void set_self_active(const bool active) override;

View file

@ -383,21 +383,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<widget*>& call_stack)
{
std::vector<widget*> my_call_stack = call_stack;
grid_.populate_dirty_list(caller, my_call_stack);
if(is_folded()) {
return;
}
for(auto& node : children_) {
std::vector<widget*> 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_);

View file

@ -249,14 +249,6 @@ private:
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<widget*>& call_stack);
/** See @ref widget::calculate_best_size. */
virtual point calculate_best_size() const override;

View file

@ -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<widget*>& call_stack)
{
std::vector<widget*> child_call_stack = call_stack;
widget_.populate_dirty_list(caller, child_call_stack);
}
void viewport::request_reduce_width(const unsigned /*maximum_width*/)
{
}

View file

@ -58,11 +58,6 @@ public:
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<widget*>& call_stack) override;
/** See @ref widget::request_reduce_width. */
virtual void request_reduce_width(const unsigned maximum_width) override;

View file

@ -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_()
@ -228,8 +226,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)
@ -253,8 +249,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)
@ -411,36 +405,6 @@ void widget::draw_foreground(surface& frame_buffer, int x_offset, int y_offset)
}
}
void widget::populate_dirty_list(window& caller,
std::vector<widget*>& 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<widget*>& /*call_stack*/)
{
/* DO NOTHING */
}
SDL_Rect widget::get_dirty_rectangle() const
{
return redraw_action_ == redraw_action::full ? get_rectangle()
@ -460,16 +424,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_) {
@ -492,8 +446,6 @@ void widget::set_visible(const visibility visible)
window->invalidate_layout();
}
}
} else {
set_is_dirty(true);
}
}

View file

@ -63,8 +63,7 @@ public:
* 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,
@ -74,9 +73,6 @@ public:
* * @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,
@ -86,9 +82,6 @@ public:
* * @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
};
@ -616,40 +609,6 @@ private:
{
}
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<widget*>& 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<widget*>& call_stack);
public:
/**
* Gets the dirty rectangle of the widget.
@ -673,9 +632,6 @@ public:
/*** *** *** *** *** *** 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;
@ -688,17 +644,6 @@ public:
/*** *** *** *** *** *** *** *** 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_;

View file

@ -283,7 +283,6 @@ window::window(const builder_window::window_resolution* definition)
, variables_()
, invalidate_layout_blocked_(false)
, suspend_drawing_(true)
, is_toplevel_(!is_in_dialog())
, automatic_placement_(definition->automatic_placement)
, horizontal_placement_(definition->horizontal_placement)
, vertical_placement_(definition->vertical_placement)
@ -302,7 +301,6 @@ window::window(const builder_window::window_resolution* definition)
, escape_disabled_(false)
, linked_size_()
, mouse_button_state_(0) /**< Needs to be initialized in @ref show. */
, dirty_list_()
#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
, debug_layout_(new debug_layout_graph(this))
#endif
@ -1038,17 +1036,6 @@ void window_swap_grid(grid* g,
} // namespace
void window::redraw_windows_on_top() const
{
std::vector<dispatcher*>& dispatchers = event::get_all_dispatchers();
auto me = std::find(dispatchers.begin(), dispatchers.end(), this);
for(auto it = std::next(me); it != dispatchers.end(); ++it) {
// Note that setting an entire window dirty like this is expensive.
dynamic_cast<widget&>(**it).set_is_dirty(true);
}
}
void window::finalize(const std::shared_ptr<builder_grid>& content_grid)
{
window_swap_grid(nullptr, &get_grid(), content_grid->build(), "_window_content_grid");

View file

@ -152,17 +152,6 @@ public:
*/
void undraw();
/**
* Adds an item to the dirty_list_.
*
* @param call_stack The list of widgets traversed to get to the
* dirty widget.
*/
void add_to_dirty_list(const std::vector<widget*>& call_stack)
{
dirty_list_.push_back(call_stack);
}
/** The status of the window. */
enum status {
NEW, /**< The window is new and not yet shown. */
@ -391,8 +380,8 @@ public:
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<std::string, linked_size>::const_iterator it = linked_size_.find(linked_group_id);
@ -632,14 +621,6 @@ private:
/** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
virtual const std::string& get_control_type() const override;
/**
* The list with dirty items in the window.
*
* When drawing only the widgets that are dirty are updated. The draw()
* function has more information about the dirty_list_.
*/
std::vector<std::vector<widget*>> dirty_list_;
/**
* In how many consecutive frames the window has changed. This is used to
* detect the situation where the title screen changes in every frame,
@ -647,9 +628,6 @@ private:
*/
unsigned int consecutive_changed_frames_ = 0u;
/** Schedules windows on top of us (if any) to redraw. */
void redraw_windows_on_top() const;
/**
* Finishes the initialization of the grid.
*

View file

@ -846,7 +846,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;
}