mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-14 04:19:12 +00:00
[lua] Dialog:modify{} now can modify the text of a separator
Fixes https://github.com/aseprite/api/issues/27
This commit is contained in:
parent
d9b0887a3a
commit
68720424c0
@ -10,6 +10,6 @@
|
||||
|
||||
// Increment this value if the scripting API is modified between two
|
||||
// released Aseprite versions.
|
||||
#define API_VERSION 10
|
||||
#define API_VERSION 11
|
||||
|
||||
#endif
|
||||
|
@ -369,7 +369,8 @@ int Dialog_separator(lua_State* L)
|
||||
{
|
||||
auto dlg = get_obj<Dialog>(L, 1);
|
||||
|
||||
std::string text;
|
||||
std::string id, text;
|
||||
|
||||
if (lua_isstring(L, 2)) {
|
||||
if (auto p = lua_tostring(L, 2))
|
||||
text = p;
|
||||
@ -381,9 +382,21 @@ int Dialog_separator(lua_State* L)
|
||||
text = p;
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
type = lua_getfield(L, 2, "id");
|
||||
if (type == LUA_TSTRING) {
|
||||
if (auto s = lua_tostring(L, -1))
|
||||
id = s;
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
auto widget = new ui::Separator(text, ui::HORIZONTAL);
|
||||
if (!id.empty()) {
|
||||
widget->setId(id.c_str());
|
||||
dlg->dataWidgets[id] = widget;
|
||||
}
|
||||
|
||||
dlg->grid.addChildInCell(widget, 2, 1, ui::HORIZONTAL | ui::TOP);
|
||||
dlg->hbox = nullptr;
|
||||
|
||||
@ -972,6 +985,9 @@ int Dialog_get_data(lua_State* L)
|
||||
for (const auto& kv : dlg->dataWidgets) {
|
||||
const ui::Widget* widget = kv.second;
|
||||
switch (widget->type()) {
|
||||
case ui::kSeparatorWidget:
|
||||
// Do nothing
|
||||
continue;
|
||||
case ui::kButtonWidget:
|
||||
case ui::kCheckWidget:
|
||||
case ui::kRadioWidget:
|
||||
@ -1062,6 +1078,9 @@ int Dialog_set_data(lua_State* L)
|
||||
|
||||
ui::Widget* widget = kv.second;
|
||||
switch (widget->type()) {
|
||||
case ui::kSeparatorWidget:
|
||||
// Do nothing
|
||||
break;
|
||||
case ui::kButtonWidget:
|
||||
case ui::kCheckWidget:
|
||||
case ui::kRadioWidget:
|
||||
|
Loading…
x
Reference in New Issue
Block a user