Merge pull request #2648 from aiongg/floating-restore

Floating dock windows: production's bar, grips and macOS resizing; grip bar and width resize for collapsed icon groups
This commit is contained in:
aiongg
2026-11-20 17:35:08 -05:00
committed by GitHub
29 changed files with 888 additions and 237 deletions
+1
View File
@@ -36,6 +36,7 @@ pub use scroll::{STRIP_BACK, STRIP_FORWARD};
#[cfg(feature = "suite")]
pub(crate) use window::MOVE_BAND;
use window::WindowMode;
pub use window::grip_band;
pub(crate) use window::keep_inside;
/// The scroll region's view in the last pass that showed it.
+16 -10
View File
@@ -13,7 +13,7 @@ use super::scroll::{
strips_of, view_within,
};
use super::size::MeasureKey;
use super::window::{WindowMode, os_window, window_instance};
use super::window::{WindowMode, os_window, top_band, window_instance};
use super::{BodyHooks, BodyView};
use crate::contract::cx::CxCore;
use crate::contract::cx::{BodyCx, BodyOwner, RegionShare};
@@ -302,7 +302,7 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
self.overflow = self.wanted_width(props).map_or(0.0, |wanted| (wanted - room.max(0.0)).max(0.0));
let (header, end) = (self.measured_header.unwrap_or(Vec2::ZERO), self.measured_end.unwrap_or(Vec2::ZERO));
let height = self.regions_size(props, body, header, self.measured_footer, end).y;
Vec2::new(width, height) + 2.0 * self.pads(props, scx.tokens)
Vec2::new(width, height) + self.frame_size(props, scx.tokens, top_band(props, ui.ctx(), id, scx.tokens))
}
/// The regions run once in an invisible sizing pass over the room, as `content` runs them, and the container takes
@@ -439,8 +439,11 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
}
let tokens = cx.tokens;
let pad = self.pads(&props, tokens);
let inner = content.shrink2(pad);
let regions = self.regions(&props, inner, pad, self.room_size(rect, inner), rtl, self.measured_sizes(), !cx.ui.is_sizing_pass());
let band = top_band(&props, cx.ui.ctx(), cx.id, tokens);
let inner = self.inner_rect(&props, tokens, content, band);
let regions = self
.regions(&props, inner, pad, self.room_size(rect, inner), rtl, self.measured_sizes(), !cx.ui.is_sizing_pass())
.below(content.min.y + band);
let (_, slots) = self.header_line(regions.header, pad_of(tokens, header.inset), parts, rtl);
Some(std::rc::Rc::new(slots))
}
@@ -451,9 +454,11 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
let rtl = pcx.flow.is_rtl();
let tokens = pcx.tokens;
let pad = self.pads(&props, tokens);
let inner = pcx.content_rect.shrink2(pad);
let band = top_band(&props, &ctx, pcx.id, tokens);
let inner = self.inner_rect(&props, tokens, pcx.content_rect, band);
let room = self.room_size(rect, inner);
let regions = self.regions(&props, inner, pad, room, rtl, self.measured_sizes(), !pcx.ui.is_sizing_pass());
let regions =
self.regions(&props, inner, pad, room, rtl, self.measured_sizes(), !pcx.ui.is_sizing_pass()).below(pcx.content_rect.min.y + band);
let scroll = scroll_of(&props);
if self.open && scroll.is_some() {
let at = regions.body;
@@ -859,7 +864,7 @@ impl BodyHooks<'_> {
fn end_measure_run(&mut self, at: &Measuring<'_, '_>, id: Id, key: MeasureKey, content: Option<Vec2>) -> Vec2 {
let props = Arc::clone(&self.props);
let ctx = at.ui.ctx();
let pad = 2.0 * self.pads(&props, at.scx.tokens);
let pad = self.frame_size(&props, at.scx.tokens, top_band(&props, ctx, id, at.scx.tokens));
let record = |key: Id, took: Vec2| layout_memory::emit_record(ctx, key, layout_memory::Measured::new(self.room, took));
record(id, self.body_size.unwrap_or(Vec2::ZERO));
if let Some(first) = self.first_line {
@@ -1070,12 +1075,13 @@ impl BodyHooks<'_> {
let rtl = env.direction.is_rtl();
let scroll = scroll_of(props);
let pad = self.pads(props, &env.tokens);
let inner = core.content_rect.shrink2(pad);
let band = top_band(props, &ctx, id, &env.tokens);
let inner = self.inner_rect(props, &env.tokens, core.content_rect, band);
let room = self.room_size(rect, inner);
// A measuring run lays out and measures: it registers no instance, focus body, scroll region or body layer,
// and claims no room in a parent flow.
let real = !ui.is_sizing_pass();
let regions = self.regions(props, inner, pad, room, rtl, self.measured_sizes(), real);
let regions = self.regions(props, inner, pad, room, rtl, self.measured_sizes(), real).below(core.content_rect.min.y + band);
let surface_slot = SurfaceSlot::reserve(ui, matches!(props.mount, Mount::Layer(_)));
let band_slot = ui.painter().add(Shape::Noop);
let window = window_instance(props, id).filter(|window| *window != id);
@@ -1846,7 +1852,7 @@ impl BodyHooks<'_> {
fn measure_plan(&mut self, at: &Measuring<'_, '_>, id: Id, scrolled_share: bool) -> MeasurePlan {
let props = Arc::clone(&self.props);
let ctx = at.ui.ctx().clone();
let pad = 2.0 * self.pads(&props, at.scx.tokens);
let pad = self.frame_size(&props, at.scx.tokens, top_band(&props, &ctx, id, at.scx.tokens));
let vertical = scroll_of(&props).is_some_and(|scroll| scroll.vertical_on());
let tolerance = measure_tolerance(crate::runtime::egui::scale::pixels_per_point(&ctx));
// A record a run of this pass left serves as before; a kept one serves only while the inputs it was measured
@@ -42,6 +42,7 @@ impl BodyHooks<'_> {
.sense(craft_behavior::Sense::DRAG)
.priority(HitPriority::new(HitLevel::Edge, 0))
.cursor(cursor)
.exact_hit()
.pointer_only("no command resizes a docked pane; its extent is the app's layout");
Some((edge, least))
}
@@ -153,6 +153,15 @@ pub(super) struct Regions {
pub(super) rules: [Option<(Rect, RectSide)>; 4],
}
impl Regions {
/// The regions with the header's band, which may spread over the padding, below `top`: the bottom of the band a
/// layer keeps clear for its top grip.
pub(super) fn below(mut self, top: f32) -> Regions {
self.header.min.y = self.header.min.y.max(top);
self
}
}
/// The sizes of the header, footer and end region that the regions are placed from (zero or `None` for a region the
/// container lacks or that has not measured).
#[derive(Clone, Copy)]
@@ -163,6 +163,20 @@ impl<'b> BodyHooks<'b> {
super::regions::pad_vec(tokens, props.pad, self.pad_edges(props))
}
/// What the container's frame adds to its regions' size: the padding on each side, and on a layer that keeps
/// `band` clear above its header for its top grip (`window::top_band`), the part of the band the padding leaves.
pub(super) fn frame_size(&self, props: &ContainerProps, tokens: &crate::style::UiTokens, band: f32) -> Vec2 {
let pad = self.pads(props, tokens);
2.0 * pad + Vec2::new(0.0, (band - pad.y).max(0.0))
}
/// The rect the regions lie in within `content`: inside the padding, and below `band` at the top.
pub(super) fn inner_rect(&self, props: &ContainerProps, tokens: &crate::style::UiTokens, content: Rect, band: f32) -> Rect {
let mut inner = content.shrink2(self.pads(props, tokens));
inner.min.y = inner.min.y.max(content.min.y + band);
inner
}
/// Whether the container's body is laid out across the width it is offered: the container is given the width,
/// passes it on, or is held across the width its column settled on.
pub(super) fn wide(&self) -> bool {
+62 -24
View File
@@ -13,7 +13,7 @@ use crate::runtime::env::{EnvView, ShellEntry};
use crate::runtime::memory::sub;
use crate::runtime::windows::{self, ResizeEdge, WindowAction, WindowHit};
use crate::runtime::{keys, pointer};
use crate::style::ComponentStyle as _;
use crate::style::{ComponentStyle as _, UiTokens};
use craft_behavior::{CursorIcon, GesturePhase, HitLevel, HitPriority, PartKey, PointerEvent, PressPhase};
use craft_host::target::{Caps, WindowChrome, WindowState};
use craft_keymap::{Chord, Key, Mods};
@@ -26,8 +26,9 @@ const GRIP: PartKey = PartKey::new("resize_grip");
/// Which move and resize parts of the body step stand for the OS window of `viewport` (16.3, 21.2): the one rule
/// every move band and grip of an OS window reads. Both need a frame the app draws (the chrome is not `Native`). The
/// band stands on a maximized window too, so its double click restores the window and a drag is the platform's (it
/// restores and moves); the grips stand only on a window that is neither maximized nor full screen. The parts stand
/// whether or not a hit-test sink is installed: the sink reads them as the window's exclusive parts.
/// restores and moves); the grips stand only on a window that is neither maximized nor full screen, nor one the OS
/// resizes from its own frame (`windows::os_resizes`: AppKit's edges, where app grips would contest its presses). The
/// parts stand whether or not a hit-test sink is installed: the sink reads them as the window's exclusive parts.
#[derive(Clone, Copy)]
struct WindowParts {
band: bool,
@@ -43,11 +44,37 @@ impl WindowParts {
fn of(ctx: &Context, viewport: ViewportId) -> WindowParts {
let window = windows::shell_of(ctx, viewport).window;
let framed_by_app = window.chrome != WindowChrome::Native;
let sized_by_os = matches!(window.state, WindowState::Maximized | WindowState::Fullscreen);
let sized_by_os = matches!(window.state, WindowState::Maximized | WindowState::Fullscreen) || windows::os_resizes(ctx, viewport);
WindowParts { band: framed_by_app && window.state != WindowState::Fullscreen, grips: framed_by_app && !sized_by_os }
}
}
/// The band a layer keeps clear at its top for its top grip, so that grip never lies over the header: the grip's
/// width ([`grip_band`]) on a layer whose header is on a line of its own and whose top grip or a top corner's stands,
/// or that the user moves: a floating window keeps the band while it has no top grip (collapsed, minimized), so its
/// header stays where it was. None elsewhere, nor on a layer whose band moves the window below it. The regions start
/// below the band, or below the padding where that is deeper. An OS window keeps none: its grips, the platform's or
/// the app's, lie over its title bar as an OS title bar's resize edge does.
pub(super) fn top_band(props: &ContainerProps, ctx: &Context, id: Id, tokens: &UiTokens) -> f32 {
let overlay = match &props.mount {
Mount::Layer(overlay) => overlay,
Mount::Viewport { fallback, .. } if !windows::mount_window(ctx, id) => fallback,
_ => return 0.0,
};
if !props.header.is_some_and(|header| !header.inline) || overlay.moves_window {
return 0.0;
}
let pinned = Pinned::of(overlay, ctx, id, false);
let top = [(0, -1), (-1, -1), (1, -1)].into_iter().any(|(dx, dy)| grip_stands(overlay.resize.edges, pinned, dx, dy));
if top || overlay.movable { grip_band(tokens) } else { 0.0 }
}
/// The width of a window's edge grips, and of the band a layer keeps clear above its header for its top grip:
/// `size.handle.sm`. A corner grip reaches twice as far along each of its edges.
pub fn grip_band(tokens: &UiTokens) -> f32 {
tokens.tokens().size.handle.sm
}
/// Whether the platform answers the hit test of `viewport`'s undecorated window itself, as it does for a window whose
/// hit-test sink is installed (`WindowHost::install_hit_sink`): it takes the move, edge and caption hits from the
/// window's exclusive parts, so a press on the move band or a grip never reaches the app as a move.
@@ -701,7 +728,6 @@ impl BodyHooks<'_> {
/// drag holds (`WindowMode::held`), which stays declared until its release.
pub(super) fn move_parts<C: Container>(props: &ContainerProps, regions: &Regions, rect: Rect, held: Option<usize>, pcx: &mut PartsCx<'_, C>) {
let ctx = pcx.ui.ctx().clone();
let handle = pcx.tokens.tokens().size.handle.sm;
let reason = "the Move and Size commands of the window command set do the same";
let os = os_window(props, &ctx, pcx.id, &pcx.env);
let stands = match (&props.mount, os) {
@@ -723,46 +749,58 @@ impl BodyHooks<'_> {
let band = move_band(props, regions, rect);
if props.header.is_some() && movable && band.is_positive() {
// The band lies under the line's own parts and children, like the reorder band, so they keep their presses.
let part = pcx
.part(MOVE_BAND, band)
.sense(craft_behavior::Sense::DRAG)
.cursor(CursorIcon::Grab)
.drag_cursor(CursorIcon::Grabbing)
.pointer_only(reason);
// On a window the OS frames (macOS `Inset`) it keeps the arrow, as an OS title bar does: the OS's resize
// areas cover its ends and top edge, and a cursor set over them fights the OS's.
let moved = os.or(moves_window.then(|| pass::current_viewport(&ctx)));
let os_bar = moved.is_some_and(|viewport| windows::shell_of(&ctx, viewport).window.chrome == WindowChrome::Inset);
let mut part = pcx.part(MOVE_BAND, band).sense(craft_behavior::Sense::DRAG).pointer_only(reason);
if !os_bar {
part = part.cursor(CursorIcon::Grab).drag_cursor(CursorIcon::Grabbing);
}
if let Some(hit) = exclusive(WindowHit::Move).or(moves_window.then_some(WindowHit::Move)) {
part.exclusive(hit);
}
}
// The grips of a layer straddle its edge; those of a window lie inside it, where the window has pixels. They
// stack above the body (`over`), so a root in the body never covers their inner half (8.3).
let (edges, inset) = match &props.mount {
Mount::Layer(overlay) | Mount::Viewport { fallback: overlay, .. } => (overlay.resize.edges, 0.0),
Mount::Window { resize } => (resize.edges, handle / 2.0),
_ => (ResizeEdges::NONE, 0.0),
let edges = match &props.mount {
Mount::Layer(overlay) | Mount::Viewport { fallback: overlay, .. } => overlay.resize.edges,
Mount::Window { resize } => resize.edges,
_ => ResizeEdges::NONE,
};
if edges == ResizeEdges::NONE || !stands.grips {
return;
}
// Every grip lies inside the frame, where a window has pixels and a layer's own rect takes the pointer: an edge
// grip `handle` deep, a corner grip twice that along each of its edges, the edge grips between the corners.
// They stack above the body (`over`), so a root in the body never covers them (8.3), and each takes exactly its
// rect (`exact_hit`), as the platform's hit test does for an exclusive grip. The top corners of a layer that
// keeps a band over its header (`top_band`) are only as tall as the band, so no grip lies over the header.
let handle = grip_band(pcx.tokens);
let corner = 2.0 * handle;
let top = top_band(props, &ctx, pcx.id, pcx.tokens);
let pinned = overlay_of(props).map_or(Pinned::NONE, |overlay| Pinned::of(overlay, &ctx, pcx.id, pcx.env.direction().is_rtl()));
let caller_sizes = overlay_of(props).is_some_and(|overlay| overlay.resize.by_caller);
for (index, (dx, dy, cursor)) in GRIPS.into_iter().enumerate() {
if held != Some(index) && !grip_stands(edges, pinned, dx, dy) {
continue;
}
let along = |edge: i8, low: f32, high: f32| match edge {
-1 => (low - handle / 2.0 + inset, low + handle / 2.0 + inset),
1 => (high - handle / 2.0 - inset, high + handle / 2.0 - inset),
_ => (low + handle / 2.0 + inset, high - handle / 2.0 - inset),
let span = |edge: i8, low: f32, high: f32, deep: f32| match edge {
-1 => (low, low + deep),
1 => (high - deep, high),
_ => (low + corner, high - corner),
};
let (x0, x1) = along(dx, rect.min.x, rect.max.x);
let (y0, y1) = along(dy, rect.min.y, rect.max.y);
let level = if dx != 0 && dy != 0 { HitLevel::Handle } else { HitLevel::Edge };
let at_corner = dx != 0 && dy != 0;
let deep = if at_corner { corner } else { handle };
let tall = if at_corner && dy == -1 && top > 0.0 { top } else { deep };
let (x0, x1) = span(dx, rect.min.x, rect.max.x, deep);
let (y0, y1) = span(dy, rect.min.y, rect.max.y, tall);
let level = if at_corner { HitLevel::Handle } else { HitLevel::Edge };
let part = pcx
.part(GRIP.at(index as u64), Rect::from_min_max(Pos2::new(x0, y0), Pos2::new(x1, y1)))
.sense(craft_behavior::Sense::DRAG)
.priority(HitPriority::new(level, 0))
.cursor(cursor)
.pointer_only(reason)
.exact_hit()
.over();
// The grips of a window its caller sizes are the app's (`window_resize`), never the platform's.
if let Some(hit) = exclusive(WindowHit::Resize(edge_of(dx, dy))).filter(|_| !caller_sizes) {
@@ -187,6 +187,14 @@ impl PartBuilder<'_> {
self
}
/// The part's hit area is its shape as declared, never grown to the pointer's target size (`size.hit.target`): a
/// frame's resize grip, whose band is sized as its reach and whose neighbours (a title row, the content) own every
/// point beside it.
pub fn exact_hit(self) -> Self {
self.decl.exact = true;
self
}
/// The part's look is the plain state layer: the paint step fills its rect with `StyleCx::state_layer` in the
/// part's state, under the component's paint, with control corners.
pub fn state_layer(self) -> Self {
+1
View File
@@ -53,6 +53,7 @@ pub use crate::runtime::pending::{Job, Pending, Progress};
#[doc(hidden)]
pub use body::REORDER_BAND;
#[doc(hidden)]
pub use body::grip_band;
pub use body::pad_of;
#[doc(hidden)]
pub use body::{STRIP_BACK, STRIP_FORWARD};
+12 -2
View File
@@ -128,6 +128,8 @@ pub(crate) struct PartDecl {
pub inactive: bool,
/// The component holds a press on the part (`PartBuilder::held`).
pub held: bool,
/// The hit area is the shape as declared, never grown to the pointer's target size (`PartBuilder::exact_hit`).
pub exact: bool,
}
impl PartDecl {
@@ -144,12 +146,18 @@ impl PartDecl {
flags: Flags::default(),
inactive: false,
held: false,
exact: false,
}
}
fn part_ref(&self) -> PartRef {
PartRef { key: self.key, index: self.index }
}
/// The least size across the part's hit area, given the pointer's target size `target`.
fn min_across(&self, target: f32) -> f32 {
if self.exact { 0.0 } else { target }
}
}
/// One member's registration for this pass.
@@ -313,7 +321,7 @@ fn rotate(state: &mut ArenaState, pass_nr: u64) {
}
fn own_part_shape(part: &PartDecl, root: Id, position: u32, target: f32) -> Shape<Id> {
Shape::new(part.shape.clone(), part.sense, root, Some(part.part_ref()), part.priority, position).min_across(target)
Shape::new(part.shape.clone(), part.sense, root, Some(part.part_ref()), part.priority, position).min_across(part.min_across(target))
}
/// The root's own parts but the `over` ones, at position 0.
@@ -338,7 +346,9 @@ fn over_position(count: usize) -> u32 {
}
fn member_part_shape(member: &MemberDecl, part: &PartDecl, position: u32, target: f32) -> Shape<Id> {
Shape::new(part.shape.clone(), part.sense, member.id, Some(part.part_ref()), part.priority, position).local(member.local).min_across(target)
Shape::new(part.shape.clone(), part.sense, member.id, Some(part.part_ref()), part.priority, position)
.local(member.local)
.min_across(part.min_across(target))
}
/// The member's root shape and its parts but the `over` ones, at its stack position.
+18 -2
View File
@@ -95,12 +95,16 @@ fn push(ctx: &Context, cursor: Cursor, priority: CursorPriority, region: Option<
/// blocked cursor. A system cursor goes out through the viewport's output; a painted cursor hides the system one and
/// is left for the overlay host, which paints it or hands it back as an image ([`show_image`]), except a badged
/// system cursor, which keeps its base and has only the badge painted. The window's image from the last pass is
/// cleared: egui keeps it until it is replaced.
/// cleared: egui keeps it until it is replaced. Over the resize areas of a window the OS resizes from its own frame
/// the cursor is the default whatever was requested: the OS shows its resize cursor there, and any other fights it.
pub(crate) fn end_pass(ctx: &Context) {
let blocked = windows::blocking_modal(ctx).is_some();
let won = PerViewport::<State>::with(ctx, pass::current_viewport(ctx), |state| {
let viewport = pass::current_viewport(ctx);
let to_os = !blocked && over_os_resize_area(ctx, viewport);
let won = PerViewport::<State>::with(ctx, viewport, |state| {
let (won, region) = match pick_index(&state.requests) {
_ if blocked => (Some(Cursor::System(CursorIcon::NotAllowed)), None),
_ if to_os => (Some(Cursor::System(CursorIcon::Default)), None),
Some(at) => (state.requests.get(at).map(|(cursor, _)| cursor.clone()), state.regions.get(at).copied().flatten()),
None => (None, None),
};
@@ -122,6 +126,18 @@ pub(crate) fn end_pass(ctx: &Context) {
}
}
/// Whether the pointer lies in the resize areas of `viewport`'s window where the OS resizes it from its own frame
/// (`windows::os_resizes`).
fn over_os_resize_area(ctx: &Context, viewport: ViewportId) -> bool {
if !windows::os_resizes(ctx, viewport) {
return false;
}
let Some(hover) = crate::runtime::pointer::pass_pointer(ctx).hover else { return false };
let content = pass::content_rect(ctx);
let at = hover - content.min;
craft_window::mac::in_resize_area([content.width(), content.height()], [at.x, at.y])
}
/// The cursor the last pass of the running viewport settled on; `None` is the default arrow.
pub fn current(ctx: &Context) -> Option<Cursor> {
PerViewport::<State>::with(ctx, pass::current_viewport(ctx), |state| state.record.clone())
@@ -34,6 +34,11 @@ pub fn current_viewport(ctx: &Context) -> ViewportId {
}
}
/// The running pass's window content, in its own points: the rect the pass lays out in.
pub(crate) fn content_rect(ctx: &Context) -> egui::Rect {
ctx.content_rect()
}
/// The viewports egui reports for the running pass.
pub(crate) fn live_viewports(ctx: &Context) -> Vec<ViewportId> {
ctx.input(|input| input.raw.viewports.keys().copied().collect())
@@ -180,6 +180,14 @@ pub(crate) fn take_sent(ctx: &Context) -> Vec<(ViewportId, WindowAction)> {
shared(ctx, |shared| std::mem::take(&mut shared.sent))
}
/// Whether the OS resizes `viewport`'s window from a frame of its own: it draws the frame (macOS `Inset`, a titled
/// window under the app's bar) and the window is resizable. A window its caller sizes opens not resizable, so the OS
/// leaves it to the app's grips.
pub(crate) fn os_resizes(ctx: &Context, viewport: ViewportId) -> bool {
let chrome = shell_of(ctx, viewport).window.chrome;
chrome == WindowChrome::Inset && PerViewport::<Record>::with(ctx, viewport, |record| record.resizable != Some(false))
}
/// Whether the app runs the move of `viewport`'s window (`Overlay::moved_by_app`).
pub(crate) fn app_moves(ctx: &Context, viewport: ViewportId) -> bool {
PerViewport::<Record>::with(ctx, viewport, |record| record.moved_by_app)
@@ -3,6 +3,7 @@
//! it is neither maximized nor full screen; a `Window` mount puts its grips on the window's edges; a double click on the
//! move band is reported once.
use craft_behavior::{Cursor, CursorIcon};
use craft_host::target::{ShellInfo, WindowChrome, WindowInfo, WindowKind};
use craft_ui::contract::overlay::Resize;
use craft_ui::contract::{
@@ -166,3 +167,21 @@ fn a_window_mounts_edges_resize_the_window_and_the_childs_press_keeps_its_click(
assert_eq!(rig.seen.borrow().activations, 1, "the child under the edge keeps its click");
assert!(resizes(&sent).is_empty(), "and the click starts no resize: {sent:?}");
}
/// Where the OS draws a resizable window's frame (macOS `Inset`), AppKit resizes the window from its edges: the app
/// registers no grips there, so a drag on an edge starts no resize of the app's, and over AppKit's resize areas the
/// cursor is the default, as the OS shows its own there.
#[trial]
fn where_appkit_resizes_a_window_the_app_registers_no_grips_and_leaves_the_cursor_to_it() {
let edge = pos2(1.0, ROOT.y / 2.0);
let (sent, _) = root_drag(WindowChrome::Inset, edge, vec2(20.0, 0.0));
assert!(resizes(&sent).is_empty(), "AppKit resizes the window, the app's grips stand down: {sent:?}");
let windows = root(WindowChrome::Inset);
let rig = Rig::new(Mount::window(Resize::GRIPS));
for _ in 0..4 {
rig.frame(&windows, vec![], vec![]);
}
rig.frame(&windows, vec![moved(edge)], vec![]);
let cursor = craft_ui::runtime::cursor::current(&windows.ctx);
assert!(matches!(cursor, None | Some(Cursor::System(CursorIcon::Default))), "over AppKit's edge the cursor is left to the OS: {cursor:?}");
}
+2 -2
View File
@@ -244,12 +244,12 @@ pub fn float_drop<P: Clone + PartialEq>(
) -> DockDropped<P> {
let size = space.size_of(unit, source).min(space.area.size());
let under = |size: Vec2| {
let min = (at - Vec2::new(size.x * 0.5, space.title_row * 0.5)).min(space.area.max - size).max(space.area.min);
let min = (at - Vec2::new(size.x * 0.5, space.chrome * 0.5)).min(space.area.max - size).max(space.area.min);
Rect::from_min_size(min, size)
};
let (rect, edge, mark) = match strip.filter(|_| !matches!(unit, DragUnit::Window(_))) {
Some(strip) => {
let shown = under((strip + Vec2::new(0.0, space.title_row)).min(space.area.size()));
let shown = under((strip + Vec2::new(0.0, space.chrome)).min(space.area.size()));
let (rect, edge) = WindowColumn::around_strip(shown, size, space.area, rtl);
(rect, Some(edge), shown)
}
+15 -7
View File
@@ -69,8 +69,9 @@ pub struct FloatSpace<P> {
pub area: Rect,
/// Room between the area's top-left corner and a unit a command floats.
pub inset: f32,
/// The height of a floating window's title row (`DockSizes::title_row`), which a drop keeps under the pointer.
pub title_row: f32,
/// The height above a floated window's body (`DockSizes::window_chrome`): its title row, which a drop keeps under
/// the pointer, and the band over it where floats show in the app window.
pub chrome: f32,
/// The size a unit floats at when neither its panel nor where it came from gives one. Its height is also the
/// most a panel, group or column floats at.
pub default_size: Vec2,
@@ -87,13 +88,20 @@ impl<P: PartialEq> FloatSpace<P> {
FloatSpace {
area,
inset: sizes.cascade_inset,
title_row: sizes.title_row,
chrome: sizes.window_chrome(true),
default_size: sizes.float_size,
panels: Vec::new(),
side_edge_zones: false,
}
}
/// For an area whose floats open in OS windows (`on`), whose chrome is their title row alone.
#[must_use]
pub fn in_os_windows(mut self, sizes: &DockSizes, on: bool) -> Self {
self.chrome = sizes.window_chrome(!on);
self
}
/// For an area drawn with `DockConfig::side_edge_zones` when the area has not drawn yet (a headless run).
#[must_use]
pub fn with_side_edge_zones(mut self, on: bool) -> Self {
@@ -120,7 +128,7 @@ impl<P: PartialEq> FloatSpace<P> {
/// The size `unit` floats at: a panel's own float size, else the size it had where it came from (`source`), else
/// the default. A window keeps its own size. A panel, group or column takes the source's width and its height
/// with the window's title row above it, at most the default height: the dock passes the height its content
/// with the window's chrome above it, at most the default height: the dock passes the height its content
/// measures at in that room, so content that fills floats at the default height.
pub fn size_of(&self, unit: &DragUnit<P>, source: Option<Vec2>) -> Vec2 {
let own = match unit {
@@ -129,15 +137,15 @@ impl<P: PartialEq> FloatSpace<P> {
};
let framed = |size: Vec2| match unit {
DragUnit::Window(_) => size,
_ => Vec2::new(size.x, (size.y + self.title_row).min(self.default_size.y)),
_ => Vec2::new(size.x, (size.y + self.chrome).min(self.default_size.y)),
};
own.or(source.map(framed)).unwrap_or(self.default_size)
}
/// The height a panel, group or column's content is measured in for a float of it: the default height less the
/// window's title row.
/// window's chrome.
pub fn content_room(&self) -> f32 {
(self.default_size.y - self.title_row).max(0.0)
(self.default_size.y - self.chrome).max(0.0)
}
fn find(sizes: &[(P, Vec2)], panel: &P) -> Option<Vec2> {
+71 -37
View File
@@ -12,7 +12,7 @@ use super::drop::{DragUnit, start_group_drag};
use super::{DockDropTarget, DockDropped, DockWords, GroupDrag, PanelDrag, PanelKey, native};
use crate::contract::BodyCx;
use crate::contract::SizeLimits;
use crate::contract::overlay::{PlacementChange, PlacementKind, Popup};
use crate::contract::overlay::{PlacementChange, PlacementKind, Popup, ResizeEdges};
use crate::contract::{
Access, Bind, BindMut, Common, Component, Container, ContainerProps, Cx, DragBand, HeaderEdge, HeaderParts, HeaderRegion, Inner, MeasureCx,
Mount, NoValue, OsFiles, Outcome, Overlay, Pad, PaintUi, PartsCx, Pointer as _, Props as _, Role, Show as _, ShowContainer as _, Sizing,
@@ -34,9 +34,9 @@ use std::hash::Hash;
#[cfg(feature = "suite")]
pub(crate) mod stories;
/// The height of a floating group's title row: a strong `TitleRow`, which is as tall as a panel header.
/// The height of a floating group's title row: a `TitleRow` of the `Bar` strength, one text row high.
pub(crate) fn title_row(tokens: &UiTokens) -> f32 {
tokens.size.panel_header
tokens.size.row.text
}
/// The actions a floating group's title row shows unless `actions` says otherwise: Close alone, as a floating panel's
@@ -61,6 +61,9 @@ pub struct WindowColumn {
pub edge: DockEdge,
/// The size of the collapsed column under the title row; `None` while the column is expanded.
pub collapsed: Option<Vec2>,
/// The least and most width the sides of a collapsed column's window resize it to
/// ([`DockSizes::iconic_bounds`](super::DockSizes::iconic_bounds)); unbounded while the column is expanded.
pub widths: (f32, f32),
/// The size of an expanded column whose content sets it (a column with steps) under the title row; `None` for a
/// column the rect sizes.
pub fitted: Option<Vec2>,
@@ -71,19 +74,20 @@ pub struct WindowColumn {
impl WindowColumn {
/// An expanded column that keeps to `edge`.
pub fn expanded(edge: DockEdge) -> Self {
WindowColumn { edge, collapsed: None, fitted: None, arrow: ColumnArrow::Collapse }
WindowColumn { edge, collapsed: None, widths: UNBOUNDED, fitted: None, arrow: ColumnArrow::Collapse }
}
/// A column collapsed to icons, `size` under the title row, that keeps to `edge`.
pub fn collapsed(edge: DockEdge, size: Vec2) -> Self {
WindowColumn { edge, collapsed: Some(size), fitted: None, arrow: ColumnArrow::Collapse }
/// A column collapsed to icons, `size` under the title row, that keeps to `edge`. The window's sides resize its
/// width within `widths`, as a docked collapsed column's inner edge does; its height stays `size`'s.
pub fn collapsed(edge: DockEdge, size: Vec2, widths: (f32, f32)) -> Self {
WindowColumn { edge, collapsed: Some(size), widths, fitted: None, arrow: ColumnArrow::Collapse }
}
/// An expanded column whose content is `size` under the title row, that keeps to `edge`. The window shows at
/// that size at its rect's place; a resize the user makes is reported for the host to turn into the column's
/// steps, and a move keeps the rect's size.
pub fn fitted(edge: DockEdge, size: Vec2) -> Self {
WindowColumn { edge, collapsed: None, fitted: Some(size), arrow: ColumnArrow::Collapse }
WindowColumn { edge, collapsed: None, widths: UNBOUNDED, fitted: Some(size), arrow: ColumnArrow::Collapse }
}
/// The column with the double arrow `arrow` ([`ColumnArrow::of`]).
@@ -92,19 +96,22 @@ impl WindowColumn {
self
}
/// Where a window that keeps `rect` shows while its column is collapsed: the collapsed column under a title row
/// `header` tall, at the top of `rect` and against the edge the window keeps to. `None` while the column is
/// expanded.
pub fn shown(self, rect: Rect, header: f32, rtl: bool) -> Option<Rect> {
let size = self.collapsed? + Vec2::new(0.0, header);
/// Where a window that keeps `rect` shows while its column is collapsed: the collapsed column under the window's
/// chrome, `chrome` tall (`DockSizes::window_chrome`), at the top of `rect` and against the edge the window keeps
/// to. `None` while the column is expanded.
pub fn shown(self, rect: Rect, chrome: f32, rtl: bool) -> Option<Rect> {
let size = self.collapsed? + Vec2::new(0.0, chrome);
let left = if at_left(self.edge, rtl) { rect.left() } else { rect.right() - size.x };
Some(Rect::from_min_size(Pos2::new(left, rect.top()), size))
}
/// The rect a window that keeps `rect` keeps when it shows at `shown`: while collapsed, `rect` moved with the
/// collapsed column ([`Self::shown`]), so it keeps its expanded size; while expanded, `shown`.
pub fn kept(self, shown: Rect, rect: Rect, header: f32, rtl: bool) -> Rect {
self.shown(rect, header, rtl).map_or(shown, |at| rect.translate(shown.min - at.min))
/// collapsed column ([`Self::shown`]) so that the column's side on the edge the window keeps to stays on that side
/// of `rect`, whatever width the column shows at; `rect` keeps its expanded size. While expanded, `shown`.
pub fn kept(self, shown: Rect, rect: Rect, chrome: f32, rtl: bool) -> Rect {
let Some(at) = self.shown(rect, chrome, rtl) else { return shown };
let dx = if at_left(self.edge, rtl) { shown.left() - at.left() } else { shown.right() - at.right() };
rect.translate(Vec2::new(dx, shown.top() - at.top()))
}
/// The edge of `bounds`, in reading order, nearer the window at `rect`: the start edge when the window's centre is
@@ -134,6 +141,9 @@ impl WindowColumn {
}
}
/// The widths of a column that is not collapsed: its window's limits are the panels'.
const UNBOUNDED: (f32, f32) = (0.0, f32::INFINITY);
/// Whether `edge`, in reading order, is the left one of the screen.
fn at_left(edge: DockEdge, rtl: bool) -> bool {
(edge == DockEdge::Start) != rtl
@@ -157,6 +167,9 @@ pub struct FloatingGroupOutput {
/// The user asked to collapse the window's column to icons (`true`) or expand it (`false`): a click on the double
/// arrow, or a double click on the title band. Only a group with a [`WindowColumn`] reports it.
pub iconic: Option<bool>,
/// The width the user gave the collapsed column of the window this pass, by a side of the window or the keyboard
/// Size mode: the host keeps it as the column's iconic width. The rect in `placed` stays the expanded one.
pub collapsed_width: Option<f32>,
/// The files dropped on the group's window that no target there took.
pub files: Vec<OsFile>,
}
@@ -182,7 +195,8 @@ impl Outcome for FloatingGroupOutput {
/// - Column: a dock window holds one column ([`column`](FloatingGroup::column)); its title row is the column's bar,
/// with the double arrow at the end the window keeps to. While the column is collapsed the group shows at the
/// collapsed size against that edge of the rect, its title row shows no actions (the band and the double arrow;
/// a context request on the band opens the menu), the edges do not resize, and a move keeps the rect's size. A
/// a context request on the band opens the menu), its sides resize its width within the column's widths (reported
/// in [`FloatingGroupOutput::collapsed_width`]) while its height stays the icons', and the rect keeps its size. A
/// column its content sizes ([`WindowColumn::fitted`]) shows at that size at the rect's place; its resizes are
/// reported as the user makes them, and in an OS window the app runs them, so the window takes only the size the
/// host gives it.
@@ -234,10 +248,14 @@ pub struct FloatingGroup<'a> {
/// The double arrow was declared this pass, and whether it was clicked.
chevron_declared: bool,
chevron: bool,
/// The title row's height and the layout direction, read when the group shows.
/// The title row's height, the height above the body (`DockSizes::window_chrome`) and the layout direction, read
/// when the group shows.
header: f32,
chrome: f32,
rtl: bool,
placed: Option<PlacementChange>,
/// The width a resize gave the collapsed column this pass.
collapsed_width: Option<f32>,
/// Starts the window-unit drag; set by `window_of`.
start_drag: Option<StartDrag<'a>>,
/// Takes the drops released on the group, on the group's own layer.
@@ -280,8 +298,10 @@ impl<'a> FloatingGroup<'a> {
chevron_declared: false,
chevron: false,
header: 0.0,
chrome: 0.0,
rtl: false,
placed: None,
collapsed_width: None,
start_drag: None,
take_drop: None,
moving: false,
@@ -329,29 +349,34 @@ impl<'a> FloatingGroup<'a> {
pub fn show_group<R>(mut self, ui: &mut Ui, mut body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R) -> Inner<FloatingGroupOutput, R> {
let env = Env::of(ui);
let header = title_row(&env.tokens);
(self.header, self.rtl) = (header, env.direction.is_rtl());
let mount = self.mount(header);
// A window in the app window keeps the band over its title row that a layer the user moves keeps for its top
// grip; an OS window's grips lie over its title row.
let band = if self.native.is_none() { crate::contract::grip_band(&env.tokens) } else { 0.0 };
(self.header, self.chrome, self.rtl) = (header, header + band, env.direction.is_rtl());
let mount = self.mount();
self.props = self.props.mount(mount);
let minimized = self.minimized;
let shown = self.show(ui, |ui, cx| (!minimized).then(|| body(ui, cx)));
Inner { output: shown.output, inner: shown.inner.flatten(), settle: shown.settle }
}
/// The layer or window the group shows in. `header` is the height of the title row.
/// The layer or window the group shows in.
///
/// A minimized group, and one with `Sizing::Content`, is placed by its position and width; its height is its
/// content's, which is the title row alone while minimized.
fn mount(&self, header: f32) -> Mount {
// The frame's limits are the body's with the title row on top.
let frame = self.limits.around(Vec2::new(0.0, header));
let collapsed = self.collapsed_rect();
let mut overlay =
Overlay::floating().movable(true).resizable(!self.minimized && collapsed.is_none()).opacity(self.opacity).body_scroll(false);
overlay = if let Some(shown) = collapsed {
overlay.placed(shown).size_limits(SizeLimits::new(shown.size(), shown.size()))
/// content's, which is the chrome alone while minimized.
fn mount(&self) -> Mount {
// The frame's limits are the body's with the chrome on top.
let frame = self.limits.around(Vec2::new(0.0, self.chrome));
let collapsed = self.collapsed_rect().zip(self.column.map(|column| column.widths));
let mut overlay = Overlay::floating().movable(true).resizable(!self.minimized).opacity(self.opacity).body_scroll(false);
overlay = if let Some((shown, (least, most))) = collapsed {
// The sides resize a collapsed column's width; its height is its icons'.
let height = shown.height();
let edges = if self.minimized { ResizeEdges::NONE } else { ResizeEdges::LEFT.union(ResizeEdges::RIGHT) };
overlay.placed(shown).resize_edges(edges).size_limits(SizeLimits::new(Vec2::new(least, height), Vec2::new(most.max(least), height)))
} else if let Some(size) = self.column.and_then(|column| column.fitted) {
// The host turns a resize into the column's steps, and the window takes the size they make.
overlay.placed(Rect::from_min_size(self.rect.min, size + Vec2::new(0.0, header))).sized_by_caller()
overlay.placed(Rect::from_min_size(self.rect.min, size + Vec2::new(0.0, self.chrome))).sized_by_caller()
} else if self.minimized {
let width = self.rect.width();
overlay.placed_at(self.rect.min).size_limits(SizeLimits::new(Vec2::new(width, 0.0), Vec2::new(width, f32::INFINITY)))
@@ -374,10 +399,10 @@ impl<'a> FloatingGroup<'a> {
}
}
/// Where the group shows while its column is collapsed: the collapsed column under the title row, at the top of
/// the rect and against its edge the window keeps to. `None` while the column is expanded.
/// Where the group shows while its column is collapsed: the collapsed column under the chrome, at the top of the
/// rect and against its edge the window keeps to. `None` while the column is expanded.
fn collapsed_rect(&self) -> Option<Rect> {
self.column?.shown(self.rect, self.header, self.rtl)
self.column?.shown(self.rect, self.chrome, self.rtl)
}
/// The double arrow's square at the end of the title row the window keeps to.
@@ -454,6 +479,7 @@ impl Component for FloatingGroup<'_> {
action: self.taken,
minimized_toggled: self.toggled && self.column.is_none(),
iconic,
collapsed_width: self.collapsed_width,
files: self.files,
};
native::raise(&cx.core.ctx, &output);
@@ -487,7 +513,7 @@ impl Container for FloatingGroup<'_> {
// the band and the double arrow; the menu, which a context request on the band opens, keeps its rows.
let collapsed = self.column.is_some_and(|column| column.collapsed.is_some());
let actions = if collapsed { &[][..] } else { &self.actions[..] };
let shown = TitleRow::new("").strength(HeaderStrength::Strong).actions(actions.iter().copied()).show(ui);
let shown = TitleRow::new("").strength(HeaderStrength::Bar).actions(actions.iter().copied()).show(ui);
self.taken = shown.action.or(self.taken);
if let Some(rows) = self.menu.as_mut() {
self.menu_opener = rows.hang(ui, &shown, cx.words::<DockWords>().panel_menu.clone());
@@ -499,8 +525,16 @@ impl Container for FloatingGroup<'_> {
let mut change = *change;
let fitted = self.column.is_some_and(|column| column.fitted.is_some());
if let Some(column) = self.column.filter(|column| column.collapsed.is_some()) {
// The collapsed window moves; the rect keeps its expanded size.
change.rect = column.kept(change.rect, self.rect, self.header, self.rtl);
// A resize of the collapsed window sets the column's width; the rect keeps its expanded size.
let resized = match change.kind {
PlacementKind::Size(_) => true,
PlacementKind::Keyboard => self.collapsed_rect().is_some_and(|shown| change.rect.width() != shown.width()),
_ => false,
};
if resized {
self.collapsed_width = Some(change.rect.width());
}
change.rect = column.kept(change.rect, self.rect, self.chrome, self.rtl);
} else if (fitted || self.sized == Sizing::Content) && change.kind == PlacementKind::Move {
// A window its content sizes moves (a cancel too, which reports the rect from before the gesture); the
// rect keeps the size the caller gave, not the one measured from the body.
@@ -14,10 +14,13 @@ const START: Rect = Rect { min: Pos2::new(40.0, 40.0), max: Pos2::new(280.0, 220
/// The icons a collapsed story column shows: three panels.
const ICON_CELLS: f32 = 3.0;
/// The size of a collapsed column of `ICON_CELLS` icon cells.
fn icon_strip(ui: &Ui) -> Vec2 {
/// A collapsed column of `ICON_CELLS` icon cells, `width` wide when the user resized it, else the rail's width: it
/// resizes from the rail's width up to the width of the expanded story window.
fn icon_strip(ui: &Ui, edge: DockEdge, width: Option<f32>) -> WindowColumn {
let sizes = IconicSizes::of(ui.ctx());
Vec2::new(sizes.cell, sizes.cell * ICON_CELLS)
let widths = (sizes.column.iconic_least, START.width());
let width = width.unwrap_or(widths.0).clamp(widths.0, widths.1);
WindowColumn::collapsed(edge, Vec2::new(width, sizes.cell * ICON_CELLS), widths)
}
#[story(FloatingGroup<'static>, covers = [Default], drive = Drive::Never)]
@@ -42,7 +45,8 @@ fn floating_group(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
fn floating_dock_window(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
let rect = *data.value("rect", START);
let collapsed = *data.value("collapsed", false);
let column = if collapsed { WindowColumn::collapsed(DockEdge::Start, icon_strip(ui)) } else { WindowColumn::expanded(DockEdge::Start) };
let width = *data.value("width", None::<f32>);
let column = if collapsed { icon_strip(ui, DockEdge::Start, width) } else { WindowColumn::expanded(DockEdge::Start) };
let shown = FloatingGroup::new("Layers", rect).column(column).sized(crate::contract::Sizing::Fill).show_group(ui, |ui, _| {
Button::new(if collapsed { "L" } else { "Add layer" }).show(ui);
});
@@ -52,6 +56,9 @@ fn floating_dock_window(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
if let Some(iconic) = shown.output.iconic {
*data.value("collapsed", false) = iconic;
}
if let Some(width) = shown.output.collapsed_width {
*data.value("width", None::<f32>) = Some(width);
}
shown.output.into()
}
@@ -59,12 +66,16 @@ fn floating_dock_window(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
#[story(FloatingGroup<'static>, covers = [Default], drive = Drive::Never)]
fn floating_collapsed_window(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
let rect = *data.value("rect", START);
let column = WindowColumn::collapsed(DockEdge::End, icon_strip(ui));
let width = *data.value("width", None::<f32>);
let column = icon_strip(ui, DockEdge::End, width);
let shown = FloatingGroup::new("Layers", rect).column(column).sized(crate::contract::Sizing::Fill).show_group(ui, |ui, _| {
Button::new("L").show(ui);
});
if let Some(change) = shown.output.placed {
*data.value("rect", START) = change.rect;
}
if let Some(width) = shown.output.collapsed_width {
*data.value("width", None::<f32>) = Some(width);
}
shown.output.into()
}
+73 -34
View File
@@ -13,16 +13,15 @@ use crate::contract::{
WordSetCx as _,
};
use crate::menu::GroupItem;
use crate::primitives::IconSpec;
use crate::primitives::TextRun;
use crate::primitives::{IconSpec, PaintShape, TextRun};
use crate::runtime::env::Label;
use crate::runtime::focus::KeyUse;
use crate::style::{ComponentStyle, Corners, GlyphRole, StyleColor, StyleCx, SurfaceKind};
use crate::style::{ComponentStyle, Corners, GlyphRole, StyleColor, StyleCx, SurfaceKind, UiTokens};
use craft_behavior::dock::{Column, DockEdge, Group};
use craft_behavior::overlay::Side;
use craft_behavior::{Axis, CursorIcon, DockSide, Metrics, PartKey, PressPhase, Sense, Value};
use craft_theme::ControlSize;
use egui::{Id, Pos2, Rect, Response, Ui, Vec2};
use egui::{CornerRadius, Id, Pos2, Rect, Response, Ui, Vec2};
use std::fmt::Debug;
use std::hash::Hash;
@@ -44,7 +43,7 @@ pub struct IconicSizes {
pub column: DockSizes,
/// The height of an icon cell (the rail button).
pub cell: f32,
/// How far an icon group's drag band reaches into its first icon.
/// The height of the grip strip at the top of each icon group, above its first icon.
pub grip: f32,
/// The room between two icon groups.
pub separator: f32,
@@ -55,6 +54,12 @@ pub struct IconicSizes {
/// The column width, in rail widths, from which the cells show their panels' names: 96 points at the Compact size.
const LABELS_IN_RAIL_WIDTHS: f32 = 2.4;
/// The length of a group's grip bar, in icon cell heights: half a cell, 15 points at the Compact size (18 at
/// Comfortable). That is several times the bar's thickness, so it reads as a handle and not as a dot, and in a
/// rail-wide column (40 points at Compact) it leaves more than a quarter of the width free on each side, so it does
/// not read as a rule between the groups.
const GRIP_BAR_IN_CELLS: f32 = 0.5;
impl IconicSizes {
/// The sizes of the style context `cx`.
pub fn style(cx: &StyleCx<'_>) -> Self {
@@ -62,7 +67,7 @@ impl IconicSizes {
IconicSizes {
column: DockSizes::style(cx),
cell: size.rail.button,
grip: size.handle.sm,
grip: size.hit.target,
separator: cx.tokens.space.gap.tight,
labels: size.rail.width * LABELS_IN_RAIL_WIDTHS,
}
@@ -74,10 +79,12 @@ impl IconicSizes {
StyleCx::with_root(ctx, IconicSizes::style)
}
/// The height of the icons of `column` under its bar: a cell per panel and the room between every two groups.
/// The height of the icons of `column` under its bar: a grip strip per group, a cell per panel and the room between
/// every two groups.
pub fn icons_height<P>(&self, column: &Column<P>) -> f32 {
let cells: usize = column.groups.iter().map(|group| group.panels.len()).sum();
cells as f32 * self.cell + column.groups.len().saturating_sub(1) as f32 * self.separator
let groups = column.groups.len();
groups as f32 * self.grip + cells as f32 * self.cell + groups.saturating_sub(1) as f32 * self.separator
}
}
@@ -94,7 +101,8 @@ pub struct IconicColumnOutput<P> {
pub iconic: Option<bool>,
/// The dock row the user picked in the column menu.
pub picked: Option<GroupItem>,
/// The width the user gave the iconic column on its inner edge this pass.
/// The width the user gave a docked iconic column on its inner edge this pass. A floating window's sides set the
/// width of the column it holds (`FloatingGroupOutput::collapsed_width`).
pub width: Option<f32>,
/// The size the user gave the open flyout, with the top edge's offset from the icons when it moved.
pub flyout: Option<FlyoutResize<P>>,
@@ -141,13 +149,22 @@ pub struct IconicColumnStyle {
name_open: StyleColor,
/// The room between an icon and its name.
name_gap: f32,
/// The ink of a group's grip bar.
grip: StyleColor,
/// The ink of a group's grip bar while the pointer is over it or drags it.
grip_active: StyleColor,
/// The grip bar's length across the group and its thickness.
grip_length: f32,
grip_thickness: f32,
/// The grip bar's corners: the theme's pill rounding.
grip_radius: CornerRadius,
}
/// A column collapsed to icons: the column bar over icon groups, one cell per panel. A panel without an icon shows the
/// first letter of its name in a box. A column widened past `IconicSizes::labels` shows each panel's name beside its
/// icon, cut with an ellipsis to the cell; a click or drag on the name acts as one on the icon. A click or Enter on an icon
/// opens the flyout of its panel beside the column, switches it to that panel or closes it; one flyout is open at a
/// time. A drag of an icon starts a move of its panel, a drag of the band on top of a group a move of the group, a
/// time. A drag of an icon starts a move of its panel, a drag of the grip bar on top of a group a move of the group, a
/// drag of the bar beside its button a move of the column; each starts through the drag session, and a press outside
/// the flyout closes it. Escape and a press
/// outside close the flyout; with `auto_collapse` the focus leaving it does too.
@@ -162,8 +179,8 @@ pub struct IconicColumnStyle {
/// The user resizes it by its top and bottom edges and the edge away from the column; each step comes back in
/// [`IconicColumnOutput::flyout`], which the host keeps in the group (`flyout_width`, `height`, `flyout_offset`).
///
/// In a floating window ([`ColumnBar::Window`]) the window's title row is the column's bar: the column shows its
/// icons under it and keeps the divider of its inner edge, which sets its width, and registers no edge bands.
/// In a floating window ([`ColumnBar::Window`]) the window's title row is the column's bar and the window's sides set
/// its width: the column shows its icons under it, with no divider on its inner edge, and registers no edge bands.
#[derive(crate::contract::Component, crate::contract::Props)]
#[component(container, overlay, probe(IconicColumn<'static, u8>))]
pub struct IconicColumn<'a, P: Value + Hash + 'static> {
@@ -224,9 +241,9 @@ struct Plan {
cells: Vec<(usize, usize, Rect)>,
/// The rest of each row in a wide column, where the panel's name shows; empty in a narrow column.
names: Vec<Rect>,
/// `(group, rect)` of each group's drag band.
/// `(group, rect)` of each group's grip strip, above its first icon.
grips: Vec<(usize, Rect)>,
/// `(group, rect)` of the cells of each group.
/// `(group, rect)` of the whole of each group: its grip strip and its cells.
groups: Vec<(usize, Rect)>,
body: Rect,
}
@@ -287,8 +304,8 @@ impl<'a, P: Value + Hash + Debug + 'static> IconicColumn<'a, P> {
/// The panels of the column in order, each with its group.
/// The divider on the column's inner edge: the width runs from the rail to the width the column expands to.
fn edge_divider(&self, rect: Rect, sizes: &DockSizes) -> Divider {
let least = sizes.iconic_least;
let most = sizes.expanded_width(self.column, self.spec).max(least).min((self.within.width() - sizes.least_pane).max(rect.width()));
let (least, most) = sizes.iconic_bounds(self.column, self.spec);
let most = most.min((self.within.width() - sizes.least_pane).max(rect.width()));
Divider::column_edge(rect, self.edge, (least, most), sizes.reach)
}
@@ -318,6 +335,8 @@ impl<'a, P: Value + Hash + Debug + 'static> IconicColumn<'a, P> {
y += sizes.separator;
}
let top = y;
let grip = Rect::from_min_max(Pos2::new(body.left(), top), Pos2::new(body.right(), top + sizes.grip));
y = grip.bottom();
for panel in 0..group.panels.len() {
let row = Rect::from_min_size(Pos2::new(body.left(), y), Vec2::new(body.width(), sizes.cell));
if wide {
@@ -329,7 +348,7 @@ impl<'a, P: Value + Hash + Debug + 'static> IconicColumn<'a, P> {
}
y += sizes.cell;
}
grips.push((at, Rect::from_min_max(Pos2::new(body.left(), top), Pos2::new(body.right(), (top + sizes.grip).min(y)))));
grips.push((at, grip));
groups.push((at, Rect::from_min_max(Pos2::new(body.left(), top), Pos2::new(body.right(), y))));
}
Plan { bar, cells, names, grips, groups, body }
@@ -368,15 +387,15 @@ impl<'a, P: Value + Hash + Debug + 'static> IconicColumn<'a, P> {
sizes: &DockSizes,
) -> Option<FlyoutPlan<P>> {
let (group_at, _) = *self.flat().get(at)?;
let icons = self.laid.as_ref()?.groups.iter().find(|(group, _)| *group == group_at)?.1;
let icons = self.laid.as_ref()?.cells.iter().find(|(group, _, _)| *group == group_at)?.2.top();
let group = self.flyout_group(at)?;
let width = group.flyout_width.filter(|width| width.is_finite() && *width > 0.0).unwrap_or(expanded).max(least.x).min(bounds.width());
let fixed = group.height.is_some_and(|height| height.is_finite() && height > 0.0);
let height = self.flyout_height(&group, sizes).max(least.y).min(bounds.height());
let offset = group.flyout_offset.filter(|offset| offset.is_finite()).unwrap_or(0.0);
let top = (icons.top() + offset).min(bounds.bottom() - height).max(bounds.top());
let top = (icons + offset).min(bounds.bottom() - height).max(bounds.top());
let left = if right { column.right() } else { column.left() - width };
Some(FlyoutPlan { group, top_left: Pos2::new(left, top), size: Vec2::new(width, height), fixed, icons_top: icons.top() })
Some(FlyoutPlan { group, top_left: Pos2::new(left, top), size: Vec2::new(width, height), fixed, icons_top: icons })
}
}
@@ -402,6 +421,11 @@ impl<P: Value + Hash + Debug + 'static> Component for IconicColumn<'_, P> {
name: cx.color(colors.text.normal),
name_open: cx.color(colors.accent.text),
name_gap: cx.tokens.space.gap.item,
grip: cx.color(colors.text.muted),
grip_active: cx.color(colors.text.normal),
grip_length: cx.tokens.size.rail.button * GRIP_BAR_IN_CELLS,
grip_thickness: cx.tokens.stroke.thick,
grip_radius: UiTokens::corner(cx.tokens.shape.radius.pill),
}
}
@@ -413,8 +437,8 @@ impl<P: Value + Hash + Debug + 'static> Component for IconicColumn<'_, P> {
Some(self.open.reborrow())
}
/// The icon cells, each toggling the flyout of its panel, and the drag band of every group. The cells win the
/// top of the first icon over the band, which is declared first.
/// The icon cells, each toggling the flyout of its panel, and the grip strip of every group, which takes exactly its
/// rect so that it never reaches into the group's first icon.
fn parts(&mut self, rect: Rect, cx: &mut PartsCx<'_, Self>) {
let sizes = cx.style.sizes;
let plan = self.plan(rect, &sizes, cx.flow.is_rtl());
@@ -440,11 +464,14 @@ impl<P: Value + Hash + Debug + 'static> Component for IconicColumn<'_, P> {
for (group, grip) in &plan.grips {
cx.part(GRIP.at(*group as u64), *grip)
.sense(Sense::DRAG)
.exact_hit()
.cursor(CursorIcon::Grab)
.drag_cursor(CursorIcon::Grabbing)
.pointer_only("Move Panel To in the panel menu moves the group's panels");
}
divider::declare(cx, rect, EDGE, 0, &self.edge_divider(rect, &sizes.column));
if self.bar == ColumnBar::Own {
divider::declare(cx, rect, EDGE, 0, &self.edge_divider(rect, &sizes.column));
}
self.laid = Some(plan);
}
@@ -479,12 +506,14 @@ impl<P: Value + Hash + Debug + 'static> Component for IconicColumn<'_, P> {
began = true;
}
}
let edge = self.edge_divider(rect, &sizes.column);
if let Some(Drag::To(coord)) = divider::pointer(cx, EDGE, 0, &edge) {
self.move_edge(rect, &edge, coord);
}
if let Some((_, coord)) = divider::keys(cx, EDGE, &[(0, edge)], sizes.column.step, sizes.column.jump) {
self.move_edge(rect, &edge, coord);
if self.bar == ColumnBar::Own {
let edge = self.edge_divider(rect, &sizes.column);
if let Some(Drag::To(coord)) = divider::pointer(cx, EDGE, 0, &edge) {
self.move_edge(rect, &edge, coord);
}
if let Some((_, coord)) = divider::keys(cx, EDGE, &[(0, edge)], sizes.column.step, sizes.column.jump) {
self.move_edge(rect, &edge, coord);
}
}
let handles: Vec<_> = (0..flat.len()).map(|at| popup.at(at)).collect();
// A toggle of an icon (click, Enter, Alt+Down) changed a popup this pass: the user chose. Otherwise the
@@ -545,10 +574,20 @@ impl<P: Value + Hash + Debug + 'static> Component for IconicColumn<'_, P> {
let cell = IconButton::new(icon).label(spec.label).selected(selected).size(ControlSize::Md).glyphs(GlyphRole::ToolRail);
ui.face(CELL.at(at as u64), cell);
}
// The edge's line lies on the column's inner edge; its handle stays inside the column.
let (rect, edge) = (cx.rect, self.edge_divider(cx.rect, &cx.style.sizes.column));
let x = if cx.flow.is_rtl() { rect.right() - (edge.at - rect.left()) } else { edge.at };
ui.face(EDGE.at(0), Splitter::new(Axis::X).boundary(x));
let style = &cx.style;
for (group, strip) in self.laid.as_ref().map_or(&[][..], |plan| &plan.grips[..]) {
let part = cx.part(GRIP.at(*group as u64));
let ink = if part.hovered || part.pressed() { style.grip_active } else { style.grip };
let bar = Rect::from_center_size(strip.center(), Vec2::new(style.grip_length.min(strip.width()), style.grip_thickness));
ui.draw().fill(&PaintShape::Rect(bar, style.grip_radius), ink);
}
// The edge's line lies on the column's inner edge; its handle stays inside the column. A floating window's
// edges are the window's.
if self.bar == ColumnBar::Own {
let (rect, edge) = (cx.rect, self.edge_divider(cx.rect, &cx.style.sizes.column));
let x = if cx.flow.is_rtl() { rect.right() - (edge.at - rect.left()) } else { edge.at };
ui.face(EDGE.at(0), Splitter::new(Axis::X).boundary(x));
}
}
fn access(&self, access: &mut Access, cx: &Cx<'_, Self>) {
@@ -564,8 +603,8 @@ impl<P: Value + Hash + Debug + 'static> Component for IconicColumn<'_, P> {
let name = words.move_group.fill(&[("name", (self.spec)(shown).label.as_str())]);
access.node(GRIP.at(*group as u64), Role::BUTTON).name = Name::Text(name);
}
divider::describe(access, EDGE, 0, &self.edge_divider(cx.rect, &sizes.column), words.resize.as_str(), sizes.column.step);
if self.bar == ColumnBar::Own {
divider::describe(access, EDGE, 0, &self.edge_divider(cx.rect, &sizes.column), words.resize.as_str(), sizes.column.step);
describe_chevron(access, &ColumnArrow::Collapse.name(&words, false));
}
}
+63 -10
View File
@@ -1,9 +1,14 @@
//! Trials of `IconicColumn`: the letter of a panel without an icon, the names a wide column shows, and the resizes
//! of its flyouts.
//! Trials of `IconicColumn`: the letter of a panel without an icon, the names a wide column shows, the grips of its
//! groups, and the resizes of its flyouts.
#![allow(clippy::panic, clippy::expect_used, reason = "trials assert by panicking")]
use super::GRIP;
use crate::contract::{Bind, Show as _, ShowContainer as _};
use crate::docking::{DockHeights, DockSizes, DockSpot, DockTargets, DragUnit, FlyoutResize, GroupAt, GroupGrip, IconicColumn, PanelKey, PanelSpec};
use crate::docking::{
DockHeights, DockSizes, DockSpot, DockTargets, DragUnit, FlyoutResize, GroupAt, GroupDrag, GroupGrip, IconicColumn, PanelKey, PanelSpec,
};
use crate::runtime::drag;
use crate::runtime::env::Direction;
use crate::sections::Panel;
use crate::style::StyleCx;
use crate::testing::memory::global;
@@ -204,9 +209,9 @@ impl Flyouts {
StyleCx::with_root(self.fixture.ctx(), DockSizes::style)
}
/// Half the side of a resize grip, which straddles the edge it moves.
/// How far a resize grip reaches in from the edge it moves.
fn grip_reach(&self) -> f32 {
StyleCx::with_root(self.fixture.ctx(), |cx| cx.tokens.size.handle.sm) / 2.0
StyleCx::with_root(self.fixture.ctx(), |cx| crate::contract::grip_band(cx.tokens))
}
}
@@ -257,7 +262,7 @@ fn flyout_top_edge_and_free_top_corner_grow_it_upward() {
}
}
/// The top grip is the standard one, straddling the edge: a press inside it resizes; a press below it reaches the
/// The top grip is the standard one, inside the edge: a press inside it resizes; a press below it reaches the
/// tab strip and drags the group.
#[trial]
fn the_flyout_top_handle_is_a_band_that_leaves_the_strip_its_drags() {
@@ -340,6 +345,51 @@ fn a_flyout_with_an_offset_in_a_short_viewport_stays_inside_and_resizes_its_widt
}
}
/// Each icon group's grip strip has its own room at the group's top: across the group, below the bar or the group
/// before it and above the group's first icon, overlapping no icon. A drag that starts on a grip moves its whole
/// group, as a drag on an icon moves its panel.
#[trial]
fn a_groups_grip_lies_above_its_icons_and_its_drag_moves_the_group() {
let overlap = |a: Rect, b: Rect| {
let both = a.intersect(b);
both.width() > 0.0 && both.height() > 0.0
};
for direction in [Direction::Ltr, Direction::Rtl] {
let mut fixture = Fixture::hosted(|ui| {
let mut column = Column::new(vec![Group::new(vec![1, 2], 0), Group::new(vec![3], 0)]);
column.iconic = true;
let place = Rect::from_min_size(Pos2::ZERO, Vec2::new(RAIL, SCREEN.y));
let output = IconicColumn::new("Panels", global("iconic column", "grips"), &column, Bind::kept(), &named)
.within(screen())
.show_flyouts_at(ui, place, |_, _, _, _| None);
Some(output.into())
});
fixture.direction(direction).room(SCREEN).settle();
let id = fixture.root_id().expect("the column shows");
let grips = [0, 1].map(|group| fixture.part_rect(id, GRIP.at(group)).expect("each group has its grip"));
let icon_rect = |label: &str| fixture.by_label(label).expect("the panel's icon").rect;
let (brushes, layers, swatches) = (icon_rect("Brushes"), icon_rect("Layers"), icon_rect("Swatches"));
assert!(grips[0].top() > 0.0, "{direction:?}: the first grip is under the bar: {grips:?}");
assert!(grips[0].bottom() <= brushes.top(), "{direction:?}: the first grip is above its group's first icon");
assert!(layers.bottom() <= grips[1].top(), "{direction:?}: the second grip is below the first group");
assert!(grips[1].bottom() <= swatches.top(), "{direction:?}: the second grip is above its group's first icon");
for grip in grips {
assert!(grip.x_range().contains(brushes.center().x), "{direction:?}: the grip runs across the group: {grip:?}");
for cell in [brushes, layers, swatches] {
assert!(!overlap(grip, cell), "{direction:?}: {grip:?} overlaps the icon {cell:?}");
}
}
assert!(!overlap(grips[0], grips[1]), "{direction:?}: the grips overlap");
for (grip, anchor) in grips.into_iter().zip([1, 3]) {
fixture.drag_hold_at(grip.center(), Vec2::new(RAIL * 2.0, 0.0));
let unit = drag::active::<GroupDrag<u8>>(fixture.ctx()).map(|drag| drag.unit.clone());
assert_eq!(unit, Some(DragUnit::Group(anchor)), "{direction:?}: a drag on the grip moves its group");
fixture.release_at(grip.center() + Vec2::new(RAIL * 2.0, 0.0)).settle();
}
}
}
/// The icon groups take drops as an expanded column's groups do: the middle of a group joins its tabs, the separator
/// between two groups is the seam between them and wins there, the top of the first group stacks above it, and the
/// bottom of the last group, down through the column's empty foot, stacks below it.
@@ -349,22 +399,25 @@ fn icon_groups_take_the_drops_of_an_expanded_columns_groups() {
let probes: Rc<RefCell<Vec<Pos2>>> = Rc::default();
let found: Rc<RefCell<Vec<Option<DockSpot<u8>>>>> = Rc::default();
let (asked, seen) = (Rc::clone(&probes), Rc::clone(&found));
let mut fixture = Fixture::new(move |ui| {
let mut fixture = Fixture::hosted(move |ui| {
let mut column = Column::new(vec![Group::new(vec![1, 2], 0), Group::new(vec![3], 0)]);
column.iconic = true;
let place = Rect::from_min_size(Pos2::ZERO, Vec2::new(RAIL, SCREEN.y));
IconicColumn::new("Panels", dock, &column, Bind::kept(), &named).within(screen()).show_flyouts_at(ui, place, |_, _, _, _| None);
let output = IconicColumn::new("Panels", dock, &column, Bind::kept(), &named).within(screen()).show_flyouts_at(ui, place, |_, _, _, _| None);
// The registry a drop reads is the previous pass's.
*seen.borrow_mut() = asked.borrow().iter().map(|at| DockTargets::<u8>::resolve(ui.ctx(), dock, *at).map(|(spot, _)| spot)).collect();
Some(output.into())
});
fixture.room(SCREEN).settle();
let rect_of = |label: &str| fixture.by_label(label).expect("the panel's icon").rect;
let (brushes, layers, swatches) = (rect_of("Brushes"), rect_of("Layers"), rect_of("Swatches"));
let grip = |group: u64| fixture.root_id().and_then(|id| fixture.part_rect(id, GRIP.at(group))).expect("the group's grip");
let (first, second) = (grip(0), grip(1));
let x = brushes.center().x;
*probes.borrow_mut() = vec![
Pos2::new(x, brushes.bottom()),
Pos2::new(x, (layers.bottom() + swatches.top()) / 2.0),
Pos2::new(x, brushes.top() + 1.0),
Pos2::new(x, (layers.bottom() + second.top()) / 2.0),
Pos2::new(x, first.center().y),
Pos2::new(x, swatches.center().y),
Pos2::new(x, swatches.bottom() + 2.0 * swatches.height()),
];
+8 -1
View File
@@ -35,8 +35,15 @@ pub struct Opening {
/// them over the dock's window this pass (the rule the group's mount falls back to a layer by) and reports where they
/// are, and every panel allows it.
pub(crate) fn allowed(ctx: &Context, config: &DockConfig, specs: &[PanelSpec]) -> bool {
opens_os_windows(ctx, config) && specs.iter().all(|spec| spec.allow_native)
}
/// Whether the dock opens its floating windows in OS windows: `config` asks for them, and the window host opens OS
/// windows and reports where they are. A panel may still keep to the app window (`PanelSpec::allow_native`).
#[doc(hidden)]
pub fn opens_os_windows(ctx: &Context, config: &DockConfig) -> bool {
let host = WindowHost::of(ctx);
config.native_windows && host.opens_windows() && host.positions_reported() && specs.iter().all(|spec| spec.allow_native)
config.native_windows && host.opens_windows() && host.positions_reported()
}
/// The window a group of panels with `specs` opens: a document window when any panel is a document, else a tool
+21 -6
View File
@@ -51,9 +51,12 @@ pub struct DockSizes {
pub strip: f32,
/// The height of a column bar (a small control).
pub bar: f32,
/// The height of a floating window's title row, which is the bar of the column the window holds: every height of
/// a window's body or content is the window's height less this.
/// The height of a floating window's title row, which is the bar of the column the window holds.
pub title_row: f32,
/// The band a floating window in the app window keeps clear over its title row for its top grip
/// (`contract::grip_band`); an OS window keeps none. Every height of a window's body or content is the window's
/// height less its chrome ([`Self::window_chrome`]).
pub top_band: f32,
/// The least body size of a column's group and the least width of an expanded column (the panel header height).
pub least: f32,
/// How thick a divider is across its boundary (the least hit size).
@@ -93,6 +96,7 @@ impl DockSizes {
strip: size.panel_header,
bar: size.control.sm,
title_row: super::floating::title_row(cx.tokens),
top_band: crate::contract::grip_band(cx.tokens),
least: size.panel_header,
reach: size.hit.target,
step: cx.control().gap,
@@ -102,6 +106,12 @@ impl DockSizes {
}
}
/// The height above a floating window's body: its title row and, for a window in the app window (`in_app`), the
/// band over it.
pub fn window_chrome(&self, in_app: bool) -> f32 {
self.title_row + if in_app { self.top_band } else { 0.0 }
}
/// The width bounds of an expanded column from the limits of its panels.
pub fn width_bounds<P>(&self, column: &Column<P>, spec: &dyn Fn(&P) -> PanelSpec) -> (f32, f32) {
let limits = column.groups.iter().flat_map(|group| group.panels.iter()).map(|panel| spec(panel).limits);
@@ -119,13 +129,18 @@ impl DockSizes {
column.width.unwrap_or(self.column).clamp(lo, hi)
}
/// The width bounds of a column collapsed to icons, docked or floating: the rail width up to the width it expands
/// to. A docked column's inner edge and a floating window's sides resize it within them.
pub fn iconic_bounds<P>(&self, column: &Column<P>, spec: &dyn Fn(&P) -> PanelSpec) -> (f32, f32) {
(self.iconic_least, self.expanded_width(column, spec).max(self.iconic_least))
}
/// The bounds [`width`](Self::width) keeps a column in: an expanded column's [`width_bounds`](Self::width_bounds);
/// a stepped one's width at one step up to its width at all its grid's columns; an iconic column's rail width up
/// to the width it expands to.
/// a stepped one's width at one step up to its width at all its grid's columns; an iconic column's
/// [`iconic_bounds`](Self::iconic_bounds).
pub fn shown_bounds<P>(&self, column: &Column<P>, spec: &dyn Fn(&P) -> PanelSpec) -> (f32, f32) {
if column.iconic {
// Widening an iconic column stops at the width it expands to.
(self.iconic_least, self.expanded_width(column, spec).max(self.iconic_least))
self.iconic_bounds(column, spec)
} else if let Some((grid, _)) = stepped(column, spec) {
(grid.width(1), grid.width(grid.most))
} else {
@@ -37,6 +37,8 @@ pub enum HeaderStrength {
Heading,
/// A quiet heading over a group of controls: label text, faint, as written, with no rule.
Caption,
/// A window's drag bar: one text row high (`size.row.text`), with label text; its action parts shrink to the row.
Bar,
}
/// What a title row's action parts ask the container to do.
@@ -339,6 +341,7 @@ impl Component for TitleRow<'_> {
HeaderStrength::Section => (cx.tokens.size.panel_header, TypeRole::BodyStrong, text.normal),
HeaderStrength::Heading => (cx.tokens.size.panel_header, TypeRole::Heading, text.normal),
HeaderStrength::Caption => (cx.control().height, TypeRole::Label, text.faint),
HeaderStrength::Bar => (cx.tokens.size.row.text, TypeRole::Label, text.normal),
};
let shade = key.tone.map_or_else(|| cx.color(shade), |tone| cx.tone_on_fill(tone));
let (ink, disabled) = (cx.ink(Ink::OnPanel), cx.color(text.disabled));
@@ -56,3 +56,9 @@ fn title_row_with_icon_and_subtitle(ui: &mut Ui, _: &mut StoryData) -> StoryOutp
fn title_row_caption(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
TitleRow::new("Preset details").strength(HeaderStrength::Caption).show(ui).edit.into()
}
#[story(TitleRow<'static>, covers = [], drive = Drive::Never)]
fn title_row_bar(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
// A floating window's drag bar: no title, the Close action at the end.
TitleRow::new("").strength(HeaderStrength::Bar).actions([HeaderAction::Close]).show(ui).edit.into()
}
+36 -18
View File
@@ -204,7 +204,7 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Drops<'_, P> {
let sizes = *cx.style.sizes();
let shell = cx.env.get::<ShellEntry>().0;
let bounds = shell.as_ref().map_or(cx.rect, ShellCx::float_bounds);
let space = float_space(bounds, &sizes, self.config, self.specs);
let space = float_space(&ctx, bounds, &sizes, self.config, self.specs);
let spec = |panel: &P| spec_in(self.specs, panel);
let protected = |panel: &P| (self.permissions)(panel).is_protected();
let (hide, _) = hide::resolved(self.hide, shell.as_ref());
@@ -538,7 +538,7 @@ fn show_area<P: Clone + Eq + Hash + Debug + Send + Sync + 'static>(
let Shown { view, floating } = hide::shown(&current.layout, maximized, hide, shell.as_ref(), &protected);
let layout: &Layout<P> = &view.layout;
let bounds = shell.as_ref().map_or(body.rect, ShellCx::float_bounds);
let space = float_space(bounds, &sizes, config, specs);
let space = float_space(ctx, bounds, &sizes, config, specs);
let scene = Scene {
dock: id,
sizes,
@@ -694,9 +694,16 @@ fn register_bands<P: Clone + Eq + Hash + Send + Sync + Debug + 'static>(
}
/// Where floats land in an area whose float bounds are `bounds`: each panel at its spec's float size, else the
/// default float size of `sizes`.
fn float_space<P: Clone + PartialEq>(bounds: Rect, sizes: &DockSizes, config: &DockConfig, specs: &HashMap<P, PanelSpec>) -> FloatSpace<P> {
let mut space = FloatSpace::new(bounds, sizes).with_side_edge_zones(config.side_edge_zones);
/// default float size of `sizes`, under the chrome of the windows the dock opens floats in.
fn float_space<P: Clone + PartialEq>(
ctx: &Context,
bounds: Rect,
sizes: &DockSizes,
config: &DockConfig,
specs: &HashMap<P, PanelSpec>,
) -> FloatSpace<P> {
let mut space =
FloatSpace::new(bounds, sizes).in_os_windows(sizes, native::opens_os_windows(ctx, config)).with_side_edge_zones(config.side_edge_zones);
for (panel, spec) in specs {
if let Some(size) = spec.float_size {
space = space.with_panel_size(panel.clone(), size);
@@ -1004,8 +1011,9 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
}
/// The steps a resize `change` of the floating window of the stepped `column`, whose first panel is `first`, sets,
/// and the window's rect at them: as wide as its steps and as tall as its title row and its content at that width.
/// `fitted` is the content's size under the title row before the change. A grip on the top or bottom edge sets the
/// and the window's rect at them: as wide as its steps and as tall as its chrome and its content at that width.
/// `fitted` is the content's size under the chrome before the change, `chrome` the height above the window's body
/// (`DockSizes::window_chrome`). A grip on the top or bottom edge sets the
/// steps by height (the fewest whose content fits), any other grip by width (the most that fit); keyboard Size
/// mode, which names no grip, by the side it changed. The window keeps its place: a grip on the left keeps the
/// right edge where it is and one on the top the bottom edge, so the window grows or shrinks that way. Reports
@@ -1017,7 +1025,7 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
column: &Column<P>,
first: &P,
change: &PlacementChange,
fitted: Vec2,
(fitted, chrome): (Vec2, f32),
) -> Option<Rect> {
let scene = self.scene;
let spec_of = |panel: &P| scene.spec(panel);
@@ -1027,7 +1035,7 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
_ => (change.rect.width() - fitted.x).abs() <= 0.5,
};
let to = if by_height {
let room = change.rect.height() - scene.sizes.title_row;
let room = change.rect.height() - chrome;
grid.steps_for_height(room, |width| self.stepped_height(ui, body, column, width, true).unwrap_or(0.0))
} else {
grid.steps_within(change.rect.width())
@@ -1035,7 +1043,7 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
if to != steps {
self.report.actions.push(Action::set_column_steps(first.clone(), to));
}
let size = Vec2::new(grid.width(to), scene.sizes.title_row + self.stepped_height(ui, body, column, grid.width(to), true).unwrap_or(0.0));
let size = Vec2::new(grid.width(to), chrome + self.stepped_height(ui, body, column, grid.width(to), true).unwrap_or(0.0));
let left = match change.kind {
PlacementKind::Size(ResizeEdge::Left | ResizeEdge::TopLeft | ResizeEdge::BottomLeft) => change.rect.right() - size.x,
_ => change.rect.left(),
@@ -1177,7 +1185,9 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
/// double arrow sits at that end, and its collapsed column shows against that edge of its rect. A move or resize
/// keeps the edge the window had when it began, so nothing jumps while the window crosses the middle. A collapsed
/// window's move ends at the edge nearer the strip where it was dropped, with the rect that shows the strip there
/// ([`WindowColumn::dropped`]); an expanded window's move leaves its edge to its rect. An OS window is measured
/// ([`WindowColumn::dropped`]); an expanded window's move leaves its edge to its rect. A collapsed window's sides
/// resize its column's width within [`DockSizes::iconic_bounds`] (`Action::ResizeIconic`, as a docked collapsed
/// column's inner edge does), and the window keeps its edge and its expanded rect's size. An OS window is measured
/// where it would sit in the app window ([`native::in_app`]), and the end of each of its moves and resizes records
/// that rect and edge; its placement keeps its expanded rect while its column is collapsed ([`WindowColumn::kept`]).
///
@@ -1238,7 +1248,7 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
let width = scene.sizes.expanded_width(&window.column, &spec_of);
let shape = if window.column.iconic {
let size = Vec2::new(scene.sizes.width(&window.column, &spec_of), IconicSizes::of(&ctx).icons_height(&window.column));
WindowColumn::collapsed(edge, size)
WindowColumn::collapsed(edge, size, scene.sizes.iconic_bounds(&window.column, &spec_of))
} else if let Some(content) = self.stepped_height(ui, body, &window.column, width, true) {
WindowColumn::fitted(edge, Vec2::new(width, content))
} else {
@@ -1284,12 +1294,14 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
cross_window::accept_cross_window(&ctx);
self.report.actions.push(dropped.action);
}
// The height above the window's body: the title row, and in the app window the band over it.
let chrome = scene.sizes.window_chrome(opening.spec.is_none());
// A resize of a window whose column has steps: the steps it sets, and the window's rect at them.
let resized = output
.placed
.filter(|change| !matches!(change.kind, PlacementKind::Move))
.zip(shape.fitted)
.and_then(|(change, fitted)| self.stepped_resize(ui, body, &window.column, &anchor, &change, fitted));
.and_then(|(change, fitted)| self.stepped_resize(ui, body, &window.column, &anchor, &change, (fitted, chrome)));
if opening.spec.is_some() {
if let Some(viewport) = WindowHost::of(&ctx).viewport_of(output.response.id) {
// The OS window takes the rect of its steps at once, so the place recorded below is that rect.
@@ -1306,18 +1318,19 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
&& let Some(change) = output.placed.filter(|change| change.phase == GesturePhase::Commit)
&& let Some(rect) = native::in_app(&ctx, change.rect)
{
let (rect, keeps) = shape.dropped(rect, scene.bounds, scene.rtl);
// A resize of a collapsed window keeps its edge; a move ends where its strip was dropped.
let (rect, keeps) =
if output.collapsed_width.is_some() { (rect, Some(edge)) } else { shape.dropped(rect, scene.bounds, scene.rtl) };
kept.edge = keeps.unwrap_or(kept.edge);
self.report.actions.push(Action::move_floating_with_edge(anchor.clone(), rect, keeps));
}
let title_row = scene.sizes.title_row;
let reported = native::reported(&ctx, window, viewport, |shown| kept.kept(shown, opening.rect, title_row, scene.rtl));
let reported = native::reported(&ctx, window, viewport, |shown| kept.kept(shown, opening.rect, chrome, scene.rtl));
self.report.actions.extend(reported);
}
} else if let Some(mut change) = output.placed {
// A collapsed window keeps the edge its move began with until the move ends where its strip was dropped.
let mut keeps = shape.collapsed.map(|_| edge);
if change.phase == GesturePhase::Commit {
if change.phase == GesturePhase::Commit && output.collapsed_width.is_none() {
(change.rect, keeps) = shape.dropped(change.rect, scene.bounds, scene.rtl);
}
// The window keeps the place of its steps; its size is the steps' own, whatever the rect keeps.
@@ -1329,6 +1342,11 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
}
moved = Some((anchor.clone(), change, keeps));
}
// The sides of a collapsed window set its column's width, as a docked collapsed column's inner edge does.
if let Some(width) = output.collapsed_width {
let work = ColumnWork { iconic: None, picked: None, resized: Vec::new(), width: Some(width), flyout: None };
self.column_work(&window.column, work);
}
// The OS close of a native window arrives here as well, also where the title row offers no Close.
if output.action == Some(HeaderAction::Close) && rights.iter().all(|rights| rights.closable) {
self.report.actions.push(Action::close_window(anchor.clone()));
@@ -1337,7 +1355,7 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> Pass<'_, P> {
self.pick(&active, item);
}
// The window's commands run from its body, below the title row.
let body = opening.rect.size() - Vec2::new(0.0, scene.sizes.title_row);
let body = opening.rect.size() - Vec2::new(0.0, chrome);
for command in commands {
self.run(&active, command, Some(body));
}
@@ -4,11 +4,12 @@ use craft_behavior::Axis;
use craft_behavior::dock::{Action, Column, DockEdge, Floating, Group, Layout, Node, Permissions, SplitSize, Workspace};
use craft_ui::contract::{Bind, BodyCx, Role, Show as _, ShowContainer as _};
use craft_ui::display::Text;
use craft_ui::docking::{DockConfig, DockPanels, GroupDrag, PanelSpec, request_actions};
use craft_ui::docking::{DockConfig, DockPanels, GroupDrag, IconicSizes, PanelSpec, request_actions};
use craft_ui::layout_components::Stack;
use craft_ui::patterns::dock::DockArea;
use craft_ui::runtime::drag::{self, DropMark};
use craft_ui::testing::pointer::{moved, press, release, secondary};
use craft_ui::testing::snapshot::layer_rects;
use craft_ui::testing::{Fixture, trial};
use egui::{Modifiers, Pos2, Rect, Ui, Vec2};
use std::cell::{Cell, RefCell};
@@ -67,8 +68,8 @@ struct Bed {
second: Rc<Cell<bool>>,
/// The tallest a floated panel opens (`FloatSpace::default_size`), as the area reported it.
float_height: Rc<Cell<f32>>,
/// The height of a floating window's title row (`FloatSpace::title_row`), as the area reported it.
title_row: Rc<Cell<f32>>,
/// The height above a floating window's body (`FloatSpace::chrome`), as the area reported it.
chrome: Rc<Cell<f32>>,
}
fn bed(layout: Layout<usize>, rights: fn(&usize) -> Permissions) -> Bed {
@@ -76,9 +77,9 @@ fn bed(layout: Layout<usize>, rights: fn(&usize) -> Permissions) -> Bed {
let actions: Rc<RefCell<Vec<Action<usize>>>> = Rc::default();
let second = Rc::new(Cell::new(false));
let float_height = Rc::new(Cell::new(0.0));
let title_row = Rc::new(Cell::new(0.0));
let chrome = Rc::new(Cell::new(0.0));
let (held, seen_actions, shows_second, seen_height) = (Rc::clone(&workspace), Rc::clone(&actions), Rc::clone(&second), Rc::clone(&float_height));
let seen_title_row = Rc::clone(&title_row);
let seen_chrome = Rc::clone(&chrome);
let mut other = Workspace::new(Layout::new(Some(Node::tabs(vec![SECOND], 0)), Vec::new()));
let mut fixture = Fixture::new(move |ui| {
let mut workspace = held.borrow().clone();
@@ -88,14 +89,14 @@ fn bed(layout: Layout<usize>, rights: fn(&usize) -> Permissions) -> Bed {
seen_actions.borrow_mut().extend(out.actions);
if let Some(space) = out.float_space {
seen_height.set(space.default_size.y);
seen_title_row.set(space.title_row);
seen_chrome.set(space.chrome);
}
if shows_second.get() {
DockArea::new("Second dock", Bind::bound(&mut other), &mut panels, DockConfig::default()).show(ui);
}
});
fixture.settle();
Bed { fixture, workspace, actions, second, float_height, title_row }
Bed { fixture, workspace, actions, second, float_height, chrome }
}
/// A point on the floating window's title row, on its band: clear of the actions and the double arrow at its end.
@@ -235,10 +236,10 @@ fn a_floating_windows_drag_bar_shows_no_title() {
assert_eq!(named, 1, "only the tab names the panel: {:?}", bed.fixture.texts());
}
/// The title row the area keeps a dropped window's under the pointer and adds to a floated unit's height is the
/// one the window draws: the window's group starts right under it.
/// The chrome the area keeps a dropped window's under the pointer and adds to a floated unit's height is the one the
/// window draws: the window's group starts right under it.
#[trial]
fn a_floating_windows_group_starts_under_the_title_row_the_area_sizes_windows_by() {
fn a_floating_windows_group_starts_under_the_chrome_the_area_sizes_windows_by() {
let bed = bed(with_window(Some(Node::tabs(vec![DOCKED], 0))), |_| Permissions::ALL);
let group = bed
.fixture
@@ -247,16 +248,80 @@ fn a_floating_windows_group_starts_under_the_title_row_the_area_sizes_windows_by
.find(|group| WINDOW_AT.expand(SLACK).contains_rect(group.rect))
.expect("the window shows its group")
.rect;
let title_row = bed.title_row.get();
assert!(title_row > 0.0, "the area reported its float space");
let chrome = bed.chrome.get();
assert!(chrome > 0.0, "the area reported its float space");
assert!(
(group.top() - WINDOW_AT.top() - title_row).abs() <= SLACK,
"the group starts at {} in a window from {} with a title row of {title_row}",
(group.top() - WINDOW_AT.top() - chrome).abs() <= SLACK,
"the group starts at {} in a window from {} with a chrome of {chrome}",
group.top(),
WINDOW_AT.top()
);
}
/// The window's rect while a press at `from` drags by `by`, before the release, which would dock a window moved over
/// the docked group.
fn dragged_from(from: Pos2, by: Vec2) -> Rect {
let mut bed = bed(with_window(Some(Node::tabs(vec![DOCKED], 0))), |_| Permissions::ALL);
press_and_move(&mut bed.fixture, from, by);
bed.workspace.borrow().layout.floating[0].rect
}
/// A floating window's title row is a drag bar, shorter than the panel header of the tab strip under it, as
/// production's 18 pt bar over its tabs was.
#[trial]
fn a_floating_windows_title_row_is_shorter_than_its_tab_strip() {
let bed = bed(with_window(Some(Node::tabs(vec![DOCKED], 0))), |_| Permissions::ALL);
let in_window = |role| bed.fixture.by_role(role).into_iter().find(|node| WINDOW_AT.expand(SLACK).contains_rect(node.rect)).map(|node| node.rect);
let row = in_window(Role::HEADING).expect("the window shows its title row");
let tab = in_window(Role::TAB).expect("the window shows its tab");
assert!(row.height() < tab.height(), "the title row ({row:?}) is shorter than the tab strip ({tab:?})");
}
/// The grips of a floating window lie inside its frame and reach at least as far as production's: a corner 12 pt
/// along each of its edges, an edge 4 pt in from it.
#[trial]
fn a_floating_windows_corner_and_edge_grips_reach_as_far_in_as_productions() {
let corner = dragged_from(Pos2::new(WINDOW_AT.right() - 11.0, WINDOW_AT.bottom() - 11.0), Vec2::new(20.0, 20.0));
assert!(
corner.width() > WINDOW_AT.width() + SLACK && corner.height() > WINDOW_AT.height() + SLACK && corner.min == WINDOW_AT.min,
"a press 11 pt in from the corner resizes from the corner: {corner:?}"
);
let edge = dragged_from(Pos2::new(WINDOW_AT.left() + 3.5, WINDOW_AT.center().y), Vec2::new(-20.0, 0.0));
assert!(
edge.width() > WINDOW_AT.width() + SLACK && (edge.height() - WINDOW_AT.height()).abs() <= SLACK && edge.right() == WINDOW_AT.right(),
"a press 3.5 pt in from the left edge resizes from that edge: {edge:?}"
);
}
/// The top grip never lies over the title row: a press just inside the row's top moves the window, at its size.
#[trial]
fn the_top_of_a_floating_windows_title_row_moves_it_and_never_resizes_it() {
let bed = bed(with_window(Some(Node::tabs(vec![DOCKED], 0))), |_| Permissions::ALL);
let row =
bed.fixture.by_role(Role::HEADING).into_iter().find(|node| WINDOW_AT.expand(SLACK).contains_rect(node.rect)).expect("the title row").rect;
let by = Vec2::new(-30.0, 20.0);
let rect = dragged_from(Pos2::new(WINDOW_AT.min.x + 40.0, row.top() + 1.0), by);
assert!((rect.size() - WINDOW_AT.size()).length() <= SLACK, "the press on the row at {row:?} resizes nothing: {rect:?}");
assert!((rect.min - (WINDOW_AT.min + by)).length() <= SLACK, "it moves the window: {rect:?}");
}
/// A click on the title row neither moves nor docks the window; a press-drag on it moves the window. A guard of
/// production's behaviour, which the move already had.
#[trial]
fn a_click_on_a_floating_windows_bar_neither_moves_nor_docks_it_and_a_drag_moves_it() {
let mut bed = bed(with_window(Some(Node::tabs(vec![DOCKED], 0))), |_| Permissions::ALL);
let at = window_title();
bed.fixture.frame(vec![moved(at)]);
bed.fixture.frame(vec![press(at)]);
bed.fixture.frame(vec![release(at)]);
bed.fixture.settle();
assert_eq!(bed.workspace.borrow().layout.floating.first().map(|window| window.rect), Some(WINDOW_AT), "a click moves nothing");
assert_eq!(bed.workspace.borrow().layout.floating.len(), 1, "and docks nothing");
let by = Vec2::new(-40.0, 30.0);
let rect = dragged_from(at, by);
assert!((rect.min - (WINDOW_AT.min + by)).length() <= SLACK, "a drag moves the window: {rect:?}");
}
/// A tab dragged out of the window floats at the width its group had where it was docked, not a default size.
#[trial]
fn a_floated_panel_fits_its_content_up_to_the_float_height() {
@@ -364,8 +429,7 @@ fn a_collapsed_window_dragged_across_the_middle_keeps_its_strip_under_the_pointe
let mut bed = bed(collapsed_at(WINDOW_AT), |_| Permissions::ALL);
let icon = button_rect(&bed, &title(WINDOW)).expect("the collapsed window shows its icon");
let by = Vec2::new(middle.map_or(-250.0, |x: f32| x - icon.center().x), 0.0);
// The title row's band, clear of the double arrow at the end the window keeps to.
let band = Pos2::new(icon.left() + 4.0, WINDOW_AT.top() + 6.0);
let band = strip_band(icon);
bed.fixture.drag_hold_at(band, by);
let held = button_rect(&bed, &title(WINDOW)).expect("the icon shows while the window moves");
assert!((held.left() - (icon.left() + by.x)).abs() <= SLACK, "by {by:?}: the strip follows the pointer: {icon:?}, then {held:?}");
@@ -407,6 +471,64 @@ fn an_icon_floated_in_the_middle_band_lands_collapsed_under_the_pointer() {
assert!((settled.left() - floated.left()).abs() <= SLACK, "the strip stays: {floated:?}, then {settled:?}");
}
/// The rect of the collapsed window's layer: the smallest layer around its icon.
fn strip_window(bed: &Bed) -> Rect {
let icon = button_rect(bed, &title(WINDOW)).expect("the collapsed window shows its icon");
let layers = layer_rects(bed.fixture.ctx()).into_iter().filter(|rect| rect.contains(icon.center()));
layers.min_by(|a, b| a.area().total_cmp(&b.area())).expect("the window's layer holds its icon")
}
/// A point of a collapsed window's title band: the band's start, clear of the side grip (`size.handle.sm` deep) and
/// of the double arrow at the end the window keeps to.
fn strip_band(icon: Rect) -> Pos2 {
Pos2::new(icon.left() + 10.0, window_title().y)
}
/// A collapsed window's sides resize its width, and only its width, as a docked collapsed column's inner edge does:
/// the column's iconic width follows, names show beside the icons from the docked column's labels width on, the
/// column stays as tall as its icons, and the expanded rect keeps its size. The width stays across expanding and
/// collapsing again.
#[trial]
fn a_collapsed_windows_sides_resize_its_width_and_show_names_from_the_docked_columns_step() {
let mut bed = bed(collapsed_at(WINDOW_AT), |_| Permissions::ALL);
let sizes = IconicSizes::of(bed.fixture.ctx());
let height = sizes.icons_height(&bed.workspace.borrow().layout.floating[0].column);
let named = |bed: &Bed| bed.fixture.texts().iter().any(|run| run.text == title(WINDOW));
let height = height + bed.chrome.get();
let strip = strip_window(&bed);
assert!(!named(&bed), "a rail-wide strip shows no names");
assert!((strip.height() - height).abs() <= SLACK, "the window is as tall as its icons and its chrome: {strip:?}, {height}");
assert!((strip.right() - WINDOW_AT.right()).abs() <= SLACK, "the strip keeps to the end edge: {strip:?}");
// The start side faces the room; a press just inside it holds the window's grip.
let mut side = Pos2::new(strip.left() + 2.0, strip.center().y);
for width in [sizes.labels - 10.0, sizes.labels + 20.0] {
let by = Vec2::new(strip_window(&bed).width() - width, 0.0);
press_and_move(&mut bed.fixture, side, by);
bed.fixture.frame(vec![release(side + by)]);
bed.fixture.settle();
side += by;
let window = bed.workspace.borrow().layout.floating[0].clone();
let shown = strip_window(&bed);
let kept = window.column.iconic_width;
assert!(window.column.iconic && kept.is_some_and(|kept| (kept - width).abs() <= SLACK), "{width}: the column keeps the width: {window:?}");
assert!((shown.width() - width).abs() <= SLACK, "{width}: the strip shows at it: {shown:?}");
assert!((shown.height() - height).abs() <= SLACK, "{width}: the height stays its icons' and its chrome's: {shown:?}");
assert!(
(window.rect.min - WINDOW_AT.min).length() <= SLACK && window.rect.size() == WINDOW_AT.size(),
"{width}: the expanded rect stays: {window:?}"
);
assert_eq!(named(&bed), width >= sizes.labels, "{width}: names show from the labels width ({}) on", sizes.labels);
}
let resized = strip_window(&bed);
for iconic in [false, true] {
bed.workspace.borrow_mut().apply(Action::set_iconic(WINDOW, iconic), false, |_| Permissions::ALL).expect("the column toggles");
bed.fixture.settle();
}
let again = strip_window(&bed);
assert!((again.width() - resized.width()).abs() <= SLACK, "collapsed again, the strip keeps its width: {resized:?}, then {again:?}");
assert_eq!(bed.workspace.borrow().layout.floating[0].rect, WINDOW_AT, "the expanded rect is unchanged");
}
/// A floating collapsed column opens its flyouts towards the room of the float area, away from the edge it keeps to.
#[trial]
fn a_floating_collapsed_columns_flyout_opens_towards_the_room() {
@@ -426,13 +548,13 @@ fn a_floating_collapsed_columns_flyout_opens_towards_the_room() {
#[trial]
fn a_double_click_on_a_floating_windows_band_collapses_and_expands_its_column() {
let mut bed = bed(with_window(None), |_| Permissions::ALL);
let band = Pos2::new(WINDOW_AT.left() + 40.0, WINDOW_AT.top() + 6.0);
let band = Pos2::new(WINDOW_AT.left() + 40.0, window_title().y);
bed.fixture.click_at(band).click_at(band).settle();
let window = bed.workspace.borrow().layout.floating[0].clone();
assert!(window.column.iconic, "the band's double click collapsed the column: {:?}", bed.actions.borrow());
assert!(window.groups().iter().all(|group| !group.minimized), "no group minimized");
let icon = button_rect(&bed, &title(WINDOW)).expect("the collapsed window shows its icon");
let band = Pos2::new(icon.left() + 4.0, WINDOW_AT.top() + 6.0);
let band = strip_band(icon);
bed.fixture.click_at(band).click_at(band).settle();
assert!(!bed.workspace.borrow().layout.floating[0].column.iconic, "a second double click expanded it: {:?}", bed.actions.borrow());
}
@@ -653,6 +653,57 @@ fn a_native_palette_collapsed_moved_and_expanded_comes_back_at_its_size() {
assert!(max.is_none_or(|max| max.x >= expanded.x && max.y >= expanded.y), "the OS lets it take that size: max {max:?}");
}
/// On macOS a native palette collapsed to icons is a window AppKit resizes, in its width only: it opens resizable with
/// its height fixed to the strip's, the app stands no grips of its own at its sides, and a width the OS gives it is the
/// column's iconic width while the model keeps the expanded size; the app sends no size back.
#[trial]
fn a_collapsed_native_palette_on_macos_is_resized_by_appkit_in_its_width_only() {
let mut dock = NativeDock::on(Os::Mac, Arc::new(FakeSystem::new()));
let mut at = FLOAT_AT;
// The OS follows the window commands of each frame, and the window reports where it is.
let follow = |dock: &mut NativeDock, at: &mut Rect, events: Vec<Event>| {
let commands = dock.frame(events).1;
*at = placed_by(&commands, *at);
dock.windows.child_info(info(true, *at));
commands
};
dock.workspace.apply(Action::set_iconic(1, true), false, |_| Permissions::ALL).expect("the column collapses");
for _ in 0..3 {
follow(&mut dock, &mut at, vec![]);
}
let strip = at;
let builder = dock.builder.clone().expect("the palette's window opened");
assert_eq!(builder.resizable, Some(true), "the collapsed window is resizable");
let (least, most) = (builder.min_inner_size.expect("a least size"), builder.max_inner_size.expect("a most size"));
assert!(least.y == most.y && (least.y - strip.height()).abs() <= 0.5, "the height is fixed to the strip's: {least:?}..{most:?}, {strip:?}");
assert!(least.x < most.x, "the width resizes: {least:?}..{most:?}");
// A press and drag at the strip's free side, in its title row, clear of the double arrow at the end it keeps to:
// no app grip stands there, so nothing asks the OS for a resize.
let end = strip.max.x >= FLOAT_AT.max.x - 1.0 && strip.min.x > FLOAT_AT.min.x + 1.0;
let side = Pos2::new(if end { 2.0 } else { strip.width() - 2.0 }, 4.0);
let mut sent = Vec::new();
for events in [vec![moved(side)], vec![press(side)], vec![moved(side + Vec2::new(0.0, 1.0))], vec![release(side)], vec![]] {
sent.extend(follow(&mut dock, &mut at, events));
}
assert!(!sent.iter().any(|command| matches!(command, ViewportCommand::BeginResize(_))), "the app stands no grip: {sent:?}");
// AppKit widens the window.
let width = strip.width() + 60.0;
at = Rect::from_min_size(at.min, Vec2::new(width, at.height()));
dock.windows.child_info(info(true, at));
let mut sent = Vec::new();
for _ in 0..3 {
sent.extend(follow(&mut dock, &mut at, vec![]));
}
let palette = &dock.workspace.layout.floating[0];
assert!(palette.column.iconic_width.is_some_and(|kept| (kept - width).abs() <= 0.5), "the column keeps the width: {:?}", palette.column);
let recorded = palette.native.clone().expect("the model records the window");
assert_eq!(Vec2::from(recorded.normal.size), FLOAT_AT.size(), "the model keeps the expanded size");
assert!(!sent.iter().any(|command| matches!(command, ViewportCommand::InnerSize(_))), "no size goes back: {sent:?}");
assert_eq!(at.width(), width, "the window keeps the width the OS gave it");
}
/// On a display at 125 % (Windows), a click on the double arrow of a native palette collapsed to icons expands its
/// column, and the OS window takes its expanded size.
#[trial]
+21
View File
@@ -21,6 +21,27 @@
use crate::policy::MacInset;
/// How far AppKit's corner resize area reaches into a titled, resizable window along each edge: AppKit takes a press
/// there before the content sees it and shows its resize cursor. Measured on macOS 26 as a 19 pt square at each
/// corner, about 15 pt of it inside a square-cornered window
/// (<https://noheger.at/blog/2026/01/11/the-struggle-of-resizing-windows-on-macos-tahoe/>); there is no published
/// measurement for earlier releases.
pub const RESIZE_CORNER: f32 = 15.0;
/// How far AppKit's edge resize area reaches into the content between the corners: a few points; most of it lies
/// outside the window.
pub const RESIZE_EDGE: f32 = 4.0;
/// Whether `at`, in the coordinates of a window's content of `size` (points from its top-left corner), lies in
/// AppKit's resize areas: a [`RESIZE_CORNER`] square at each corner and a [`RESIZE_EDGE`] strip along each edge.
pub fn in_resize_area(size: [f32; 2], at: [f32; 2]) -> bool {
let [w, h] = size;
let [x, y] = at;
let inside = (0.0..=w).contains(&x) && (0.0..=h).contains(&y);
let near = |pos: f32, len: f32, reach: f32| pos <= reach || pos >= len - reach;
inside && ((near(x, w, RESIZE_CORNER) && near(y, h, RESIZE_CORNER)) || near(x, w, RESIZE_EDGE) || near(y, h, RESIZE_EDGE))
}
/// The three buttons as AppKit laid them out, in points.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Lights {
+187 -60
View File
@@ -127,6 +127,7 @@ Pure UI behaviours (layer 1): press lifecycle, `ValueDrag`, navigation, item lay
- `fn is_section(&self, at: usize) -> bool`. Whether the position is a section header, which a move skips.
- `fn enabled(&self, at: usize) -> bool`. Whether the position can take the lead.
- `fn row_len(&self, _row: usize) -> Option<usize>`. `RaggedGrid`: the number of positions in `row`; rows hold consecutive positions. `None` past the last row.
- `fn column_shift(&self, _from: usize, _to: usize) -> isize`. `RaggedGrid`: how many columns a vertical move from row `from` to row `to` shifts the column by, for rows that are
- `fn columns(&self) -> usize`. `Cell`: the cells of every position (a row of a sheet).
- `fn first_column(&self) -> Option<usize>`. `WrappedGrid`: the column of position 0 when the grid has blank cells before it (the leading days of a
- `fn rect(&self, _at: usize) -> Option<Rect>`. `Spatial`: where the position sits, in any one coordinate space.
@@ -422,7 +423,7 @@ Cursor requests as plain data and the rule that picks the winner (8.5).
- `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<CursorBadge> }, Outline { rings: Vec<Vec<Pos2>>, centre: bool, badge: Option<CursorBadge> }, Hand, Zoom { out: bool }, Tool { icon: IconId, hotspot: Vec2, badge: Option<CursorBadge> }, Badged { base: CursorIcon, badge: CursorBadge }, Turn { toward: Vec2 }, Distort { dir: Vec2 }, Skew { dir: Vec2 }, TypeOn { path: bool }, Locator, Arrow { hollow: bool }, PathText { start: bool, end: bool }, PointerTool { pointer: PointerGlyph, icon: IconId }, Hidden }`. 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<CursorBadge> }, Outline { rings: Vec<Vec<Pos2>>, centre: bool, badge: Option<CursorBadge> }, Hand, Zoom { out: bool }, Tool { icon: IconId, hotspot: Vec2, badge: Option<CursorBadge> }, Badged { base: CursorIcon, badge: CursorBadge }, Turn { toward: Vec2 }, Distort { dir: Vec2 }, Skew { dir: Vec2 }, TypeOn { path: bool }, Locator, Arrow { hollow: bool, toward: Option<Vec2> }, 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
- `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<Vec<Pos2>>) -> Self`. App shapes as closed rings, with no centre mark and no badge.
@@ -434,6 +435,7 @@ Cursor requests as plain data and the rule that picks the winner (8.5).
- `pub const fn skew(dir: Vec2) -> Self`. The skew pointer along screen direction `dir`.
- `pub const fn type_on(path: bool) -> Self`. The type tool's pointer, over a path when `path`.
- `pub const fn arrow(hollow: bool) -> Self`. An arrow with its tip on the hotspot, hollow when `hollow`.
- `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 badged(base: CursorIcon, badge: CursorBadge) -> Self`. A system cursor with a mark.
@@ -646,8 +648,9 @@ The dock model: the tree of splits over panel frames, the side of a group a drop
`EditorInput`: the one ordered input stream the IME engine produces and an editor part reads (18.4).
- `craft_behavior::editor::EditorInput`: `pub enum EditorInput { Text(Arc<str>), Move(NavMove, MoveMods), Delete { forward: bool, by: Granularity }, DeleteSurrounding { before: usize, after: usize, unit: SurroundingUnit }, Select { anchor: TextPos, focus: TextPos }, Preedit { text: Arc<str>, cursor: Option<Range<usize>> }, ImeCommit, Edit(EditCommand), Newline, Tab, Cancel }`. One input of an editor part.
- `pub const fn delete(forward: bool, by: Granularity) -> Self`. A `Delete` of `by`.
- `craft_behavior::editor::EditorInput`: `pub enum EditorInput { Text(Arc<str>), Move(NavMove, MoveMods), Delete { forward: bool, by: Granularity, shift: bool }, DeleteSurrounding { before: usize, after: usize, unit: SurroundingUnit }, Select { anchor: TextPos, focus: TextPos }, Preedit { text: Arc<str>, cursor: Option<Range<usize>> }, ImeCommit, Edit(EditCommand), Newline, Tab, BackTab, Cancel }`. One input of an editor part.
- `pub const fn delete(forward: bool, by: Granularity) -> Self`. A `Delete` of `by`, without Shift.
- `pub const fn delete_with_shift(forward: bool, by: Granularity, shift: bool) -> Self`. A `Delete` of `by` with Shift held when `shift`.
- `pub const fn delete_surrounding(before: usize, after: usize) -> Self`. A `DeleteSurrounding` of `before` and `after` characters.
- `pub const fn delete_surrounding_bytes(before: usize, after: usize) -> Self`. A `DeleteSurrounding` of `before` and `after` bytes of UTF-8 text, as winit reports it.
- `pub fn preedit(text: impl Into<Arc<str>>, cursor: Option<Range<usize>>) -> Self`. A `Preedit` of `text` with the IME's cursor.
@@ -667,14 +670,15 @@ When a component's remembered state is due for eviction.
The fit rules: which tabs, bar items or titles stay in a strip and which go to an overflow menu. [`fit`] and
- `craft_behavior::fit::Fit`: `pub struct Fit { pub shown: Vec<usize>, pub overflow: Vec<usize> }`. Which items the strip shows and which go to the overflow menu, as indexes into the input, in input order.
- `craft_behavior::fit::FitItem`: `pub struct FitItem { pub extent: f32, pub section: u16, pub keep: FitKeep }`. One item as the fit rule sees it: its extent along the strip, its section and whether it may overflow.
- `craft_behavior::fit::Fit`: `pub struct Fit { pub shown: Vec<usize>, pub overflow: Vec<usize>, pub short: Vec<usize> }`. Which items the strip shows and which go to the overflow menu, as indexes into the input, in input order.
- `craft_behavior::fit::FitItem`: `pub struct FitItem { pub extent: f32, pub section: u16, pub keep: FitKeep, pub short: Option<f32> }`. One item as the fit rule sees it: its extent along the strip, its section and whether it may overflow.
- `pub const fn new(extent: f32, section: u16, keep: FitKeep) -> Self`. An item `extent` long in `section`.
- `pub const fn short(mut self, extent: f32) -> Self`. The item with a shorter form `extent` long, which it takes before any free item leaves.
- `craft_behavior::fit::FitKeep`: `pub enum FitKeep { Free, Pinned, Menu }`. Whether an item may move into the overflow menu, or lives there.
- `craft_behavior::fit::TabFit`: `pub struct TabFit { pub shown: Vec<(usize, f32)>, pub overflow: Vec<usize>, pub overflow_width: f32 }`. Tabs visible on a strip and tabs that need an overflow menu, all in original order.
- `craft_behavior::fit::fit`: `pub fn fit(natural: &[f32], selected: usize, available: f32, minimum_width: f32, overflow_width: f32, keep_selected: bool) -> TabFit`. Fit tab widths into `available` points, shrinking the widest tabs first to a common cap.
- `craft_behavior::fit::fit_items`: `pub fn fit_items(items: &[FitItem], available: f32, gap: f32, section_gap: f32, overflow_extent: f32) -> Fit`. Decides which items stay in a strip `available` long. Everything fits and no item is `Menu`: all items show.
- `craft_behavior::fit::fit_whole`: `pub fn fit_whole(natural: &[f32], selected: usize, available: f32, overflow_width: f32) -> TabFit`. Fit tabs at their natural widths; the tabs that do not fit go to an overflow menu.
- `craft_behavior::fit::fit_whole`: `pub fn fit_whole(natural: &[f32], selected: usize, kept: &[bool], available: f32, overflow_width: f32) -> TabFit`. Fit tabs at their natural widths; the tabs that do not fit go to an overflow menu.
- `craft_behavior::fit::run_extent`: `pub fn run_extent(items: &[FitItem], shown: &[bool], gap: f64, section_gap: f64) -> f64`. The length of the items marked in `shown`, with `gap` between neighbours of a section and `section_gap` between
## `craft_behavior::flow`
@@ -762,6 +766,7 @@ Pure canvas geometry in document units: the transform box ([`quad`]), snapping (
- `craft_behavior::geometry::SnapKinds`: re-export of `craft_behavior::geometry::snap::SnapKinds`.
- `craft_behavior::geometry::SnapLine`: re-export of `craft_behavior::geometry::snap::SnapLine`.
- `craft_behavior::geometry::SnapOptions`: re-export of `craft_behavior::geometry::snap::SnapOptions`.
- `craft_behavior::geometry::SnapSuspend`: re-export of `craft_behavior::geometry::snap::SnapSuspend`.
- `craft_behavior::geometry::SnapTarget`: re-export of `craft_behavior::geometry::snap::SnapTarget`.
- `craft_behavior::geometry::SnapTargets`: re-export of `craft_behavior::geometry::snap::SnapTargets`.
- `craft_behavior::geometry::StrokeLock`: re-export of `craft_behavior::geometry::move_gesture::StrokeLock`.
@@ -980,7 +985,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 }`. What a plain corner or edge drag does.
- `craft_behavior::geometry::quad::ScaleRule`: `pub enum ScaleRule { Proportional, Free, 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
@@ -1013,7 +1018,9 @@ Box geometry of transform boxes: where the box goes when a part of it is dragged
- `pub fn without(self, kind: SnapKind) -> Self`. This set without `kind`.
- `pub fn contains(self, kind: SnapKind) -> bool`. Whether `kind` is in this set.
- `craft_behavior::geometry::snap::SnapLine`: `pub struct SnapLine { pub along: Axis, pub position: f64, pub kind: SnapKind, pub span: Option<(f64, f64)> }`. The line the UI draws for a snap that happened.
- `craft_behavior::geometry::snap::SnapOptions`: `pub struct SnapOptions { pub on: bool, pub guides: bool, pub grid: bool, pub layers: bool, pub document_bounds: bool, pub selection: bool, pub smart_guides: bool }`. View › Snap To and View › Show › Smart Guides, as the app stores them.
- `craft_behavior::geometry::snap::SnapOptions`: `pub struct SnapOptions { pub on: bool, pub guides: bool, pub grid: bool, pub layers: bool, pub document_bounds: bool, pub selection: bool, pub smart_guides: bool, pub suspend: SnapSuspend }`. View › Snap To and View › Show › Smart Guides, as the app stores them.
- `craft_behavior::geometry::snap::SnapSuspend`: `pub enum SnapSuspend { Control, Alt }`. The key that suspends snapping.
- `pub fn is_held(self, mods: Mods, os: Platform) -> bool`. Whether this key is held in `mods` on `os`: Control is the Control key without ⌘ on macOS and Ctrl
- `craft_behavior::geometry::snap::SnapTarget`: `pub struct SnapTarget { pub along: Axis, pub position: f64, pub kind: SnapKind, pub span: Option<(f64, f64)> }`. One snap position on one axis.
- `pub const fn new(along: Axis, position: f64, kind: SnapKind) -> Self`. A full-height line of `kind` running `along` an axis, at `position` across it: a line along `Axis::Y`
- `craft_behavior::geometry::snap::SnapTargets`: `pub struct SnapTargets`. The snap targets of one gesture.
@@ -1024,6 +1031,7 @@ Box geometry of transform boxes: where the box goes when a part of it is dragged
- `pub fn filtered(&self, keep: impl Fn(SnapKind) -> bool) -> SnapTargets`. Only the targets `keep` accepts (Snap To with one kind off).
- `pub fn is_empty(&self) -> bool`. Whether there is no target.
- `pub fn nearest_of(&self, along: Axis, value: f64, tolerance: f64, kinds: SnapKinds) -> Option<SnapTarget>`. The nearest target of a kind in `kinds` among the lines that run `along` an axis, within `tolerance` of
- `pub fn nearest_within(&self, along: Axis, value: f64, across: Option<(f64, f64)>, tolerance: f64, kinds: SnapKinds) -> Option<SnapTarget>`. [`nearest_of`](Self::nearest_of) that also takes the query's extent `across` the other axis: a target with a
- `pub fn nearest(&self, along: Axis, value: f64, tolerance: f64) -> Option<SnapTarget>`. The nearest target among the lines that run `along` an axis, within `tolerance` of `value` across them.
- `pub fn snap_point(&self, point: Point, tolerance: f64) -> (Point, Vec<SnapLine>)`. `point` snapped on each axis independently, with the lines to draw.
- `pub fn snap_point_of(&self, point: Point, tolerance: f64, kinds: SnapKinds) -> (Point, Vec<SnapLine>)`. [`snap_point`](Self::snap_point) to the targets of a kind in `kinds` only (a Distort corner snaps to guides
@@ -1102,7 +1110,7 @@ Intents: a key, an AccessKit action or typed text turned into meaning (spec 9.2)
- `pub const fn new(action: accesskit::Action, target: Option<PartRef>, data: Option<accesskit::ActionData>) -> Self`. A request for `action` on `target`.
- `craft_behavior::intent::EditCommand`: `pub enum EditCommand { Cut, Copy, Paste, SelectAll, Undo, Redo, Delete }`. An edit command a component lists in its `KeyUse` to receive it as `Intent::Edit`.
- `craft_behavior::intent::Granularity`: `pub enum Granularity { Unit, Word, Line, Paragraph, Document }`. How far a move reaches.
- `craft_behavior::intent::Intent`: `pub enum Intent { Activate, Submit, SubmitForce, Cancel, Move(NavMove, MoveMods), Delete { forward: bool, by: Granularity, shift: bool }, Space, TogglePick, Digit(u8), Rename, ContextMenu, Reset, Text(Arc<str>), Tab, Edit(EditCommand), SwitchPage { forward: bool }, MoveItem { front: bool, all_the_way: bool }, Open, Close, Access(AccessRequest) }`. What the runtime routes to a focused component.
- `craft_behavior::intent::Intent`: `pub enum Intent { Activate, Submit, SubmitForce, Cancel, Move(NavMove, MoveMods), Delete { forward: bool, by: Granularity, shift: bool }, Space, TogglePick, Digit(u8), Rename, ContextMenu, Reset, Text(Arc<str>), Tab, BackTab, Edit(EditCommand), SwitchPage { forward: bool }, MoveItem { front: bool, all_the_way: bool }, Open, Close, Access(AccessRequest) }`. What the runtime routes to a focused component.
- `pub const fn delete(forward: bool, by: Granularity) -> Intent`. `Delete` of `by`, forward or back.
- `pub const fn switch_page(forward: bool) -> Intent`. `SwitchPage` to the next page when `forward`.
- `pub const fn move_item(front: bool, all_the_way: bool) -> Intent`. `MoveItem` toward the front when `front`, all the way when `all_the_way`.
@@ -1129,6 +1137,7 @@ Item geometry: where each item of a collection sits for a scroll offset and view
- `fn hit(&self, point: Pos2, offset: ScrollPos) -> Option<usize>`. The item under `point`.
- `fn nav(&self) -> NavShape`. How arrow keys move through the items.
- `fn row_len(&self, _row: usize) -> Option<usize>`. `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
- `fn shown(&self, _at: usize) -> bool`. Whether item `at` takes a place in the layout; a hidden item (in a closed group) cannot take the lead.
- `fn cells(&self, _at: usize, _offset: ScrollPos, _out: &mut Vec<(ColumnKey, Rect)>)`. The cells of item `at`, with their rects.
- `fn grid(&self) -> Option<&GridView>`. Column virtualisation and sections of a sheet.
@@ -1306,6 +1315,7 @@ The navigation core (spec 9.5): shapes, the key-free outline, stepping, roving g
- `fn is_section(&self, at: usize) -> bool`. Whether the position is a section header, which a move skips.
- `fn enabled(&self, at: usize) -> bool`. Whether the position can take the lead.
- `fn row_len(&self, _row: usize) -> Option<usize>`. `RaggedGrid`: the number of positions in `row`; rows hold consecutive positions. `None` past the last row.
- `fn column_shift(&self, _from: usize, _to: usize) -> isize`. `RaggedGrid`: how many columns a vertical move from row `from` to row `to` shifts the column by, for rows that are
- `fn columns(&self) -> usize`. `Cell`: the cells of every position (a row of a sheet).
- `fn first_column(&self) -> Option<usize>`. `WrappedGrid`: the column of position 0 when the grid has blank cells before it (the leading days of a
- `fn rect(&self, _at: usize) -> Option<Rect>`. `Spatial`: where the position sits, in any one coordinate space.
@@ -1515,6 +1525,7 @@ Scroll positions and the range a scroll part shows.
- `craft_behavior::scroll::drag`: `pub fn drag(span: &ScrollSpan, track: f32, min_thumb: f32, delta: f32) -> Range<f64>`. The visible range after the thumb moved `delta` points along the track, kept inside the content range.
- `craft_behavior::scroll::jump`: `pub fn jump(span: &ScrollSpan, mv: NavMove) -> Option<Range<f64>>`. The visible range after a navigation move that scrolls: a page up or down, or to the start or the end of the
- `craft_behavior::scroll::page`: `pub fn page(span: &ScrollSpan, toward_end: bool) -> Range<f64>`. The visible range one visible length further toward the end (or the start), kept inside the content range.
- `craft_behavior::scroll::shifted`: `pub fn shifted(span: &ScrollSpan, shift: f64) -> Range<f64>`. Moves the visible range by `shift` content units, keeping it within the scrollable range.
- `craft_behavior::scroll::thumb`: `pub fn thumb(span: &ScrollSpan, track: f32, min_thumb: f32) -> (f32, f32)`. The thumb of `span` on a track `track` points long: its start along the track and its length, at least
## `craft_behavior::selection`
@@ -1792,10 +1803,12 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `fn item_layout_from(&self, _previous: Option<Self::ItemLayout>, source: &dyn ItemSource<Self::Key>, width: f32, _item: Option<Vec2>, cx: &StyleCx<'_>,) -> Self::ItemLayout`. The layout of `source` at `width`, given the layout of the last pass. An implementor may reuse `previous`
- `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<Vec2>, _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 ideal_width(&self, _item: Option<Vec2>, _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<Self::Key>, _env: &crate::runtime::env::Env) -> Option<Box<dyn ItemSource<Self::Key> + 's>>`. A view of `source` for this pass, such as the rows a filter keeps; `None` shows `source` as it is.
- `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<EditResponse<String>>`. 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`
- `fn header_cell(&mut self, _ui: &mut PaintUi<'_>, _column: &ColumnKey, _key: HostedKey, _rect: Rect)`. Hosts a component in the header cell of `column`, in `rect`, measured and shown under `key` (the column's index
- `fn rename_draft(&self, _key: &Self::Key) -> Option<String>`. The text the rename field of the item `key` opens with; `None` for the item's own text.
- `fn can_rename(&self, _key: &Self::Key) -> bool`. Whether the item `key` may be renamed; a rename request on another item does nothing.
- `fn can_drag(&self, _key: &Self::Key) -> bool`. Whether the item `key` may be dragged (reordered, moved in a free layout, or dragged to another collection).
@@ -1854,6 +1867,7 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `fn header_parts(&self, _cx: &MeasureCx<'_, Self>) -> HeaderParts`. The room the container's own parts take at the edges of its header's line (a menu button, a drag band). The
- `fn controls(&mut self, _ui: &mut Ui, _cx: &mut BodyCx<'_>)`. Fills the header's trailing region.
- `fn footer(&mut self, _ui: &mut Ui, _cx: &mut BodyCx<'_>)`. Fills the footer region.
- `fn body_end(&mut self, _ui: &mut Ui, _cx: &mut BodyCx<'_>)`. Fills the region under the body and above the footer, whatever the footer's place.
- `fn end(&mut self, _ui: &mut Ui, _cx: &mut BodyCx<'_>)`. Fills the end region, after the body.
- `fn closed(&mut self, _why: CloseReason)`. The container closed, and why: a layer's dismissal rule, a close the body or footer asked for with
- `fn placement_changed(&mut self, _change: &overlay::PlacementChange)`. The user moved or resized the container's layer: by the move band, a grip or the keyboard Move and Size
@@ -1888,12 +1902,12 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `craft_ui::contract::ShowCollection`: `pub trait ShowCollection: Collection + sealed::ShowCollection`. Shows a collection's items.
- `fn show_items<'r>(self, ui: &mut Ui, source: &dyn ItemSource<Self::Key>, item: &mut ItemFn<'r, Self>) -> Self::Output`. Shows the visible items of `source`, one `item` call each.
- `craft_ui::contract::ShowContainer`: `pub trait ShowContainer: Container + sealed::ShowContainer`. Shows a container with its body.
- `fn show<R>(self, ui: &mut Ui, body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R) -> Inner<Self::Output, R>`. Shows the container in the flow of `ui`.
- `fn show_at<R>(self, ui: &mut Ui, rect: Rect, body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R) -> Inner<Self::Output, R>`. Shows the container at `rect`, with no allocation: a frame over a split or a layer the parent places.
- `fn show_at_taking_room<R>(self, ui: &mut Ui, rect: Rect, body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R) -> Inner<Self::Output, R>`. Shows the container at `rect` and takes that rect's room in the flow of `ui`: what is shown after it lies
- `fn measure_in<R>(&mut self, ui: &Ui, proposal: Proposal, body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R) -> Vec2`. Measures the container with `body` without allocating: steps 1 to 5 under the id `show` would use next, with
- `fn show_with_tip<R>(self, ui: &mut Ui, body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R, tip: impl FnOnce(&mut Ui)) -> Inner<Self::Output, R>`. Shows the container with rich tooltip content.
- `fn show_at_with_tip<R>(self, ui: &mut Ui, rect: Rect, body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R, tip: impl FnOnce(&mut Ui),) -> Inner<Self::Output, R>`. Shows the container at `rect` with rich tooltip content.
- `fn show<R>(self, ui: &mut Ui, mut body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R) -> Inner<Self::Output, R>`. Shows the container in the flow of `ui`.
- `fn show_at<R>(self, ui: &mut Ui, rect: Rect, mut body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R) -> Inner<Self::Output, R>`. Shows the container at `rect`, with no allocation: a frame over a split or a layer the parent places.
- `fn show_at_taking_room<R>(self, ui: &mut Ui, rect: Rect, mut body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R) -> Inner<Self::Output, R>`. Shows the container at `rect` and takes that rect's room in the flow of `ui`: what is shown after it lies
- `fn measure_in<R>(&mut self, ui: &Ui, proposal: Proposal, mut body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R) -> Vec2`. Measures the container with `body` without allocating: steps 1 to 5 under the id `show` would use next, with
- `fn show_with_tip<R>(self, ui: &mut Ui, mut body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R, tip: impl FnOnce(&mut Ui)) -> Inner<Self::Output, R>`. Shows the container with rich tooltip content.
- `fn show_at_with_tip<R>(self, ui: &mut Ui, rect: Rect, mut body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R, tip: impl FnOnce(&mut Ui),) -> Inner<Self::Output, R>`. Shows the container at `rect` with rich tooltip content.
- `craft_ui::contract::ShowShape`: `pub trait ShowShape: sealed::ShowShape`. Which show trait applies, and the shape's default sense.
- `const KIND: ShapeKind`. The shape as a value.
- `const DEFAULT_SENSE: Sense`. Leaf `CLICK | FOCUS`; body empty; items `CLICK | DRAG | FOCUS | WHEEL | TAKE_FOCUS`.
@@ -1928,6 +1942,7 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `craft_ui::contract::BodyCx`: `pub struct BodyCx<'a> { pub id: Id, pub env: EnvView<'a>, pub resolved: &'a Resolved<'a>, pub rect: Rect, pub memory: &'a mut MemoryStage }`. What a body closure and the header, footer and empty hooks read: a view over the pipeline's memory stage
- `pub fn open_url(&mut self, url: &str, new_tab: bool)`. Asks the platform to open `url`, in a new tab where the platform has tabs and `new_tab` is set: the opener
- `pub fn take_pick_answer(&self, ticket: craft_host::PickId) -> Option<craft_host::Picked>`. 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 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.
@@ -2000,15 +2015,17 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `craft_ui::contract::ColumnAlign`: `pub enum ColumnAlign { Start, End }`. Where a column's content sits.
- `craft_ui::contract::ColumnCommands`: `pub enum ColumnCommands { Resize, MoveLeft, MoveRight }`. The commands of a column header (17.1): resize works from the keyboard through them, and the header menu lists
- `pub const ALL: [ColumnCommands; 3]`. Every header command, in menu order.
- `craft_ui::contract::ColumnEvent`: `pub enum ColumnEvent { Sort { key: ColumnKey, descending: bool }, Resized { key: ColumnKey, width: f32 }, Moved { key: ColumnKey, to: usize }, Shown { key: ColumnKey, shown: bool }, Unsorted, Reset }`. A change to the columns.
- `craft_ui::contract::ColumnEvent`: `pub enum ColumnEvent { Sort { key: ColumnKey, descending: bool }, Resized { key: ColumnKey, width: f32 }, Moved { key: ColumnKey, to: usize }, Shown { key: ColumnKey, shown: bool }, Unsorted, Reset, Removed { key: ColumnKey } }`. A change to the columns.
- `craft_ui::contract::ColumnKey`: re-export of `craft_behavior::columns::ColumnKey`.
- `craft_ui::contract::ColumnKind`: `pub enum ColumnKind { Content, Toggle(ToggleColumn) }`. What a column's cells are.
- `craft_ui::contract::ColumnRemove`: `pub struct ColumnRemove { pub name: Label, pub enabled: bool }`. The remove control of a column's header.
- `craft_ui::contract::ColumnRequest`: `pub enum ColumnRequest { Shown(ColumnKey, bool), Reset, Command(crate::contract::ColumnCommands) }`. What a pick in the header menu asks of the header, given back with `Cx::column_request`.
- `craft_ui::contract::ColumnSort`: `pub struct ColumnSort { pub key: ColumnKey, pub descending: bool }`. The column the rows are sorted by and the direction: the app's value, which it changes on `ColumnEvent::Sort`.
- `pub const fn new(key: ColumnKey, descending: bool) -> Self`. Rows sorted by `key`, descending when `descending`.
- `pub const fn ascending(key: ColumnKey) -> Self`. Rows sorted by `key`, ascending.
- `pub const fn descending(key: ColumnKey) -> Self`. Rows sorted by `key`, descending.
- `craft_ui::contract::ColumnSpec`: `pub struct ColumnSpec { pub key: ColumnKey, pub header: Label, pub width: ColumnWidth, pub resizable: bool, pub sortable: bool, pub movable: bool, pub frozen: bool, pub kind: ColumnKind, pub align: ColumnAlign, pub tabular: bool, pub first_descending: bool, pub icon: Option<craft_behavior::IconId>, pub tip: Option<Label>, pub max_share: Option<f32>, pub hideable: bool }`. One column of a collection.
- `craft_ui::contract::ColumnSpec`: `pub struct ColumnSpec { pub key: ColumnKey, pub header: Label, pub width: ColumnWidth, pub resizable: bool, pub sortable: bool, pub movable: bool, pub frozen: bool, pub kind: ColumnKind, pub align: ColumnAlign, pub tabular: bool, pub first_descending: bool, pub icon: Option<craft_behavior::IconId>, pub tip: Option<Label>, pub max_share: Option<f32>, pub hideable: bool, pub remove: Option<ColumnRemove> }`. One column of a collection.
- `pub fn removable(mut self, name: impl Into<Label>, enabled: bool) -> Self`. The column gets a remove control named `name` at its header's end, disabled unless `enabled`.
- `pub fn new(key: ColumnKey, header: impl Into<Label>, width: ColumnWidth) -> Self`. A content column with a header and a width; the other settings off.
- `pub fn toggle(key: ColumnKey, header: impl Into<Label>, toggle: ToggleColumn) -> Self`. A toggle column as wide as a toggle cell, with a header; the other settings off.
- `pub fn sortable(mut self) -> Self`. Activating the header sorts.
@@ -2066,6 +2083,7 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `pub const fn label_column(mut self, on: bool) -> Self`. The labelled rows of the body share the widest label as one column. A nested container with its own
- `pub const fn labels(mut self, scheme: LabelScheme) -> Self`. The labelled rows under the container show their labels in `scheme`: its regions, its body and every container
- `craft_ui::contract::ContextMenuRequest`: `pub struct ContextMenuRequest<K> { pub key: K, pub at: Pos2, pub column: Option<ColumnKey>, pub part: Option<PartRef> }`. A request for the context menu of an item. Collections never open menus: the app does.
- `pub fn new(key: K, at: Pos2) -> Self`. A request for the menu of `key` that opens at `at`, from the item itself: no column and no part. A component
- `craft_ui::contract::Cx`: `pub struct Cx<'a, C: Component> { pub core: &'a mut CxCore<'a>, pub style: &'a C::Style, pub mixed: bool }`. What component code reads and calls. It derefs to [`CxCore`] for reading only.
- `pub fn reset_part(&self) -> Option<PartRef>`. The part a reset aimed at, when it declared `own_reset`; `update` proposes the value with that part at its
- `pub fn layout_doc(&self, text: &crate::primitives::DocText<'_>) -> TextLayout`. Lays document `text` out `text.wrap` wide: the call `ContentPainterCx::layout` and `MeasureCx::layout_doc`
@@ -2075,6 +2093,7 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `pub fn part_activated(&self, part: impl Into<PartRef>) -> Option<FireSource>`. Where an activation of `part` came from this pass: `Key` for a keyboard activation while `part` is the
- `pub fn context_part(&self) -> Option<PartRef>`. The part this pass's context request was made at: the part under the pointer for a secondary click, the
- `pub fn context_requested(&self) -> bool`. Whether the component was asked for its context menu in this pass: a secondary click on it, the Menu key or
- `pub fn context_requests(&self) -> Vec<(Id, Rect)>`. The context requests made in this pass so far, in order: each component asked and the rect its menu opens at
- `pub fn roving_arrival(&mut self, member: Id)`. Names the member of this container's roving group (`ContainerProps.roving`) that Tab arrives at; the
- `pub fn focus_part(&mut self, part: impl Into<PartRef>)`. Moves focus to one of this component's focusable parts, in this pass: the rest of the pass reads the new
- `pub fn focus_own(&mut self)`. Moves focus to the component's own stop (not a part), under the rule of `focus_part`.
@@ -2111,10 +2130,15 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `fn begin(&mut self)`. Opens a gesture.
- `fn commit(&mut self)`. Commits the proposed value.
- `fn cancel(&mut self, reason: CancelReason)`. Cancels the running gesture.
- `craft_ui::contract::EditResponse`: `pub struct EditResponse<T> { pub response: Response, pub events: EditEvents<T>, pub submitted: bool, pub submit_mods: craft_keymap::Mods, pub left_by_tab: Option<bool>, pub escaped: bool, pub unparsed: bool, pub validity: Validity<T>, pub shown: Option<Mixed<Arc<T>>>, pub value_text: Option<String> }`. The output of a component that edits a value. Only `cx.edit_response()` builds it.
- `craft_ui::contract::EditResponse`: `pub struct EditResponse<T> { pub response: Response, pub events: EditEvents<T>, pub submitted: bool, pub submit_mods: craft_keymap::Mods, pub left_by_tab: Option<bool>, pub escaped: bool, pub unparsed: bool, pub validity: Validity<T>, pub shown: Option<Mixed<Arc<T>>>, pub value_text: Option<String>, pub tab: Option<bool>, pub caret: Option<usize>, pub hover: Hover }`. The output of a component that edits a value. Only `cx.edit_response()` builds it.
- `pub fn lifted(response: Response, events: EditEvents<T>, shown: Option<Mixed<Arc<T>>>) -> Self`. The response of a composite that edits one value through several child components: `events` are the edits of
- `pub fn value(&self) -> Option<&T>`. The latest value the pass's events carry: a proposal, a commit or a set; `None` when nothing was edited or no
- `pub fn map<U>(self, f: impl Fn(T) -> U) -> EditResponse<U>`. The response of a child component's edit as the response of the edit of a value built from it: the events, the
- `craft_ui::contract::EditorHandle`: `pub struct EditorHandle`. The editor part's widget, rect, purpose, focus and read-only state of this pass, which a body that runs inside a
- `pub fn report(&self, ctx: &egui::Context, state: EditorState<'_>)`. Reports the caret and composition to the input-method engine and puts the text facts in the running pass's
- `pub fn ime_receipt(&self, ctx: &egui::Context, before: ImeStamp, after: ImeStamp) -> bool`. Notes the input-method receipt between the stamps `before` and `after` for this editor part; true when the
- `pub fn ime_application_change(&self, ctx: &egui::Context)`. Notes an application change of this editor part's committed text.
- `pub fn ime_interrupt(&self, ctx: &egui::Context)`. Asks for the OS composition to be interrupted this pass, because this editor part refused an input method's
- `craft_ui::contract::EndRegion`: `pub struct EndRegion { pub full_height: bool, pub gap: Gap, pub rule: bool }`. An end region, filled by `Container::end`: content in reading order at the line's end edge, beside the body and
- `pub const fn new() -> Self`. An end region as high as the line, `space.gap.tight` from the body, with no rule.
- `pub const fn rule(mut self, on: bool) -> Self`. Whether a rule separates the end region from the body.
@@ -2170,7 +2194,9 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `fn take_reveal(&mut self, view: Rect) -> Option<Vec2>`. For a container that is its body's scroll owner with a view of its own: the reveal a child asked of it, as the
- `fn register_menu_bar(&mut self)`. Registers that this component is a menu bar that takes the menu-bar keys of the next input hook (9.7).
- `fn take_menu_keys(&mut self) -> Vec<MenuKey>`. The menu-bar keys of the pass: F10 or a lone Alt press focus the bar, Alt and a letter open a menu.
- `craft_ui::contract::FooterPlace`: `pub enum FooterPlace { Across, EndBottom, EndTop, Body }`. Where a footer region sits.
- `fn register_menu_bar_by_claim(&mut self)`. Registers this component as a menu bar like [`register_menu_bar`](Focus::register_menu_bar) that has no mnemonic
- `fn take_first_claimed(&mut self, chords: &[Chord]) -> Option<Chord>`. The earliest of `chords` that arrived this pass for this component, consuming it, so a caller applies the
- `craft_ui::contract::FooterPlace`: `pub enum FooterPlace { Across, EndBottom, EndTop, Body }`. Where a footer region sits. In every place, `Container::body_end` fills the body's column under its content, so
- `pub const fn in_end(self) -> bool`. Whether the footer sits in the end region.
- `craft_ui::contract::FooterRegion`: `pub struct FooterRegion { pub rule: bool, pub place: FooterPlace, pub gap: Option<Gap>, pub inset: Pad, pub status: bool }`. A footer region, filled by `Container::footer`.
- `pub const fn new() -> Self`. A footer across the container under the line, with no rule and no inset.
@@ -2216,6 +2242,7 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `fn measure(&mut self, cx: &MeasureCx<'_, H>, key: HostedKey, proposal: Proposal) -> Vec2`. The leaf's size at `proposal`, as `show` will show it under `key`.
- `fn show(self: Box<Self>, ui: &mut PaintUi<'_>, key: HostedKey, rect: Rect)`. Shows the leaf at `rect` under `key` and hands its output on.
- `craft_ui::contract::HostedKey`: `pub type HostedKey = (&'static str, usize)`. The key a hosted leaf is measured and shown under: the slot's name and its index among the host's slots.
- `craft_ui::contract::Hover`: `pub struct Hover { pub over: bool, pub entered: bool, pub left: bool, pub clicked: bool }`. A command-bound control's report of the pointer's stay over it.
- `craft_ui::contract::Input`: re-export of `craft_behavior::input::Input`.
- `craft_ui::contract::InsideLabel`: `pub struct InsideLabel`. What a control shows in its slot for a side label with `FieldLayout::Inside` (`EnvView::inside_label`): the
- `pub const PART: PartKey`. The part a control declares its slot as (`PartsCx::label_part`).
@@ -2247,7 +2274,7 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `pub fn show<R>(self, ui: &mut Ui, add: impl FnOnce(&mut Ui) -> R) -> Option<R>`. Runs `add` in a child `Ui` placed in flow in `ui`, or takes the remembered extent there; `None` when it did not
- `craft_ui::contract::LeadOnOpen`: `pub enum LeadOnOpen { Selected, First }`. Where the lead starts when the collection first shows rows.
- `craft_ui::contract::LeadSource`: `pub enum LeadSource { Keys, Pointer }`. What moved the lead.
- `craft_ui::contract::LeastWidth`: `pub enum LeastWidth { Popup, Dialog, DialogButton, DialogSideButton, Rail(std::num::NonZeroU8) }`. A size role that sets the least width of a container's content or of a button.
- `craft_ui::contract::LeastWidth`: `pub enum LeastWidth { Popup, Dialog, DialogButton, DialogSideButton, Rail(std::num::NonZeroU8), WideDialog, SideMenu }`. A size role that sets the least width of a container's content or of a button.
- `pub fn points(self, tokens: &craft_theme::Tokens) -> f32`. The width the role names in `tokens`.
- `craft_ui::contract::ListDrag`: `pub struct ListDrag<K> { pub list: Id, pub keys: Vec<K>, pub grabbed: K }`. What a row drag carries through the drag session (8.4).
- `pub fn new(list: Id, keys: Vec<K>, grabbed: K) -> Self`. A drag of `keys` from `list`, grabbed at `grabbed`.
@@ -2353,12 +2380,12 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `pub fn is_rtl(&self) -> bool`. Whether the owner lays out right to left: a layer its caller places by position mirrors its own geometry by it,
- `pub fn anchor_part(&self, part: impl Into<PartRef>) -> Anchor`. The anchor at the rect of the toggling part `part` of the owner. The layer's placement mirrors the side and
- `pub fn contain_popups_below(&mut self)`. Keeps the popups this component shows from here on, and every popup opened from them, below the component:
- `pub fn show<R>(&mut self, popup: PopupHandle, overlay: Overlay, body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R) -> Option<R>`. Shows the popup while its handle is open, on a popup surface, inside `POPUP_PAD`; the content is a body closure.
- `pub fn show_container<C: ShowContainer, R>(&mut self, popup: PopupHandle, container: C, body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R,) -> Option<Inner<C::Output, R>>`. Shows `container` as the layer of `popup`, through the container pipeline: its body step with the move band
- `pub fn show<R>(&mut self, popup: PopupHandle, overlay: Overlay, mut body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R) -> Option<R>`. Shows the popup while its handle is open, on a popup surface, inside `POPUP_PAD`; the content is a body closure.
- `pub fn show_container<C: ShowContainer, R>(&mut self, popup: PopupHandle, container: C, mut body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R,) -> Option<Inner<C::Output, R>>`. Shows `container` as the layer of `popup`, through the container pipeline: its body step with the move band
- `craft_ui::contract::Overlays`: `pub trait Overlays`. The `Cx` trait that registers popups.
- `fn popup(&mut self, name: &'static str) -> PopupHandle`. Registers the popup `name` of this component for this pass and returns its handle. A component registers every
- `craft_ui::contract::POPUP_PAD`: `pub const POPUP_PAD: Pad`. The padding of every popup surface around its content.
- `craft_ui::contract::Pad`: `pub enum Pad { None, Control, Regular, Roomy }`. The padding tier of a body.
- `craft_ui::contract::Pad`: `pub enum Pad { None, Control, Regular, Roomy, Page }`. The padding tier of a body.
- `craft_ui::contract::PadEdges`: `pub enum PadEdges { All, Block, Inline }`. The edges a container's padding tier applies to.
- `craft_ui::contract::PaintUi`: `pub struct PaintUi<'a> { pub env: &'a Env }`. What `paint` and `paint_over` get instead of a `Ui`.
- `pub fn draw(&self) -> Draw<'_>`. The content-paint API: text, rules, surfaces and shapes, recorded for the later steps. While the component
@@ -2372,6 +2399,7 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `pub fn labelled<C: Show>(&mut self, key: impl Hash + Debug, rect: Rect, label: Label, side: SideLabel, child: C) -> C::Output`. Runs the label step (B2) for one leaf child at `rect`: the label's placement beside or above the child, the
- `pub fn face<C: Show>(&mut self, part: impl Into<PartRef>, face: C)`. Paints `face` as the look of `part`: its style, surface and state fill from the part's state merged with the
- `pub fn face_in<C: Show>(&mut self, part: impl Into<PartRef>, face: C, ink: &Stateful<StyleColor>)`. `face`, for a face on a fill the composite draws for that part alone (a plate over a picture): the face reads
- `pub fn face_faded<C: Show>(&mut self, part: impl Into<PartRef>, face: C, share: f32)`. [`face`](Self::face) painted `share` as opaque as it would be (1 paints as `face` does, 0 paints nothing): a
- `pub fn reserve_slot(&self, clip: Rect) -> PaintSlot`. Reserves an empty shape at the end of the component's layer, clipped to `clip`, for shapes added later by code
- `pub fn content_painter<C: ContentPainter>(&self, cx: &Cx<'_, C>) -> ContentPainterCx<'_>`. The raw painter for an allowlisted content painter, clipped to the component's own rect. Its data paths paint
- `craft_ui::contract::PaneEdge`: `pub enum PaneEdge { Center, Start, End, Top, Bottom }`. Where a shell pane sits.
@@ -2390,6 +2418,7 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `pub fn focus_shape(self, shape: FocusShape) -> Self`. The shape the focus ring takes around the part.
- `pub fn flags(self, flags: Flags) -> Self`. Value flags of the part, merged into its state at step 12 and its sub-node at step 16.
- `pub fn over(self) -> Self`. The part sits above the body or items in the stacking order and is painted by `paint_over`.
- `pub fn exact_hit(self) -> Self`. The part's hit area is its shape as declared, never grown to the pointer's target size (`size.hit.target`): a
- `pub fn state_layer(self) -> Self`. The part's look is the plain state layer: the paint step fills its rect with `StyleCx::state_layer` in the
- `pub fn tooltip(self, tooltip: impl Into<Tooltip>) -> Self`. The part's tooltip.
- `pub fn value_part(self) -> Self`. The part shows the component's value: a double click on it resets the value, as one on the root does. A
@@ -2422,6 +2451,7 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `fn hover_pos(&self, part: impl Into<PartRef>) -> Option<Pos2>`. Where the pointer is over `part` this pass, in the component's layer space; `None` when `part` is not hovered.
- `fn press(&self) -> &PressState`. The component's own press.
- `fn hit(&self) -> bool`. The pointer is over the component's own shapes.
- `fn hover(&self) -> Hover`. The pointer's stay over the component: over it, entered, left, and clicked while it has stayed over.
- `fn activation(&self) -> Option<Activation>`. Set only when the component's own shapes won the press and it was released as a click, or
- `fn activated_member(&self) -> Option<Id>`. For an arena root, the member activated this pass.
- `fn take_wheel(&mut self) -> Option<Wheel>`. This pass's wheel share, once, with the pointer it came at (`Wheel::at`) in this component's egui layer space (8.3).
@@ -2505,7 +2535,7 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `pub const fn edge(mut self, edge: PaneEdge) -> Self`. The pane at `edge`.
- `pub const fn extent(mut self, extent: f32) -> Self`. The pane's size along its edge, exactly: the pane host shows it at this extent in every pass.
- `pub const fn at(mut self, rect: Rect) -> Self`. The pane in `rect`, which the caller laid out for this pass. The pane takes no room from its siblings.
- `craft_ui::contract::ShownRow`: `pub struct ShownRow<K> { pub key: K, pub rect: egui::Rect, pub cells: Vec<(ColumnKey, egui::Rect)>, pub openers: Vec<(crate::contract::ItemOpener, Response)> }`. The geometry of one row the collection showed this pass.
- `craft_ui::contract::ShownRow`: `pub struct ShownRow<K> { pub key: K, pub id: egui::Id, pub rect: egui::Rect, pub cells: Vec<(ColumnKey, egui::Rect)>, pub openers: Vec<(crate::contract::ItemOpener, Response)>, pub hovered: bool }`. The geometry of one row the collection showed this pass.
- `craft_ui::contract::SideLabel`: `pub struct SideLabel { pub kind: LabelKind, pub layout: FieldLayout, pub role: FieldLabelRole, pub scrub: bool, pub reset_dot: bool, pub icon: Option<IconSpec<'static>>, pub detail: Option<Label>, pub tooltip: Option<Tooltip> }`. What `ContainerProps.label` holds: how the label is shown and what it does. The text is `Common.label`.
- `pub const fn new() -> Self`. A text label beside its control that names it.
- `pub fn kind(mut self, kind: LabelKind) -> Self`. How the label is shown.
@@ -2524,7 +2554,9 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `pub fn around(self, extra: Vec2) -> Self`. The limits of a frame that holds a size with these limits and `extra` around it: both ends grow by `extra`.
- `pub fn clamp(self, size: Vec2) -> Vec2`. `size` within these limits; the minimum wins over a smaller maximum.
- `pub fn valid(self) -> bool`. Whether every value is finite and non-negative, the maximum is no less than the minimum and no value is
- `craft_ui::contract::Sizing`: `pub enum Sizing { Fill, FillWidth, Content }`. How a container's size follows its content.
- `craft_ui::contract::Sizing`: `pub enum Sizing { Fill, FillWidth, Content, FillHeight }`. How a container's size follows its content.
- `pub const fn content_width(self) -> bool`. Whether the width follows the content: `Content` and `FillHeight`.
- `pub const fn fills_height(self) -> bool`. Whether the height is the available height: `Fill` and `FillHeight`.
- `craft_ui::contract::Slot`: re-export of `craft_ui::runtime::memory::Slot`.
- `craft_ui::contract::SpaceAction`: `pub enum SpaceAction { Activate, ToggleCell, Preview, None }`. What Space does in a collection (Enter always activates the lead).
- `craft_ui::contract::Stateless`: `pub struct Stateless<F>`. A callback in props: a fn item or a capture-free closure, which is zero-sized, so its type alone says what it
@@ -2574,16 +2606,20 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st
- `fn label(&self) -> Label`. The label as given, a cheap clone.
- `fn words<L: WordSet + Send + Sync + 'static>(&self) -> Arc<L>`. The word set `L` in the language of the scope; built once per installed `Words`.
- `fn format(&self) -> &Format`. How the scope writes numbers: locale digits, separators and grouping.
- `craft_ui::contract::WrapWidth`: `pub enum WrapWidth { Dialog }`. A size role that sets the line length of the paragraphs in a container whose width comes from its content: a
- `craft_ui::contract::WrapWidth`: `pub enum WrapWidth { Dialog, Column }`. A size role that sets the line length of the paragraphs in a container whose width comes from its content: a
- `pub fn points(self, tokens: &craft_theme::Tokens) -> f32`. The width the role names in `tokens`.
- `craft_ui::contract::announce`: `pub fn announce(ctx: &Context, text: impl Into<String>, politeness: Politeness)`. Announces `text`; for code without a context. Components call `cx.announce`. The same announcement made again
- `craft_ui::contract::bind_tracked`: re-export of `craft_ui::bind_tracked` (defined outside these crates).
- `craft_ui::contract::clicked`: `pub fn clicked(response: &Response) -> bool`. Whether `response` reports a click, by pointer or by keyboard activation.
- `craft_ui::contract::item_part_open`: `pub fn item_part_open(ctx: &Context, item: Id, part: impl Into<craft_behavior::PartRef>) -> bool`. Whether a menu or popover hung from the part `part` of the item `item` (`ItemCx::part_opener`) is open: an item
- `craft_ui::contract::measure_item`: `pub fn measure_item<C>(ui: &mut Ui, item: &mut C, at: crate::runtime::access::SetPosition, proposal: craft_behavior::Proposal) -> Vec2 where C: super::Component + super::Props + super::Show,`. Measures `item` as the item at `at` of a set, under the id and the item facts [`show_item`] shows it with.
- `craft_ui::contract::pressed`: `pub fn pressed(response: &Response) -> bool`. Whether a pointer press went down on `response`'s component and is still held.
- `craft_ui::contract::register_contract`: re-export of `craft_ui_macros::register_contract` (outside these crates).
- `craft_ui::contract::request_rename`: `pub fn request_rename<K: Clone + Send + Sync + 'static>(ctx: &Context, collection: Id, key: &K)`. Asks the collection `collection` (the id it is built with, `Props::id`) to start renaming the item `key`. At its
- `craft_ui::contract::scroll_step`: `pub fn scroll_step(ctx: &Context, owner: Id, view: Rect, units: &[Rect], right: bool) -> bool`. Steps the scrolling body `owner` by one of its units: toward the right of the screen (`right`) or the left. `view`
- `craft_ui::contract::section_part`: `pub fn section_part<K: std::hash::Hash>(key: &K) -> craft_behavior::PartRef`. The part of a collection that stands for the section row `key` (`ItemSource::section_stop`): the item step builds
- `craft_ui::contract::show_item`: `pub fn show_item<C>(ui: &mut Ui, rect: Rect, item: C, at: crate::runtime::access::SetPosition) -> C::Output where C: super::Component + super::Props + super::Show,`. Shows `item` in `rect` as the item at `at` of a set, with the item facts a collection installs.
- `craft_ui::contract::show_item_in_flow`: `pub fn show_item_in_flow<C>(ui: &mut Ui, item: C, at: crate::runtime::access::SetPosition) -> C::Output where C: super::Component + super::Props + super::Show,`. Shows `item` in the flow of `ui` as the item at `at` of a set, taking the room the flow gives it.
- `craft_ui::contract::spec`: re-export of the module `craft_ui::runtime::motion::spec`.
- `craft_ui::contract::step_stop`: `pub fn step_stop(stops: &[usize], from: Option<usize>, forward: bool) -> Option<usize>`. The stop one step from the entry at `from` (a position in the entries), toward the end when `forward`. A step holds
- `craft_ui::contract::step_stops`: `pub fn step_stops<T>(entries: &[Entry<T>]) -> Vec<usize>`. The positions of the entries a step over a closed control stops on ([`Entry::is_stepped`]), in order.
@@ -2599,7 +2635,7 @@ The ghost layer's content (8.4, 8.5): the running drag's preview beside the poin
Chapter 15: the `Overlay` data, its presets, popup handles, `OverlayUi` and the overlay host.
- `craft_ui::contract::overlay::Anchor`: `pub enum Anchor { Rect(Rect), Response, Point(Pos2), Pointer, Corner(Rect, Align2) }`. Where an overlay hangs from.
- `craft_ui::contract::overlay::Anchor`: `pub enum Anchor { Rect(Rect), Response, Point(Pos2), Pointer, Corner(Rect, Align2), Parent }`. Where an overlay hangs from.
- `craft_ui::contract::overlay::Dismiss`: `pub struct Dismiss { pub outside: Outside, pub enter: bool, pub focus_left: bool, pub on_activate: bool, pub anchor_gone: bool, pub timeout: Option<f32> }`. When a layer closes by itself. Escape goes through the focus policy's `CancelRule`.
- `pub const fn new() -> Self`. An outside press closes; nothing else does.
- `pub const fn outside(mut self, outside: Outside) -> Self`. Sets what an outside press does.
@@ -2607,9 +2643,10 @@ Chapter 15: the `Overlay` data, its presets, popup handles, `OverlayUi` and the
- `pub const fn focus_left(mut self, on: bool) -> Self`. Closes when focus leaves the scope.
- `pub const fn on_activate(mut self, on: bool) -> Self`. Closes when a component inside is activated, except an opener toggling its popup.
- `pub const fn timeout(mut self, seconds: Option<f32>) -> Self`. Closes after `seconds`.
- `craft_ui::contract::overlay::FloatPlace`: `pub struct FloatPlace { pub pos: Option<Pos2> }`. Where a floating layer sits.
- `craft_ui::contract::overlay::FloatPlace`: `pub struct FloatPlace { pub pos: Option<Pos2>, pub corner: Align2 }`. Where a floating layer sits.
- `pub const fn centred() -> Self`. Centred in the viewport.
- `pub const fn at(pos: Pos2) -> Self`. At `pos`.
- `pub const fn at(pos: Pos2) -> Self`. With its left-top at `pos`.
- `pub const fn corner_at(pos: Pos2, corner: Align2) -> Self`. With its `corner` at `pos`.
- `craft_ui::contract::overlay::HOLD`: `pub const HOLD: f64`. The seconds a press must be held for `Trigger::Hold`.
- `craft_ui::contract::overlay::OpenFilter`: re-export of `craft_ui::runtime::overlay::OpenFilter`.
- `craft_ui::contract::overlay::Opener`: `pub struct Opener { pub id: Id, pub rect: Rect, pub layer: areas::Layer, pub trigger: Trigger, pub enabled: bool, pub anchor: Option<Anchor>, pub others: Vec<Opener> }`. A component that opens a free-standing popup, and how. A layer with several openers keeps the first as its
@@ -2657,8 +2694,8 @@ Chapter 15: the `Overlay` data, its presets, popup handles, `OverlayUi` and the
- `pub fn is_rtl(&self) -> bool`. Whether the owner lays out right to left: a layer its caller places by position mirrors its own geometry by it,
- `pub fn anchor_part(&self, part: impl Into<PartRef>) -> Anchor`. The anchor at the rect of the toggling part `part` of the owner. The layer's placement mirrors the side and
- `pub fn contain_popups_below(&mut self)`. Keeps the popups this component shows from here on, and every popup opened from them, below the component:
- `pub fn show<R>(&mut self, popup: PopupHandle, overlay: Overlay, body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R) -> Option<R>`. Shows the popup while its handle is open, on a popup surface, inside `POPUP_PAD`; the content is a body closure.
- `pub fn show_container<C: ShowContainer, R>(&mut self, popup: PopupHandle, container: C, body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R,) -> Option<Inner<C::Output, R>>`. Shows `container` as the layer of `popup`, through the container pipeline: its body step with the move band
- `pub fn show<R>(&mut self, popup: PopupHandle, overlay: Overlay, mut body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R) -> Option<R>`. Shows the popup while its handle is open, on a popup surface, inside `POPUP_PAD`; the content is a body closure.
- `pub fn show_container<C: ShowContainer, R>(&mut self, popup: PopupHandle, container: C, mut body: impl FnMut(&mut Ui, &mut BodyCx<'_>) -> R,) -> Option<Inner<C::Output, R>>`. Shows `container` as the layer of `popup`, through the container pipeline: its body step with the move band
- `craft_ui::contract::overlay::Overlays`: `pub trait Overlays`. The `Cx` trait that registers popups.
- `fn popup(&mut self, name: &'static str) -> PopupHandle`. Registers the popup `name` of this component for this pass and returns its handle. A component registers every
- `craft_ui::contract::overlay::Place`: `pub enum Place { Anchored { anchor: Anchor, side: Side, align: Align, flips_across: bool }, Float(FloatPlace) }`. Where an egui layer sits.
@@ -2738,6 +2775,7 @@ The toast host (15.5): one layer per window root (its id derives from the scope
- `craft_ui::contract::tooltip::DELAY`: `pub const DELAY: f64`. Seconds the pointer rests on a component before its tooltip shows.
- `craft_ui::contract::tooltip::GRACE`: `pub const GRACE: f64`. Seconds after a tooltip hides during which the next one shows at once.
- `craft_ui::contract::tooltip::TipStyle`: `pub struct TipStyle`. The look of a tooltip card.
- `craft_ui::contract::tooltip::at_pointer`: `pub fn at_pointer(ui: &Ui, owner: egui::Id, tip: Option<&Tooltip>, at: Option<egui::Pos2>, pressed: bool)`. Shows `tip` at the pointer for a surface whose tips have no part of their own (a canvas tool's hover tip): the same
- `craft_ui::contract::tooltip::attach`: `pub fn attach(response: &egui::Response, tooltip: &Tooltip)`. Shows `tooltip` for a raw egui response during the app migration: the same delay, grace and placement as a
- `craft_ui::contract::tooltip::with_chord`: `pub fn with_chord(base: &str, chord: &craft_keymap::Chord, os: craft_keymap::Platform) -> String`. A tooltip's text followed by the chord that does the same, as every tooltip shows a key: "Hide Layers (⌘,)".
@@ -2769,8 +2807,10 @@ The layout services: `LabelColumn`, `ColumnGroup`, the `Grid` cursor, `measure_s
- `craft_ui::layout::arrange`: `pub fn arrange(ui: &mut Ui, layout: &dyn Arrangement, children: &mut [Placed<'_>]) -> Rect`. Places `children` by `layout` in the rest of `ui` and shows each once. The placement is logical; its output
- `craft_ui::layout::control_baseline`: `pub fn control_baseline(ctx: &egui::Context, id: Id, label: Vec2, label_baseline: f32) -> Option<f32>`. The control's first baseline from its top, as `record_control_baseline` stored it last pass. A control that paints
- `craft_ui::layout::empty_cell`: `pub fn empty_cell(ui: &mut Ui)`. Leaves the next cell of the `Grid` body that encloses `ui` directly empty: the next child takes the cell after it.
- `craft_ui::layout::levelled_unit`: `pub fn levelled_unit(ui: &mut Ui, key: Id, levels: usize, mut show: impl FnMut(&mut Ui, usize))`. Shows `show`, one unit of the unwrapped `Row` body around it that fits in discrete levels (a ribbon group: full,
- `craft_ui::layout::measure_slot`: `pub fn measure_slot(ui: &mut Ui, width: f32, body: impl FnOnce(&mut Ui)) -> Vec2`. Runs `body` in an invisible sizing pass `width` wide and returns the size it took. Nothing is allocated in
- `craft_ui::layout::place_label`: `pub fn place_label(ui: &Ui, id: Id, column: &LabelColumn, flow: Flow, label: Vec2, label_baseline: f32) -> LabelPlacement`. Places a label of `label` size with baseline `label_baseline` and the control of the row `id` in `flow`'s
- `craft_ui::layout::plan_levels`: `pub fn plan_levels(units: &[Vec<f32>], room: f32) -> Vec<usize>`. The level of each unit of a row whose units show in discrete levels, for `room`. `units` holds each unit's width
- `craft_ui::layout::record_control_baseline`: `pub fn record_control_baseline(ui: &Ui, id: Id, baseline: f32)`. Stores the distance from the top of the control of the row `id` to its first baseline, for the next
- `craft_ui::layout::shrink_widths`: `pub fn shrink_widths(units: &[ShrinkUnit], fixed: f32, room: f32, order: ShrinkOrder) -> Vec<f32>`. The widths of the units of a row whose units, with `fixed` (its other children and gaps), ask for more than `room`:
@@ -2786,13 +2826,15 @@ Painters, `Draw`, the sensing core, the text adapter and `ImeSurface`.
- `craft_ui::primitives::AppIcons`: `pub struct AppIcons { pub name: &'static str, pub stroke_width: Option<f32>, pub icons: &'static [(&'static str, &'static [u8])] }`. An app's own icon set: SVG documents drawn beside the built-in catalog in every `IconSet`.
- `pub const fn new(name: &'static str, stroke_width: Option<f32>, icons: &'static [(&'static str, &'static [u8])]) -> Self`. The set `name` of `icons`, each an icon name and its SVG document, drawn with `stroke_width` when it is `Some`.
- `craft_ui::primitives::CachedTexture`: `pub struct CachedTexture { pub id: TextureId, pub size: PixelSize }`. A stored picture as a painter draws it: `painter.image(texture.id, rect, uv, tint)`.
- `pub fn size_vec2(&self) -> Vec2`. `size` as a vector, for fitting: only the aspect matters to a cell.
- `pub fn sized(&self) -> SizedTexture`. The texture with its size, the form `PreviewPane` and egui's image widgets take.
- `craft_ui::primitives::CachedTexture`: `pub struct CachedTexture { pub id: TextureId, pub size: PixelSize, pub origin: [u32; 2], pub page: PixelSize }`. A stored picture as a painter draws it: `painter.image(texture.id, rect, uv, tint)`.
- `pub fn uv(&self) -> Rect`. The picture's part of its page texture, in uv coordinates, to paint with `id`: the full rect for an unpacked
- `pub fn size_vec2(&self) -> Vec2`. `size` as a vector, for fitting: only the aspect matters to a cell. It is the picture's own size, also for a
- `pub fn sized(&self) -> SizedTexture`. The texture with its size, the form `PreviewPane` and egui's image widgets take. Those draw the whole
- `craft_ui::primitives::Checker`: `pub struct Checker { pub size: Option<f32>, pub light: Option<DataColor>, pub dark: Option<DataColor> }`. The cells of the transparency checkerboard: their side and the two colours. A field left unset takes the
- `pub const fn new() -> Self`. The theme's checker.
- `pub const fn size(mut self, size: f32) -> Self`. Cells of `size` points.
- `pub const fn colors(mut self, light: DataColor, dark: DataColor) -> Self`. The light and dark colours.
- `pub fn polygon_shape(&self, ctx: &Context, tokens: &UiTokens, corners: &[Pos2], origin: Pos2) -> Shape`. The checkerboard over the convex polygon `corners` as one textured mesh, a light cell with its top-left corner at
- `pub fn shape(&self, ctx: &Context, tokens: &UiTokens, area: CheckerArea, origin: Pos2) -> Shape`. The checkerboard over `area` as one textured shape: square cells of the light and dark colours, a light cell
- `craft_ui::primitives::CheckerArea`: `pub enum CheckerArea { Rect(Rect, CornerRadius), Quad([Pos2; 4]) }`. Where a [`Checker`] paints.
- `craft_ui::primitives::ChordText`: `pub struct ChordText`. A chord formatted for the OS, as one text run laid out as its own left-to-right run.
@@ -2809,6 +2851,7 @@ Painters, `Draw`, the sensing core, the text adapter and `ImeSurface`.
- `pub fn ink(&self) -> Color32`. The colour of text and glyphs on the surface being painted: the resolved content-text colour `Draw` paints
- `pub fn stroke_width(&self, width: StrokeWidth) -> f32`. The width in points of a named stroke width on this display, as `Draw::stroke` strokes it: a content painter
- `pub fn faded(&self, share: f32, paint: impl FnOnce(&ContentPainterCx<'_>))`. Runs `paint` with a `ContentPainterCx` whose painting is `share` as opaque as it would be: the fade
- `pub fn clipped(&self, rect: egui::Rect, paint: impl FnOnce(&ContentPainterCx<'_>))`. Runs `paint` with a `ContentPainterCx` whose painting is clipped to `rect` (inside the clip it already has).
- `pub fn layout(&self, text: &DocText<'_>) -> TextLayout`. The one sanctioned text layout for content painters: document runs with their own font, size and colour,
- `craft_ui::primitives::Dashes`: `pub struct Dashes { pub dash: f32, pub gap: f32, pub phase: f32 }`. The lengths of a dashed stroke, in points along the path.
- `pub fn new(dash: f32, gap: f32) -> Self`. Dashes of `dash` with gaps of `gap`, starting at the pattern's beginning.
@@ -2837,7 +2880,9 @@ Painters, `Draw`, the sensing core, the text adapter and `ImeSurface`.
- `pub fn text_on_line(&self, rect: Rect, run: &TextRun<'_>, line: TypeRole) -> TextLayout`. Paints a one-line `run` as `text` does, on the baseline of a line of `line` centred on the middle of `rect`'s
- `pub fn line_baseline(&self, centre: f32, role: TypeRole) -> f32`. The baseline of a control's line of `role` whose centre line lies at `centre`: every text in the line sits on
- `pub fn doc(&self, rect: Rect, text: &DocText<'_>) -> TextLayout`. Lays `text` out in `rect`'s width and paints it top aligned, its block placed in `rect` by `text.align` (Start
- `pub fn face_run(&self, start: Pos2, run: &FaceRun<'_>, load: impl FnOnce() -> Option<FaceBytes>) -> TextLayout`. Paints `run` in its document face with the start of its first baseline at `start`, and returns its layout, whose
- `pub fn layout(&self, run: &TextRun<'_>, max_width: f32) -> TextLayout`. Lays `run` out in `max_width` without painting it: the one text layout path for painters that measure before
- `pub fn drop_label(&self)`. Records that the face dropped its label, so the component's tooltip text does not count it.
- `pub fn galley(&self, pos: Pos2, layout: &TextLayout)`. Paints a laid-out run at `pos`. Records the first baseline and, when the layout cut text, the full text, as
- `pub fn icon(&self, rect: Rect, icon: &super::IconSpec<'_>)`. Paints `icon` centred in `rect`, in the colour or ink the spec names, mirrored under right-to-left when it is
- `pub fn reset_mark(&self, look: &crate::style::ResetMarkLook, center: Pos2, differs: bool)`. Paints the reset mark of `look` centred on `center`: the dot while the value `differs`, else the ring.
@@ -2854,8 +2899,10 @@ Painters, `Draw`, the sensing core, the text adapter and `ImeSurface`.
- `pub fn stroke(&self, shape: &PaintShape, width: impl Into<DataStrokeWidth>, color: impl Into<StrokeColor>)`. Strokes `shape` at a theme width or a width from the document, in a theme colour or a colour from data (a
- `pub fn data_fill(&self, shape: &PaintShape, color: DataColor)`. Fills `shape` with a colour from data (a swatch well, a layer label dot, an avatar). A component that paints its
- `pub fn texture(&self, rect: Rect, texture: TextureId, uv: Rect)`. Paints the part `uv` of `texture` (from `TextureCache` or a `TextureStore`) into `rect`, untinted. The picture
- `pub fn texture_quad(&self, corners: [Pos2; 4], texture: TextureId, uv: Rect)`. Paints `uv` of `texture` onto the clockwise quad `corners` (from `uv`'s top left), untinted, as data: a
- `pub fn checker(&self, checker: &super::Checker, rect: Rect, radius: CornerRadius)`. Paints `checker` over `rect` with corners `radius`, a light cell at the rect's top left. It shows through data,
- `pub fn swatch_well(&self, well: Rect, radius: CornerRadius, color: Option<Srgba>)`. Paints the well of a colour swatch over `well` with corners `radius`: the colour, over a checkerboard where it is
- `pub fn swatch_polygon_well(&self, corners: &[Pos2], color: Option<Srgba>)`. [`Self::swatch_well`] over the convex polygon `corners` (a honeycomb cell): the same parts, the checkerboard and
- `pub fn dashed(&self, path: &[Pos2], pattern: Dashes, width: impl Into<DataStrokeWidth>, color: impl Into<StrokeColor>)`. Strokes the open path `path` as dashes (copy marks, drag previews, reference lines), with the width and colour
- `pub fn dashes(&self) -> Dashes`. The theme's dash pattern: `stroke.dash` dashes with `stroke.dash_gap` gaps.
- `pub fn clipped(&self, rect: Rect, paint: impl FnOnce(&Draw<'_>))`. Runs `paint` with a `Draw` whose painting is cut to `rect` (inside the clip already in force): scrolled content
@@ -2865,8 +2912,15 @@ Painters, `Draw`, the sensing core, the text adapter and `ImeSurface`.
- `craft_ui::primitives::EditorPurpose`: `pub enum EditorPurpose { Text, Code, Number, Password }`. What an editor part edits.
- `craft_ui::primitives::EditorRun`: `pub struct EditorRun<'a> { pub bytes: Range<usize>, pub rtl: bool, pub positions: &'a [f32], pub widths: &'a [f32] }`. One bidi run of a line: its bytes, direction, each character's start offset and advance.
- `pub const fn new(bytes: Range<usize>, rtl: bool, positions: &'a [f32], widths: &'a [f32]) -> Self`. A run over `bytes`.
- `craft_ui::primitives::EditorState`: `pub struct EditorState<'a> { pub caret: Rect, pub lines: &'a [EditorLine<'a>], pub caret_at: TextPos, pub selection: Option<(TextPos, TextPos)>, pub composing: bool, pub can_undo: bool, pub can_redo: bool }`. What an own-caret editor reports once per frame for the IME and AccessKit.
- `craft_ui::primitives::EditorState`: `pub struct EditorState<'a> { pub caret: Rect, pub lines: &'a [EditorLine<'a>], pub caret_at: TextPos, pub selection: Option<(TextPos, TextPos)>, pub composing: bool, pub shows_marked: bool, pub can_undo: bool, pub can_redo: bool, pub surrounding: Option<(u64, EditorSurrounding<'a>)> }`. What an own-caret editor reports once per frame for the IME and AccessKit.
- `pub fn surrounding(mut self, epoch: u64, s: EditorSurrounding<'a>) -> Self`. Reports `s` as the committed text around the caret, for the input-method target at `epoch`.
- `pub const fn new(caret: Rect, lines: &'a [EditorLine<'a>], caret_at: TextPos) -> Self`. A state with no selection, no marked text and nothing to undo.
- `pub const fn marked(mut self, composing: bool) -> Self`. Reports an editor that draws the input method's marked text, `composing` while it shows some
- `craft_ui::primitives::EditorSurrounding`: re-export of `craft_ui::runtime::ime::EditorSurrounding`.
- `craft_ui::primitives::FaceRun`: `pub struct FaceRun<'a> { pub text: &'a str, pub key: &'a str, pub size: f32, pub color: DataColor }`. A run of text in one face of a document's fonts, which [`Draw::face_run`](super::Draw::face_run) draws on a
- `pub const fn new(text: &'a str, key: &'a str, size: f32, color: DataColor) -> Self`. `text` in the face `key` at `size` points in `color`.
- `pub fn largest_size(ctx: &Context) -> f32`. The largest size, in points, a face run is drawn at on `ctx`'s display: a glyph stays within a quarter of the
- `pub fn drawn_size(&self, ctx: &Context) -> f32`. The size the run is drawn at on `ctx`'s display: its own, within 1 point and [`largest_size`](Self::largest_size).
- `craft_ui::primitives::FacesCx`: `pub trait FacesCx`. Where a document face is asked for: a component's context, its measure or a content painter.
- `fn document_face(&self, key: &str, load: impl FnOnce() -> Option<FaceBytes>) -> FaceState`. The face registered under `key` as a family of its own. `load` runs only for a new key within the frame's
- `craft_ui::primitives::FakeThumbSource`: `pub struct FakeThumbSource<K>`. A [`ThumbSource`] for stories and tests in every crate: pictures made from the key and a revision the test sets,
@@ -2886,13 +2940,14 @@ Painters, `Draw`, the sensing core, the text adapter and `ImeSurface`.
- `fn directional(&self) -> bool`. Whether the glyph has a reading direction (an arrow) and so flips under right-to-left.
- `fn paint(&self, painter: &Painter, tokens: &UiTokens, rect: Rect, color: Color32, mirrored: bool)`. Paints the glyph into `rect` in `color`, with the strokes of `tokens`. `mirrored` is set when a directional
- `craft_ui::primitives::GridAxis`: `pub struct GridAxis { pub minor: Vec<f64>, pub major: Vec<f64> }`. The lines of one axis: positions along it, in the grid's space.
- `craft_ui::primitives::GridCrowding`: `pub enum GridCrowding { Hide, Thin }`. What a grid does when its lines come closer than the minimum step.
- `craft_ui::primitives::GridInk`: `pub struct GridInk { pub major: Option<DataColor>, pub minor: Option<DataColor>, pub stroke: GridStroke }`. The colours a grid's lines take; an unset one is the theme's.
- `pub const fn new() -> Self`. The theme's colours and solid lines.
- `pub const fn major(mut self, color: DataColor) -> Self`. The major lines in `color`.
- `pub const fn minor(mut self, color: DataColor) -> Self`. The minor lines in `color`.
- `pub const fn stroke(mut self, stroke: GridStroke) -> Self`. The lines drawn as `stroke`.
- `craft_ui::primitives::GridLines`: `pub struct GridLines { pub x: GridAxis, pub y: GridAxis, pub extent: Option<kurbo::Rect>, pub crossings: bool, pub view: Option<CanvasView> }`. The lines of a grid, as [`grid_lines`] draws them: vertical lines (by x) and horizontal lines (by y), each
- `pub fn document(view: &CanvasView, extent: kurbo::Rect, spacing: kurbo::Vec2, origin: kurbo::Point, subdivisions: u32) -> Self`. The lines of a grid in document units: majors every `spacing` from `origin`, `subdivisions` steps to a major
- `pub fn document(view: &CanvasView, extent: kurbo::Rect, spacing: kurbo::Vec2, origin: kurbo::Point, subdivisions: u32, crowding: GridCrowding,) -> Self`. The lines of a grid in document units: majors every `spacing` from `origin`, `subdivisions` steps to a major
- `pub fn screen(rect: Rect, spacing: Vec2, clip: Rect, pixels_per_point: f32) -> Self`. The lines over `rect` that `clip` shows, every `spacing` points from the rect's top-left corner, all major.
- `craft_ui::primitives::GridLook`: `pub struct GridLook`. What the lines of a grid read from the tokens: the line colour and width, and the dash and gap lengths.
- `pub fn of(tokens: &UiTokens) -> Self`. The grid look of `tokens`.
@@ -2904,9 +2959,12 @@ Painters, `Draw`, the sensing core, the text adapter and `ImeSurface`.
- `craft_ui::primitives::HandleShape`: `pub enum HandleShape { Square, Circle, Diamond }`. The outline of a handle.
- `craft_ui::primitives::HiddenContent`: `pub struct HiddenContent { pub left: f32, pub right: f32, pub top: f32, pub bottom: f32 }`. How far a scroll view's content runs past each of its edges, in points.
- `pub fn new(content: Vec2, view: Vec2, offset: Vec2, rtl: bool) -> Self`. The content of `content` points past a view of `view` points scrolled by `offset`, with x counted from the
- `craft_ui::primitives::IconMark`: `pub enum IconMark { Dot(DataColor), Bar { color: DataColor, weight: Option<f32> } }`. A data-colour mark on an icon.
- `pub const fn bar(color: DataColor) -> Self`. A bar of `color` with the default thickness.
- `pub const fn weighted_bar(color: DataColor, weight: f32) -> Self`. A bar of `color` `weight` points thick.
- `craft_ui::primitives::IconSet`: re-export of `craft_ui::primitives::icon::IconSet` (defined outside these crates).
- `craft_ui::primitives::IconSource`: `pub enum IconSource<'a> { Svg(IconId), Glyph(&'a(dyn Glyph + 'static)), Swatch(Option<Srgba>), Disc, Initial(char), Mark(craft_behavior::CursorBadge) }`. Where an icon's drawing comes from.
- `craft_ui::primitives::IconSpec`: `pub struct IconSpec<'a> { pub source: IconSource<'a>, pub ink: Ink, pub color: Option<StyleColor>, pub mirror: Mirror, pub badge: Option<DataColor> }`. An icon to paint.
- `craft_ui::primitives::IconSpec`: `pub struct IconSpec<'a> { pub source: IconSource<'a>, pub ink: Ink, pub color: Option<StyleColor>, pub mirror: Mirror, pub badge: Option<IconMark> }`. An icon to paint.
- `pub fn svg(id: IconId) -> Self`. An icon of the SVG set or a tool icon, in the panel ink.
- `pub fn mark(badge: craft_behavior::CursorBadge) -> IconSpec<'a>`. An icon whose glyph is the mark of the cursor `badge` (the plus or minus drawn at the cursor), painted by the
- `pub fn glyph(glyph: &'a(dyn Glyph + 'static)) -> Self`. An icon of `glyph` in the panel ink.
@@ -2919,6 +2977,8 @@ Painters, `Draw`, the sensing core, the text adapter and `ImeSurface`.
- `pub fn data_color(mut self, color: DataColor) -> Self`. Sets the colour from data, in place of the ink's: an icon drawn in document content (an annotation pictogram),
- `pub fn mirror(mut self, mirror: Mirror) -> Self`. Sets the mirroring.
- `pub fn badge(mut self, color: DataColor) -> Self`. Adds a dot of `color` at the bottom-trailing corner of an SVG or glyph icon, ringed in the icon's colour: the
- `pub fn with_mark(mut self, mark: IconMark) -> Self`. Puts `mark` on the icon in place of any mark it has.
- `craft_ui::primitives::ImeStamp`: re-export of `craft_ui::primitives::text_input::ImeStamp` (defined outside these crates).
- `craft_ui::primitives::ImeSurface`: `pub struct ImeSurface`. The handle of an editor part's focus widget.
- `craft_ui::primitives::LayoutRun`: `pub struct LayoutRun { pub bytes: Range<usize>, pub rtl: bool, pub positions: Vec<f32>, pub widths: Vec<f32> }`. One direction run of a single-row layout, owned.
- `craft_ui::primitives::LeastLayout`: `pub struct LeastLayout { pub whole: TextLayout, pub width: f32 }`. A run laid out whole on its line, and its width at its readable least: what a text that elides measures at
@@ -2976,8 +3036,9 @@ Painters, `Draw`, the sensing core, the text adapter and `ImeSurface`.
- `pub fn strip_arrow(strip: Rect, back: bool, color: Color32) -> Shape`. The filled arrow of a scroll strip, centred in `strip`: pointing up for the strip before the view (`back`),
- `pub fn thumb(min_thumb: f32, track: Rect, axis: Axis, rtl: bool, span: &ScrollSpan) -> Rect`. The thumb inside `track`, a bar along `axis`, for `span`: its length is the shown share of the track, at least
- `pub fn shapes(look: &ScrollBarLook, track: Rect, axis: Axis, rtl: bool, span: &ScrollSpan, state: &StateSet) -> Vec<Shape>`. The shapes of the bar in `track` along `axis` for `span`, in `state` (the bar's: hovered while the pointer is
- `craft_ui::primitives::Span`: `pub struct Span<'a> { pub text: Cow<'a, str>, pub italic: bool, pub tabular: bool, pub mono: bool, pub muted: bool, pub shortcut: bool, pub highlight: bool, pub underline: bool, pub strong: bool }`. One styled stretch of a run.
- `craft_ui::primitives::Span`: `pub struct Span<'a> { pub text: Cow<'a, str>, pub italic: bool, pub tabular: bool, pub mono: bool, pub muted: bool, pub shortcut: bool, pub highlight: bool, pub underline: bool, pub strong: bool, pub flag: Option<Tone> }`. One styled stretch of a run.
- `pub fn new(text: impl Into<Cow<'a, str>>) -> Self`. A plain span.
- `pub fn flag(mut self, tone: Tone) -> Self`. Underlines the span in the ink of `tone` (spelling `Bad`, grammar `Info`).
- `pub fn italic(mut self) -> Self`. Italic.
- `pub fn tabular(mut self) -> Self`. Tabular figures.
- `pub fn mono(mut self) -> Self`. The monospace face.
@@ -2993,12 +3054,14 @@ Painters, `Draw`, the sensing core, the text adapter and `ImeSurface`.
- `craft_ui::primitives::StrokeWidth`: `pub enum StrokeWidth { Hairline, Thin, Medium, Thick, Heavy }`. A line width from the theme, so content never picks a literal one.
- `craft_ui::primitives::Surface`: `pub struct Surface`. The surface painter: shadow, fill, then edge.
- `pub fn shapes(style: &SurfaceStyle, fill: Option<Color32>, rect: Rect, corners: Corners, direction: Direction, pixels_per_point: f32,) -> Vec<Shape>`. The shapes of `style` over `rect`, snapped to the pixel grid: shadow, fill, edge. `fill` replaces the
- `craft_ui::primitives::TabKey`: `pub enum TabKey { Moves, Inserts, Rewrites, Reports }`. What Tab does in a text field.
- `craft_ui::primitives::TextKey`: `pub struct TextKey<V>`. A text part's key, typed by the value its codec gives.
- `pub const fn new(key: PartKey) -> Self`. The key of the text part `key`.
- `pub const fn key(self) -> PartKey`. The part key.
- `craft_ui::primitives::TextLayout`: `pub struct TextLayout { pub galley: Arc<Galley>, pub elided: bool, pub full: String, pub first_baseline: f32, pub runs: Vec<LayoutRun>, pub rotation: f32 }`. A laid-out run.
- `pub fn size(&self) -> egui::Vec2`. The galley size.
- `craft_ui::primitives::TextOptions`: `pub struct TextOptions { pub placeholder: Option<Label>, pub lines: Option<usize>, pub limit: Option<usize>, pub mask: bool, pub live: bool, pub clear_on_escape: bool, pub mono: bool, pub role: TypeRole, pub ink: Option<Ink>, pub tab_inserts: bool, pub complete: Option<Arc<dyn Completer>>, pub complete_on_enter: bool, pub replace_selection: Option<String>, pub commit_on: &'static [char], pub enabled: bool, pub steps_value: bool, pub select_on_focus: bool, pub submits: bool, pub mixed: bool, pub centred: bool, pub arrows_from_end: bool, pub unparsed: Option<Message>, pub own_menu: bool, pub tab_rewrites: bool, pub holds_drafts: bool }`. How a text part behaves beyond its codec.
- `pub fn char_x(&self, chars: usize) -> f32`. Where a caret before character `chars` (counted from the start of the text) stands, from the layout's left edge:
- `craft_ui::primitives::TextOptions`: `pub struct TextOptions { pub placeholder: Option<Label>, pub lines: Option<usize>, pub limit: Option<usize>, pub mask: bool, pub live: bool, pub clear_on_escape: bool, pub mono: bool, pub role: TypeRole, pub ink: Option<Ink>, pub tab: TabKey, pub caret: Option<usize>, pub complete: Option<Arc<dyn Completer>>, pub complete_on_enter: bool, pub replace_selection: Option<String>, pub commit_on: &'static [char], pub enabled: bool, pub steps_value: bool, pub select_on_focus: bool, pub submits: bool, pub mixed: bool, pub centred: bool, pub arrows_from_end: bool, pub unparsed: Option<Message>, pub own_menu: bool, pub holds_drafts: bool }`. How a text part behaves beyond its codec.
- `pub fn new() -> Self`. Options with every default.
- `craft_ui::primitives::TextOutcome`: `pub struct TextOutcome<V> { pub rect: Rect, pub draft: Option<String>, pub value: Option<V>, pub layout: Option<super::TextLayout>, pub caret_visible: bool, pub invalid: bool, pub committed: Option<craft_behavior::ParseNote>, pub composing: bool, pub completions: Vec<super::Completion>, pub clicked: bool }`. A text part's result this pass.
- `pub const fn new(rect: Rect) -> Self`. An outcome over `rect` with no draft or value.
@@ -3039,14 +3102,16 @@ Painters, `Draw`, the sensing core, the text adapter and `ImeSurface`.
- `pub fn put_failure(&self, ctx: &Context, key: K, revision: Revision, failure: LoadFailure)`. Records that making `key`'s picture at `revision` failed (state `Failed`), so nothing asks for it again
- `pub fn forget(&self, ctx: &Context, key: &K)`. Drops `key`'s entry and frees its texture.
- `pub fn retain(&self, ctx: &Context, mut keep: impl FnMut(&K) -> bool)`. Keeps only the entries whose key `keep` accepts (PhotoCraft's `prune_thumbs` when the open documents
- `pub fn clear(&self, ctx: &Context)`. Drops every entry (another library opened).
- `pub fn clear(&self, ctx: &Context)`. Drops every entry (another library opened); a packed store's pages start over and keep their textures.
- `pub fn allow_upload(&self, ctx: &Context, bytes: usize) -> bool`. Whether this frame's upload allowance has room for one more upload of `bytes`: fewer than `uploads_per_pass`
- `pub fn statistics(&self, ctx: &Context) -> TextureStatistics`. What the store holds and uploaded this frame.
- `pub fn options(&self) -> TextureStoreOptions`. The options the store was made with.
- `craft_ui::primitives::TextureStoreOptions`: `pub struct TextureStoreOptions { pub budget: TextureBudget, pub filter: TextureOptions }`. A store's settings, read when the store is created (`TextureStore::in_context`).
- `craft_ui::primitives::TextureStoreOptions`: `pub struct TextureStoreOptions { pub budget: TextureBudget, pub filter: TextureOptions, pub packed: Option<u32> }`. A store's settings, read when the store is created (`TextureStore::in_context`).
- `pub const fn thumbnails() -> Self`. Row and grid thumbnails: 32 MiB and 512 entries.
- `pub const fn pages() -> Self`. Document pages: 128 MiB and 64 entries.
- `pub const fn frames() -> Self`. Video frames and other named images: 64 MiB and 512 entries.
- `pub const fn packed(mut self, max_side: u32) -> Self`. Puts pictures up to `max_side` texels per side on a few shared page textures written in place, so browsing
- `pub const fn packed_small(self) -> Self`. [`packed`](Self::packed) for the small pictures of an interface (a style tile, a font sample row): those up to a
- `pub const fn filter(mut self, filter: TextureOptions) -> Self`. The sampling of every texture.
- `pub const fn budget(mut self, budget: TextureBudget) -> Self`. Other limits.
- `craft_ui::primitives::TextureWords`: re-export of `craft_ui::primitives::textures::TextureWords` (defined outside these crates).
@@ -3105,6 +3170,7 @@ Painters, `Draw`, the sensing core, the text adapter and `ImeSurface`.
- `craft_ui::primitives::member_gesture_running`: `pub fn member_gesture_running(ctx: &Context, viewport: ViewportId, arena: Id) -> bool`. Whether a member of the arena root `arena` (a canvas control in a canvas, say) has a running gesture, in
- `craft_ui::primitives::outline`: `pub fn outline(tokens: &UiTokens, shape: &PaintShape) -> Vec<Shape>`. The line that marks a shape on any image: a `thick` halo under a `medium` line, in the overlay colours.
- `craft_ui::primitives::paint_surround`: `pub fn paint_surround(painter: &egui::Painter, area: CheckerArea, look: &SurroundLook)`. Paints the surround `look` over `area`: the fill, and with a pattern one textured shape of the dot tile over it.
- `craft_ui::primitives::painted_image`: `pub fn painted_image(env: &Env, cursor: &PaintedCursor, scale: f32) -> Option<CursorBitmap>`. The window image of the painted pointer `cursor` at `scale` device pixels per point, rasterised from the art the
- `craft_ui::primitives::ramp`: `pub fn ramp(rect: Rect, radius: CornerRadius, stops: &[(f32, DataColor)], axis: Axis) -> Vec<Shape>`. A colour ramp over `rect` with corners of `radius` (`CornerRadius::ZERO` for square ones): the strip shades from
- `craft_ui::primitives::reduce_image`: `pub fn reduce_image(image: &ColorImage, factor: u32) -> ColorImage`. `image` box-averaged by the whole `factor`, in premultiplied values.
- `craft_ui::primitives::register_app_icons`: `pub fn register_app_icons(set: &'static AppIcons)`. Registers `set` in the process-wide list beside the built-in catalog; runs before the first pass.
@@ -3135,12 +3201,14 @@ Frosted backdrops: a bounded blurred composition of the layers under a surface,
- `pub const CAPACITY: usize`. The number of textures above which the cache drops those no frame asked for lately.
- `pub fn texture<K: Hash + 'static>(ctx: &Context, key: K, image: impl FnOnce() -> ColorImage) -> TextureId`. The texture for `key`: loads `image()` on the first request and returns the same texture afterwards. A key
- `pub fn texture_with<K: Hash + 'static>(ctx: &Context, key: K, options: TextureOptions, image: impl FnOnce() -> ColorImage) -> TextureId`. The texture for `key` sampled with `options` (a repeating pattern, nearest filtering); see [`Self::texture`].
- `pub fn texture_if<K: Hash + 'static>(ctx: &Context, key: K, image: impl FnOnce() -> Option<ColorImage>) -> Option<TextureId>`. The texture for `key`, or `None` when `image` has nothing to draw; the answer is kept like a texture, so
- `pub fn len(ctx: &Context) -> usize`. The number of textures the context holds.
- `pub fn is_empty(ctx: &Context) -> bool`. Whether the context holds no texture.
- `pub fn clear(ctx: &Context)`. Drops every texture of the context; the next request loads again.
- `craft_ui::primitives::textures::CachedTexture`: `pub struct CachedTexture { pub id: TextureId, pub size: PixelSize }`. A stored picture as a painter draws it: `painter.image(texture.id, rect, uv, tint)`.
- `pub fn size_vec2(&self) -> Vec2`. `size` as a vector, for fitting: only the aspect matters to a cell.
- `pub fn sized(&self) -> SizedTexture`. The texture with its size, the form `PreviewPane` and egui's image widgets take.
- `craft_ui::primitives::textures::CachedTexture`: `pub struct CachedTexture { pub id: TextureId, pub size: PixelSize, pub origin: [u32; 2], pub page: PixelSize }`. A stored picture as a painter draws it: `painter.image(texture.id, rect, uv, tint)`.
- `pub fn uv(&self) -> Rect`. The picture's part of its page texture, in uv coordinates, to paint with `id`: the full rect for an unpacked
- `pub fn size_vec2(&self) -> Vec2`. `size` as a vector, for fitting: only the aspect matters to a cell. It is the picture's own size, also for a
- `pub fn sized(&self) -> SizedTexture`. The texture with its size, the form `PreviewPane` and egui's image widgets take. Those draw the whole
- `craft_ui::primitives::textures::FakeThumbSource`: `pub struct FakeThumbSource<K>`. A [`ThumbSource`] for stories and tests in every crate: pictures made from the key and a revision the test sets,
- `pub fn new() -> Self`. Synchronous square pictures at revision 0.
- `pub fn later(mut self, later: bool) -> Self`. Renders as `Later` jobs.
@@ -3189,14 +3257,16 @@ Frosted backdrops: a bounded blurred composition of the layers under a surface,
- `pub fn put_failure(&self, ctx: &Context, key: K, revision: Revision, failure: LoadFailure)`. Records that making `key`'s picture at `revision` failed (state `Failed`), so nothing asks for it again
- `pub fn forget(&self, ctx: &Context, key: &K)`. Drops `key`'s entry and frees its texture.
- `pub fn retain(&self, ctx: &Context, mut keep: impl FnMut(&K) -> bool)`. Keeps only the entries whose key `keep` accepts (PhotoCraft's `prune_thumbs` when the open documents
- `pub fn clear(&self, ctx: &Context)`. Drops every entry (another library opened).
- `pub fn clear(&self, ctx: &Context)`. Drops every entry (another library opened); a packed store's pages start over and keep their textures.
- `pub fn allow_upload(&self, ctx: &Context, bytes: usize) -> bool`. Whether this frame's upload allowance has room for one more upload of `bytes`: fewer than `uploads_per_pass`
- `pub fn statistics(&self, ctx: &Context) -> TextureStatistics`. What the store holds and uploaded this frame.
- `pub fn options(&self) -> TextureStoreOptions`. The options the store was made with.
- `craft_ui::primitives::textures::TextureStoreOptions`: `pub struct TextureStoreOptions { pub budget: TextureBudget, pub filter: TextureOptions }`. A store's settings, read when the store is created (`TextureStore::in_context`).
- `craft_ui::primitives::textures::TextureStoreOptions`: `pub struct TextureStoreOptions { pub budget: TextureBudget, pub filter: TextureOptions, pub packed: Option<u32> }`. A store's settings, read when the store is created (`TextureStore::in_context`).
- `pub const fn thumbnails() -> Self`. Row and grid thumbnails: 32 MiB and 512 entries.
- `pub const fn pages() -> Self`. Document pages: 128 MiB and 64 entries.
- `pub const fn frames() -> Self`. Video frames and other named images: 64 MiB and 512 entries.
- `pub const fn packed(mut self, max_side: u32) -> Self`. Puts pictures up to `max_side` texels per side on a few shared page textures written in place, so browsing
- `pub const fn packed_small(self) -> Self`. [`packed`](Self::packed) for the small pictures of an interface (a style tile, a font sample row): those up to a
- `pub const fn filter(mut self, filter: TextureOptions) -> Self`. The sampling of every texture.
- `pub const fn budget(mut self, budget: TextureBudget) -> Self`. Other limits.
- `craft_ui::primitives::textures::TextureWords`: re-export of `craft_ui::primitives::textures::words::TextureWords` (defined outside these crates).
@@ -3248,7 +3318,7 @@ Per-pass and per-frame services and the one egui adapter.
- `craft_ui::runtime::RecordShift`: re-export of `craft_ui::runtime::egui::RecordShift` (defined outside these crates).
- `craft_ui::runtime::Shift`: `pub trait Shift`. A value a record holds, at the place a replay adds the record (`RecordShift`): rects and points move with the record,
- `fn shifted(&self, by: &RecordShift) -> Self`. `self` at the place `by` names.
- `fn snapped(&self, to: &Self, within: f32) -> Self`. `self` with each coordinate `shifted` moves, and each float it holds, taken from `to` where the two lie within
- `fn snapped(&self, to: &Self, within: f32) -> Self`. `self` with each coordinate `shifted` moves, and each distance a hit shape holds (`reach`, `min_across`), taken
- `craft_ui::runtime::install`: re-export of `craft_ui::runtime::install::install`.
## `craft_ui::runtime::access`
@@ -3271,6 +3341,7 @@ Per-pass and per-frame services and the one egui adapter.
- `pub fn required(&mut self, on: bool) -> &mut Self`. The input must be filled in.
- `pub fn url(&mut self, url: impl Into<String>) -> &mut Self`. The target of a link.
- `pub fn shortcut(&mut self, text: impl Into<String>) -> &mut Self`. The keyboard shortcut, over the bound command's.
- `pub fn no_shortcut(&mut self) -> &mut Self`. The node lists no keyboard shortcut, though a command bound to the component has a chord.
- `pub fn access_key(&mut self, key: char) -> &mut Self`. The mnemonic letter.
- `pub fn labelled_by(&mut self, id: Id) -> &mut Self`. The node `id` names this one. Targets are `cx.key(..)` ids; one shown in a later frame follows the
- `pub fn described_by(&mut self, id: Id) -> &mut Self`. The node `id` describes this one.
@@ -3311,6 +3382,7 @@ Per-pass and per-frame services and the one egui adapter.
- `pub fn column(&mut self, key: craft_behavior::ColumnKey) -> &mut Self`. The column of a cell of an item row; the item step reads the cell's column index from the collection's
- `pub fn access_key(&mut self, key: char) -> &mut Self`. The mnemonic letter.
- `pub fn shortcut(&mut self, text: impl Into<String>) -> &mut Self`. The key that activates the sub-node, as the access tree lists it (`Access::shortcut` for the component's own
- `pub fn url(&mut self, url: impl Into<String>) -> &mut Self`. The address a link sub-node goes to (`Access::url` for the component's own node): a hyperlink a content
- `pub fn has_popup(&mut self, kind: PopupKind) -> &mut Self`. What kind of popup the sub-node opens.
- `pub fn expanded(&mut self, on: bool) -> &mut Self`. Whether the sub-node's popup or region is open.
- `pub fn current(&mut self, on: bool) -> &mut Self`. The sub-node is the current one of its set: the current page of a trail.
@@ -3335,6 +3407,8 @@ The command board: the registry and typed sets, per-frame state, the queue, firi
- `craft_ui::runtime::commands::AppCatalog`: `pub struct AppCatalog`. Commands an app defines at run time (plug-ins, its tool list), all in the app scope ([`Scope::app`]). They join
- `pub fn new(defs: Vec<CommandDef>, generation: u64) -> Result<Self, CommandDefError>`. A catalog of `defs`; `generation` changes when the app's rows do. Refuses two defs with one id (`Duplicate`) and a
- `pub fn replace_defaults(mut self, id: impl Into<String>, bindings: Vec<Binding>) -> Self`. Gives the linked set's command `id` the default chords `bindings` in place of the set's own; an empty list drops
- `pub fn typing_rule(mut self, rule: TypingRule) -> Self`. Sets which chords fire while a text component has the keyboard. The keymap's default,
- `pub fn generation(&self) -> u64`. The app's version of the catalog. The board rebuilds the keymap when it differs from the last frame's, and never
- `craft_ui::runtime::commands::CommandGate`: `pub struct CommandGate`. The app's one gate over commands: a dialog is open, a workspace is not ready, a recorder has the keys or an
- `pub fn new<P: MemoProps + Send + Sync + 'static>(props: P, allows: fn(&P, &CommandRef) -> bool) -> Self`. A gate that lets through the commands `allows` accepts under `props`.
@@ -3374,10 +3448,10 @@ The command board: the registry and typed sets, per-frame state, the queue, firi
- `fn take_step(&mut self, can_undo: bool, can_redo: bool) -> Option<Step>`. Declares Undo and Redo on the innermost instance around this context, enabled as `can_undo` and `can_redo`
- `fn resolve_command(&self, command: impl Into<CommandRef>) -> Option<Arc<ResolvedCommand>>`. `command` as this context shows it: the label, icon and chord with the scoped bindings of the scopes above
- `craft_ui::runtime::commands::FirePhase`: `pub enum FirePhase { Press, Repeat, Release }`. The phase of the key press that fired a command.
- `craft_ui::runtime::commands::FireSource`: `pub enum FireSource { Key, Menu, Palette, Pointer, Automation, Access }`. Where a fired command came from.
- `craft_ui::runtime::commands::FireSource`: `pub enum FireSource { Key, Menu, Palette, Pointer, Automation, Access, Keytip }`. Where a fired command came from.
- `craft_ui::runtime::commands::Fired`: `pub struct Fired { pub command: CommandRef, pub target: Option<Id>, pub source: FireSource, pub phase: FirePhase, pub cycle: bool, pub alt_variant: bool, pub time: f64 }`. A command a surface or a key fired, as the instance or the app takes it.
- `pub fn new(command: CommandRef, source: FireSource, phase: FirePhase, time: f64) -> Fired`. `command` fired from `source` in `phase` at the input time `time`, for the app scope (no target), without a group
- `craft_ui::runtime::commands::ResolvedCommand`: `pub struct ResolvedCommand { pub label: Arc<str>, pub icon: Option<Cow<'static, str>>, pub chord: Option<Chord>, pub chord_text: Option<Arc<str>>, pub enabled: bool, pub checked: Option<bool>, pub marked: bool, pub hint: Option<Arc<str>>, pub kind: CommandKind, pub instance: Option<Id> }`. A command as a surface shows and fires it.
- `craft_ui::runtime::commands::ResolvedCommand`: `pub struct ResolvedCommand { pub label: Arc<str>, pub icon: Option<Cow<'static, str>>, pub chord: Option<Chord>, pub chord_text: Option<Arc<str>>, pub enabled: bool, pub checked: Option<bool>, pub marked: bool, pub hint: Option<Arc<str>>, pub kind: CommandKind, pub edit: bool, pub instance: Option<Id> }`. A command as a surface shows and fires it.
- `craft_ui::runtime::commands::bindings`: `pub fn bindings(ctx: &Context, command: &CommandRef) -> Vec<Binding>`. The keys `command` has in the runtime's keymap: its defaults under the user's overrides (`CommandInput`), on the
- `craft_ui::runtime::commands::chord`: `pub fn chord(ctx: &Context, command: &CommandRef) -> Option<Chord>`. The chord a surface shows for `command`: its first single-press binding in the runtime's keymap that runs it
- `craft_ui::runtime::commands::fire`: `pub fn fire(ctx: &Context, command: impl Into<CommandRef>, source: FireSource) -> bool`. Fires `command` from a surface that has no component of its own: a menu, the palette or automation. Scoped
@@ -3419,7 +3493,9 @@ The command board: the registry and typed sets, per-frame state, the queue, firi
- `craft_ui::runtime::commands::NavCommand`: `pub enum NavCommand { NextPane, PreviousPane, FocusMenuBar }`. The `window` commands that move focus between the window's panes and onto its menu bar (spec 9.4, 9.7). Their keys
- `craft_ui::runtime::commands::Platform`: re-export of `craft_keymap::Platform` (outside these crates).
- `craft_ui::runtime::commands::Scope`: re-export of `craft_keymap::Scope` (outside these crates).
- `craft_ui::runtime::commands::TypingRule`: re-export of `craft_keymap::TypingRule` (outside these crates).
- `craft_ui::runtime::commands::WindowCommand`: `pub enum WindowCommand { Move, Size }`. The `window` commands (16.3): a floating container moves and resizes from the keyboard. macOS binds no chord to
- `craft_ui::runtime::commands::keymap`: `pub fn keymap(ctx: &Context) -> Option<Arc<Keymap>>`. The window's own keymap: the registry scopes, the app catalog, the window shortcuts and the app's overrides, as the
## `craft_ui::runtime::cursor`
@@ -3508,6 +3584,8 @@ AccessKit node building, `register_accesskit_parent` and `set_accesskit_focus`:
- `pub fn has_popup_of(&self, key: NodeKey) -> Option<PopupKind>`. The kind of popup the node of `key` opens.
- `pub fn access_key_of(&self, key: NodeKey) -> Option<char>`. The access key of the node of `key`.
- `pub fn current_of(&self, key: NodeKey) -> bool`. Whether the node of `key` is the current item of its set (the current page).
- `pub fn level_of(&self, key: NodeKey) -> Option<usize>`. The level a node by key states: a heading's outline level, a list item's list level, a tree item's depth.
- `pub fn url_of(&self, key: NodeKey) -> Option<&str>`. The address a link node by key goes to.
- `pub fn parent_of(&self, id: Id) -> Option<NodeKey>`. The nearest ancestor of `id` that screen readers see: AccessKit's consumer drops generic containers.
- `pub fn parent_of_key(&self, key: NodeKey) -> Option<NodeKey>`. [`AccessTree::parent_of`] for a node by key.
- `pub fn in_ltr_axis(&self, key: NodeKey) -> bool`. Whether the node is, or lies inside, a component whose horizontal axis keeps its left-to-right order
@@ -3522,6 +3600,7 @@ AccessKit node building, `register_accesskit_parent` and `set_accesskit_focus`:
- `craft_ui::runtime::egui::access::Declared`: `pub enum Declared { Focus, Click, Increment, Decrement, SetValue, SetTextSelection, Expand, Collapse, Custom, ScrollUp, ScrollDown, ScrollLeft, ScrollRight }`. An action a node declares.
- `craft_ui::runtime::egui::access::NodeKey`: `pub struct NodeKey`. A node's number in the tree.
- `pub fn of(id: Id) -> NodeKey`. The key of the node of `id`.
- `craft_ui::runtime::egui::access::TreeUpdate`: re-export of `accesskit::TreeUpdate` (outside these crates).
## `craft_ui::runtime::egui::areas`
@@ -3586,6 +3665,8 @@ One-shot screenshot slots and the facts a screenshot is measured against.
- `craft_ui::runtime::env::Scoped`: `pub struct Scoped { pub ink: Ink, pub key: EnvKey, pub size: ControlSize, pub glyphs: GlyphRole, pub enabled: bool, pub read_only: bool, pub wheel: WheelScope, pub direction: Direction, pub text_direction: Direction, pub ids_stable: bool, pub arena: Option<ArenaId>, pub transform: Option<CanvasTransform> }`. The values of an env.
- `pub fn hit_reach(&self) -> f32`. How far from a handle, point or edge a press still takes it, in screen points: the theme's `size.hit.target`.
- `craft_ui::runtime::env::AgeStyle`: re-export of `craft_i18n::AgeStyle` (outside these crates).
- `craft_ui::runtime::env::AltCodePages`: `pub struct AltCodePages { pub ansi: u16, pub oem: u16 }`. Code pages that decode Alt+numpad codes; the app sets them from the system locale.
- `pub const fn new(ansi: u16, oem: u16) -> Self`. The ANSI and OEM code pages.
- `craft_ui::runtime::env::AppValues`: `pub struct AppValues`. The app values a root, a scope or a component's `content_env` carries: one entry per `EnvValue` type, the
- `pub fn set<T: EnvValue>(&mut self, value: T) -> &mut Self`. Sets the value of type `T`.
- `craft_ui::runtime::env::ArenaId`: `pub struct ArenaId(pub Id)`. The id of an arena, carried in `Env.arena`.
@@ -3632,12 +3713,14 @@ One-shot screenshot slots and the facts a screenshot is measured against.
- `craft_ui::runtime::env::MotionPolicy`: `pub struct MotionPolicy { pub mode: MotionMode, pub tokens: MotionTokens }`. The motion mode in effect, carried in `Env.motion`.
- `pub const fn new(mode: MotionMode, tokens: MotionTokens) -> Self`. The policy that runs animations at `mode` with `tokens`.
- `craft_ui::runtime::env::Overrides`: `pub struct Overrides { pub size: Option<ControlSize>, pub enabled: Option<bool>, pub read_only: Option<bool>, pub wheel: Option<WheelScope>, pub motion: Option<MotionMode>, pub direction: Option<Direction>, pub words: Option<WordsOverride>, pub values: AppValues }`. Changes to the inherited values for a stretch of code.
- `craft_ui::runtime::env::PageBandRoom`: `pub struct PageBandRoom { pub rect: Rect, pub start: f32, pub end: f32 }`. The room of the page band while a full-window page shows: the title-bar-high strip at the window's top and the room
- `pub const fn new(rect: Rect, start: f32, end: f32) -> Self`. The band at `rect`, the window's start end taking `start` of it and its end end `end`.
- `craft_ui::runtime::env::PaneEdge`: `pub enum PaneEdge { Center, Start, End, Top, Bottom }`. Where a shell pane sits.
- `craft_ui::runtime::env::PointSize`: `pub enum PointSize { PostScript, Traditional }`. The size of a point, the Point/Pica Size of the Units preference. An app sets it once on its root env with
- `pub const fn points_per_inch(self) -> f64`. How many points make an inch.
- `craft_ui::runtime::env::ResolvedRoot`: `pub struct ResolvedRoot { pub mode: Mode, pub contrast: Contrast, pub motion: MotionMode }`. The mode, contrast and motion of a pass, with `System` resolved.
- `craft_ui::runtime::env::RevealEdge`: `pub enum RevealEdge { Top, Start, End }`. An edge of the window whose slots a pointer at the edge reveals in body-only mode. The bottom edge and the centre
- `craft_ui::runtime::env::RootEnv`: `pub struct RootEnv { pub sizes: Arc<AppSizes>, pub text_size: TextSize, pub direction: Direction, pub motion: MotionChoice, pub mode: ModeChoice, pub contrast: ContrastChoice, pub density: Size, pub scale: Scale, pub tab_all_controls: bool, pub tab_toggles_chrome: bool, pub dialog_tab: TabReach, pub canvas_pattern: bool, pub values: AppValues, pub today: Option<CalendarDate> }`. The app's root values each frame.
- `craft_ui::runtime::env::RootEnv`: `pub struct RootEnv { pub sizes: Arc<AppSizes>, pub text_size: TextSize, pub direction: Direction, pub motion: MotionChoice, pub mode: ModeChoice, pub contrast: ContrastChoice, pub density: Size, pub scale: Scale, pub tab_all_controls: bool, pub tab_toggles_chrome: bool, pub dialog_tab: TabReach, pub canvas_pattern: bool, pub values: AppValues, pub today: Option<CalendarDate>, pub wheel: WheelSpeed, pub alt_codes: AltCodePages }`. The app's root values each frame.
- `pub fn new() -> Self`. A root with every value at its default.
- `pub fn scale(mut self, scale: Scale) -> Self`. Sets the interface scale.
- `pub fn direction(mut self, direction: Direction) -> Self`. Sets the layout direction.
@@ -3653,6 +3736,8 @@ One-shot screenshot slots and the facts a screenshot is measured against.
- `pub fn contrast(mut self, contrast: impl Into<ContrastChoice>) -> Self`. Sets the contrast choice.
- `pub fn density(mut self, density: Size) -> Self`. Sets the density preset.
- `pub fn today(mut self, date: CalendarDate) -> Self`. Sets today's date, as the host's clock and time zone give it.
- `pub fn wheel_speed(mut self, speed: WheelSpeed) -> Self`. Sets this frame's wheel speed.
- `pub fn alt_code_pages(mut self, pages: AltCodePages) -> Self`. Sets the code pages that decode Alt+numpad codes.
- `craft_ui::runtime::env::RowPressed`: `pub enum RowPressed { Row, Cell(ColumnKey), Part { was_lead: bool } }`. Where the collection holds a primary press on a row, within slop, or the press a part of the row holds.
- `craft_ui::runtime::env::Scale`: `pub struct Scale(pub f32)`. The interface scale: pixels per point.
- `pub const fn new(pixels_per_point: f32) -> Self`. `pixels_per_point` pixels per point.
@@ -3678,6 +3763,8 @@ One-shot screenshot slots and the facts a screenshot is measured against.
- `pub fn edge_revealed(&self, edge: RevealEdge) -> bool`. Is the edge reveal on for `edge`? False in normal mode and during the Tab reveal.
- `pub fn regions(&self) -> &ShellRegions`. The body rect and the shown slots of this pass.
- `pub fn float_bounds(&self) -> Rect`. Where floating frames may go: the body rect plus the area under bars that overlay the body.
- `pub fn page_band(&self) -> Option<PageBandRoom>`. The page band's room while a full-window page shows, else `None`.
- `pub fn with_page_band(mut self, room: Option<PageBandRoom>) -> Self`. The page band's room while a full-window page shows; `None` when no page shows or the window is full screen.
- `craft_ui::runtime::env::ShellRegions`: `pub struct ShellRegions { pub body: Rect, pub slots: Vec<(SlotKey, Rect)> }`. What one shell pass laid out.
- `pub fn new(body: Rect) -> Self`. A layout with `body` and no slots.
- `pub fn with_slot(mut self, key: SlotKey, rect: Rect) -> Self`. The layout with the shown slot `key` at `rect`, after the slots already listed.
@@ -3723,6 +3810,8 @@ One-shot screenshot slots and the facts a screenshot is measured against.
- `pub fn length_reader(&self, lengths: LengthUnits) -> Reader`. A reader for lengths shown in `lengths.shown`: the spellings of every length unit and of pixels convert to it,
- `pub fn document_reader(&self, ruler: UnitKind, extent: f64, pixels_per_inch: f64, points_per_inch: f64) -> Reader`. A reader for the numbers of a document measured in `ruler`: the unit spellings of every pixel and length unit
- `craft_ui::runtime::env::WheelScope`: `pub enum WheelScope { Plain, Free, Gated }`. How the wheel takers of a scope take the wheel.
- `craft_ui::runtime::env::WheelSpeed`: `pub struct WheelSpeed { pub line: f32, pub point: f32 }`. The user's wheel multipliers: `line` for notches, `point` for touchpad deltas. Distinct from
- `pub const fn new(line: f32, point: f32) -> Self`. The multipliers for line (notch) and point (touchpad) scrolling.
- `craft_ui::runtime::env::WindowKey`: `pub struct WindowKey`. The key of a window. It equals the placement `SaveKey` of the window, so two windows of one app need different keys.
- `pub fn main() -> Self`. The first window, `"main"`.
- `pub fn new(key: impl Into<String>) -> Self`. A key from any string.
@@ -3742,8 +3831,10 @@ The focus service: stops, scopes and roving groups registered per pass, the focu
- `craft_ui::runtime::focus::FocusMove`: `pub enum FocusMove { Keys, Other }`. What moved the key focus.
- `craft_ui::runtime::focus::FocusShape`: `pub enum FocusShape { Rect, Circle, Polygon(Vec<egui::Pos2>) }`. The shape the focus ring takes around a part.
- `craft_ui::runtime::focus::has`: `pub fn has(ctx: &Context, id: Id) -> bool`. Whether focus is on the component `id` or on one of its parts (a canvas's editor part), from the focus record of
- `craft_ui::runtime::focus::host_canvas`: `pub fn host_canvas(ctx: &Context, id: Id, keys: KeyUse)`. Registers the app's own egui widget `id`, drawn in the running pass, as its window's document canvas: a focus stop
- `craft_ui::runtime::focus::request`: `pub fn request(ctx: &Context, target: FocusTarget) -> bool`. Moves focus to `target`, leaves modality unchanged and asks the enclosing scroll owner to reveal it. Called
- `craft_ui::runtime::focus::takes_letters`: `pub fn takes_letters(keys: &KeyUse) -> bool`. Whether a stop with these keys takes typed letters: a text field or a shortcut recorder. The letters a keytip or a
- `craft_ui::runtime::focus::ActivateKeys`: `pub enum ActivateKeys { Neither, Enter, Space, Both }`. The keys that activate a component.
- `pub const fn enter(self) -> bool`. Whether Enter activates.
- `pub const fn space(self) -> bool`. Whether Space activates.
@@ -3806,6 +3897,7 @@ The focus service: stops, scopes and roving groups registered per pass, the focu
- `pub const fn with_end(mut self, end: EndKey) -> Self`. The same use with `end` as the meaning of a bare End.
- `pub const fn with_keep(mut self, keep: KeepKeys) -> Self`. The same use with `keep` as the keys it keeps from the key stage.
- `pub const fn with_chrome_key(mut self, chrome_key: bool) -> Self`. The same use with `chrome_key` as whether the component marks its window as showing a document: a canvas
- `pub const fn is_document_editor(&self) -> bool`. Whether the component is a document canvas's editor part: the document (`chrome_key`) holding its editor's
- `pub fn claims_chord(&self, chord: &Chord) -> bool`. Whether the component claims `chord`.
- `craft_ui::runtime::focus::Letters`: `pub enum Letters { None, TypeAhead }`. Whether a roving group matches typed letters to entries.
- `craft_ui::runtime::focus::Roving`: `pub struct Roving { pub shape: NavShape, pub wrap: bool, pub home_end: bool, pub page: Option<usize>, pub letters: Letters, pub arrows: Arrows, pub first_column: Option<usize>, 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.
@@ -3843,15 +3935,25 @@ The frame plugin: the per-pass and per-frame steps, with the inputs the app sets
- `craft_ui::runtime::frame::stepped_clock`: `pub fn stepped_clock(ctx: &Context, step: f64) -> f64`. The pass clock in seconds rounded down to a multiple of `step`, for content that changes with time (a rescan every
- `craft_ui::runtime::frame::take_output`: `pub fn take_output(ctx: &Context) -> FrameOutput`. Everything accumulated since the last call, across passes and discarded passes.
## `craft_ui::runtime::ime`
The IME engine (18.4): who owns the IME this frame, the composing flag, preedit and commit delivery, and the
- `craft_ui::runtime::ime::EditorSurrounding`: `pub enum EditorSurrounding<'a> { Text { text: &'a str, cursor: usize, anchor: usize }, Unavailable { revision: Option<u64> } }`. An owner's surrounding report as the engine keeps it for one pass: an owned copy of at most
- `pub const fn text(text: &'a str, cursor: usize, anchor: usize) -> Self`. The text around the caret, with byte offsets of the cursor and the selection anchor into `text`.
- `pub const fn unavailable(revision: Option<u64>) -> Self`. No text to report, at `revision` if the editor keeps one.
## `craft_ui::runtime::inspect`
Decision records and findings. Inspected regions ([`record`]) collect pipeline steps. Fixture frames also collect
- `craft_ui::runtime::inspect::Element`: `pub struct Element { pub id: Id, pub part: Option<PartRef>, pub component: &'static str, pub depth: usize, pub rect: Rect, pub content: Rect, pub facts: Option<Facts>, pub stop: Option<usize> }`. One element an inspected region showed: a component, or a part of one with a node, a hit area or a focus stop.
- `craft_ui::runtime::inspect::Element`: `pub struct Element { pub id: Id, pub part: Option<PartRef>, pub component: &'static str, pub depth: usize, pub rect: Rect, pub content: Rect, pub facts: Option<Facts>, pub stop: Option<usize>, pub command: Option<CommandRef> }`. One element an inspected region showed: a component, or a part of one with a node, a hit area or a focus stop.
- `pub fn node(&self) -> Id`. The id of the access node the element stands for: the component's own id, or the sub-node of its part. A
- `craft_ui::runtime::inspect::Facts`: `pub struct Facts { pub role: String, pub name: Option<String>, pub labelled_by: Vec<Id>, pub value: Option<String>, pub actions: Vec<&'static str>, pub disabled: bool, pub interactive: bool }`. What a node says, as step 16 reported it.
- `craft_ui::runtime::inspect::HitArea`: `pub struct HitArea { pub owner: Id, pub part: Option<PartRef>, pub rect: Rect }`. A hit area the sensing core registered for a component of the region.
- `craft_ui::runtime::inspect::Recorded`: `pub struct Recorded { pub elements: Vec<Element>, pub hits: Vec<HitArea> }`. What an inspected region showed in a pass.
- `craft_ui::runtime::inspect::Recorded`: `pub struct Recorded { pub layer: areas::LayerKey, pub elements: Vec<Element>, pub hits: Vec<HitArea> }`. What an inspected region showed in a pass.
- `pub fn stop_rect(&self, index: usize) -> Option<Rect>`. The rect of the element at `index` where Tab stops on it: its hit area when it has one, else its box.
- `pub fn rect_in(&self, ctx: &Context, index: usize, target: areas::LayerKey) -> Option<Rect>`. The stop rect of the element at `index` (as [`Recorded::stop_rect`]) mapped into the layer `target`.
- `craft_ui::runtime::inspect::point_at`: `pub fn point_at(ctx: &Context, key: Id, index: Option<usize>)`. Points the list of the region `key` at the element at `index`, or at none. A region shown earlier in the pass that
- `craft_ui::runtime::inspect::pointed`: `pub fn pointed(ctx: &Context, key: Id) -> Option<usize>`. The element of the region `key` its list points at (the row under the pointer), read as a value.
- `craft_ui::runtime::inspect::record`: `pub fn record<R>(ui: &mut Ui, key: Id, body: impl FnOnce(&mut Ui) -> R) -> (R, Option<Arc<Recorded>>)`. Shows `body` as the inspected region `key`: the components it shows in a real run are recorded, and the record is
@@ -3929,13 +4031,14 @@ Ids and memory: `Remember`, the memory stage, `Facts`, eviction and saved state.
- `fn saved<T: Savable>(&mut self, key: &SaveKey) -> &mut T`. The saved slot of `key`: it goes only through `forget_saved`. With a host in the frame it is loaded from the
- `fn recall<T: Slot>(&self) -> T`. A read-only copy of the shown slot, for paint.
- `fn pending<K: Hash, T: Slot, E: Slot>(&mut self, key: K, start: impl FnOnce() -> Job<T, E>) -> &Pending<T, E>`. The result of the job `start` returns, one per `key`: it is submitted once, cancelled when the owner is
- `fn appeared(&self) -> bool`. True on the first pass a shown stage exists for this id.
- `fn appeared(&self) -> bool`. True on the first pass a shown stage exists for this id, and on the first pass after the id was left unshown
- `craft_ui::runtime::memory::Savable`: `pub trait Savable: Slot + Serialize + DeserializeOwned`. A slot that also lives in saved state.
- `craft_ui::runtime::memory::SaveKey`: `pub struct SaveKey`. The key of a saved slot, such as `"craft_dialogs.export.place"`. The crate prefix is checked, and the key
- `pub const fn new(key: &'static str) -> Self`. A key `crate_prefix.name`; evaluated in a const context it rejects a malformed name at compile time. The
- `pub fn named(key: impl Into<Arc<str>>) -> Self`. A key `crate_prefix.name` built at run time, for slots kept per item, such as a window for each open
- `pub fn as_str(&self) -> &str`. The key's text.
- `craft_ui::runtime::memory::Slot`: `pub trait Slot: Clone + Default + Send + Sync + 'static`. A value kept in memory. `Clone` is required because egui's temp store clones on insert; large caches hold `Arc`s.
- `craft_ui::runtime::memory::key_salt`: `pub fn key_salt(key: &impl Hash) -> u64`. A salt for an id made from `key`, a value that is only `Hash`: the ids egui makes also ask for `Debug`, which an
- `craft_ui::runtime::memory::saved_value`: `pub fn saved_value<T: Savable>(ctx: &Context, key: &SaveKey) -> T`. The saved value under `key`, outside a dialog: an app reads one SAVED value through the same store the dialogs'
- `craft_ui::runtime::memory::set_saved_value`: `pub fn set_saved_value<T: Savable>(ctx: &Context, key: &SaveKey, value: T)`. Writes `value` as the saved value under `key`, outside a dialog. It is stored through the host when its
@@ -3947,6 +4050,8 @@ The motion service (13): tweens over one clock, the motion table, and one repain
- `fn anim<T: Interpolate>(&self, name: &'static str, target: T, spec: MotionSpec) -> T`. `target` approached over `spec`'s duration; the first call returns `target` without animating.
- `fn anim_bool(&self, name: &'static str, on: bool, spec: MotionSpec) -> f32`. A 0 to 1 value approaching 1 when `on`, else 0.
- `fn presence(&self, name: &'static str, open: bool, spec: MotionSpec) -> Presence`. Open-close presence for something shown while it opens and fades out.
- `fn presence_keyed<P: Clone + Send + Sync + 'static>(&self, name: &'static str, key: impl Hash, open: bool, payload: P, spec: MotionSpec,) -> Presence`. Open-close presence of one of a set of things under `name`, told apart by `key`, such as the items of a list
- `fn exiting<P: Clone + Send + Sync + 'static>(&self, name: &'static str, spec: MotionSpec) -> Vec<(Presence, P)>`. The keys of `name` that no pass of this frame drove open through `presence_keyed`, fading out, each with the
- `fn jump<T: Interpolate>(&self, name: &'static str, value: T)`. Sets `name` to `value` with no animation.
- `fn phase(&self, period: f64, tick: Option<f64>) -> Option<f32>`. The 0 to 1 position of a loop of `period` seconds, stepped every `tick` seconds when given; `None` when
- `fn blink(&self, restart: f64) -> bool`. Whether a caret last moved at `restart` (a pass time) shows now: solid right after `restart`, then
@@ -3994,6 +4099,7 @@ The layer stack (15.2): the record of the egui layers shown, their order and the
- `craft_ui::runtime::overlay::close_popups`: `pub fn close_popups(ctx: &Context)`. Queues a close of every popup layer of the running viewport shown last frame: its menus, dropdowns and lists. The
- `craft_ui::runtime::overlay::family`: `pub fn family(ctx: &Context, id: Id) -> SmallVec<[Id; 4]>`. `id` and everything opened from inside it, shown last frame.
- `craft_ui::runtime::overlay::is_open`: `pub fn is_open(ctx: &Context, id: Id) -> bool`. Whether the layer `id` was shown last frame.
- `craft_ui::runtime::overlay::pressed_outside`: `pub fn pressed_outside(ctx: &Context, id: Id) -> bool`. Whether a primary press landed outside the layer `id` in this pass while its dismissal kept it open.
- `craft_ui::runtime::overlay::request_close`: `pub fn request_close(ctx: &Context, id: Id, why: CloseReason)`. Queues a close of the layer `id` (a popup or a container). The owner's step 9 or `OverlayUi::show` collects it and
- `craft_ui::runtime::overlay::top`: `pub fn top(ctx: &Context) -> Option<Id>`. The layer that receives Cancel: the newest member of the topmost family that takes keys.
@@ -4105,7 +4211,7 @@ The toast queues: one per window (`WindowKey`), filled from any code with a `Con
- `craft_ui::runtime::windows::ScreenshotError`: re-export of `craft_ui::runtime::egui::screenshot::ScreenshotError`.
- `craft_ui::runtime::windows::ScreenshotFacts`: re-export of `craft_ui::runtime::egui::screenshot::ScreenshotFacts`.
- `craft_ui::runtime::windows::ScreenshotSlot`: re-export of `craft_ui::runtime::egui::screenshot::ScreenshotSlot`.
- `craft_ui::runtime::windows::WindowAction`: `pub enum WindowAction { Close, Minimize, ToggleMaximize, ToggleFullscreen, SetFullscreen(bool), SetMaximized(bool), Focus, StartMove, StartResize(ResizeEdge), SetOuterPosition(Pos2), SetInnerSize(Vec2), SetLevel(WindowLevel), SetTitle(String), SetOpacity(f32) }`. A window command `act` sends.
- `craft_ui::runtime::windows::WindowAction`: `pub enum WindowAction { Close, Minimize, ToggleMaximize, ToggleFullscreen, SetFullscreen(bool), SetMaximized(bool), Focus, StartMove, StartResize(ResizeEdge), SetOuterPosition(Pos2), SetInnerSize(Vec2), Restore, SetMinInnerSize(Vec2), SetLevel(WindowLevel), SetTitle(String), SetOpacity(f32) }`. A window command `act` sends.
- `craft_ui::runtime::windows::WindowFacts`: `pub struct WindowFacts { pub inner: Rect, pub outer: Option<Rect>, pub scale: Option<f32>, pub state: WindowState, pub focused: bool }`. What the OS tells about a window, in desktop points.
- `craft_ui::runtime::windows::WindowHit`: `pub enum WindowHit { Move, Resize(ResizeEdge), Caption(Button) }`. What a part of the window does for the operating system: a press on it moves the window, resizes it from an edge,
- `craft_ui::runtime::windows::WindowHost`: `pub struct WindowHost`. The multi-window driver of one context.
@@ -4118,6 +4224,7 @@ The toast queues: one per window (`WindowKey`), filled from any code with a `Con
- `pub fn visible(&self) -> bool`. Whether the running viewport's window is drawn; a minimized or covered window runs no UI pass, so this reads
- `pub fn is_open(&self, viewport: ViewportId) -> bool`. Whether `viewport`'s window is open this pass, measured or not.
- `pub fn screenshot_facts(&self, viewport: ViewportId) -> Option<ScreenshotFacts>`. What a screenshot of `viewport` measures this pass; `None` when the viewport is not running.
- `pub fn access_tree(&self, viewport: ViewportId) -> Option<crate::runtime::egui::access::TreeUpdate>`. The viewport's latest settled AccessKit update, a host fact of the window as its screenshot facts are; `None`
- `pub fn inject_move(&self, viewport: ViewportId, at: Pos2, mods: Mods, rest: f64)`. Queues a pointer move to `at` in `viewport` with `mods` held, delivered on a pass of its own; the modifiers stay
- `pub fn inject_click(&self, viewport: ViewportId, at: Pos2, button: PointerButton, count: u32, mods: Mods, hold: bool)`. Queues a move to `at`, then `count` presses and releases of `button` with `mods` held, one pass each. With
- `pub fn inject_key(&self, viewport: ViewportId, key: Key, mods: Mods, hold: bool)`. Queues `key` pressed with `mods` held, as the platform reports them, and released unless `hold`.
@@ -4149,6 +4256,7 @@ The toast queues: one per window (`WindowKey`), filled from any code with a `Con
- `pub fn key_window(&self) -> ViewportId`. The window that has the keys: the one the platform reports focused, else the main window. A key the platform
- `pub fn typing(&self) -> bool`. Whether a text field has the keys in [`key_window`](Self::key_window), as its last pass ended: the focused
- `pub fn monitors(&self) -> Vec<Monitor>`. The connected monitors, in desktop pixels; none where the platform does not list them.
- `pub fn monitor_of(&self, viewport: ViewportId) -> Option<Monitor>`. The monitor `viewport`'s window lies on: the one its top-left corner is on, the rule its scale
- `pub fn set_outer(&self, viewport: ViewportId, outer: Rect) -> bool`. Places `viewport`'s outer rect at `outer`: its position, and the inner size that leaves the window's
- `pub fn viewport_of(&self, id: Id) -> Option<ViewportId>`. The viewport of the container `id` while its window is open.
- `pub fn viewport_at(&self, at: Pos2) -> Option<ViewportId>`. The window under the desktop point `at`: where windows overlap, the focused one, else the one focused last,
@@ -4218,8 +4326,9 @@ The style layer: the state set and its resolver, style parts and `ComponentStyle
- `pub fn points(self, pixels_per_point: f32) -> f32`. The width in points on a display of `pixels_per_point`.
- `craft_ui::style::ScrollBarKind`: `pub enum ScrollBarKind { Floating, Docked }`. Which of the two scroll bar looks a bar has.
- `craft_ui::style::ScrollBarLook`: `pub struct ScrollBarLook { pub track: Stateful<StyleColor>, pub thumb: Stateful<StyleColor>, pub thickness: f32, pub thumb_width: Stateful<f32>, pub min_thumb: f32, pub fade: f32 }`. A scroll bar's track and thumb, of a [`ScrollBarKind`].
- `craft_ui::style::Span`: `pub struct Span<'a> { pub text: Cow<'a, str>, pub italic: bool, pub tabular: bool, pub mono: bool, pub muted: bool, pub shortcut: bool, pub highlight: bool, pub underline: bool, pub strong: bool }`. One styled stretch of a run.
- `craft_ui::style::Span`: `pub struct Span<'a> { pub text: Cow<'a, str>, pub italic: bool, pub tabular: bool, pub mono: bool, pub muted: bool, pub shortcut: bool, pub highlight: bool, pub underline: bool, pub strong: bool, pub flag: Option<Tone> }`. One styled stretch of a run.
- `pub fn new(text: impl Into<Cow<'a, str>>) -> Self`. A plain span.
- `pub fn flag(mut self, tone: Tone) -> Self`. Underlines the span in the ink of `tone` (spelling `Bad`, grammar `Info`).
- `pub fn italic(mut self) -> Self`. Italic.
- `pub fn tabular(mut self) -> Self`. Tabular figures.
- `pub fn mono(mut self) -> Self`. The monospace face.
@@ -4243,6 +4352,7 @@ The style layer: the state set and its resolver, style parts and `ComponentStyle
- `pub fn density(&self) -> Size`. The density preset of the scope, for a style whose shape differs between presets.
- `pub fn of_env(ctx: &'a Context, env: &'a crate::runtime::env::Env) -> Self`. The style context of the scope `env` describes, in the secondary variant: for code outside a style function
- `pub fn with_root<R>(ctx: &Context, f: impl FnOnce(&StyleCx<'_>) -> R) -> R`. Runs `f` with the style context of the root scope (`Env::of_root(ctx)`), for code with no `Ui` that reads a
- `pub fn exiting<P: Clone + Send + Sync + 'static>(&self, name: &'static str, spec: MotionSpec, listed: &[impl Hash]) -> Vec<(Presence, P)>`. The keyed presences of `name` in the motion memory of the component this context is scoped to, for the keys
- `pub fn env<T: StyleValue>(&self) -> T`. An app value set by a scope. Its hash is part of the style cache key.
- `pub fn color(&self, color: Rgba) -> StyleColor`. The one constructor of `StyleColor`: a semantic token read or a token-group field becomes a style colour here.
- `pub fn ink_on(&self, fill: DataColor) -> StyleColor`. The ink for text on a user colour: the higher-contrast of `text.normal` and `text.on_strong` on the fill,
@@ -4280,7 +4390,8 @@ The style layer: the state set and its resolver, style parts and `ComponentStyle
- `pub const fn new() -> Self`. No replacements.
- `pub fn push<K: StyleKey, S: ComponentStyle>(&mut self, f: Replacement<K, S>) -> &mut Self`. Replaces the style function of the component whose style key is `K`. Two replacements for one key are an
- `craft_ui::style::SurfaceEdge`: `pub enum SurfaceEdge { None, Border(Stroke), Bevel { top_left: Color32, bottom_right: Color32, width: f32 } }`. A surface's edge, resolved from the theme's edge style.
- `craft_ui::style::SurfaceKind`: `pub enum SurfaceKind { Background, Canvas, Chrome, Panel, Raised, Pressed, Sunken, Well, Knob, Popup, Dialog, Floating, Scrim, Frame }`. The surface a container or part sits on, which picks fill, edge, shadow and ink.
- `craft_ui::style::SurfaceKind`: `pub enum SurfaceKind { Background, Canvas, Chrome, Panel, Raised, Pressed, Sunken, Well, Knob, Popup, Dialog, Floating, Scrim, Frame, Brand }`. The surface a container or part sits on, which picks fill, edge, shadow and ink.
- `pub const ALL: [SurfaceKind; 15]`. Every kind, in the order the gallery shows them.
- `pub const fn ink(self) -> super::Ink`. The ink text and icons read on this surface.
- `craft_ui::style::SurfaceLook`: `pub struct SurfaceLook { pub kind: Option<SurfaceKind>, pub kind_down: Option<SurfaceKind>, pub kind_on: Option<SurfaceKind>, pub fill: Stateful<StyleColor>, pub border: Option<Stateful<StyleColor>>, pub border_width: f32, pub inner: Option<Stateful<StyleColor>>, pub radius: CornerRadius, pub corners: Corners, pub border_replaces_edge: bool }`. A component's or part's surface.
- `pub fn new(fill: Stateful<StyleColor>) -> Self`. A look with `fill` and no kind, border or radius.
@@ -4307,7 +4418,7 @@ The style layer: the state set and its resolver, style parts and `ComponentStyle
- `craft_ui::style::TypeRole`: re-export of `craft_theme::TypeRole` (outside these crates).
- `craft_ui::style::UiTokens`: `pub struct UiTokens`. One resolved token set with the theme's token-group values and a key of their content. Each theme scope
- `pub fn new(tokens: Arc<Tokens>, contrast: Contrast, density: Size) -> Self`. A token set resolved under `contrast` and `density`, with no theme values for token groups, drawing the default
- `pub fn of_theme(theme: &ThemeDef, appearance: Appearance, sizes: &AppSizes) -> Self`. The tokens `theme` resolves to under `appearance` and `sizes`, drawing the icon pack the theme names.
- `pub fn of_theme(theme: &ThemeDef, appearance: Appearance, app: Option<&AppId>, sizes: &AppSizes) -> Self`. The tokens `theme` resolves to under `appearance` and `sizes`, with the pins of `app` (`None`: no app's), drawing
- `pub fn tokens(&self) -> &Arc<Tokens>`. The source tokens.
- `pub fn groups(&self) -> &GroupValues`. The theme's token-group values.
- `pub fn key(&self) -> u64`. Equal for equal sets and distinct for different ones; the token-group and style caches key on it.
@@ -4338,9 +4449,9 @@ The fixture, the suite runner and the story helpers.
- `craft_ui::testing::in_audit_run`: `pub fn in_run(ctx: &Context) -> bool`. Whether the code running in `ctx` is a run of the audit: a test that counts its own runs of a view counts none in
- `craft_ui::testing::install_spec`: re-export of `craft_ui::testing::windows::install_spec`.
- `craft_ui::testing::is_measuring`: re-export of `craft_ui::runtime::measure::active` (defined outside these crates).
- `craft_ui::testing::kept_measurement_leaves`: re-export of `craft_ui::runtime::layout_memory::kept_leaves`.
- `craft_ui::testing::last_frame_memo_runs`: re-export of `craft_ui::runtime::measure::last_frame_memo_runs` (defined outside these crates).
- `craft_ui::testing::last_pass_measure_asks`: re-export of `craft_ui::runtime::measure::last_pass_measure_asks` (defined outside these crates).
- `craft_ui::testing::kept_measurement_leaves`: re-export of `craft_ui::runtime::layout_memory::kept_leaves`.
- `craft_ui::testing::last_pass_measuring_runs`: re-export of `craft_ui::runtime::measure::last_pass_body_runs` (defined outside these crates).
- `craft_ui::testing::last_pass_memo_key_bytes`: re-export of `craft_ui::runtime::measure::last_pass_memo_key_bytes` (defined outside these crates).
- `craft_ui::testing::last_pass_memo_runs`: re-export of `craft_ui::runtime::measure::last_pass_memo_runs` (defined outside these crates).
@@ -4405,6 +4516,8 @@ What the accessibility trials read: the AccessKit tree a frame produced, and the
- `pub fn has_popup_of(&self, key: NodeKey) -> Option<PopupKind>`. The kind of popup the node of `key` opens.
- `pub fn access_key_of(&self, key: NodeKey) -> Option<char>`. The access key of the node of `key`.
- `pub fn current_of(&self, key: NodeKey) -> bool`. Whether the node of `key` is the current item of its set (the current page).
- `pub fn level_of(&self, key: NodeKey) -> Option<usize>`. The level a node by key states: a heading's outline level, a list item's list level, a tree item's depth.
- `pub fn url_of(&self, key: NodeKey) -> Option<&str>`. The address a link node by key goes to.
- `pub fn parent_of(&self, id: Id) -> Option<NodeKey>`. The nearest ancestor of `id` that screen readers see: AccessKit's consumer drops generic containers.
- `pub fn parent_of_key(&self, key: NodeKey) -> Option<NodeKey>`. [`AccessTree::parent_of`] for a node by key.
- `pub fn in_ltr_axis(&self, key: NodeKey) -> bool`. Whether the node is, or lies inside, a component whose horizontal axis keeps its left-to-right order
@@ -4473,6 +4586,14 @@ Text dumps for tests: ordered `key = value` lines compared exactly with a file,
- `craft_ui::testing::dump::themes`: `pub fn themes() -> Vec<(String, UiTokens)>`. Every built-in theme in each mode it has, at standard contrast, as (`<theme>.<mode>`, tokens).
- `craft_ui::testing::dump::update_requested`: `pub fn update_requested() -> bool`. Whether `UPDATE_DUMPS` is set (to anything but `0`).
## `craft_ui::testing::face_runs`
`FaceRuns`: the story card of [`Draw::face_run`](crate::primitives::Draw::face_run), text drawn in a document's own
- `craft_ui::testing::face_runs::FaceRuns`: `pub struct FaceRuns`. Three runs in a document face, as an input method's composition is drawn in the text's own font: at its own size,
- `pub fn new() -> Self`. The card.
- `craft_ui::testing::face_runs::FaceRunsStyle`: `pub struct FaceRunsStyle`. The look of the card: its ink and the baseline rule.
## `craft_ui::testing::fixture`
`Fixture`: one story or closure shown over [`Frames`], with the env a test varies and input by AccessKit query or part.
@@ -4481,8 +4602,14 @@ Text dumps for tests: ordered `key = value` lines compared exactly with a file,
- `pub fn new(show: impl FnMut(&mut Ui) + 'static) -> Self`. A fixture that shows `show` in a room of 400 by 300 points.
- `pub fn story(story: &Story) -> Self`. A fixture that shows `story`; its data and outputs are read with [`Fixture::data`] and [`Fixture::take_outputs`].
- `pub fn story_scoped(story: &Story, scope: fn(&mut Overrides)) -> Self`. A fixture that shows `story` inside an env scope `scope` changes: disabled, read-only, or both.
- `pub fn hosted(mut show: impl FnMut(&mut Ui) -> Option<StoryOutput> + 'static) -> Self`. A fixture that shows a story through `show`, which hosts it and keeps its values: a viewer's story body in its
- `pub fn probe_purity(&mut self) -> &mut Self`. Runs every following pass of the story under the purity probe: a measuring run of the story before each real
- `pub fn impure(&self) -> Vec<Impure>`. The impure passes the fixture has seen so far under [`Fixture::probe_purity`]; see [`Impure`].
- `pub fn root(&mut self, root: RootEnv) -> &mut Self`. The root values of every following frame, whole: the env an app's settings restore.
- `pub fn commands(&mut self, commands: CommandInput) -> &mut Self`. The command input of every following pass, whole, as an app's `FrameInput.commands` gives it: the states and
- `pub fn pixels_per_point(&mut self, pixels_per_point: f32) -> &mut Self`. The pixels per point of every following frame.
- `pub fn record_paint(&mut self) -> &mut Self`. Keeps what every following frame paints, for [`Fixture::take_paint`].
- `pub fn take_paint(&mut self) -> Option<fixture::FullOutput>`. What the frames painted since the last call, as a renderer takes it: the latest frame's shapes and every texture
- `pub fn command_state(&mut self, command: impl Into<CommandRef>, state: CommandState) -> &mut Self`. Gives app-scope `command` this state in every following pass, as an app's `FrameInput.commands` does; a later
- `pub fn gate(&mut self, gate: CommandGate) -> &mut Self`. Sets the app's one gate over commands for every following pass, as an app's `FrameInput.commands` does.
- `pub fn room(&mut self, room: Vec2) -> &mut Self`. The room the story is shown in.
@@ -4933,7 +5060,7 @@ Reading text parts in trials: the widget id, the caret and the text a frame pain
- `craft_ui::testing::text::run_end`: `pub fn run_end(owner: Id, runs: &[(usize, std::ops::Range<usize>, &str)], pos: craft_behavior::TextPos) -> Option<(Id, usize)>`. The run node and character index a position maps to among runs given as `(line, bytes, text)`.
- `craft_ui::testing::text::run_node`: `pub fn run_node(owner: Id, line: usize, run: usize) -> Id`. The id of the run node `run` of line `line` below the text component `owner`.
- `craft_ui::testing::text::widget_id`: `pub fn widget_id(id: Id, key: PartKey) -> Id`. The egui widget id of the text part `key` of component `id`.
- `craft_ui::testing::text::ImeSeen`: `pub struct ImeSeen { pub owner: egui::Id, pub interrupt: bool, pub reset: Option<egui::ImeResetId>, pub caret: Rect }`. The IME output of a frame: the owner widget, whether it asks the OS to interrupt a composition, the caret rect.
- `craft_ui::testing::text::ImeSeen`: `pub struct ImeSeen { pub owner: egui::Id, pub interrupt: bool, pub reset: Option<egui::ImeResetId>, pub caret: Rect, pub generation: u64, pub surrounding: egui::output::IMESurroundingText, pub cause: egui::output::ImeChangeCause }`. The IME output of a frame: the owner widget, whether it asks the OS to interrupt a composition, the caret rect.
- `craft_ui::testing::text::ime_preedit`: `pub fn ime_preedit(text: &str) -> Event`. An IME preedit event of `text` with no cursor range.
- `craft_ui::testing::text::set_value_request`: `pub fn set_value_request(target: egui::Id, text: &str) -> Event`. An AccessKit `SetValue` request carrying `text` for the node of `target`.
- `craft_ui::testing::text::text_selection_request`: `pub fn text_selection_request(target: egui::Id, anchor:(egui::Id, usize), focus:(egui::Id, usize)) -> Event`. An AccessKit `SetTextSelection` request for the node of `target`, from character `anchor.1` of the run node
+1 -1
View File
@@ -122,7 +122,7 @@ The theme's docking sizes (`DockSizes`) set the drop bands and zones. `DockWords
## Floating and native windows
A floating window is a `Floating` in the layout: its one `column`, its `rect` in logical points in the app's viewport, and `native` and `monitor` while it is an OS window. `FloatingGroup` shows it, with the column inside drawn as a dock column is (`ColumnBar::Window`): the window's title row is the column's bar, whose double arrow, like a double click on the row, collapses the column to icons. A collapsed window shows its icons against the edge of the float area it keeps to, under a title row of the band and the double arrow alone (a context request on the band opens the window's menu), and keeps its expanded size for when it expands. With `DockConfig::native_windows` (on by default), every floating window opens in its own OS window (`docking::native`) where the window host opens OS windows and reports where they are (`WindowHost::positions_reported`; not on Wayland); a window never shown native yet opens over its place in the main window. Elsewhere, and for a panel with `allow_native` off, the window stays inside the main window. The OS close of a native window is its Close action: the window closes when every panel in it may close. Dragging a native window by its title row moves the whole window and docks it where it is released over a group of the main window, as a floating window inside the main window does: the app runs that move (`Overlay::moved_by_app`, which the group's mount carries, so the window is opened knowing it). On macOS the row's press hands the move to the OS, the app follows the system pointer and button (`Caps::OS_MOVES_TRACKED`), and a press that ends within the click distance is a click, which docks nothing; elsewhere the app moves the window, and Escape puts it back. The app sends an OS window its place only when the app changes it (an undo, a reloaded layout); the OS's own moves and resizes are recorded and never sent back. `window_kind` says whether an OS window is a document or a tool window. A tool window's title row is its only title bar, whatever frame the main window has (`craft_window::policy::tool_frame`).
A floating window is a `Floating` in the layout: its one `column`, its `rect` in logical points in the app's viewport, and `native` and `monitor` while it is an OS window. `FloatingGroup` shows it, with the column inside drawn as a dock column is (`ColumnBar::Window`): the window's title row is the column's bar, whose double arrow, like a double click on the row, collapses the column to icons. The title row is one text row high (`HeaderStrength::Bar`). A window in the main window keeps a band above it for its top grip (`contract::grip_band`), so the grip never covers the row; an OS window keeps none, and on macOS AppKit resizes it from its own edges, with no app grips there (`DockSizes::window_chrome`). A collapsed window shows its icons against the edge of the float area it keeps to, under a title row of the band and the double arrow alone (a context request on the band opens the window's menu), and keeps its expanded size for when it expands. Its sides resize its width, and only its width, within the bounds of a docked collapsed column (`DockSizes::iconic_bounds`), on every platform and in the main window alike; names show beside the icons from `IconicSizes::labels`, and the width is the column's `iconic_width` (`Action::ResizeIconic`, `FloatingGroupOutput::collapsed_width`), kept across collapse and expand. With `DockConfig::native_windows` (on by default), every floating window opens in its own OS window (`docking::native`) where the window host opens OS windows and reports where they are (`WindowHost::positions_reported`; not on Wayland); a window never shown native yet opens over its place in the main window. Elsewhere, and for a panel with `allow_native` off, the window stays inside the main window. The OS close of a native window is its Close action: the window closes when every panel in it may close. Dragging a native window by its title row moves the whole window and docks it where it is released over a group of the main window, as a floating window inside the main window does: the app runs that move (`Overlay::moved_by_app`, which the group's mount carries, so the window is opened knowing it). On macOS the row's press hands the move to the OS, the app follows the system pointer and button (`Caps::OS_MOVES_TRACKED`), and a press that ends within the click distance is a click, which docks nothing; elsewhere the app moves the window, and Escape puts it back. The app sends an OS window its place only when the app changes it (an undo, a reloaded layout); the OS's own moves and resizes are recorded and never sent back. `window_kind` says whether an OS window is a document or a tool window. A tool window's title row is its only title bar, whatever frame the main window has (`craft_window::policy::tool_frame`).
A panel or group floated out of the dock (a drag, the Float command, a tab torn out of the window) opens at the width it had docked and at the height its group measures at in a floating window's room (`Proposal::Size`), at most `size.float.height`: content that fills its body opens at that height, other content at its own. A column opens at its docked size, at most that height. The area measures once, where the float starts: for a drag in the pass it starts, which adds the size to the drag's payload (`runtime::drag::amend`). A panel's own `PanelSpec` float size wins, and a window that already floats keeps its size.