mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-20 18:40:57 +00:00
[lua] Add "focus", "enabled", and "visible" common properties to tabs
This commit is contained in:
parent
60233ba144
commit
ba99f41d82
@ -504,6 +504,29 @@ int Dialog_close(lua_State* L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void set_widget_flags(lua_State* L, int idx, Widget* widget)
|
||||
{
|
||||
// Focus magnet
|
||||
int type = lua_getfield(L, idx, "focus");
|
||||
if (type != LUA_TNIL && lua_toboolean(L, -1))
|
||||
widget->setFocusMagnet(true);
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Enabled
|
||||
type = lua_getfield(L, idx, "enabled");
|
||||
if (type != LUA_TNIL)
|
||||
widget->setEnabled(lua_toboolean(L, -1));
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Visible
|
||||
widget->setVisible(true);
|
||||
type = lua_getfield(L, idx, "visible");
|
||||
if (type != LUA_TNIL) {
|
||||
widget->setVisible(lua_toboolean(L, -1));
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
int Dialog_add_widget(lua_State* L, Widget* widget)
|
||||
{
|
||||
auto dlg = get_obj<Dialog>(L, 1);
|
||||
@ -540,23 +563,11 @@ int Dialog_add_widget(lua_State* L, Widget* widget)
|
||||
label = lua_tostring(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Focus magnet
|
||||
type = lua_getfield(L, 2, "focus");
|
||||
if (type != LUA_TNIL && lua_toboolean(L, -1))
|
||||
widget->setFocusMagnet(true);
|
||||
lua_pop(L, 1);
|
||||
set_widget_flags(L, 2, widget);
|
||||
|
||||
// Enabled
|
||||
type = lua_getfield(L, 2, "enabled");
|
||||
if (type != LUA_TNIL)
|
||||
widget->setEnabled(lua_toboolean(L, -1));
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Visible
|
||||
type = lua_getfield(L, 2, "visible");
|
||||
if (type != LUA_TNIL) {
|
||||
visible = lua_toboolean(L, -1);
|
||||
widget->setVisible(visible);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
@ -588,7 +599,6 @@ int Dialog_add_widget(lua_State* L, Widget* widget)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
auto hbox = new ui::HBox;
|
||||
if (widget->type() == ui::kButtonWidget)
|
||||
hbox->enableFlags(ui::HOMOGENEOUS);
|
||||
@ -1346,6 +1356,8 @@ int Dialog_tab(lua_State* L)
|
||||
lua_setfield(L, -2, "tab");
|
||||
});
|
||||
}
|
||||
|
||||
set_widget_flags(L, 2, tabBtn);
|
||||
}
|
||||
|
||||
lua_pushvalue(L, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user