Skip to content

[lua] Improve Dialog labels and buddy enabled handling (fix #5117) #5554

Merged
dacap merged 1 commit into
aseprite:betafrom
ckaiser:script-dialog-labels
Mar 9, 2026
Merged

[lua] Improve Dialog labels and buddy enabled handling (fix #5117) #5554
dacap merged 1 commit into
aseprite:betafrom
ckaiser:script-dialog-labels

Conversation

@ckaiser

@ckaiser ckaiser commented Nov 22, 2025

Copy link
Copy Markdown
Member

Fixes #5117, and makes some changes to default behaviors.

Marking as draft because of Widget changes, decided to go for the "simple but disruptive" approach of just adding a new signal to Widget and modifying the default onEnabled, it's definitely the simplest approach but it does have ripple effects on the entire app.

Decided to leave the "buddy enabled sync" feature disabled by default behind a flag, but we could easily just simplify it and make this the default behavior and void having an extra bool - in fact I think that's probably the way to go before the merge, but I figured I'd first validate this is what we want without any side-effects.

Added the placeholder and labelalign propertes to Dialog_add_widget, the former is self-explanatory, the latter is because I noticed all of the labels were aligned to the top-right and it looks kinda bad, but maybe some things rely on the old behavior so I changed the default to ui::LEFT | ui::CENTER and added a way to change the alignment if desired to go back to the previous default or any other.

Here's a little test script:

local d = Dialog()
local b = true

d:entry{ id="entry_1", label="Entry 1", text="", placeholder="Placeholder" }
:entry{ id="entry_2", label="Entry 2", text="rrrrr" }
:entry{ id="entry_3", label="Entry 3", labelalign=Align.TOP | Align.LEFT, text="old align default" }
:entry{ id="entry_4", label="Entry 4", text="bbbbb" }
:button{ id="button_1", label="Button 1", labelalign=Align.BOTTOM, text="aligned bottom" }
:button{ id="button_2", label="Button 2", labelalign=Align.RIGHT, text="aligned right" }
:button{ id="button_3", text="3" }
:button{ id="button_4", text="4" }

:button{ id="button_5", label="Button 5", text="5" }
:button{ id="button_6", text="6" }
:button{ id="button_7", text="7" }

:separator()

:button{ id="disable", text="Toggle Disabled", onclick=function()
    b = not b
    d:modify{ id="entry_2", enabled=b }
    :modify{ id="entry_4", enabled=b }
    :modify{ id="button_1", enabled=b }
    :modify{ id="button_3", enabled=b }
    --
    :modify{ id="button_5", enabled=b }
    :modify{ id="button_6", enabled=b }
    :modify{ id="button_7", enabled=b }
    --
end}
:button{ id="ok", text="Close" }

d:show()

@ckaiser ckaiser requested a review from dacap as a code owner November 22, 2025 14:48
@ckaiser ckaiser marked this pull request as draft November 22, 2025 14:48

@aseprite-bot aseprite-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread src/app/script/dialog_class.cpp Outdated
Comment thread src/app/script/dialog_class.cpp Outdated
Comment thread src/ui/widget.h
@ckaiser ckaiser force-pushed the script-dialog-labels branch from e5eb1bc to fa6dc0f Compare December 5, 2025 07:39
@ckaiser ckaiser marked this pull request as ready for review December 5, 2025 07:40

@aseprite-bot aseprite-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread src/app/script/dialog_class.cpp Outdated
@ckaiser ckaiser force-pushed the script-dialog-labels branch from fa6dc0f to ad863d4 Compare December 5, 2025 07:44
@dacap

dacap commented Mar 9, 2026

Copy link
Copy Markdown
Member

LGTM 👍 As we talked I'll try to investigate a way to reduce the obs::signal size or create a new lightweight signal for these cases.

@dacap dacap merged commit 466f023 into aseprite:beta Mar 9, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Labels of disabled dialog widgets should appear in a different color to match their content

3 participants