From 2c377985bb85bf2618a963856d2d66e666876490 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Mon, 17 Feb 2025 11:51:10 +0800 Subject: [PATCH] tiles: Limit panel x to out of bounds, but keep retaining 64px. (#632) - Adjust `tile_grid_size` default to `8px`. - Fix unexpected scroll size by `-1px` design. --- crates/ui/src/dock/tiles.rs | 13 ++++++++----- crates/ui/src/theme.rs | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/ui/src/dock/tiles.rs b/crates/ui/src/dock/tiles.rs index 055f430b..782b36b8 100644 --- a/crates/ui/src/dock/tiles.rs +++ b/crates/ui/src/dock/tiles.rs @@ -233,12 +233,13 @@ impl Tiles { let mut new_origin = self.dragging_initial_bounds.origin + delta; // Avoid out of bounds - if new_origin.x < px(0.) { - new_origin.x = px(0.); - } if new_origin.y < px(0.) { new_origin.y = px(0.); } + let min_left = -self.dragging_initial_bounds.size.width + px(64.); + if new_origin.x < min_left { + new_origin.x = min_left; + } let final_origin = round_point_to_nearest_ten(new_origin, cx); // Only push to history if bounds have changed @@ -754,8 +755,9 @@ impl Tiles { .border_1() .border_color(cx.theme().border) .absolute() - .left(item.bounds.origin.x - px(1.)) - .top(item.bounds.origin.y - px(1.)) + .left(item.bounds.origin.x) + .top(item.bounds.origin.y) + // More 1px to account for the border width when 2 panels are too close .w(item.bounds.size.width + px(1.)) .h(item.bounds.size.height + px(1.)) .overflow_hidden() @@ -875,6 +877,7 @@ impl Render for Tiles { .id("tiles") .track_scroll(&self.scroll_handle) .size_full() + .top(-px(1.)) .overflow_scroll() .children( panels diff --git a/crates/ui/src/theme.rs b/crates/ui/src/theme.rs index 6bcdfbec..2c5c0723 100644 --- a/crates/ui/src/theme.rs +++ b/crates/ui/src/theme.rs @@ -544,7 +544,7 @@ impl From for Theme { radius: px(4.), shadow: true, scrollbar_show: ScrollbarShow::default(), - tile_grid_size: px(4.), + tile_grid_size: px(8.), tile_shadow: true, colors, }