don't call invalidate_layout() unless needed

commit 8000a868 added an invalidate layout() call to fix issues arisiong from widgets that change its site when their 'value' is changes.
But with this, some dialogs, in particular the custom help dialgog in the addon "world conquest 2", reacted much slower to user input because invalidate_layout() causes the dialogs to recaclulate all its siszes which is very slow. Since most of the widgets, in particular 'multi_page' don't change their size when the value is changed, this commit fixes the mentioned custom help dialog by not calling invalidate_layout() when cahnging the value of those widgets.
(cherry picked from commit 808bd59dae)
This commit is contained in:
gfgtdf 2018-10-11 21:01:39 +02:00 committed by GitHub
parent 00a1edd149
commit cc8a9e8128

View file

@ -453,8 +453,6 @@ int show_message_box(lua_State* L) {
int intf_set_dialog_value(lua_State* L)
{
gui2::widget *w = find_widget(L, 2, false);
if (w)
w->get_window()->invalidate_layout();
if(gui2::listbox* list = dynamic_cast<gui2::listbox*>(w))
{
@ -493,6 +491,7 @@ int intf_set_dialog_value(lua_State* L)
selectable->set_value(luaL_checkinteger(L, 1) -1);
}
} else if (gui2::text_box* text_box = dynamic_cast<gui2::text_box*>(w)) {
w->get_window()->invalidate_layout();
const t_string& text = luaW_checktstring(L, 1);
text_box->set_value(text.str());
} else if (gui2::slider* slider = dynamic_cast<gui2::slider*>(w)) {
@ -529,6 +528,7 @@ int intf_set_dialog_value(lua_State* L)
}
}
} else if(gui2::unit_preview_pane* unit_preview_pane = dynamic_cast<gui2::unit_preview_pane*>(w)) {
w->get_window()->invalidate_layout();
if(const unit_type* ut = luaW_tounittype(L, 1)) {
unit_preview_pane->set_displayed_type(*ut);
} else if(unit* u = luaW_tounit(L, 1)) {
@ -563,6 +563,7 @@ int intf_set_dialog_value(lua_State* L)
}
}
} else {
w->get_window()->invalidate_layout();
t_string v = luaW_checktstring(L, 1);
gui2::styled_widget* c = dynamic_cast<gui2::styled_widget*>(w);
if(!c) {