Repository navigation
Fix axis conversion between horizontal layout types - #44
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/layout.rs:81
same_axis_direction()implicitly defines axis orientation as “Column vs everything else”. That matches the mapping used inNode::layoutand severalmatch LayoutType::Row | LayoutType::Overlay | LayoutType::Grid => ...blocks, but it conflicts withLayoutType::select*insrc/types.rswhich currently groupsGridwithColumn(types.rs:24-27). Having multiple, inconsistent sources of truth for axis grouping makes future fixes risky (e.g., grid sizing/min/max selection can diverge from axis-conversion logic).
Consider consolidating the axis-orientation definition onto LayoutType (e.g., is_horizontal_main_axis()), and have both same_axis_direction() and LayoutType::select* use that single helper (or update select* to match the intended Grid grouping).
#[inline]
fn same_axis_direction(a: LayoutType, b: LayoutType) -> bool {
matches!(a, LayoutType::Column) == matches!(b, LayoutType::Column)
}
ExtraBinoss
force-pushed
the
fix/overlay-row-axis
branch
from
August 20, 2026 16:13
807d9d7 to
b96f294
Compare
ExtraBinoss
force-pushed
the
fix/overlay-row-axis
branch
from
August 20, 2026 16:15
b96f294 to
65c5285
Compare
geom3trik
approved these changes
Aug 20, 2026
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/layout.rs:1443
- The preceding comment still says that every differing
LayoutTypeswaps axes, which is the assumption this change removes. It now contradicts the predicate and would mislead future edits; describe the horizontal-versus-vertical transition instead.
let (mut parent_main, mut parent_cross) = if same_axis_direction(parent_layout_type, layout_type) {
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.
Summary
Fix layout constraint conversion when a parent and child use different
LayoutTypevariants with the same physical main axis.For example, an
Overlaycontaining a stretchedRowcurrently transposes the available width and height because the conversion checks whether the enum variants are equal. In a 1920 x 1000 container, the row therefore lays out its children against 1000 px of main-axis space instead of 1920 px.Root cause
Morphorm performs much of its layout in main/cross-axis coordinates. The existing conversion logic assumes that different layout types always use different axis directions:
That assumption does not match Morphorm's axis model:
Row,Overlay, andGriduse width as the main axis.Columnuses height as the main axis.As a result, transitions such as
OverlaytoRowswap axes even though both layouts are horizontally oriented.Fix
Compare the physical axis direction instead of comparing
LayoutTypevariants directly. Main and cross constraints are now swapped only when layout crosses between the horizontal group (Row,Overlay,Grid) andColumn.The same predicate is used consistently across child constraint propagation and auto/min/max size resolution, so each path follows the axis semantics already used by
NodeExt::mainandNodeExt::cross.Regression coverage
The new test builds the failing hierarchy directly:
With two 16 px gaps, the flexible stage must receive 1388 px. Before this fix it received 468 px because the row used the parent's 1000 px height as its main-axis constraint.
The patch was also validated in the downstream VIZIA layout that exposed the issue: at a 1920 px window width, its flexible content expanded from 444 px to the expected 1348 px after accounting for the application's outer padding.
Validation
cargo fmt --checkcargo clippy --all-targets -- -D warningscargo test(149 tests passed)No public API changes are introduced.