Skip to content

feat(ui): reorder maps and layouts by dragging their Browser rows (#2829) - #2836

Draft
jgregoriorincon wants to merge 1 commit into
opengeos:mainfrom
jgregoriorincon:feat/2829-browser-drag-views
Draft

jgregoriorincon wants to merge 1 commit into
opengeos:mainfrom
jgregoriorincon:feat/2829-browser-drag-views

Conversation

@jgregoriorincon

Copy link
Copy Markdown
Contributor

Summary

Maps and layouts can be reordered by dragging their tabs or with Move Up/Down in their menu (#2802), but their rows in the Browser could only be moved one place at a time through that menu, unlike layers in the Layers pane (#2829).

  • Drag a Browser row to move it. The rows of the Browser's Maps and Layouts lists (catalog, crates/ui-egui/src/panes.rs) take a drag with the primary button: a mark shows where the row will land, and letting go runs map.move or layout.move, the commands [Feature]: Reorder maps and layouts: drag their tabs, Move Up/Down in their menu, and a command to set the order #2802 added. Each move is one undo step; the map or layout in view stays in view; a click still opens the row, and its right-click menu is unchanged.
  • The tabs' drop, shared. The row reuses the tabs' drag payload (DraggedTab, by kind and name) and their drop (tab_drop, crates/ui-egui/src/mapview.rs), which now takes the kind it drops (and so the command: map.move or layout.move) and the axis: along the strip (x) or down the list (y). In the list, a row let go off its own kind's rows (a map over the layouts or the toolboxes) lands nowhere; on the strip, nothing changes. Held near the Browser's top or bottom, the list scrolls, faster the closer the pointer is, as the strip and the Layers pane do.
  • Since both share one payload, a tab dragged from the strip can also be let go on its kind's rows in the Browser, and the other way round.

Surfaces. The Browser is drawn by panes.rs for the desktop app and the browser build (rustgis-web), and for the phone when it switches to the desktop interface. No command, parameter or project format changes. On a touch screen, a drag that starts on a map's or layout's name now moves the row instead of scrolling the Browser, as the tabs and the Layers pane's rows already do; a drag that starts beside the name still scrolls it.

Testing

  • New tests in crates/ui-egui/tests/smoke.rs, written first and seen failing (nothing moved: ["World", "M2", "M3"]; "World landed at 0"):
    • dragging_browser_rows_reorders_maps_or_layouts_in_one_undo_step: a one-map project (nothing moves), a map onto the upper half of the first row (first, one undo step, the map in view kept), let go within its own row (a drag, not a click: the map in view doesn't change), over the layouts or dragged with the secondary button (nothing), a layout onto the lower half of the last row (last), undo, and a click still opening a map.
    • a_row_dragged_to_the_edge_of_a_long_browser_scrolls_it: with 41 maps, a row held near the Browser's bottom edge lands past the rows first in view.
  • The tab tests of [Feature]: Reorder maps and layouts: drag their tabs, Move Up/Down in their menu, and a command to set the order #2802 pass unchanged.
  • cargo fmt --all --check, cargo clippy (-D warnings), cargo nextest run (9304 passed), doctests, cargo xtask layers and cargo xtask schema --check: all pass.

UI evidence

ui_shot on Linux, 1000 × 680 window: World Atlas with three more maps and two layouts, Browser open. Before (left) and after (right): Africa's row dragged onto World's upper half; while dragging the mark shows where it will land (top); let go, Africa is first in the Browser and on the strip, and World stays in view (bottom). Before, the drag did nothing.

pr-2829-drag.png

Not in this PR

  • A mark on the row being dragged, as the dragged tab has; the row keeps its usual hover look.
  • Naming the drop's direction with a small enum instead of the vertical flag.

Related issue

Closes #2829

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no bugs, security problems or performance problems, and no AGENTS.md breaks. I did not post inline comments because nothing reached the bar for one. I could not run the build or tests here, so the correctness read is by inspection; the author reports cargo nextest (9304 passed), clippy and layers as passing.

Bugs

None found. I checked:

  • The strip path is unchanged in behaviour. The payload filter moved into tab_drop, and tabs.first() is now required alongside tabs.last(), which is equivalent for non-empty tab lists.
  • Drop index math: for [A, B, C] dragging A to between B and C gives slot = 2, to = 1, which yields [B, A, C], matching map.move (to is a final index, clamped past the end).
  • A map payload can't reach the layout list and vice versa, because of the filter(|d| d.layout == layout) in tab_drop.
  • Indexing Pos2 with a ∈ {0, 1} can't panic.
  • Auto-scroll sign is consistent with the existing x-axis strip behaviour.
  • Confidence: medium-high. The egui API details (Response::interact union, scroll_with_delta_animation target) are assumed from the author's passing tests and not checked against the vendored egui.

Security

None. The change is UI-only and adds no parsing, I/O or command surface.

Performance

None. The per-frame work is one Rect per map or layout row, which is trivial.

Quality (low, optional)

  • Two bool flags on tab_drop (layout, vertical). The PR already defers this to "Not in this PR". Confidence: high that it's a readability cost, low severity.
  • drag_tab's bool return is discarded at panes.rs:2645 and :2704. The call is for its side effect (setting the payload). A separate start_drag helper would state that intent. Confidence: high, low severity.
  • Scope of the drag-to-scroll change. The PR description says the name-drag no longer scrolls the Browser on touch. If egui's ScrollArea drag-to-scroll also applies to the mouse, a mouse drag starting on a name no longer scrolls either, and the docs don't say so. I could not verify egui's mouse behaviour from here. Confidence: low; worth one sentence in the PR if it's true.

AGENTS.md

None found. Checked:

  • No new command or parameter, so command-surface.txt is unchanged.
  • No new dotted command literals or ui.* ids.
  • No unwrap/expect/panic in non-test code; the test helpers' panic! is in test code.
  • No desktop-only code added, so the wasm build is unaffected.
  • No new user-visible literals, so nothing needs tl!.
  • The PR states the surfaces it reaches.
  • Docs are updated.
  • The screenshot is a GitHub web attachment, which docs/contributing.md permits.

Prior concerns

No prior review threads exist on this PR, so I left none alone.

Change size

Compared with main (merge base 463133b to PR head 0c97299).

Measure Value
Files changed 4 (added 0, modified 4, removed 0, renamed 0)
Size before 1,170.4 KB
Size after 1,177.0 KB
Total size change +6.6 KB
File Before After Change
crates/ui-egui/tests/smoke.rs 257.7 KB 262.6 KB +4.9 KB
crates/ui-egui/src/mapview.rs 365.3 KB 366.1 KB +821 B
crates/ui-egui/src/panes.rs 492.5 KB 493.3 KB +803 B
docs/user-guide/workspace.md 54.9 KB 55.0 KB +119 B

@jgregoriorincon

Copy link
Copy Markdown
Contributor Author

Thanks. All three quality points are reply-only:

  • Two bool flags on tab_drop: deferred, as listed under "Not in this PR".
  • drag_tab's return discarded in the Browser: deferred; a start-only helper (or using it for a dragged-row mark, also listed) can come with that follow-up.
  • Mouse drag-to-scroll: not affected. egui 0.37's ScrollArea scrolls on drag only on touch screens (ScrollSource::drag defaults to DragScroll::OnTouch, egui/src/containers/scroll_area.rs:286), and ui-egui never changes it, so with a mouse a drag on a name never scrolled the Browser; the wheel and the scroll bar work as before. The PR's note covers the touch case.

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2836/
Web app https://preview.rustgis.app/pr-2836/app/
Commit 0c97299

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

This branch has not been deployed

No deployments
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.

[Feature]: Drag the Browser's Maps and Layouts rows to reorder them

1 participant