Skip to content

Editable canvas toolbar - #894

Merged
marcinz606 merged 1 commit into
mainfrom
feat/editable-toolbar
Aug 18, 2026
Merged

Editable canvas toolbar#894
marcinz606 merged 1 commit into
mainfrom
feat/editable-toolbar

Conversation

@marcinz606

Copy link
Copy Markdown
Owner

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.py

  • TOOLBAR_ITEMS — one (id, category, label) entry per row-eligible control — plus DEFAULT_TOOLBAR_IDS and load_toolbar_items(repo) (global setting toolbar_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/3 are 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_groups and 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_peek was 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). defaults adds 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 public relayout_floating_widgets(), so the toolbar re-places the pill after an edit without reaching into a private method.

Plus a REGISTRY entry (edit_toolbar, no default key — nothing obvious was free), its action-map entry, and a sentence in the canvas-toolbar paragraphs of docs/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 all green. 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_peek on 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.

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.
@marcinz606
marcinz606 merged commit 1852c43 into main Aug 18, 2026
1 check passed
@marcinz606
marcinz606 deleted the feat/editable-toolbar branch August 18, 2026 19:40
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.

1 participant