Editable canvas toolbar - #894
Merged
Merged
Conversation
The row was 20 imperative addWidget calls, three hard-coded separators and a hand-written collapse ladder. Now it is a table: TOOLBAR_ITEMS carries an id, a category and a label per control, and the row is rebuilt from a stored id list. Edit Toolbar… in the ⋯ menu opens the Favourites column-chooser, which took plain (id, category, label) triples already and needed only four optional strings to serve both panels. Separators follow the categories, so a reordered row still gets dividers where the kinds change, and the default order reproduces today's layout exactly. Responsive collapse hides from the end of the user's order inward, per button rather than per group: the order is now a stated priority, so there is no second ladder to keep in step with it. The ⋯ menu is untouched and still carries every action. btn_flat_peek was built and never laid out; it is now offerable on the row.
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.
Pick which controls sit on the canvas toolbar, and in what order, from Edit Toolbar… in the ⋯ menu.
What changed
negpy/desktop/view/canvas/toolbar.pyTOOLBAR_ITEMS— one(id, category, label)entry per row-eligible control — plusDEFAULT_TOOLBAR_IDSandload_toolbar_items(repo)(global settingtoolbar_items; unknown ids drop so a retired button degrades quietly, an absent setting means the stock row)._rebuild_row()lays the row out from the stored id list between three fixed anchors: the two panel toggles and the ⋯ button, which is the only route back to the editor. Unchosen buttons stay parented but hidden — they are still state holders the controller syncs against._sync_separators()puts a divider at each category boundary between two visible controls._sep1/2/3are gone; the default order reproduces the current layout exactly.set_available_width()hides from the end of the user's order inward, one button at a time._collapse_groupsand its five group lists are deleted — the order is now a stated priority, so a second hard-coded ladder would only drift from it.btn_flat_peekwas constructed and never laid out; it is now offerable on the row.negpy/desktop/view/widgets/favourites_dialog.py— four optional kwargs (title,chosen_header,hint,defaults).defaultsadds a Restore Defaults button, which the toolbar needs and Favourites skips. The Favourites call site and its tests are unchanged.negpy/desktop/view/canvas/widget.py— one publicrelayout_floating_widgets(), so the toolbar re-places the pill after an edit without reaching into a private method.Plus a
REGISTRYentry (edit_toolbar, no default key — nothing obvious was free), its action-map entry, and a sentence in the canvas-toolbar paragraphs ofdocs/USER_GUIDE.md.Out of scope
The ⋯ menu stays a fixed, complete list; only the row is customizable. One global setting, no per-image toolbars. Reordering uses the dialog's existing up/down buttons, not drag-and-drop.
Verification
make allgreen. New tests cover the stored order driving the row, unknown/malformed settings, a separator at every visible category boundary with none left dangling after a collapse, collapse eating from the end,flat_peekon the row driving the controller, the save/rebuild and cancel paths, and the ⋯ menu staying complete with an empty row.Driven offscreen against the real
MainWindow: the stock row renders in full, an edit to["flat_peek", "prev", "next", "loupe"]redraws the row and survives a reload from the repo, and at a 400 px budget the row collapses to six items measuring 376 px.