[lua] Make Dialog:separator more in line with other widgets (fix #4989)

This commit is contained in:
Maplegecko 2025-05-25 17:25:03 +02:00 committed by David Capello
parent 03422e7251
commit 698d79b049
3 changed files with 12 additions and 13 deletions

View File

@ -713,6 +713,7 @@
<background color="window_face" />
<background-border part="separator_horz" align="middle" />
<text color="separator_label" x="4" align="left middle" />
<text color="disabled" x="4" align="left middle" state="disabled"/>
</style>
<style id="menu_separator" extends="horizontal_separator" />
<style id="separator_in_view" extends="horizontal_separator">

View File

@ -706,6 +706,7 @@
<background color="window_face" />
<background-border part="separator_horz" align="middle" />
<text color="separator_label" x="4" align="left middle" />
<text color="disabled" x="4" align="left middle" state="disabled"/>
</style>
<style id="menu_separator" extends="horizontal_separator" />
<style id="separator_in_view" extends="horizontal_separator">

View File

@ -575,8 +575,9 @@ int Dialog_add_widget(lua_State* L, Widget* widget)
bool vexpand = (widget->type() == Canvas::Type());
// This is to separate different kind of widgets without label in
// different rows.
if (dlg->lastWidgetType != widget->type() || dlg->autoNewRow) {
// different rows. Separator widgets will always create a new row.
if (dlg->lastWidgetType != widget->type() || dlg->autoNewRow ||
widget->type() == ui::kSeparatorWidget) {
dlg->lastWidgetType = widget->type();
dlg->hbox = nullptr;
}
@ -631,8 +632,8 @@ int Dialog_add_widget(lua_State* L, Widget* widget)
dlg->labelWidgets[id] = labelWidget;
}
else {
// For tabs we don't want the empty space of an unspecified label.
if (widget->type() != Tabs::Type()) {
// For tabs and separators, we don't want the empty space of an unspecified label.
if (widget->type() != Tabs::Type() && widget->type() != ui::kSeparatorWidget) {
dlg->currentGrid->addChildInCell(new ui::HBox, 1, 1, ui::LEFT | ui::TOP);
}
}
@ -641,14 +642,15 @@ int Dialog_add_widget(lua_State* L, Widget* widget)
if (widget->type() == ui::kButtonWidget)
hbox->enableFlags(ui::HOMOGENEOUS);
// For tabs we don't want the empty space of an unspecified label, so
// For tabs and unlabeled separators, we don't want the empty space of an unspecified label, so
// span 2 columns.
const int hspan = (widget->type() == Tabs::Type() ? 2 : 1);
const int hspan =
((widget->type() == Tabs::Type()) || (widget->type() == ui::kSeparatorWidget && !label) ? 2 :
1);
dlg->currentGrid->addChildInCell(hbox,
hspan,
1,
ui::HORIZONTAL | (vexpand ? ui::VERTICAL : ui::TOP));
dlg->hbox = hbox;
}
@ -709,12 +711,7 @@ int Dialog_separator(lua_State* L)
dlg->dataWidgets[id] = widget;
}
dlg->mainWidgets.push_back(widget);
dlg->currentGrid->addChildInCell(widget, 2, 1, ui::HORIZONTAL | ui::TOP);
dlg->hbox = nullptr;
lua_pushvalue(L, 1);
return 1;
return Dialog_add_widget(L, widget);
}
int Dialog_label(lua_State* L)