mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 02:09:00 +00:00
Dock grips: the strip keeps space above and below the marks (photocraft#16426)
The grip strip above an icon group and under a tool rail's column bar was the least hit size (8 points), so the 5-point ticks nearly touched its top edge. It is now tall enough for the theme's marks with space.gap.tight above and below them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4ba7c7e215
commit
9b25308edc
@@ -71,6 +71,15 @@ impl GripMarks {
|
||||
}
|
||||
}
|
||||
|
||||
/// The height of a grip strip (above an icon group, under a tool rail's column bar): at least the least hit size, and
|
||||
/// tall enough that the theme's marks keep `space.gap.tight` above and below them, so they never touch the strip's
|
||||
/// edge (photocraft#16426).
|
||||
pub(crate) fn grip_strip(tokens: &Tokens) -> f32 {
|
||||
let GripShape { mark, length, width, .. } = tokens.shape.grip;
|
||||
let marks = if mark == GripMark::Ticks { length } else { width };
|
||||
tokens.size.hit.target.max(marks + 2.0 * tokens.space.gap.tight)
|
||||
}
|
||||
|
||||
/// What a group grip reports: its response, the second press of a double click and whether it started a group
|
||||
/// drag this pass.
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -62,7 +62,7 @@ impl IconicSizes {
|
||||
IconicSizes {
|
||||
column: DockSizes::style(cx),
|
||||
cell: size.rail.button,
|
||||
grip: size.hit.target,
|
||||
grip: super::group::grip_strip(cx.tokens),
|
||||
separator: cx.tokens.space.gap.tight,
|
||||
labels: size.rail.width * LABELS_IN_RAIL_WIDTHS,
|
||||
}
|
||||
|
||||
@@ -486,14 +486,20 @@ fn a_groups_grip_is_a_row_of_upright_ticks_in_the_grip_ink() {
|
||||
});
|
||||
fixture.room(SCREEN).settle();
|
||||
let id = fixture.root_id().expect("the column shows");
|
||||
let (panel, grip, shape) =
|
||||
StyleCx::with_root(fixture.ctx(), |cx| (cx.tokens.color.surface.panel, cx.tokens.color.line.grip, cx.tokens.shape.grip));
|
||||
let (panel, grip, shape, tight) = StyleCx::with_root(fixture.ctx(), |cx| {
|
||||
(cx.tokens.color.surface.panel, cx.tokens.color.line.grip, cx.tokens.shape.grip, cx.tokens.space.gap.tight)
|
||||
});
|
||||
assert_eq!(shape, craft_theme::GripShape::DEFAULT, "the fixture's theme sets no grip shape");
|
||||
for group in [0, 1] {
|
||||
let strip = fixture.part_rect(id, GRIP.at(group)).expect("each group has its grip");
|
||||
let shapes = fixture.frame_shapes();
|
||||
let (ticks, ink) = grip_ticks(&shapes, strip).expect("the grip paints its ticks");
|
||||
assert_grip_ticks(&ticks, ink, strip, panel, grip, shape, &format!("group {group}"));
|
||||
let run = ticks.iter().fold(Rect::NOTHING, |run, tick| run.union(*tick));
|
||||
assert!(
|
||||
run.top() - strip.top() >= tight - 0.01 && strip.bottom() - run.bottom() >= tight - 0.01,
|
||||
"group {group}: the marks keep space.gap.tight ({tight}) off the strip's edges: {run:?} in {strip:?}"
|
||||
);
|
||||
fixture.frame(vec![egui::Event::PointerMoved(strip.center())]);
|
||||
let hovered = fixture.frame_shapes();
|
||||
let (_, hover_ink) = grip_ticks(&hovered, strip).expect("the grip paints its ticks under the pointer");
|
||||
|
||||
@@ -82,7 +82,7 @@ pub struct DockSizes {
|
||||
pub rail_step: f32,
|
||||
/// The height of a grip strip, the band with the dock's grip marks: above each icon group of a collapsed column,
|
||||
/// and under the column bar of a tool rail (a group whose panel has a [`DockGrid`](super::DockGrid)) that the host
|
||||
/// shows itself (the least hit size).
|
||||
/// shows itself: the least hit size, or the theme's grip marks with `space.gap.tight` above and below them.
|
||||
pub grip: f32,
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ impl DockSizes {
|
||||
column: size.dock.column,
|
||||
rail_first: size.rail.button + 2.0 * cx.tokens.space.pad.control,
|
||||
rail_step: size.rail.button + cx.tokens.space.gap.tight,
|
||||
grip: size.hit.target,
|
||||
grip: super::group::grip_strip(cx.tokens),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user