Skip to content

Add groups of layers, with Group, Ungroup and drag and drop - #710

Merged
aalex merged 12 commits into
devfrom
feat-layer-groups
Dec 5, 2026
Merged

aalex merged 12 commits into
devfrom
feat-layer-groups

Conversation

@aalex

@aalex aalex commented Dec 4, 2026

Copy link
Copy Markdown
Member

Summary

  • Put layers in groups, that fold in the list of layers and that show, hide, lock, put in solo or fade their layers together.
    • Edit > Group (Ctrl+G) puts the selected layers in a new group named after them: "Truck 1", "Truck 2" and "Truck 3" make "Truck". Ungroup (Ctrl+Shift+G) takes them out and removes the group. New Group adds an empty group.
    • Several layers are selected with Shift or Ctrl.
    • Dragging a layer onto a group, which the list frames, puts it in the group. Dragging it between two rows, where the list draws a line, puts it there, in the group or out of it. A group is dragged with its layers.
    • The cross of a group, or Delete, deletes it with its layers, after asking.
    • Each of these gestures is one step to undo.
  • The eye, solo, lock and opacity of a group add to those of its layers. They can be linked to a key or a MIDI control while learning, like those of a layer. Selecting a group shows its page, with its opacity.
  • A folded group shows how many layers it holds, as "Trees (3)".
  • The project keeps the groups and their fold (groups, and group_id on each layer: see docs/project-format.md). A project without groups is written byte for byte as before.
  • OSC sets the name, eye, solo, lock and opacity of a group (/mapmap/group/...), and puts a layer in a group or takes it out (/mapmap/layer/group). MCP lists, creates and deletes groups (list_groups, create_group, delete_group). See docs/informations/osc.md.
  • Groups do not contain groups yet. A group has no effect yet, and its shapes do not move together.

Also in this pull request:

Translations: French and English only. The other eight languages keep the new texts untranslated: no speaker has read them.

Demo

  1. Open a project with three layers "Camion 1", "Camion 2", "Camion 3" and a fourth one. Select the three with Shift, then Edit > Group: a group "Camion" appears, with the three layers.
  2. While learning keys (Edit > Keyboard Learn), link the eye of the group to a key, then press it: the layers disappear, and their eyes go grey.
  3. Drag the fourth layer onto the group: it goes in. Lower the opacity of the group in its page: the four layers fade together.
  4. Lock the group, fold it, save, and open the project again: the group is still locked and folded.
  5. Undo everything: the list of layers is flat again, in its first order.

Tests

  • On macOS 26 (Apple Silicon), every commit builds and passes the tests (32 suites), one commit at a time.
  • New tests: the stack with groups, places and moves of layers and groups, undo of stack changes, names given to groups, the list of layers with groups (folding, buttons, drag and drop), OSC and MCP for groups, and the project round trip with and without groups.
  • By hand on macOS: grouping a Shift selection; dragging a layer onto a group, between two layers of a group, out of a group; dragging a group; the cross of a group, answering No then Yes; undoing all of it, back to the first order; the menus and the question to delete a group, in French and in English, singular and plural.
  • Not run here: Ubuntu and Windows (the checks of GitHub run them).

aalex added 11 commits December 4, 2026 15:56
A group gathers layers that follow one another in the stack. It is an
element, like a layer: a name, an eye, a solo, a lock and an opacity,
declared as settings. Its state adds to that of each of its layers: a
layer is shown when its eye and that of its group are open, a group in
solo puts its layers in solo, a locked group locks the shapes of its
layers, and the opacity of a layer is multiplied by that of its group.

MappingManager keeps the top level of the stack: layers in no group, and
groups with their layers. A layer put in a group moves next to its other
layers. A layer of a group moves among its layers only; a layer in no
group moves over a whole group. Groups do not contain groups.

Project files get a "groups" array at the top and a "group_id" in each
layer of a group, both written only when there is a group, so that a
project without groups keeps its bytes. A group without layers is kept,
placed by its "depth": the number of layers above it. Links reach the
settings of a group with the element "group".

The list of layers does not show the groups yet: it follows their order.
OSC sets the name, eye, solo, lock and opacity of a group, by id or by a
name pattern (/mapmap/group/visible), or any of its settings by path
(/mapmap/group/<id>/<path>). /mapmap/layer/group puts a layer in a group,
or takes it out with 0.

MCP lists, creates and deletes groups (list_groups, create_group,
delete_group, with or without their layers); set_property and
list_settings take the kind "group"; list_layers gives the group of each
layer, and get_state the number of groups.
/mapmap/layer/depth, the path form /mapmap/layer/<id>/depth and the MCP
tool set_property changed the number of a layer but left it at its place
in the stack, and the next move put the numbers back. Written once the
layer is in a project, the depth now moves the layer to that row, from 0
at the top; past the bottom, to the bottom. A layer of a group stays in
its group, as with move_layer. Read from a project file, the depth is
only kept, so that the file keeps its bytes.
Quitting pauses playback, and pausing redrew the icon of every source
through updateSourceItem(), which marks the project modified. So MapMap
asked to save the project at every quit, even right after a save or
with nothing changed. Playing and pausing are not saved in the project:
their icons are now redrawn by showSourceItem(), which does not mark it.

Editing a layer in the list (its name, eye, solo or lock) counted on that
side effect to mark the project modified; it now does so itself.

Fixes #605.
Each group is a row with its layers under it. Its eye, solo and lock
act on the group, even folded, and can be linked to a key or a pad
while learning. Selecting a group shows its page, with its opacity.

A folded group shows how many layers it holds, as "Trees (3)", and
keeps its fold in the project file ("collapsed"). Selecting a layer
of a folded group, as when a project opens, keeps the group folded.
Group (Ctrl+G) puts the layers selected in the list in a new group,
named after them: "Truck 1" and "Truck 2" make "Truck". Ungroup
(Ctrl+Shift+G) takes them out, and New Group adds a group without
layers. Several layers are selected with Shift or Ctrl.

Dropped onto a group, which the list frames, a layer goes into it;
dropped between two rows, beside them. A group is dragged too, between
the rows of the top level. The cross of a group, or Delete, deletes it
with its layers, after asking.

Each of these is one step to undo: the places of the stack before and
after are kept.
In English the command and the page of a group are both "Group"; in
other languages a verb and a noun. The tooltip of Ungroup says what
happens to the group.
The other languages keep these texts untranslated: no speaker has read
them yet.
@aalex aalex added this to the 1.0 milestone Dec 4, 2026
@aalex aalex self-assigned this Dec 4, 2026
@aalex
aalex requested a review from sofian December 4, 2026 23:02
@sofian

sofian commented Dec 5, 2026

Copy link
Copy Markdown
Member

Tried on Ubuntu 26.04 (Qt 6.10.2, Wayland) with the Ubuntu archive of commit 5559e7e, built by https://github.com/mapmapteam/mapmap/actions/runs/47451485623.

Crash: right-click on a group

  1. Select several layers, then Edit > Group: the group appears, with its layers.
  2. Right-click the eye of the group.

MapMap closes at once. The kernel log gives a segfault at address 0 in MainWindow::showLayerContextMenu:

mapmap[1939061]: segfault at 0 ip 00005b46556d044c ... in mapmap[7144c,5b46556b0000+1ec000]

It happened twice in a row, at the same address.

addr2line resolves 0x7144c to mmp::MainWindow::showLayerContextMenu(QPoint const&).

Read from the code, not confirmed with a debugger: showLayerContextMenu takes currentLayerItemId() and calls mappingManager->getLayerById(layerId), which returns a null pointer when the current row is a group. The next line, layer->isLocked(), dereferences it (src/gui/MainWindow.cpp, line 5754). LayerItemDelegate::editorEvent asks for this menu on a right-click on any valid row, group rows included.

The menu needs a case for a group row, or at least to return when no layer is found. A test that asks for the menu on a group row would catch it.

The rest of the demo has not been tried yet: only its first step, which works.

@sofian

sofian commented Dec 5, 2026

Copy link
Copy Markdown
Member

The crash of a right-click on a group is fixed in a214858.

The menu of the list of layers now opens on the row of a group, with the actions of a layer greyed and Delete, Ungroup and New Group kept. "Change Layer Source" is greyed too: chosen on a group, it crashed in the same way (loadLayerMedia() reads the current layer).

Right-click on the eye of the group "Arbre" of tests/fixtures/groups.mmp, on Ubuntu 26.04 (Qt 6.10.2):

pr710-group-menu

Checked on Ubuntu 26.04 with a script of clicks on a display nobody sees (scripts/sh_screenshot_linux.sh): before the fix, MapMap dies at the right-click on a group; after it, the menu opens on a group with layers, an empty group, a folded group and a layer in a group. The unit tests pass (32 suites). No unit test covers it: the tests do not build MainWindow.

Not checked: macOS and Windows. Nothing in the cause depends on the system.

@aalex
aalex merged commit 1cec86e into dev Dec 5, 2026
3 checks passed
@aalex
aalex deleted the feat-layer-groups branch December 5, 2026 14:12
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.

2 participants