Repository navigation
Feature/982 lua form designer - #1064
Merged
Merged
Conversation
The designer edits the table passed to opensak.form{} inside a macro: it
finds the table around the cursor, reads it without running the macro and
writes the edited form back as Lua (opensak.macro.form_code). GSAK macro
forms can be converted to opensak.form{} (opensak.macro.gsak_form).
Split off from the macro UI functions branch (feature/982-lua-ui-forms),
which this branch builds on.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve import conflict in src/opensak/macro/api_docs.py: keep both the editor-support/stdlib imports from beta (OpenSAK-Org#1060) and the form-doc imports from this branch. Generated macro docs are left to the docs bot.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lua macros: visual form designer (#982)
Part of #938 / #982. The form designer was split off from the UI-functions PR so the runtime API could be reviewed on its own.
What it does
Tools → Form designer… (
Ctrl+Shift+D) in the macro window buildsopensak.form{}dialogs with the mouse:opensak.form{…}table, the designer opens that form and Update macro writes it back. Otherwise Insert into macro puts a new form at the cursor, indented to match.macro/form_code.py). Callbacks and other Lua expressions are shown as (Lua expression) and written back unchanged.layout = "absolute":layout = "auto"): an outline shows the fields top to bottom. Up/Down and Into/Out of group rearrange them.FormDialog.<Data> VarName=$form … <enddata>) from the clipboard, or import one from a.gsk/.txtmacro (macro/gsak_form.py). The designer then lists what changed in the conversion so you can check it.Changes
src/opensak/gui/dialogs/form_designer.py: the designer dialog (new)src/opensak/macro/form_code.py: finds, parses and writes the Lua table without running it (new, Qt-free)src/opensak/macro/gsak_form.py: GSAK form →opensak.form{}converter (new, Qt-free)src/opensak/gui/dialogs/macro_dialog.py: new Tools menu and the insert/update logicsrc/opensak/macro/api_docs.py: the Forms section mentions the designer (CI regeneratesapi.md)macros/examples/corrected_coords_form.lua, with a form built in the designerTests
tests/unit-tests/test_macro_forms.py: Lua table parse/write round trip, expressions kept as written, GSAK conversiontests/unit-tests/test_macro_form_dialog.py: designer canvas, selection, align tools, insert/updateHow to try it
corrected_coords_form.lua, put the cursor inside theopensak.form{…}table, and open Tools → Form designer.<Data> VarName=$formblock through Paste form from clipboard and check the conversion notes.Closes #982