design-lint on next: the plain artboard edge's black as a data colour, the task bar grip story's drag in drag thresholds, dock column cards take their outer inset as a CardInset step, the link label ink story reads the link's click from its output

This commit is contained in:
aiongg
2026-11-24 14:59:40 +00:00
parent 43c89a0b99
commit f4d3f6c557
10 changed files with 78 additions and 41 deletions
@@ -90,7 +90,7 @@ pub enum ArtboardEdge {
}
/// The edge of the active artboard under [`ArtboardEdge::Plain`]: black.
const PLAIN_ACTIVE: DataColor = DataColor::new(Color32::BLACK);
const PLAIN_ACTIVE: DataColor = DataColor::new(Color32::from_gray(0));
/// The edge of another artboard under [`ArtboardEdge::Plain`]: grey 120.
const PLAIN_OTHER: DataColor = DataColor::new(Color32::from_gray(120));
@@ -207,10 +207,15 @@ fn hover_grip(fixture: &mut Fixture) {
}
}
/// How far the grip is dragged, in drag thresholds: left and down, far enough that the bar visibly moves.
const GRIP_DRAG_THRESHOLDS: [f32; 2] = [-8.0, 6.0];
/// Drags the bar by its grip and holds it there, the button down.
fn drag_grip(fixture: &mut Fixture) {
if let Some(grip) = fixture.by_label("Move bar") {
fixture.drag_hold_at(grip.center(), egui::vec2(-40.0, 30.0));
let threshold = crate::testing::input::slop(fixture.ctx());
let [x, y] = GRIP_DRAG_THRESHOLDS;
fixture.drag_hold_at(grip.center(), egui::vec2(x * threshold, y * threshold));
}
}
+8 -8
View File
@@ -6,7 +6,7 @@
//! user did; the dock decides what a drop changes.
use super::divider::{self, Divider, Drag};
use super::{DockSizes, DockSpot, DockTargets, DockWords, DragUnit, PanelKey, PanelSpec, Splitter};
use super::{CardInset, DockSizes, DockSpot, DockTargets, DockWords, DragUnit, PanelKey, PanelSpec, Splitter};
use crate::contract::{
Access, BodyCx, Common, Component, Container, ContainerProps, Cx, NoValue, Outcome, Pad, PaintUi, PartsCx, Props as _, Role, ShowContainer as _,
Sizing, WordSetCx as _,
@@ -197,11 +197,11 @@ pub struct DockColumn<'a, P: Value + Hash + 'static> {
/// The rect the dock may grow within, which bounds how wide its inner edge can make the column.
#[prop]
within: Rect,
/// The inset on the outer side of the column's card, when it shows as one
/// ([`DockConfig::column_cards`](super::DockConfig::column_cards), [`DockSizes::card_inset`]): its bar and groups
/// Which inset the outer side of the column's card takes, when it shows as one
/// ([`DockConfig::column_cards`](super::DockConfig::column_cards), [`DockSizes::card_place`]): its bar and groups
/// sit inside the card, inset by that on its outer side and by [`DockSizes::card`] on its top and bottom.
#[prop]
card: Option<f32>,
card: Option<CardInset>,
/// The plan `parts` laid out this pass, which update, paint and access read.
laid: Option<Plan>,
resized: Vec<(P, f32)>,
@@ -291,7 +291,7 @@ impl<'a, P: Value + Hash + Debug + 'static> DockColumn<'a, P> {
/// on top.
fn edge_divider(&self, rect: Rect, sizes: &DockSizes) -> Divider {
let (least, most) = sizes.shown_bounds(self.column, self.spec);
let inset = self.card.unwrap_or(0.0);
let inset = self.card.map_or(0.0, |place| sizes.inset(place));
let (least, most) = (least + inset, most + inset);
Divider::column_edge(rect, self.edge, (least, most.min((self.within.width() - sizes.least_pane).max(rect.width()))), sizes.reach)
}
@@ -315,10 +315,10 @@ impl<'a, P: Value + Hash + Debug + 'static> DockColumn<'a, P> {
}
/// The card of a docked column in `rect`, the column's rect in a dock on the window edge `edge`: `rect` inset by
/// `card`, the card's outer inset ([`DockSizes::card_inset`]), on its outer side, the one towards `edge`, and by
/// the card's outer inset at `card` ([`DockSizes::inset`]) on its outer side, the one towards `edge`, and by
/// [`DockSizes::card`] on its top and bottom; `rect` for a column that is no card.
pub(crate) fn card_rect(rect: Rect, card: Option<f32>, sizes: &DockSizes, edge: DockEdge, rtl: bool) -> Rect {
let Some(outer) = card else { return rect };
pub(crate) fn card_rect(rect: Rect, card: Option<CardInset>, sizes: &DockSizes, edge: DockEdge, rtl: bool) -> Rect {
let Some(outer) = card.map(|place| sizes.inset(place)) else { return rect };
let inner = rect.shrink2(egui::vec2(0.0, sizes.card));
if (edge == DockEdge::Start) != rtl { inner.with_min_x(inner.left() + outer) } else { inner.with_max_x(inner.right() - outer) }
}
@@ -1,7 +1,7 @@
//! Stories of `DockColumn`.
use crate::contract::{ShowContainer as _, Tracked};
use crate::docking::{ColumnBar, DockColumn, DockGrid, DockSizes, PanelSpec};
use crate::docking::{CardInset, ColumnBar, DockColumn, DockGrid, DockSizes, PanelSpec};
use crate::rails::tool::stories::{BRUSH, tools};
use crate::rails::{LastUsed, RailDensity, ToolRail, ToolSlot};
use crate::runtime::env::Env;
@@ -64,7 +64,7 @@ fn a_tool_rail_card(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
let room = Flow::new(ui.available_rect_before_wrap(), Env::of(ui).direction.is_rtl()).span(0.0, width);
let rect = room.with_max_y(room.top() + CARD_HEIGHT);
// The column takes the cell a dock gives it, as high as the dock, whatever its rail's height.
let shown = DockColumn::new("Panels", global("dock column", "rail card story"), &column, &spec).card(sizes.card_inset(0)).show_groups_at(
let shown = DockColumn::new("Panels", global("dock column", "rail card story"), &column, &spec).card(CardInset::Edge).show_groups_at(
ui,
rect,
|_, rect, ui, _| {
@@ -83,17 +83,19 @@ fn a_tool_rail_card(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
fn a_panel_column_card(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
let at = *data.choice("place", 0_usize, &[("At the window edge", 0), ("Inward of another column", 1)]);
let column = Column::new(vec![Group::new(vec![0, 1], 0), Group::new(vec![2], 0)]);
let inset = DockSizes { column_cards: true, ..DockSizes::of_scope(ui) }.card_inset(at);
let sizes = DockSizes { column_cards: true, ..DockSizes::of_scope(ui) };
let inset = sizes.card_inset(at);
let room = Flow::new(ui.available_rect_before_wrap(), Env::of(ui).direction.is_rtl()).span(0.0, CARD_WIDTH + inset);
let rect = room.with_max_y(room.top() + 2.0 * CARD_HEIGHT);
let shown = DockColumn::new("Panels", global("dock column", "panel card story"), &column, &spec).card(inset).show_groups_at(
ui,
rect,
|group, rect, ui, _| {
let title = group.active_panel().map_or_else(String::new, |panel| spec(panel).label.as_str().to_owned());
Panel::new(title).show_at(ui, rect, |_, _| ());
},
);
let shown = DockColumn::new("Panels", global("dock column", "panel card story"), &column, &spec);
let shown = match sizes.card_place(at) {
Some(place) => shown.card(place),
None => shown,
};
let shown = shown.show_groups_at(ui, rect, |group, rect, ui, _| {
let title = group.active_panel().map_or_else(String::new, |panel| spec(panel).label.as_str().to_owned());
Panel::new(title).show_at(ui, rect, |_, _| ());
});
ui.advance_cursor_after_rect(rect);
shown.into()
}
+5 -5
View File
@@ -6,7 +6,7 @@ use super::dock_column::{
register_edges, show_bar,
};
use super::group::GripMarks;
use super::{DockSizes, DockSpot, DockTargets, DockWords, DragUnit, Flyout, GroupAt, PanelKey, PanelSpec, Splitter, start_icon_drag};
use super::{CardInset, DockSizes, DockSpot, DockTargets, DockWords, DragUnit, Flyout, GroupAt, PanelKey, PanelSpec, Splitter, start_icon_drag};
use crate::buttons::IconButton;
use crate::contract::overlay::Anchor;
use crate::contract::{
@@ -225,11 +225,11 @@ pub struct IconicColumn<'a, P: Value + Hash + 'static> {
/// palette window, the work area.
#[prop]
within: Rect,
/// The inset on the outer side of the docked column's card, when it shows as one
/// ([`DockConfig::column_cards`](super::DockConfig::column_cards), [`DockSizes::card_inset`]): its bar and icons
/// Which inset the outer side of the docked column's card takes, when it shows as one
/// ([`DockConfig::column_cards`](super::DockConfig::column_cards), [`DockSizes::card_place`]): its bar and icons
/// sit inside the card, inset by that on its outer side and by [`DockSizes::card`] on its top and bottom.
#[prop]
card: Option<f32>,
card: Option<CardInset>,
open: Bind<'a, Option<P>>,
view: Option<FlyoutView<'a, P>>,
/// The bar's rect this pass.
@@ -365,7 +365,7 @@ impl<'a, P: Value + Hash + Debug + 'static> IconicColumn<'a, P> {
/// a card's inset on top.
fn edge_divider(&self, rect: Rect, sizes: &DockSizes) -> Divider {
let (least, most) = sizes.iconic_bounds(self.column, self.spec);
let inset = self.card.unwrap_or(0.0);
let inset = self.card.map_or(0.0, |place| sizes.inset(place));
let (least, most) = (least + inset, most + inset);
let most = most.min((self.within.width() - sizes.least_pane).max(rect.width()));
Divider::column_edge(rect, self.edge, (least, most), sizes.reach)
@@ -97,9 +97,14 @@ fn icon_groups(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
#[story(IconicColumn<'static, u8>, covers = [], drive = Drive::Never)]
fn icons_as_a_card(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
let at = *data.choice("place", 1_usize, &[("At the window edge", 0), ("Inward of another column", 1)]);
let inset = DockSizes { column_cards: true, ..DockSizes::of_scope(ui) }.card_inset(at);
let sizes = DockSizes { column_cards: true, ..DockSizes::of_scope(ui) };
let inset = sizes.card_inset(at);
let column = Column::new(vec![Group::new(vec![0, 1], 0), Group::new(vec![2], 0)]);
let column = IconicColumn::new("Panels", global("iconic column", "card story"), &column, Bind::kept(), &spec).card(inset);
let column = IconicColumn::new("Panels", global("iconic column", "card story"), &column, Bind::kept(), &spec);
let column = match sizes.card_place(at) {
Some(place) => column.card(place),
None => column,
};
at_stage_wider(ui, column, inset, |group, at, ui, _| {
let GroupAt::Show(rect) = at else { return None };
let title = group.active_panel().map_or_else(String::new, |panel| spec(panel).label.as_str().to_owned());
+1 -1
View File
@@ -45,7 +45,7 @@ pub use placed::{Placing, placed_rect, with_area_rules};
pub use root::{DockRoot, DockRootOutput, DockRootStyle};
pub use spec::{DockGrid, DockHeights, PanelSpec};
pub use splitter::{Splitter, SplitterStyle};
pub use targets::{DockSizes, DockSpot, DockTargets, GroupDrag, ZoneRule};
pub use targets::{CardInset, DockSizes, DockSpot, DockTargets, GroupDrag, ZoneRule};
pub use words::DockWords;
pub use commands::{
+28 -3
View File
@@ -102,6 +102,16 @@ pub struct DockSizes {
pub grip: f32,
}
/// Which inset a docked column's card takes on its outer side ([`DockSizes::card_place`]).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum CardInset {
/// The first column, at the dock's window edge: [`DockSizes::card`].
Edge,
/// A column past its outer neighbour's card: [`DockSizes::card_gutter`].
Gutter,
}
impl DockSizes {
/// The sizes in the root scope's style, for code outside a style pass:
/// `StyleCx::with_root(ctx, DockSizes::style)`.
@@ -206,10 +216,25 @@ impl DockSizes {
/// [`card_gutter`](Self::card_gutter) for the others, which stand that far from their outer neighbour's card. A
/// docked column is that much wider than its content.
pub fn card_inset(&self, at: usize) -> f32 {
self.card_place(at).map_or(0.0, |place| self.inset(place))
}
/// Which inset the card of a dock's docked column `at` from the window edge inwards takes on its outer side: none
/// without [`column_cards`](Self::column_cards); [`CardInset::Edge`] for the first column, [`CardInset::Gutter`]
/// for the others.
pub fn card_place(&self, at: usize) -> Option<CardInset> {
match (self.column_cards, at) {
(false, _) => 0.0,
(true, 0) => self.card,
(true, _) => self.card_gutter,
(false, _) => None,
(true, 0) => Some(CardInset::Edge),
(true, _) => Some(CardInset::Gutter),
}
}
/// The inset on the outer side of a card at `place`: [`card`](Self::card) or [`card_gutter`](Self::card_gutter).
pub fn inset(&self, place: CardInset) -> f32 {
match place {
CardInset::Edge => self.card,
CardInset::Gutter => self.card_gutter,
}
}
+8 -8
View File
@@ -11,7 +11,7 @@ use crate::contract::{
use crate::docking::SplitFramesCx as _;
use crate::docking::stack::{StackSection, StackSections, section_heights};
use crate::docking::tree::FrameRules;
use crate::docking::{Arrangement, close_requests, cross_window, end_replaced_drags, float_drop, native, open_requests};
use crate::docking::{Arrangement, CardInset, close_requests, cross_window, end_replaced_drags, float_drop, native, open_requests};
use crate::docking::{
ColumnArrow, ColumnBar, DockColumn, DockCommands, DockConfig, DockDropTarget, DockDropped, DockEvent, DockGroup, DockPanels, DockRoot, DockScene,
DockSizes, DockSpot, DockTargets, DockTo, DockWords, DragUnit, FloatSpace, FloatingGroup, FlyoutResize, GroupAt, GroupDrag, GroupGrip,
@@ -451,8 +451,8 @@ struct ColumnAt<P> {
bar: ColumnBar,
within: Rect,
open: Option<P>,
/// The outer inset of the column's card, a docked column's in a dock that shows cards ([`DockSizes::card_inset`]).
card: Option<f32>,
/// Which outer inset the column's card takes, a docked column's in a dock that shows cards ([`DockSizes::card_place`]).
card: Option<CardInset>,
}
/// What a column reported.
@@ -1239,7 +1239,7 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
// (photocraft#16461). Content taller than the dock scrolls inside. Only a floating stepped window is as
// tall as its content.
self.report.placed.push((first.clone(), cell));
let card = scene.sizes.column_cards.then(|| scene.sizes.card_inset(at));
let card = scene.sizes.card_place(at);
let at = ColumnAt { cell, edge: plan.edge, bar: ColumnBar::Own, within: body.rect, open: plan.open.clone(), card };
self.column(ui, body, column, at);
}
@@ -1342,8 +1342,8 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
// Only a docked column's icons are a rail; a floating window's open flyouts.
let mode = if in_window { IconicMode::Flyouts } else { scene.config.iconic_mode };
// The width the user gives a column by its inner edge leaves out its card's inset.
let inset = card.unwrap_or(0.0);
let mut icons = |cell: Rect, open: Option<P>, card: Option<f32>| {
let inset = card.map_or(0.0, |place| scene.sizes.inset(place));
let mut icons = |cell: Rect, open: Option<P>, card: Option<CardInset>| {
let footer = scene.rail_footer.filter(|panel| mode == IconicMode::Rail && column.panels().any(|item| item == *panel));
let pass = RefCell::new(&mut *self);
let draw = |ui: &mut Ui, rect: Rect, open: Option<P>| {
@@ -1355,7 +1355,7 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
.auto_collapse(scene.auto_collapse)
.mode(mode);
let shown = match card {
Some(inset) => shown.card(inset),
Some(place) => shown.card(place),
None => shown,
};
shown.show_flyouts_at(ui, rect, |group, at, ui, body| pass.borrow_mut().group_of(ui, body, group, at, in_window))
@@ -1412,7 +1412,7 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
.within(within)
.auto_collapse(scene.auto_collapse);
let shown = match card {
Some(inset) => shown.card(inset),
Some(place) => shown.card(place),
None => shown,
};
let output = shown.show_groups_at(ui, cell, |group, rect, ui, body| {
+1 -1
View File
@@ -70,7 +70,7 @@ fn field_link_label_ink(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
}
.show(ui);
// The field the label names reports the link click; the story is its host.
field.inner.as_ref().is_some_and(|field| field.link) || link.clicked()
field.inner.as_ref().is_some_and(|field| field.link) || StoryOutput::from(link).clicked
})
.inner
== Some(true)