From a3012f34c810e91fe0ed4b1124471842f846e44d Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Fri, 13 Nov 2026 14:20:09 +0100 Subject: [PATCH] Correct horizontal and vertical centering icon actions --- crates/midra-layout/src/gui.rs | 14 ++++++++++---- docs/midra-layout.md | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/crates/midra-layout/src/gui.rs b/crates/midra-layout/src/gui.rs index fe0a9ae..e94f2a5 100644 --- a/crates/midra-layout/src/gui.rs +++ b/crates/midra-layout/src/gui.rs @@ -882,8 +882,8 @@ impl Editor { (0, 2, "Align bottom left", Some(Left), Some(Bottom)), (1, 2, "Align bottom", None, Some(Bottom)), (2, 2, "Align bottom right", Some(Right), Some(Bottom)), - (3, 0, "Center vertically", None, Some(VerticalCenter)), - (3, 2, "Center horizontally", Some(HorizontalCenter), None), + (3, 0, "Center horizontally", Some(HorizontalCenter), None), + (3, 2, "Center vertically", None, Some(VerticalCenter)), ] { let rect = Rect::from_min_size( grid.min + Vec2::new(col as f32 * 44.0, row as f32 * 44.0), @@ -1719,6 +1719,12 @@ fn alignment_icon( Some(Alignment::Bottom) => 6.0, _ => 0.0, }; + // The standalone centering icons indicate the direction of movement. + let (horizontal, vertical) = match (horizontal, vertical) { + (Some(Alignment::HorizontalCenter), None) => (None, Some(Alignment::VerticalCenter)), + (None, Some(Alignment::VerticalCenter)) => (Some(Alignment::HorizontalCenter), None), + axes => axes, + }; for (axis, value) in [(0, horizontal), (1, vertical)] { if let Some(value) = value { let offset = match value { @@ -2712,8 +2718,8 @@ mod tests { (6, Some(0.0), Some(1080.0)), (7, None, Some(1080.0)), (8, Some(1920.0), Some(1080.0)), - (9, None, Some(540.0)), - (10, Some(960.0), None), + (9, Some(960.0), None), + (10, None, Some(540.0)), ] { let mut app = Editor::default(); app.layout.set_output([2560, 1440]).unwrap(); diff --git a/docs/midra-layout.md b/docs/midra-layout.md index b909eb3..4a274f5 100644 --- a/docs/midra-layout.md +++ b/docs/midra-layout.md @@ -145,7 +145,8 @@ An explicitly chosen reference layer takes precedence, stays fixed and does not need to be selected. There is no separate Screen option for multi-selection. The compact icon grid offers four corners, top/bottom/left/right edges, center -on both axes, and separate horizontal/vertical centering. Edge buttons change +on both axes, and separate horizontal/vertical centering. The top-right button +centers horizontally (X); the bottom-right button centers vertically (Y). Edge buttons change only their axis; corner buttons change both axes. Hover an icon for its label. Every action preserves layer sizes and is one undo step, including corner moves. The menu also works with one selected layer and a different reference layer.