Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1768,13 +1768,16 @@ where

match child_position {
PositionType::Absolute => {
let (child_main_before, child_main_after) = if is_rtl {
let (child_main_before, child_main_after) = if is_row_rtl {
(child.node.main_after(store, layout_type), child.node.main_before(store, layout_type))
} else {
(child.node.main_before(store, layout_type), child.node.main_after(store, layout_type))
};
let child_cross_before = child.node.cross_before(store, layout_type);
let child_cross_after = child.node.cross_after(store, layout_type);
let (child_cross_before, child_cross_after) = if is_rtl && layout_type == LayoutType::Column {
(child.node.cross_after(store, layout_type), child.node.cross_before(store, layout_type))
} else {
(child.node.cross_before(store, layout_type), child.node.cross_after(store, layout_type))
};

let parent_main = parent_main + padding_main_before + padding_main_after;
let parent_cross = parent_cross + padding_cross_before + padding_cross_after;
Expand Down
23 changes: 23 additions & 0 deletions tests/absolute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,26 @@ fn auto_parent_pixels_child_percentage_absolute_child() {
assert_eq!(world.cache.bounds(child1), Some(&Rect { posx: 0.0, posy: 0.0, width: 50.0, height: 50.0 }));
assert_eq!(world.cache.bounds(child2), Some(&Rect { posx: 0.0, posy: 0.0, width: 25.0, height: 13.0 }));
}

#[test]
fn rtl_absolute_in_column_only_flips_horizontal_offsets() {
let mut world = World::default();

let root = world.add(None);
world.set_layout_type(root, LayoutType::Column);
world.set_direction(root, Direction::RightToLeft);
world.set_width(root, Units::Pixels(600.0));
world.set_height(root, Units::Pixels(400.0));

let node = world.add(Some(root));
world.set_position_type(node, PositionType::Absolute);
world.set_width(node, Units::Pixels(100.0));
world.set_height(node, Units::Pixels(80.0));
world.set_left(node, Units::Pixels(20.0));
world.set_top(node, Units::Pixels(10.0));

root.layout(&mut world.cache, &world.tree, &world.store, &mut ());

// RTL mirrors only horizontal offsets, so left becomes trailing while top is unchanged.
assert_eq!(world.cache.bounds(node), Some(&Rect { posx: 480.0, posy: 10.0, width: 100.0, height: 80.0 }));
}
Loading