diff --git a/docs/contract-api.md b/docs/contract-api.md index d968b1e09..3128890a6 100644 --- a/docs/contract-api.md +++ b/docs/contract-api.md @@ -57,6 +57,7 @@ Pure UI behaviours (layer 1): press lifecycle, `ValueDrag`, navigation, item lay - `craft_behavior::ColumnWidth`: re-export of `craft_behavior::columns::ColumnWidth`. - `craft_behavior::CommandFlags`: re-export of `craft_behavior::command::CommandFlags`. - `craft_behavior::ControlMetrics`: re-export of `craft_behavior::sizing::ControlMetrics`. +- `craft_behavior::CopyKeys`: re-export of `craft_behavior::keys::CopyKeys`. - `craft_behavior::CountMark`: re-export of `craft_behavior::cursor::CountMark`. - `craft_behavior::Cursor`: re-export of `craft_behavior::cursor::Cursor`. - `craft_behavior::CursorBadge`: re-export of `craft_behavior::cursor::CursorBadge`. @@ -79,6 +80,7 @@ Pure UI behaviours (layer 1): press lifecycle, `ValueDrag`, navigation, item lay - `craft_behavior::Ended`: re-export of `craft_behavior::typing::Ended`. - `craft_behavior::EscapeRule`: re-export of `craft_behavior::typing::EscapeRule`. - `craft_behavior::Escaped`: re-export of `craft_behavior::typing::Escaped`. +- `craft_behavior::FRAME_STEP_MAX`: re-export of `craft_behavior::frame_step::FRAME_STEP_MAX`. - `craft_behavior::Flow`: re-export of `craft_behavior::flow::Flow`. - `craft_behavior::FreeLayout`: re-export of `craft_behavior::item_layout::FreeLayout`. - `craft_behavior::GESTURE_GAP`: re-export of `craft_behavior::wheel::GESTURE_GAP`. @@ -112,6 +114,8 @@ Pure UI behaviours (layer 1): press lifecycle, `ValueDrag`, navigation, item lay - `craft_behavior::MarqueeMode`: re-export of `craft_behavior::item_marquee::MarqueeMode`. - `craft_behavior::MarqueeSelect`: re-export of `craft_behavior::item_marquee::MarqueeSelect`. - `craft_behavior::Metrics`: re-export of `craft_behavior::sizing::Metrics`. +- `craft_behavior::MiddleButton`: re-export of `craft_behavior::middle_scroll::MiddleButton`. +- `craft_behavior::MiddleScroll`: re-export of `craft_behavior::middle_scroll::MiddleScroll`. - `craft_behavior::Mixed`: re-export of `craft_behavior::value::Mixed`. - `craft_behavior::Monitor`: re-export of `craft_behavior::monitor::Monitor`. - `craft_behavior::MonitorKey`: re-export of `craft_behavior::monitor::MonitorKey`. @@ -169,16 +173,19 @@ Pure UI behaviours (layer 1): press lifecycle, `ValueDrag`, navigation, item lay - `craft_behavior::PointerSample`: re-export of `craft_behavior::press::PointerSample`. - `craft_behavior::Positions`: `pub struct Positions`. The display order of a grid whose row keys are their positions (a sheet, a document table): `key(at) == at`, and - `pub const fn new(rows: u32) -> Self`. The order of `rows` rows. +- `craft_behavior::PressAside`: re-export of `craft_behavior::press::PressAside`. - `craft_behavior::PressCancel`: re-export of `craft_behavior::press::PressCancel`. - `craft_behavior::PressFocus`: re-export of `craft_behavior::focus::PressFocus`. - `craft_behavior::PressMachine`: re-export of `craft_behavior::press::PressMachine`. - `craft_behavior::PressPhase`: re-export of `craft_behavior::press::PressPhase`. +- `craft_behavior::PressPick`: re-export of `craft_behavior::press::PressPick`. - `craft_behavior::PressStart`: re-export of `craft_behavior::press::PressStart`. - `craft_behavior::PressState`: re-export of `craft_behavior::press::PressState`. - `craft_behavior::PressStep`: re-export of `craft_behavior::press::PressStep`. - `craft_behavior::Preview`: re-export of `craft_behavior::value::Preview`. - `craft_behavior::Proposal`: re-export of `craft_behavior::sizing::Proposal`. - `craft_behavior::Reader`: re-export of `craft_behavior::quantity::Reader`. +- `craft_behavior::ReorderKeys`: re-export of `craft_behavior::keys::ReorderKeys`. - `craft_behavior::ResolveFor`: re-export of `craft_behavior::hit::ResolveFor`. - `craft_behavior::RoleRule`: re-export of `craft_behavior::role_rule::RoleRule`. - `craft_behavior::Roving`: `pub struct Roving { pub shape: NavShape, pub wrap: bool, pub home_end: bool, pub page: Option, pub letters: Letters, pub arrows: Arrows, pub first_column: Option, pub hands_back: bool, pub no_lead: bool, pub keeps_lead_moves: bool }`. A roving group's rules: one Tab stop whose members take moves. @@ -195,13 +202,14 @@ Pure UI behaviours (layer 1): press lifecycle, `ValueDrag`, navigation, item lay - `pub const fn state(&self, lead: Option) -> NavState`. The state a step over this group starts from, at `lead`, or from no lead when the group has none. - `pub const fn takes(&self, mv: NavMove, mods: MoveMods) -> bool`. Whether the group handles `mv` with `mods`: Page moves only with a page size and without `lead` (on a document - `craft_behavior::RowAt`: re-export of `craft_behavior::selection::RowAt`. -- `craft_behavior::RulerUnits`: `pub struct RulerUnits { pub per_doc: f64, pub ticks: Ticks }`. The ruler unit of one document axis: its size and its ticks. Rulers label their ticks with it; guides use it for - - `pub const fn new(per_doc: f64, ticks: Ticks) -> Self`. Ruler units of `per_doc` per document unit, spaced by `ticks`. +- `craft_behavior::RulerUnits`: `pub struct RulerUnits { pub per_doc: f64, pub ticks: Ticks, pub labels: TickLabels }`. The ruler unit of one document axis: its size, its ticks and how it labels them. Rulers label their ticks with it; + - `pub const fn new(per_doc: f64, ticks: Ticks) -> Self`. Ruler units of `per_doc` per document unit, spaced by `ticks`, labelled as [`TickLabels::Distance`]. + - `pub const fn with_labels(mut self, labels: TickLabels) -> Self`. The units with their ticks written as `labels`. - `pub const fn pixels() -> Self`. Whole document pixels. - `pub fn step(&self, zoom: f64, step_min: f32) -> (f64, u32)`. The labelled step in ruler units and its subdivisions when one document unit is `zoom` screen points along - `pub fn snap_to_tick(&self, position: f64, zero: f64, zoom: f64, step_min: f32) -> f64`. `position` (document units) moved to the nearest minor tick of the ruler counting from `zero`, at `zoom` - `pub fn distance(&self, position: f64, zero: f64) -> f64`. The distance of `position` (document units) from `zero`, in ruler units. - - `pub fn label_decimals(&self, step: f64) -> usize`. The decimals a ruler writes a tick of labelled step `step` with. Whole ticks are whole numbers; a step of at + - `pub fn label_decimals(&self, step: f64) -> RangeInclusive`. The least and most decimals a ruler writes a tick of labelled step `step` with. Whole ticks are whole numbers; - `pub fn label_value(&self, value: f64, step: f64) -> f64`. The number a ruler prints at the tick `value` (ruler units from the zero point) for a labelled step `step`: - `craft_behavior::SHEET_ZOOM`: re-export of `craft_behavior::item_layout::SHEET_ZOOM`. - `craft_behavior::ScopeKind`: re-export of `craft_behavior::focus::ScopeKind`. @@ -218,6 +226,7 @@ Pure UI behaviours (layer 1): press lifecycle, `ValueDrag`, navigation, item lay - `craft_behavior::SpanLayout`: re-export of `craft_behavior::item_layout::SpanLayout`. - `craft_behavior::SurroundingUnit`: re-export of `craft_behavior::editor::SurroundingUnit`. - `craft_behavior::TextPos`: re-export of `craft_behavior::intent::TextPos`. +- `craft_behavior::TickLabels`: `pub enum TickLabels { Distance, Signed }`. How a ruler writes the number at a labelled tick. - `craft_behavior::Ticks`: `pub enum Ticks { Decimal { whole: bool }, Custom(fn(f64) -> (f64, u32)) }`. How a ruler divides its unit at a zoom. - `pub const fn decimal(whole: bool) -> Self`. PhotoCraft's decimal steps; `whole` keeps the step a whole number of units without 2.5. - `craft_behavior::TileLayout`: re-export of `craft_behavior::item_layout::TileLayout`. @@ -238,6 +247,7 @@ Pure UI behaviours (layer 1): press lifecycle, `ValueDrag`, navigation, item lay - `craft_behavior::ViewPlace`: `pub struct ViewPlace { pub key: K, pub center: Point, pub zoom: f64 }`. Where a view stood: what it showed (`key`: a page, an artboard, a document) and the view's - `pub const fn new(key: K, center: Point, zoom: f64) -> Self`. The view of `key` centred on `center` at `zoom`. - `craft_behavior::Wheel`: re-export of `craft_behavior::wheel::Wheel`. +- `craft_behavior::WheelEase`: re-export of `craft_behavior::wheel::WheelEase`. - `craft_behavior::WheelFocus`: re-export of `craft_behavior::wheel::WheelFocus`. - `craft_behavior::WheelGesture`: re-export of `craft_behavior::wheel::WheelGesture`. - `craft_behavior::WheelNotch`: re-export of `craft_behavior::wheel::WheelNotch`. @@ -251,6 +261,7 @@ Pure UI behaviours (layer 1): press lifecycle, `ValueDrag`, navigation, item lay - `craft_behavior::ZoomScheme`: re-export of `craft_behavior::canvas::zoom::ZoomScheme`. - `craft_behavior::count_clicks`: re-export of `craft_behavior::press::count_clicks`. - `craft_behavior::decimals_for_step`: re-export of `craft_behavior::codec::decimals_for_step`. +- `craft_behavior::frame_step`: re-export of `craft_behavior::frame_step::frame_step`. - `craft_behavior::is_checkable`: re-export of `craft_behavior::role_rule::is_checkable`. - `craft_behavior::is_selectable`: re-export of `craft_behavior::role_rule::is_selectable`. - `craft_behavior::keyed`: re-export of `craft_behavior::item_source::keyed`. @@ -312,14 +323,16 @@ The transform a canvas body is shown through, and the canvas view with its zoom - `pub fn layer_transform(&self) -> Option`. The transform a canvas body is shown through when this view only scales and moves the document: unturned, - `pub fn axis_aligned(&self) -> bool`. Whether the rotation is a multiple of 90°, so document axes are screen axes. - `pub fn level(&self, zero: Point) -> CanvasView`. The view without its rotation, moved so it draws `zero` where this view does: the same -- `craft_behavior::canvas::RulerUnits`: `pub struct RulerUnits { pub per_doc: f64, pub ticks: Ticks }`. The ruler unit of one document axis: its size and its ticks. Rulers label their ticks with it; guides use it for - - `pub const fn new(per_doc: f64, ticks: Ticks) -> Self`. Ruler units of `per_doc` per document unit, spaced by `ticks`. +- `craft_behavior::canvas::RulerUnits`: `pub struct RulerUnits { pub per_doc: f64, pub ticks: Ticks, pub labels: TickLabels }`. The ruler unit of one document axis: its size, its ticks and how it labels them. Rulers label their ticks with it; + - `pub const fn new(per_doc: f64, ticks: Ticks) -> Self`. Ruler units of `per_doc` per document unit, spaced by `ticks`, labelled as [`TickLabels::Distance`]. + - `pub const fn with_labels(mut self, labels: TickLabels) -> Self`. The units with their ticks written as `labels`. - `pub const fn pixels() -> Self`. Whole document pixels. - `pub fn step(&self, zoom: f64, step_min: f32) -> (f64, u32)`. The labelled step in ruler units and its subdivisions when one document unit is `zoom` screen points along - `pub fn snap_to_tick(&self, position: f64, zero: f64, zoom: f64, step_min: f32) -> f64`. `position` (document units) moved to the nearest minor tick of the ruler counting from `zero`, at `zoom` - `pub fn distance(&self, position: f64, zero: f64) -> f64`. The distance of `position` (document units) from `zero`, in ruler units. - - `pub fn label_decimals(&self, step: f64) -> usize`. The decimals a ruler writes a tick of labelled step `step` with. Whole ticks are whole numbers; a step of at + - `pub fn label_decimals(&self, step: f64) -> RangeInclusive`. The least and most decimals a ruler writes a tick of labelled step `step` with. Whole ticks are whole numbers; - `pub fn label_value(&self, value: f64, step: f64) -> f64`. The number a ruler prints at the tick `value` (ruler units from the zero point) for a labelled step `step`: +- `craft_behavior::canvas::TickLabels`: `pub enum TickLabels { Distance, Signed }`. How a ruler writes the number at a labelled tick. - `craft_behavior::canvas::Ticks`: `pub enum Ticks { Decimal { whole: bool }, Custom(fn(f64) -> (f64, u32)) }`. How a ruler divides its unit at a zoom. - `pub const fn decimal(whole: bool) -> Self`. PhotoCraft's decimal steps; `whole` keeps the step a whole number of units without 2.5. - `craft_behavior::canvas::ViewHistory`: `pub struct ViewHistory`. The places a window jumped between, oldest first, with the one it shows now. The app records @@ -384,6 +397,8 @@ Zoom rules as pure functions on a [`CanvasView`]: the zoom scheme's range and Zo - `pub fn new(reader: Reader, decimals: usize) -> Self`. A codec reading with `reader` and writing at most `decimals` decimal places. - `pub fn fixed(mut self) -> Self`. The same codec writing every decimal place, trailing zeros included ("1.00"), as a field of a quantity shown - `pub fn zoom_typing(mut self) -> Self`. The same codec with the typing rules of a zoom field: digits, `/` and the decimal separator, `a/b` as the + - `pub fn signed_zoom(mut self) -> Self`. Allow a leading minus in zoom input so the field can reject negative values instead of discarding the sign. + - `pub fn share_of_start(mut self) -> Self`. The same codec reading a lone percentage (`50%`, [`Reader::share`]) as that share of the value the edit - `pub fn at_most(mut self, decimals: usize) -> Self`. The same codec writing at most `decimals` decimal places. - `pub fn or_parse(mut self, parse: impl Fn(&str) -> Option + Send + Sync + 'static) -> Self`. The same codec with `parse` as a second reader: it runs when the reader rejects the text, so words of the - `pub fn widest(&self, range: &RangeInclusive) -> String`. The widest text the codec writes for a number in `range`: the longest of each end and the number one place of @@ -429,11 +444,11 @@ Cursor requests as plain data and the rule that picks the winner (8.5). - `craft_behavior::cursor::Cursor`: `pub enum Cursor { System(CursorIcon), Painted(PaintedCursor) }`. What a cursor request names. - `craft_behavior::cursor::CursorBadge`: `pub enum CursorBadge { Add, Subtract, Intersect, Copy, NotAllowed, Scissors, Close, Move, Arrow, Target, Continue, Count(CountMark), Corner }`. A mark beside a painted cursor. - `craft_behavior::cursor::CursorIcon`: `pub enum CursorIcon { Default, None, ContextMenu, Help, PointingHand, Progress, Wait, Cell, Crosshair, Text, VerticalText, Alias, Copy, Move, NoDrop, NotAllowed, Grab, Grabbing, AllScroll, ResizeHorizontal, ResizeNeSw, ResizeNwSe, ResizeVertical, ResizeColumn, ResizeEast, ResizeSouthEast, ResizeSouth, ResizeSouthWest, ResizeWest, ResizeNorthWest, ResizeNorth, ResizeNorthEast, ZoomIn, ZoomOut }`. A system cursor: craft-behavior's copy of egui's set, converted by `runtime::egui::output`. -- `craft_behavior::cursor::CursorPriority`: `pub enum CursorPriority { Default, Tool, Hover, Part, DropTarget, Drag }`. Who asks, in ascending order of precedence. +- `craft_behavior::cursor::CursorPriority`: `pub enum CursorPriority { Default, Tool, Hover, Part, DropTarget, Drag, Hidden }`. Who asks, in ascending order of precedence. - `craft_behavior::cursor::IconId`: `pub struct IconId`. An icon's egui-free key (5.2), so plain data such as [`PaintedCursor::Tool`] names icons without egui. - `pub const fn new(name: &'static str) -> Self`. The icon named `name`. - `pub fn name(&self) -> &str`. The name. -- `craft_behavior::cursor::PaintedCursor`: `pub enum PaintedCursor { Crosshair, Circle { radius: f32, centre: bool, badge: Option }, Outline { rings: Vec>, centre: bool, badge: Option }, Hand, Zoom { out: bool }, Tool { icon: IconId, hotspot: Vec2, badge: Option }, Badged { base: CursorIcon, badge: CursorBadge }, Turn { toward: Vec2 }, Distort { dir: Vec2 }, Skew { dir: Vec2 }, TypeOn { path: bool }, Locator, Arrow { hollow: bool, toward: Option }, PathText { start: bool, end: bool }, PointerTool { pointer: PointerGlyph, icon: IconId }, Hidden, IBeam }`. A cursor the overlay host paints. Geometry is in screen points around the pointer (a tool scales its brush +- `craft_behavior::cursor::PaintedCursor`: `pub enum PaintedCursor { Crosshair, Circle { radius: f32, centre: bool, badge: Option }, Outline { rings: Vec>, centre: bool, badge: Option }, Hand, Zoom { out: bool }, Tool { icon: IconId, hotspot: Vec2, badge: Option }, Badged { base: CursorIcon, badge: CursorBadge }, Turn { toward: Vec2 }, Distort { dir: Vec2 }, Skew { dir: Vec2 }, TypeOn { path: bool }, Locator, Arrow { hollow: bool, toward: Option }, PathText { start: bool, end: bool }, PointerTool { pointer: PointerGlyph, icon: IconId, badge: Option }, Hidden, IBeam }`. A cursor the overlay host paints. Geometry is in screen points around the pointer (a tool scales its brush - `pub const CENTRE_ARM: f32`. The arm of the centre mark of a circle or an outline, in points. - `pub const fn circle(radius: f32) -> Self`. A circle of `radius` points, with no centre mark and no badge. - `pub fn outline(rings: Vec>) -> Self`. App shapes as closed rings, with no centre mark and no badge. @@ -448,6 +463,7 @@ Cursor requests as plain data and the rule that picks the winner (8.5). - `pub const fn arrow_toward(dir: Vec2) -> Self`. A solid arrow turned about its hotspot to point along `dir`. - `pub const fn path_text(start: bool, end: bool) -> Self`. An I-beam across the path with a triangle toward each grabbable side. - `pub const fn pointer_tool(pointer: PointerGlyph, icon: IconId) -> Self`. `pointer` with the tool's icon below and right of it. + - `pub const fn pointer_tool_badged(pointer: PointerGlyph, icon: IconId, badge: Option) -> Self`. `pointer` with the tool's icon below and right of it, and `badge` at the icon's lower right. - `pub const fn badged(base: CursorIcon, badge: CursorBadge) -> Self`. A system cursor with a mark. - `craft_behavior::cursor::PointerGlyph`: `pub enum PointerGlyph { Crosshair, Arrow }`. The pointer of a [`PaintedCursor::PointerTool`]. - `craft_behavior::cursor::pick`: `pub fn pick(requests: &[(Cursor, CursorPriority)]) -> Option<&Cursor>`. The winning request: the highest priority, the later request on a tie. @@ -655,7 +671,7 @@ The dock model: the tree of splits over panel frames, the side of a group a drop - `craft_behavior::edit_history::EditHistory`: `pub struct EditHistory`. Undo and redo stacks of a value `T`, at most 100 steps. A gesture is one step: `Begin` opens it, `Commit` closes it, - `pub fn new(now: &T) -> Self`. A history that starts at `now`. - `pub fn with_budget(mut self, max: usize, weight: fn(&T) -> usize) -> Self`. The undo steps' summed weight stays at or under `max`: after each push the oldest go first, the newest always - - `pub fn record(&mut self, event: &EditEvent)`. Takes in one event. Events of a gesture other than the open one are ignored. + - `pub fn record(&mut self, event: &EditEvent)`. Takes in one event. Events of a gesture other than the open one are ignored. A concrete - `pub fn is_open(&self) -> bool`. A gesture is open: a caller that restores a draft waits for it to end. - `pub fn step(&mut self, now: &mut T, step: Step) -> bool`. Steps `now` back or forward. False when there is nowhere to go. An open gesture is abandoned. - `pub fn take_back(&mut self) -> Option`. Takes back the newest undo step without a redo entry, for an edit that was refused: `settled` returns to the @@ -748,6 +764,13 @@ Pure focus rules (spec 9.3, 9.4, 8.3): key ownership, the Escape order and the f - `craft_behavior::focus::key_owner`: `pub fn key_owner(blocked: bool, present: &[OwnerClass]) -> KeyOwner`. Key ownership, in the order blocked, `Menu`, `Recorder`, `Dialog`, `Text`, `Popup` and `PassivePopup`, - `craft_behavior::focus::route_escapes`: `pub fn route_escapes(escapes: usize, press_captured: bool) -> EscapeRouting`. Routes `escapes` Escapes of one pass: with a press captured, the first one is the press's (`escape_step`'s +## `craft_behavior::frame_step` + +The step of one pass of motion: a Hand glide, a held Zoom press and an autoscroll integrate over it. + +- `craft_behavior::frame_step::FRAME_STEP_MAX`: `pub const FRAME_STEP_MAX: f64`. The longest step motion integrates, in seconds, so a stalled pass never jumps the view. +- `craft_behavior::frame_step::frame_step`: `pub fn frame_step(dt: f64) -> f64`. The step of a pass that came `dt` seconds after the previous one, `dt` being the time between two readings of the + ## `craft_behavior::geometry` Pure canvas geometry in document units: the transform box ([`quad`]), snapping ([`snap`]), the @@ -756,6 +779,7 @@ Pure canvas geometry in document units: the transform box ([`quad`]), snapping ( - `craft_behavior::geometry::AspectHold`: re-export of `craft_behavior::geometry::crop::AspectHold`. - `craft_behavior::geometry::BoxAllow`: re-export of `craft_behavior::geometry::quad::BoxAllow`. - `craft_behavior::geometry::BoxDrag`: re-export of `craft_behavior::geometry::quad::BoxDrag`. +- `craft_behavior::geometry::BoxHandles`: re-export of `craft_behavior::geometry::quad::BoxHandles`. - `craft_behavior::geometry::BoxPart`: re-export of `craft_behavior::geometry::quad::BoxPart`. - `craft_behavior::geometry::BoxRules`: re-export of `craft_behavior::geometry::quad::BoxRules`. - `craft_behavior::geometry::BoxState`: re-export of `craft_behavior::geometry::quad::BoxState`. @@ -830,7 +854,7 @@ The crop frame's pure geometry: the box, where a press lands on it, what each ge - `pub fn swapped(&self) -> Self`. Width and height swapped about the centre, the angle kept (X). - `pub fn nudged(&self, part: BoxPart, by: Vec2, ratio: Option) -> Self`. The frame after an arrow key moves `part` by `by`, as a plain drag of the part would, with `ratio` held. - `pub fn crop_size(&self) -> Option<(f64, f64)>`. The size Enter would crop to: the frame's own width and height in whole document units, at least 1; `None` - - `pub fn size_ok(&self) -> bool`. Whether both sides are at least one document unit. + - `pub fn size_ok(&self, min: f64) -> bool`. Whether both sides are at least `min`, and never under one document unit whatever `min` says (a `min` that is - `pub fn resized(&self, part: BoxPart, by: Vec2, hold: AspectHold, alt: bool) -> Self`. The frame with `part` dragged by the page vector `by`: along the frame's own axes, the opposite edges kept on - `pub fn resized_centred(&self, part: BoxPart, by: Vec2, hold: AspectHold, alt: bool) -> Option`. [`resized`](Self::resized) for Auto Center Preview in image mode: `part` dragged by `by` grows or shrinks the - `pub fn turned_to(&self, grab: f64, to: Point, step: Option, image: bool) -> Self`. The frame turned from this one's angle by the pointer's sweep about the centre, from direction `grab` @@ -967,15 +991,19 @@ Box geometry of transform boxes: where the box goes when a part of it is dragged - `pub const fn new(rotate: bool, skew: bool, distort: bool) -> Self`. What the content allows: turning, skewing and distorting. - `pub const fn with_warp(mut self, warp: bool) -> Self`. Whether the content allows warping. - `craft_behavior::geometry::quad::BoxDrag`: `pub enum BoxDrag { Move, Pivot, Rotate, Scale, Distort, Perspective, Skew, SlideCorner }`. What a drag of a box part does ([`BoxRules::drag_kind`]). +- `craft_behavior::geometry::quad::BoxHandles`: `pub enum BoxHandles { All, Corners, Sides }`. Which handles of a box are shown. - `craft_behavior::geometry::quad::BoxPart`: `pub enum BoxPart { Corner(u8), Edge(u8), Pivot, Inside, Outside }`. A part of a box under the pointer or picked from the keyboard. Edge `k` joins corners `k` and - `pub const fn index(self) -> u64`. The number a part is keyed by in a canvas control's part keys: 0 inside or outside, 1 to 4 the corners, 5 to - `pub const fn from_index(index: u64) -> Option`. The part keyed by `index`: the inverse of [`index`](Self::index), with 0 the inside. -- `craft_behavior::geometry::quad::BoxRules`: `pub struct BoxRules { pub mode: TransformMode, pub scale: ScaleRule, pub aspect_linked: bool, pub allow: BoxAllow, pub rotate_step: f64, pub min_side: f64 }`. How drags change a box. +- `craft_behavior::geometry::quad::BoxRules`: `pub struct BoxRules { pub mode: TransformMode, pub scale: ScaleRule, pub aspect_linked: bool, pub allow: BoxAllow, pub rotate_step: f64, pub min_side: f64, pub handles: BoxHandles, pub edge_band: f32 }`. How drags change a box. - `pub fn in_mode(mode: TransformMode) -> BoxRules`. The rules of `mode` with the default scale rule, a linked aspect, everything allowed and - `pub fn with_scale(mut self, scale: ScaleRule) -> BoxRules`. The rules with `scale` as the plain corner and edge drag rule. - `pub fn with_aspect_linked(mut self, linked: bool) -> BoxRules`. The rules with the options bar's aspect link on or off. - `pub fn with_allow(mut self, allow: BoxAllow) -> BoxRules`. The rules with `allow` as what the content permits. - `pub fn with_min_side(mut self, side: f64) -> BoxRules`. The rules with `side` as the minimum side of a scaled box, in document units. + - `pub fn with_handles(mut self, handles: BoxHandles) -> BoxRules`. The rules with `handles` as the handles the box shows. + - `pub fn with_edge_band(mut self, points: f32) -> BoxRules`. The rules with each side grabbed within `points` of its line ([`edge_band`](Self::edge_band)). + - `pub fn shows(&self, part: BoxPart) -> bool`. Whether the box shows `part`: `Corners` shows the four corners and no side, `Sides` the right and left sides - `pub fn effective_mode(&self) -> TransformMode`. The mode drags follow: a mode the content refuses scales as Free Transform does. - `pub fn allows(&self, part: BoxPart) -> bool`. Whether a drag of `part` changes the box: in Distort only the corners, the inside and the - `pub fn drag_kind(&self, part: BoxPart, mods: Mods) -> Option`. What a drag of `part` with `mods` held (as the host has them, before @@ -1005,7 +1033,7 @@ Box geometry of transform boxes: where the box goes when a part of it is dragged - `craft_behavior::geometry::quad::Parts`: `pub struct Parts { pub w: f64, pub h: f64, pub angle: f64, pub skew_h: f64, pub skew_v: f64 }`. A box read as the options bar shows it: the starting rect scaled by `w` and `h`, skewed by - `pub const fn new(w: f64, h: f64, angle: f64, skew_h: f64, skew_v: f64) -> Self`. The readings: scale factors `w` and `h`, the `angle` in degrees and the two skews in degrees. - `craft_behavior::geometry::quad::SKEW_LIMIT`: `pub const SKEW_LIMIT: f64`. The skew fields' reach in degrees: a skew of ±90° would flatten the box (PhotoCraft's). -- `craft_behavior::geometry::quad::ScaleRule`: `pub enum ScaleRule { Proportional, Free, Shape, Corners }`. What a plain corner or edge drag does. +- `craft_behavior::geometry::quad::ScaleRule`: `pub enum ScaleRule { Proportional, Free, LargerAxis, Shape, Corners }`. What a plain corner or edge drag does. - `craft_behavior::geometry::quad::TransformMode`: `pub enum TransformMode { Free, Rotate, Skew, Distort, Perspective }`. Edit › Transform's modes. - `craft_behavior::geometry::quad::bisector`: `pub fn bisector(screen: &BoxState, i: usize) -> emath::Vec2`. Corner `i` of `screen`'s unit bisector, pointing into the box; zero for a collapsed corner. The - `craft_behavior::geometry::quad::drag`: `pub fn drag(start: &BoxState, last: &BoxState, part: BoxPart, from: Point, to: Point, mods: Mods, rules: &BoxRules) -> BoxState`. The box after dragging `part` from `from` to `to` (document points) with `mods` held, from the @@ -1070,7 +1098,7 @@ The `Grid` cursor: columns resolved from last pass's measurements, and the cell - `craft_behavior::grid::GridCursor`: `pub struct GridCursor`. Hands out the cells of one `Grid` pass, row-major. Cells are placed from `last` pass's measurements; this - `pub fn new(flow: Flow, columns: &[ColumnWidth], gap: Vec2, last: &GridMeasure) -> Self`. A cursor over `columns` in `flow`'s rect, with `gap` between columns (x) and rows (y), placed by `last`. A - `pub fn sized_by_content(flow: Flow, columns: &[ColumnWidth], gap: Vec2, last: &GridMeasure) -> Self`. A cursor for a measuring run under a body sized from its content: each `Fill` column of `columns` is placed - - `pub fn unbounded(flow: Flow, columns: &[ColumnWidth], gap: Vec2) -> Self`. A cursor for the sweep that asks each column for its least: every column but a `Fixed` one is placed as a + - `pub fn unbounded(flow: Flow, columns: &[ColumnWidth], gap: Vec2) -> Self`. A cursor for the sweep that asks each column for its least: the cells of every `Content` and `Fill` column - `pub fn each_alone(mut self) -> Self`. The cursor with each `Content` column measuring in the room the other columns leave at their least, whatever - `pub fn short(&self) -> bool`. Whether the columns, as this sweep measured them, do not fit beside each other: the columns that do not share - `pub fn cell(&mut self, size: Vec2) -> Rect`. The cell of the next child, whose measured size is `size`. @@ -1107,15 +1135,16 @@ Hit shapes, their priority and the arena's resolve rule (8.3). - `pub fn hit(&self, point: Pos2) -> bool`. Whether `point` hits the shape. - `craft_behavior::hit::LINE_REACH`: `pub const LINE_REACH: f32`. How far from a line a point still hits it, in points. - `craft_behavior::hit::ResolveFor`: `pub enum ResolveFor { Press, Hover }`. What a resolution is for. -- `craft_behavior::hit::Shape`: `pub struct Shape { pub shape: HitShape, pub sense: Sense, pub owner: O, pub part: Option, pub priority: HitPriority, pub position: u32, pub local: bool, pub min_across: f32 }`. One registered shape of the shape record: a root's, a member's or a part's. +- `craft_behavior::hit::Shape`: `pub struct Shape { pub shape: HitShape, pub sense: Sense, pub owner: O, pub part: Option, pub priority: HitPriority, pub position: u32, pub local: bool, pub min_across: f32, pub stacking: u32, pub drag_to_root: bool }`. One registered shape of the shape record: a root's, a member's or a part's. - `pub fn translated(&self, by: Vec2) -> Self`. The shape moved by `by`. - `pub fn snapped(&self, to: &Shape, within: f32) -> Self`. The shape with its geometry and least size across taken from `to`'s where they lie within `within` points - `pub const fn new(shape: HitShape, sense: Sense, owner: O, part: Option, priority: HitPriority, position: u32) -> Self`. A shape of `owner` at stack `position`. - `pub const fn min_across(mut self, across: f32) -> Self`. The hit area is at least `across` points wide and high. + - `pub const fn stacking(mut self, order: u32) -> Self`. The shape's stacking order among shapes of its priority: the higher order wins before the nearest centre. - `pub const fn local(mut self, local: bool) -> Self`. The shape lies in the body layer's space. - `pub fn hits(&self, point: Pos2) -> bool`. Whether `point` lies in the hit area: the shape grown to be at least its `min_across` wide and high. The -- `craft_behavior::hit::Winner`: `pub struct Winner { pub index: usize, pub owner: O, pub part: Option, pub sense: Sense, pub local: bool }`. The shape that won a resolution. -- `craft_behavior::hit::resolve`: `pub fn resolve(shapes: &[Shape], point: Pos2, what: ResolveFor) -> Option>`. The winner among `shapes` at `point`: stack position first, then level, sub-level, the nearest centre, the last +- `craft_behavior::hit::Winner`: `pub struct Winner { pub index: usize, pub owner: O, pub part: Option, pub sense: Sense, pub local: bool, pub drag_to_root: bool }`. The shape that won a resolution. +- `craft_behavior::hit::resolve`: `pub fn resolve(shapes: &[Shape], point: Pos2, what: ResolveFor) -> Option>`. The winner among `shapes` at `point`: stack position first, then level, sub-level, stacking order, the nearest - `craft_behavior::hit::resolve_mapped`: `pub fn resolve_mapped(shapes: &[Shape], point: Pos2, what: ResolveFor, to_local: impl Fn(Pos2) -> Pos2) -> Option>`. [`resolve`] where shapes with `local` set are tested at `to_local(point)`. ## `craft_behavior::hold_repeat` @@ -1168,6 +1197,7 @@ Item geometry: where each item of a collection sits for a scroll offset and view - `fn visible(&self, offset: ScrollPos, view: Vec2, out: &mut Vec)`. The indices of the items that intersect a viewport of size `view` scrolled to `offset`, ascending. - `fn rect(&self, at: usize, offset: ScrollPos) -> Rect`. The rect of item `at`. - `fn hit(&self, point: Pos2, offset: ScrollPos) -> Option`. The item under `point`. + - `fn drop_hit(&self, point: Pos2, offset: ScrollPos) -> Option`. The item whose drop area contains `point`. Layouts with visible gaps can include those in a drop area while - `fn nav(&self) -> NavShape`. How arrow keys move through the items. - `fn row_len(&self, _row: usize) -> Option`. `NavShape::RaggedGrid`: the number of items in `row`, rows holding consecutive items and a run of hidden items - `fn column_shift(&self, _from: usize, _to: usize) -> isize`. `NavShape::RaggedGrid`: the columns a vertical move from row `from` to row `to` shifts the column by, when the rows @@ -1242,6 +1272,7 @@ Where a collection's items come from: the data traits and the one way to show a - `fn open(&self, _at: usize) -> bool`. Whether the children of entry `at` show. - `fn is_section(&self, _at: usize) -> bool`. Whether entry `at` is a section header, which navigation skips. - `fn section_stop(&self, _at: usize) -> bool`. Whether section `at` is a stop of navigation: it holds the lead, takes Enter, the context-menu key and a + - `fn selectable_section(&self, _at: usize) -> bool`. Whether a section stop also represents an item that keyboard selection can pick or extend over. - `fn section_stops_before(&self, _at: usize) -> usize`. How many section stops (`section_stop`) come before entry `at`. They are not members of the set of items, so - `fn enabled(&self, _at: usize) -> bool`. Whether entry `at` can take the lead. - `fn text(&self, _at: usize) -> Option>`. The text type-ahead matches entry `at` against. @@ -1265,13 +1296,16 @@ Where a collection's items come from: the data traits and the one way to show a The key table (spec 9.2): the one place that maps a key press to an intent and modifiers to `MoveMods`. +- `craft_behavior::keys::ALT_ARROW_KEYS`: `pub const ALT_ARROW_KEYS: [Chord; 4]`. The four Alt+arrow chords of `ReorderKeys::AltArrows`. +- `craft_behavior::keys::CopyKeys`: `pub enum CopyKeys { Alt, Platform }`. Which held key turns a drag into a copy over a target. - `craft_behavior::keys::DropOperation`: `pub enum DropOperation { Move, Copy, Link }`. What a drop of a dragged payload does with it. -- `craft_behavior::keys::KeyRole`: `pub struct KeyRole { pub resettable: bool, pub space: bool, pub multi_select: bool, pub reorderable: bool, pub rename: bool, pub pages: bool, pub nudge: bool, pub document: bool, pub type_ahead: bool, pub digits: bool, pub value: bool, pub text: bool, pub moves: bool, pub deletes: bool, pub stacked: bool, pub owner_arrows: bool, pub home_row: usize }`. What the focused stop is, as far as the table's rows differ. +- `craft_behavior::keys::KeyRole`: `pub struct KeyRole { pub resettable: bool, pub space: bool, pub multi_select: bool, pub reorderable: Option, pub reorder_axis: Axis, pub rename: bool, pub pages: bool, pub nudge: bool, pub document: bool, pub type_ahead: bool, pub digits: bool, pub value: bool, pub text: bool, pub moves: bool, pub deletes: bool, pub stacked: bool, pub owner_arrows: bool, pub home_row: usize }`. What the focused stop is, as far as the table's rows differ. - `pub const fn new() -> KeyRole`. A role with no special rows. - `pub const fn resettable(mut self, on: bool) -> Self`. Delete resets the control. - `pub const fn space(mut self, on: bool) -> Self`. Space is the component's own intent. - `pub const fn multi_select(mut self, on: bool) -> Self`. Ctrl+Space toggles the lead's pick. - - `pub const fn reorderable(mut self, on: bool) -> Self`. The stacking keys move the selected items. + - `pub const fn reorderable(mut self, keys: Option) -> Self`. The scheme's keys move the selected items; `None` when the stop does not reorder. + - `pub const fn reorder_axis(mut self, axis: Axis) -> Self`. The axis the order is laid out along. - `pub const fn rename(mut self, on: bool) -> Self`. Rename has its key. - `pub const fn pages(mut self, on: bool) -> Self`. Ctrl+Tab switches pages. - `pub const fn nudge(mut self, on: bool) -> Self`. Arrows are nudges, not moves. @@ -1286,9 +1320,10 @@ The key table (spec 9.2): the one place that maps a key press to an intent and m - `pub const fn home_row(mut self, row: usize) -> Self`. Ctrl or Cmd with Home goes to item `row`. - `pub const fn text(mut self, on: bool) -> Self`. The stop is a text part. - `craft_behavior::keys::REORDER_KEYS`: `pub const REORDER_KEYS: [Chord; 6]`. The stacking keys (Photoshop's Bring Forward and Send Backward): Cmd+] moves the selected items one place toward the -- `craft_behavior::keys::drop_operation`: `pub fn drop_operation(os: Os, mods: Mods) -> DropOperation`. The drop operation the held modifiers pick. +- `craft_behavior::keys::ReorderKeys`: `pub enum ReorderKeys { Stacking, AltArrows }`. The named key scheme of a reorderable collection. +- `craft_behavior::keys::drop_operation`: `pub fn drop_operation(os: Os, mods: Mods, copy: CopyKeys) -> DropOperation`. The drop operation the held modifiers pick over a target that copies with `copy`. Link is Ctrl+Shift, Cmd+Option on - `craft_behavior::keys::intent`: `pub fn intent(os: Os, key: Key, mods: Mods, role: KeyRole) -> Option`. The intent a key press has for a stop of `role`, if any. `Enter` and `Space` as activation are not rows: -- `craft_behavior::keys::reorder_intent`: `pub fn reorder_intent(key: Key, mods: Mods) -> Option`. The `Intent::MoveItem` a stacking key asks for, `None` for any other press. +- `craft_behavior::keys::reorder_intent`: `pub fn reorder_intent(key: Key, mods: Mods, keys: ReorderKeys, axis: Axis) -> Option`. The `Intent::MoveItem` a key of the scheme `keys` asks for in an order laid out along `axis`, `None` for any other - `craft_behavior::keys::split_digits`: `pub fn split_digits(text: &str) -> (Vec, String)`. Typed `text` split for a role that takes digits: the ASCII digits it holds, in order, and the text without them. - `craft_behavior::keys::toward_end`: `pub fn toward_end(front: bool, axis: Axis) -> bool`. Whether a move toward the front goes toward the end of an order laid out along `axis`. The front of a vertical @@ -1312,6 +1347,20 @@ The tolerance rule of layout memory: when a measured size asks for a discard pas - `craft_behavior::layout_memory::measure_tolerance`: `pub fn measure_tolerance(pixels_per_point: f32) -> f32`. The tolerance in points under which a measured size equals the one placement used: half a physical pixel. - `craft_behavior::layout_memory::measured_change_asks_for_discard`: `pub fn measured_change_asks_for_discard(recorded: Option, real: Vec2, changed_last_frame: bool, tolerance: f32) -> bool`. Whether a measured size asks for a discard pass. `recorded` is the size placement used this frame +## `craft_behavior::middle_scroll` + +The middle button's auto-scroll latch: the gesture state of one middle press. + +- `craft_behavior::middle_scroll::MiddleButton`: `pub enum MiddleButton { Pan, AutoScroll }`. What the middle button does over a scroll area. +- `craft_behavior::middle_scroll::MiddleScroll`: `pub struct MiddleScroll`. The auto-scroll latch of one middle press. + - `pub fn press(&mut self, at: Pos2, inside: bool)`. A middle press: inside the scroll area it latches at `at`; a second press ends the latch. + - `pub fn release(&mut self)`. The button went up: after two held passes with the pointer past the dead zone the latch ends; an earlier + - `pub fn swallows(&mut self, phase: PressPhase) -> bool`. Whether a press's `phase` belongs to the press that ended a latch and so reaches nothing else: true for the + - `pub fn cancel(&mut self)`. Ends the latch. + - `pub fn step(&mut self, pointer: Pos2, held: bool, dt: f64, invert: bool) -> Vec2`. One pass: with this pass's `pointer` and `held` state it counts the held passes past the 15 pt dead zone and + - `pub fn anchor(&self) -> Option`. Where the latch is anchored, `None` when there is none. + - `pub fn active(&self) -> bool`. Whether a latch is active. + ## `craft_behavior::monitor` The connected monitors, as every window placement reads them. @@ -1491,6 +1540,7 @@ Pointer values and the press lifecycle (8.1, 8.2), egui-free: the runtime conver - `craft_behavior::press::PointerSample`: `pub struct PointerSample { pub pressure: f32, pub tilt: [f32; 2], pub rotation: f32, pub eraser: bool, pub wheel: Option }`. Pressure and tilt of the current contact. - `pub const fn new(pressure: f32) -> Self`. A sample with no tilt or rotation. - `pub fn sanitized(self) -> Self`. The sample with every field in range: pressure within 0 to 1, tilt and rotation finite radians, a stray value +- `craft_behavior::press::PressAside`: `pub struct PressAside { pub target: T, pub start: PressStart, pub pos: Pos2 }`. A secondary press made and released while a primary press was open ([`PressStep::aside`]). Its target is the one - `craft_behavior::press::PressCancel`: `pub enum PressCancel { Escape, FocusLost, Disabled, Removed, Host, Gesture }`. Why a captured press ended without a release. - `craft_behavior::press::PressMachine`: `pub struct PressMachine`. The press lifecycle of one root: the press winner it picked, kept until release or cancel. - `pub const fn new() -> Self`. A machine with no press. @@ -1500,7 +1550,8 @@ Pointer values and the press lifecycle (8.1, 8.2), egui-free: the runtime conver - `pub fn start(&self) -> Option`. The press the open press began as. - `pub fn take_over(&mut self, target: T, sense: Sense, start: PressStart)`. Takes over a press whose button is down and went down elsewhere, as a drag of `target` from `start`: the next - `pub fn release_held(&self) -> bool`. Whether the button went up and the release waits for a later pass, which the caller must ask for: no input may - - `pub fn step(&mut self, input: PassInput<'_>, mut pick: impl FnMut(Pos2) -> Option<(T, Sense)>) -> PressStep`. Runs one pass. `pick` chooses the press winner and what it senses at a press position; it returns `None` + - `pub fn step(&mut self, input: PassInput<'_>, mut pick: impl FnMut(Pos2, PointerButton) -> Option>) -> PressStep`. Runs one pass. `pick` chooses the press winner and what it senses at a press position, for the button pressed + - `pub fn hand_over(&mut self, target: T, sense: Sense) -> Option>`. Makes `target` the open press's target in the pass that reported `passes`, dragging from the same - `craft_behavior::press::PressPhase`: `pub enum PressPhase { Idle, Hover, Down { start: PressStart }, Held { start: PressStart, pos: Pos2 }, DragStart { start: PressStart, pos: Pos2 }, Drag { start: PressStart, pos: Pos2, delta: Vec2 }, Release { start: PressStart, pos: Pos2, click: bool }, Cancel { start: PressStart, reason: PressCancel } }`. One part's press state in one pass. - `pub const fn is_press(&self) -> bool`. A press is in progress or just ended: not `Idle` or `Hover`. - `pub const fn start(&self) -> Option`. The press the phase belongs to. @@ -1508,16 +1559,20 @@ Pointer values and the press lifecycle (8.1, 8.2), egui-free: the runtime conver - `pub const fn is_drag(&self) -> bool`. Whether the phase is a drag in progress. - `pub const fn is_click(&self) -> bool`. Whether the phase is a click: a release within slop. - `pub fn mapped(self, point: impl Fn(Pos2) -> Pos2, delta: impl Fn(Vec2) -> Vec2) -> PressPhase`. The phase with its positions mapped by `point` and its drag delta by `delta`, for a part whose space -- `craft_behavior::press::PressStart`: `pub struct PressStart { pub origin: Pos2, pub button: PointerButton, pub time: f64, pub clicks: u32 }`. Where and when a press began. +- `craft_behavior::press::PressPick`: `pub struct PressPick { pub target: T, pub sense: Sense, pub passed: bool }`. The press winner a root picks at a press position, as [`PressMachine::step`]'s `pick` returns it. + - `pub fn new(target: T, sense: Sense) -> Self`. `target`, sensing `sense`, takes the press. + - `pub fn passed(mut self) -> Self`. The press's click went to a shape above that passes its drag to this target. +- `craft_behavior::press::PressStart`: `pub struct PressStart { pub origin: Pos2, pub button: PointerButton, pub time: f64, pub clicks: u32, pub handed: bool }`. Where and when a press began. - `pub const fn new(origin: Pos2, button: PointerButton, time: f64, clicks: u32) -> Self`. A press of `button` at `origin`. -- `craft_behavior::press::PressState`: `pub struct PressState { pub phase: PressPhase, pub mods: Mods, pub sample: Option, pub captured: bool }`. A part's phase, the modifiers held, the pen sample and whether it holds the pointer. +- `craft_behavior::press::PressState`: `pub struct PressState { pub phase: PressPhase, pub mods: Mods, pub sample: Option, pub captured: bool, pub context: Option }`. A part's phase, the modifiers held, the pen sample and whether it holds the pointer. - `pub const IDLE: PressState`. A part with no press history. - - `pub const fn new(phase: PressPhase) -> Self`. A state in `phase` with no modifiers, sample or capture. + - `pub const fn new(phase: PressPhase) -> Self`. A state in `phase` with no modifiers, sample, capture or aside context request. + - `pub const fn context(mut self, at: Option) -> Self`. The aside secondary press that came up on the part at `at` in this pass. - `pub const fn mods(mut self, mods: Mods) -> Self`. The modifiers held. - `pub const fn sample(mut self, sample: Option) -> Self`. The pen sample of the contact. - `pub const fn captured(mut self, captured: bool) -> Self`. Whether a drag holds the pointer. - `pub const fn double_pressed(&self) -> bool`. Whether the phase is the `Down` of the second press of a double click: true once, false while the button is -- `craft_behavior::press::PressStep`: `pub struct PressStep { pub target: Option, pub phase: Option, pub dragging: bool, pub activated: Option }`. What one pass did to the press. +- `craft_behavior::press::PressStep`: `pub struct PressStep { pub target: Option, pub phase: Option, pub dragging: bool, pub activated: Option, pub passes: Option, pub aside: Option> }`. What one pass did to the press. - `craft_behavior::press::count_clicks`: `pub fn count_clicks(previous: Option<(Pos2, f64, u32, Mods)>, pos: Pos2, time: f64, mods: Mods, slop: f32) -> u32`. The click count of a press at `pos` and `time` with `mods` held, given the previous press `(pos, time, clicks, ## `craft_behavior::quantity` @@ -1535,6 +1590,7 @@ Pointer values and the press lifecycle (8.1, 8.2), egui-free: the runtime conver - `pub fn decimal_separator(&self) -> char`. The decimal separator the reader reads and writes. - `pub fn read(&self, text: &str, start: Option) -> Result`. The value of `text`. `start` is the value relative input applies to. - `pub fn read_tagged(&self, text: &str, start: Option) -> Result<(f64, Option), NotAValue>`. The value of `text` and the tag of the unit its last quantity named (`None` for a bare number or an untagged + - `pub fn share(&self, text: &str) -> Option`. The fraction a lone percentage writes (`50%` is 0.5): a number and `%`, with no sign, unit or operator; - `craft_behavior::quantity::is_unit_spelling`: `pub fn is_unit_spelling(spelling: &str) -> bool`. Whether `spelling` can be registered with [`Reader::unit`]: letters and unit symbols only, so the reader can ## `craft_behavior::role_rule` @@ -1776,7 +1832,7 @@ The value core of chapter 10: the bound every value type meets, `Mixed`, edit ev Wheel gesture values, as craft-behavior's copy of egui's types so the wheel split is egui-free. - `craft_behavior::wheel::GESTURE_GAP`: `pub const GESTURE_GAP: f64`. The seconds between wheel events that still belong to one gesture. -- `craft_behavior::wheel::Wheel`: `pub struct Wheel { pub scroll: Vec2, pub lines: Vec2, pub zoom: f32, pub mods: Mods, pub unit: WheelUnit, pub phase: WheelPhase, pub source: WheelSource, pub at: Option, pub zooms: bool, pub touch_zoom: f32, pub rotation: f32, pub touch_rotation: f32, pub touch_pan: Vec2 }`. One wheel event, or the sum of one pass's, as a taker reads it with `take_wheel`. +- `craft_behavior::wheel::Wheel`: `pub struct Wheel { pub scroll: Vec2, pub lines: Vec2, pub zoom: f32, pub mods: Mods, pub unit: WheelUnit, pub phase: WheelPhase, pub source: WheelSource, pub at: Option, pub zooms: bool, pub touch_zoom: f32, pub rotation: f32, pub touch_rotation: f32, pub touch_pan: Vec2, pub gathered: Vec2, pub moved: bool }`. One wheel event, or the sum of one pass's, as a taker reads it with `take_wheel`. - `pub const fn new(scroll: Vec2, mods: Mods, unit: WheelUnit, phase: WheelPhase) -> Self`. A scroll of `scroll` points with no zoom. - `pub const fn zoom(mut self, zoom: f32) -> Self`. The same gesture with zoom factor `zoom`. - `pub const fn touch_zoom(mut self, zoom: f32) -> Self`. The same gesture with the two-finger touch zoom factor `zoom`. @@ -1785,6 +1841,11 @@ Wheel gesture values, as craft-behavior's copy of egui's types so the wheel spli - `pub const fn touch_pan(mut self, pan: Vec2) -> Self`. The same gesture with the two-finger touch movement `pan`, in points. - `pub const fn source(mut self, source: WheelSource) -> Self`. The same gesture from `source`. - `pub const fn at(mut self, at: Pos2) -> Self`. The same gesture with the pointer at `at`. +- `craft_behavior::wheel::WheelEase`: `pub struct WheelEase`. The eased motion of a canvas's line wheel: notches gather into owed motion that later passes pay out. + - `pub fn feed(&mut self, pan: Vec2, now: f64)`. Adds the line pan `pan` of this pass, at time `now`, to the owed motion; a burst of notches under 0.08 s apart + - `pub fn cancel_axis(&mut self, x: bool, y: bool)`. Drops the owed motion on the axes marked. + - `pub fn step(&mut self, now: f64) -> Vec2`. The step this pass pays at time `now`: `1 − 0.1^(dt/0.1)` of the owed motion, with `dt` since the last paid pass. + - `pub fn owes(&self) -> bool`. Whether motion is still owed. - `craft_behavior::wheel::WheelFocus`: `pub struct WheelFocus { pub taker: Option, pub app_field: bool, pub by_position: bool }`. Who holds key focus, as the split reads it. - `pub const fn new(taker: Option) -> Self`. Focus on `taker`, or on nothing that takes the wheel. - `pub const fn app_field(mut self, on: bool) -> Self`. The same focus, in a text field the app drew itself when `on`. @@ -1850,7 +1911,7 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st - `fn measures_items(&self) -> bool`. Whether the layout sizes its items from their own measure: the items step measures every item at its ideal - `fn dress_inputs(&self) -> u64`. What `dress` reads of the collection, hashed: a kept measure of the items serves only while it is the same. - `fn ideal_width(&self, _item: Option, _rows: usize, _cx: &StyleCx<'_>) -> f32`. The width the collection asks for when it takes its width from its content, over its widest row: a grid of - - `fn filtered<'s>(&self, _source: &'s dyn ItemSource, _env: &crate::runtime::env::Env) -> Option + 's>>`. A view of `source` for this pass, such as the rows a filter keeps; `None` shows `source` as it is. + - `fn filtered<'s>(&self, _source: &'s dyn ItemSource, _env: &crate::runtime::env::Env, _kept: Option<&Self::Key>,) -> Option + 's>>`. A view of `source` for this pass, such as the rows a filter keeps; `None` shows `source` as it is. `kept` is the - `fn dress<'r>(&self, item: Self::Item<'r>, _row: &RowState) -> Self::Item<'r>`. Adjusts the item the closure built for a row, from the row's state. An auto row's measure reads the item this - `fn rename_editor(&mut self, _ui: &mut Ui, _draft: Bind<'_, String>, _label: Rect, _name: &str) -> Option>`. The rename editor at `label`: the label rect the renaming item reports (`ItemOutput::label_rect`), else its row. - `fn hosts_header(&self, _column: &ColumnKey) -> bool`. Whether the collection hosts a component in the header cell of `column`: the header then calls `header_cell` @@ -1861,7 +1922,8 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st - `fn accepts(&self, _drag: &ListDrag, _over: Option<&Self::Key>, _insert: usize) -> bool`. Whether the collection's own dragged items may land before `insert` (a position of the display order, `over` is - `fn drops(&self) -> &[DropKind<'_, Self::Key>]`. What the collection takes from drags that did not start in it, in order: the first kind that takes the drag's - `fn edge_press(&self) -> Option<&EdgePress<'_, Self::Key>>`. The press on the line between two adjacent rows the collection takes, reported as - - `fn zooms(&self) -> bool`. Whether the collection takes the zoom share of the wheel (Ctrl or Cmd with the wheel): it reports + - `fn zooms(&self) -> bool`. Whether the collection takes the zoom share of the wheel (Ctrl or Cmd with the wheel): the items step reports + - `fn zoom_anchor(&self, _wheel: Option) -> Option`. The point whose row stays in place across a zoom step this collection takes in the current pass, in screen - `fn empty_height(&self, width: f32, ui: &Ui, cx: &StyleCx<'_>) -> f32`. The height of the empty state at `width`: a `Sizing::Content` collection with no rows is this tall. The - `fn empty(&mut self, ui: &mut Ui, cx: &mut BodyCx<'_>)`. The empty state at the rect the item step placed. The default shows `CollectionProps::empty`. - `craft_ui::contract::Component`: `pub trait Component: Meta + Sized`. The core trait: every UI type is a `Component`. @@ -1873,6 +1935,7 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st - `const PARTS: bool`. Whether the component declares parts, a text part or an editor part: `false` skips the parts step (the parts - `const STOPS: bool`. Whether the component or its parts can take key focus: `false` skips the stop registration of step 7, except - `const FOCUS_SCOPE: crate::runtime::focus::FocusPolicy`. The focus scope a leaf runs in, as `ContainerProps::focus` gives a container's: the leaf's own stop and its + - `fn focus_scope(&self) -> crate::runtime::focus::FocusPolicy`. The focus scope this instance runs in. The default is `FOCUS_SCOPE`; a component whose scope is a choice of its - `const KEYS: crate::runtime::focus::KeyUse`. Keys the focused component keeps from egui and the shortcut dispatcher. - `fn keys(&self) -> crate::runtime::focus::KeyUse`. The keys this instance keeps in its current state. The default is `KEYS`; a component whose key use depends - `const SHOWS_LABEL: bool`. Whether the component paints its label as visible text. `false` for a face that shows only an icon or a @@ -1886,6 +1949,7 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st - `fn shows_label(&self) -> bool`. Whether this instance paints its label as visible text; `SHOWS_LABEL` unless an instance prop decides, as - `fn label_detail(&self) -> Option`. The muted line a `LABELLED_AFTER` control's label shows after its text (`SideLabel::detail`), as a radio's - `fn paint_outset(_tokens: &crate::style::UiTokens) -> f32`. How far the component paints outside its rect by design, in points (a graph node's ports sit on its edge). + - `fn default_variant(_env: &crate::runtime::env::Env) -> Option`. The variant an instance that asks for none takes in `env`; `None` takes the style's first. A variant the caller - `fn style(cx: &StyleCx<'_>, key: Self::StyleKey) -> Self::Style`. Pure function of the resolved context and the key. - `fn padding(&self, _rect: Rect, style: &Self::Style) -> craft_behavior::Insets`. The insets from `rect` to the content rect where the component is shown: the style's padding. A component - `fn measure(&mut self, _cx: &MeasureCx<'_, Self>) -> Vec2`. Content size only; the pipeline adds padding and minimum size. @@ -1992,6 +2056,7 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st - `pub fn take_pick_answer(&self, ticket: craft_host::PickId) -> Option`. The host file service's answer to the picker `ticket`, taken once. A measuring run gets none and leaves - `pub fn is_exiting(&self) -> bool`. Whether the container has closed and its body only stays on screen while it fades out. `is_open` reads true - `pub fn field_message(&self) -> Option<(Message, craft_theme::variant::Tone)>`. The validity message of the first control in the container's label scope, recorded last frame, with the + - `pub fn moving(&self) -> bool`. Whether a drag of the container's move band (`DragBand::Move`) moves its layer in this pass, from the pass the - `pub fn is_open(&self) -> bool`. Whether the body is open. - `pub fn open(&mut self) -> &mut bool`. The open state: a title row's disclosure binds to it, and step 15 writes a change to its owner. - `pub fn gate(&mut self) -> Option<&mut bool>`. The gate's shown copy, for a container whose value is a bool: a title row's check box binds to it, and @@ -2014,20 +2079,26 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st - `pub fn align(self, align: RowAlign) -> Self`. A `Row` with `align`; any other layout is unchanged. - `craft_ui::contract::Bracket`: `pub enum Bracket { Linked, Unlinked }`. The bracket a `Row` draws from the labelled rows of its first child to the child after them (Image Size's width and - `craft_ui::contract::CanvasGesture`: re-export of `craft_ui::runtime::sampler::CanvasGesture`. +- `craft_ui::contract::CaptionColumn`: `pub struct CaptionColumn`. Whether the beside captions of a [`LabelScheme::Inline`] form share one column. Off (the default), each caption is + - `pub const SHARED: CaptionColumn`. The captions share one column. + - `pub const OWN: CaptionColumn`. Each caption is as wide as its own text (the default). + - `pub const fn shared(self) -> bool`. Whether the captions share one column. +- `craft_ui::contract::CaptionInk`: `pub enum CaptionInk { Muted, Normal }`. The ink of a side label's name, other than a link's ([`LinkLabelInk`]) and the text after a check box or a radio, - `craft_ui::contract::CellWidth`: `pub type CellWidth = ColumnWidth`. The width of a caption's cell. - `craft_ui::contract::Collapse`: `pub struct Collapse { pub initially_open: bool, pub animated: bool }`. Collapse configuration. - `pub const fn new() -> Self`. A collapsible body that starts open, animated. - `pub const fn initially_open(mut self, on: bool) -> Self`. Whether the body starts open. - `pub const fn animated(mut self, on: bool) -> Self`. Whether opening and closing animate. -- `craft_ui::contract::CollectionEvent`: `pub enum CollectionEvent { Selection { change: SelectionChange, by: LeadSource, mods: craft_keymap::Mods }, Picked { key: K, mods: craft_keymap::Mods }, LeadMoved { key: K, by: LeadSource }, Activate(K), Rested(K), EmptyActivated, EmptyContextMenu { at: Pos2 }, Preview(K), ContextMenu(ContextMenuRequest), EdgePressed { above: K, below: K, mods: craft_keymap::Mods }, CommandClick { key: K, mods: craft_keymap::Mods }, Delete(Vec), Open(OpenChange), Reorder(EditEvent>), Move(EditEvent), Dropped { at: DropAt, op: DropOperation, payload: DropPayload }, Zoom { factor: f32, about: Pos2 }, Rename(EditEvent>), Toggle(EditEvent>), Column(ColumnEvent), Item(K, E) }`. What a collection reports, in drawing order. -- `craft_ui::contract::CollectionProps`: `pub struct CollectionProps { pub select: SelectMode, pub reorder: Option, pub rename: bool, pub rename_column: Option, pub slow_click_rename: bool, pub columns: Vec, pub sort: Option, pub empty: Option