diff --git a/crates/ui-panels/src/rails/flyout.rs b/crates/ui-panels/src/rails/flyout.rs index 6218acc49a..4f95ab1e6a 100644 --- a/crates/ui-panels/src/rails/flyout.rs +++ b/crates/ui-panels/src/rails/flyout.rs @@ -519,7 +519,7 @@ struct TearOffBar { } impl TearOffBar { - /// A bar `height` tall. + /// A bar `height` tall, and never shorter than its grip. fn new(height: f32) -> Self { TearOffBar { common: Common::new(), height, torn: None } } @@ -547,8 +547,10 @@ impl Component for TearOffBar { } } + /// At least as tall as the grip. In the popup's measuring run the rows report no height yet, and a bar measured with + /// none left its width out of the flyout's size, so the flyout cut the bar off at its edge. fn measure(&mut self, cx: &MeasureCx<'_, Self>) -> Vec2 { - Vec2::new(cx.style.width, self.height) + Vec2::new(cx.style.width, self.height.max(cx.style.grip)) } fn sense(&self) -> Sense { diff --git a/crates/ui-panels/tests/it/rails/mod.rs b/crates/ui-panels/tests/it/rails/mod.rs index feacf2f095..cbbb3c7c17 100644 --- a/crates/ui-panels/tests/it/rails/mod.rs +++ b/crates/ui-panels/tests/it/rails/mod.rs @@ -420,6 +420,28 @@ fn dragging_the_flyout_bar_clicking_it_or_releasing_a_hold_over_it_reports_the_t assert!(plain.fixture.by_label(TEAR_OFF).is_none(), "a flyout without tear_off has no bar"); } +/// The flyout is wide enough for its tear-off bar: the bar is not clipped at the flyout's edge, and the three lines of +/// its grip paint whole inside the clip they paint under. +#[trial] +fn the_flyout_tear_off_bar_is_not_clipped_and_draws_its_grip() { + let mut rig = tear_rig(true); + let at = first_button(&rig.fixture).center(); + open_by_context(&mut rig.fixture, at); + let bar = bar(&rig.fixture).rect; + let grip: Vec<(Rect, Rect)> = rig + .fixture + .frame_clipped_shapes() + .into_iter() + .map(|(clip, shape)| (clip, shape.visual_bounding_rect())) + .filter(|(_, bounds)| bounds.is_finite() && bounds.width() < bar.width() && bar.expand(1.0).contains_rect(*bounds)) + .collect(); + assert_eq!(grip.len(), 3, "the bar paints its three grip lines: {grip:?} in {bar:?}"); + for (clip, line) in &grip { + assert!(clip.width() >= bar.width() - 0.5, "the bar's clip is as wide as the bar, not cut by the flyout's edge: {clip:?} for {bar:?}"); + assert!(clip.contains_rect(*line), "the grip line paints inside its clip: {line:?} under {clip:?}"); + } +} + /// Where the pointer holds the window a group floats in, from its top left: on its title row. const GRAB: Vec2 = Vec2::new(30.0, 8.0); /// The size the window floats at.