mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-27 04:38:49 +00:00
Contract stubs: craft-ui-contract, craft-ui-widgets
This commit is contained in:
@@ -19,6 +19,8 @@ struct BandDouble(bool);
|
||||
struct SurfacePress {
|
||||
pressed: bool,
|
||||
double: bool,
|
||||
#[allow(dead_code)] // P3(chrome-w5): ch.K32
|
||||
clicked: bool,
|
||||
}
|
||||
|
||||
impl BodyCx<'_> {
|
||||
@@ -53,6 +55,13 @@ impl BodyCx<'_> {
|
||||
!self.memory.is_peek() && self.memory.recall::<SurfacePress>(sub(self.id, "surface_press")).double
|
||||
}
|
||||
|
||||
/// Whether this pass's primary release ends a press that went down on the container's own surface, moved less
|
||||
/// than `PointerFrame::slop` and was released inside. A drag, a cancel, a release elsewhere and a measuring run
|
||||
/// give false. It takes no focus and is no Tab stop.
|
||||
pub fn surface_clicked(&self) -> bool {
|
||||
todo!("ch.K32")
|
||||
}
|
||||
|
||||
/// Requests `cursor` at `priority` for this pass, in the cursor service the parts' and components' requests go
|
||||
/// to: the highest priority of the pass wins, the later request on a tie. A body that learns something only after
|
||||
/// its children ran (a drag its panes report as refused) sets the cursor in the same pass. A measuring run
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use super::columns::{ColumnSort, ColumnSpec};
|
||||
use super::events::ListDrag;
|
||||
use crate::contract::Notch;
|
||||
use crate::contract::{Notch, ScrollAnchor};
|
||||
pub use crate::runtime::env::RowPressed;
|
||||
use crate::runtime::env::{Counted, Label};
|
||||
use crate::style::StyleCx;
|
||||
@@ -241,6 +241,9 @@ pub struct CollectionProps {
|
||||
/// While a drag whose payload is neither the collection's own nor one of its drop kinds rests over an item that is
|
||||
/// not selected, the item becomes the lead and the selection in that pass.
|
||||
pub select_under_drag: bool,
|
||||
/// Which end of the rows a collection that scrolls its own rows stays at while rows are added; `End` keeps the offset
|
||||
/// at the end as long as the user left it there.
|
||||
pub scroll_anchor: ScrollAnchor,
|
||||
}
|
||||
|
||||
type Payload = Arc<dyn Any + Send + Sync>;
|
||||
@@ -324,6 +327,7 @@ impl CollectionProps {
|
||||
pages: false,
|
||||
current: None,
|
||||
select_under_drag: false,
|
||||
scroll_anchor: ScrollAnchor::Start,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -786,6 +786,8 @@ pub struct ContainerProps {
|
||||
pub collection_body: bool,
|
||||
/// The labelled rows of the body share the widest label as one column.
|
||||
pub label_column: bool,
|
||||
/// The rank by which a body unit of a shrinking row leaves whole; unranked units never leave by rank.
|
||||
pub fit_rank: Option<u8>,
|
||||
/// How the labelled rows under the container show their labels; `None` keeps the scheme of the scope.
|
||||
pub labels: Option<LabelScheme>,
|
||||
/// The component whose memory holds the container's shown memory and its layer's bookkeeping, when it is another:
|
||||
@@ -868,6 +870,7 @@ impl ContainerProps {
|
||||
outer_edit: false,
|
||||
collection_body: false,
|
||||
label_column: false,
|
||||
fit_rank: None,
|
||||
labels: None,
|
||||
owner: None,
|
||||
}
|
||||
@@ -1022,6 +1025,12 @@ impl ContainerProps {
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the rank by which the container leaves a shrinking row whole.
|
||||
pub const fn fit_rank(mut self, rank: u8) -> Self {
|
||||
self.fit_rank = Some(rank);
|
||||
self
|
||||
}
|
||||
|
||||
/// Makes the container an arena root.
|
||||
pub const fn arena(mut self, on: bool) -> Self {
|
||||
self.arena = on;
|
||||
|
||||
@@ -217,6 +217,11 @@ impl<C: Component> Cx<'_, C> {
|
||||
text.layout(&self.core.ctx, &Env::of_root(&self.core.ctx).tokens, craft_i18n::Direction::Ltr)
|
||||
}
|
||||
|
||||
/// Whether the control's link label was clicked in this pass.
|
||||
pub fn link_activated(&self) -> bool {
|
||||
todo!("wg.W08")
|
||||
}
|
||||
|
||||
/// Asks the platform to open `url`, in a new tab where the platform has tabs and `new_tab` is set.
|
||||
pub fn open_url(&mut self, url: &str, new_tab: bool) {
|
||||
crate::runtime::egui::output::open_url(&self.core.ctx, url, new_tab);
|
||||
@@ -236,7 +241,8 @@ impl<C: Component> Cx<'_, C> {
|
||||
/// activation came from (`part_activated` gives it). Returns whether the command was queued.
|
||||
pub fn fire(&mut self, command: impl Into<CommandRef>, source: FireSource) -> bool {
|
||||
let Some(resolved) = commands::resolve_scoped(&self.core.ctx, self.core.env.command_chain(), &command.into()) else { return false };
|
||||
commands::fire_resolved(&self.core.ctx, &resolved, source)
|
||||
// P3(widgets-w3): ap.AP9
|
||||
commands::fire_resolved(&self.core.ctx, &resolved, source, craft_keymap::Mods::NONE)
|
||||
}
|
||||
|
||||
/// Where an activation of `part` came from this pass: `Key` for a keyboard activation while `part` is the
|
||||
|
||||
@@ -75,6 +75,13 @@ impl<'r, K> ItemCx<'_, 'r, K> {
|
||||
self.tip = Some(Box::new(tip));
|
||||
}
|
||||
|
||||
/// Shows `body` under the item, across the content width, in a child `Ui` with id `sub(item_id, "detail")`. It adds
|
||||
/// its height to the item's slot, which keeps its last shown height out of view.
|
||||
pub fn detail(&mut self, body: impl FnOnce(&mut Ui) + 'r) {
|
||||
let _ = body;
|
||||
todo!("ap.AP12")
|
||||
}
|
||||
|
||||
/// The opener for the item's part `part`: after the collection is shown, `CollectionResponse::opener` gives the
|
||||
/// part's response (its click this pass and its rect), and a layer-5 menu opens from it with `opened_by`.
|
||||
pub fn part_opener(&mut self, part: impl Into<craft_behavior::PartRef>) -> ItemOpener {
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::primitives::PartResult;
|
||||
use crate::runtime::drag::{self, DragPreview, DropTarget, DropZone, Typed, WindowDropTarget};
|
||||
use crate::runtime::egui::areas;
|
||||
use crate::runtime::{cursor, frame, pointer, wheel};
|
||||
use craft_behavior::{Cursor, CursorPriority, DropOperation, PartKey, PartRef, PressCancel, PressState, Wheel};
|
||||
use craft_behavior::{Cursor, CursorPriority, DropOperation, MultiTap, PartKey, PartRef, PressCancel, PressState, Wheel};
|
||||
use egui::{Id, Pos2};
|
||||
use std::any::{Any, TypeId};
|
||||
use std::ops::Range;
|
||||
@@ -35,6 +35,9 @@ pub trait Pointer {
|
||||
fn activated_member(&self) -> Option<Id>;
|
||||
/// This pass's wheel share, once, with the pointer it came at (`Wheel::at`) in this component's egui layer space (8.3).
|
||||
fn take_wheel(&mut self) -> Option<Wheel>;
|
||||
/// This pass's tap, once, when it lies in this component's rect and this component (an arena root with its members)
|
||||
/// wins a press there.
|
||||
fn take_multi_tap(&mut self) -> Option<MultiTap>;
|
||||
/// Requests `cursor` at `priority`; the highest priority of the pass wins.
|
||||
fn cursor(&mut self, cursor: impl Into<Cursor>, priority: CursorPriority);
|
||||
/// Ends every captured press of this viewport.
|
||||
@@ -107,6 +110,10 @@ impl Pointer for CxCore<'_> {
|
||||
Some(wheel)
|
||||
}
|
||||
|
||||
fn take_multi_tap(&mut self) -> Option<MultiTap> {
|
||||
todo!("cv.F19")
|
||||
}
|
||||
|
||||
fn cursor(&mut self, cursor: impl Into<Cursor>, priority: CursorPriority) {
|
||||
if self.cursor.as_ref().is_none_or(|(_, held)| priority > *held) {
|
||||
self.cursor = Some((cursor.into(), priority));
|
||||
@@ -198,6 +205,10 @@ impl<C: Component> Pointer for Cx<'_, C> {
|
||||
self.core.take_wheel()
|
||||
}
|
||||
|
||||
fn take_multi_tap(&mut self) -> Option<MultiTap> {
|
||||
self.core.take_multi_tap()
|
||||
}
|
||||
|
||||
fn cursor(&mut self, cursor: impl Into<Cursor>, priority: CursorPriority) {
|
||||
self.core.cursor(cursor, priority);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ use crate::contract::collection::{
|
||||
CollectionEvent, CollectionProps, ColumnKind, DropAt, DropPayload, DropPlace, ListDrag, PendingDrop, ReorderMove, ToggleColumn, ToggleEdit,
|
||||
};
|
||||
use crate::contract::reorder;
|
||||
use crate::contract::reorder::EDGE_ROWS_PER_SECOND;
|
||||
use crate::contract::{Collection, Cx, DragPreview, DropMark, DropTarget, Pointer as _};
|
||||
use crate::runtime::drag;
|
||||
use crate::runtime::env::Label;
|
||||
@@ -23,9 +24,6 @@ use craft_behavior::{
|
||||
use egui::{Pos2, Rect, Vec2};
|
||||
use std::any::Any;
|
||||
|
||||
/// Rows per second the view scrolls at when the pointer is a full edge band beyond the view's edge.
|
||||
pub(super) const EDGE_ROWS_PER_SECOND: f32 = 4.0;
|
||||
|
||||
/// A toggle sweep: the value it sets and the rows it has crossed.
|
||||
#[derive(Clone)]
|
||||
struct Sweep<K> {
|
||||
@@ -57,6 +55,9 @@ pub enum SweepStep<K> {
|
||||
Restore(ToggleEdit<K>),
|
||||
/// Undo the `ShowOnly` of a cancelled Alt sweep: the cell has the value from before it.
|
||||
UndoShowOnly(ToggleEdit<K>),
|
||||
/// The first press held exactly one of the [`SweepApply::claims`] modifiers: it belongs to the host. It flips
|
||||
/// nothing, and the cells its drag crosses give nothing. Reported once; its Cancel gives nothing.
|
||||
Claimed(ToggleEdit<K>),
|
||||
}
|
||||
|
||||
/// The state a sweep needs between events: which gesture opened it and whether Alt was held.
|
||||
@@ -83,6 +84,8 @@ struct Run {
|
||||
pub struct SweepApply {
|
||||
run: Option<Run>,
|
||||
show_only: bool,
|
||||
#[allow(dead_code)] // P3(appearance-w1): dp.C8
|
||||
claims: Vec<craft_keymap::Mods>,
|
||||
}
|
||||
|
||||
/// A move of a collection's own items as they stand before the drop, and as the drop leaves them.
|
||||
@@ -96,7 +99,15 @@ impl SweepApply {
|
||||
|
||||
/// A column where Alt plus the first press shows only that cell.
|
||||
pub fn show_only() -> Self {
|
||||
SweepApply { run: None, show_only: true }
|
||||
SweepApply { run: None, show_only: true, claims: Vec::new() }
|
||||
}
|
||||
|
||||
/// A first press with exactly `mods` held belongs to the host: it flips nothing, and the cells its drag crosses
|
||||
/// give nothing (`SweepStep::Claimed`). Claims are checked before `show_only`'s Alt, and the method can be called
|
||||
/// more than once.
|
||||
pub fn claims(self, mods: craft_keymap::Mods) -> Self {
|
||||
let _ = mods;
|
||||
todo!("dp.C8")
|
||||
}
|
||||
|
||||
/// Whether this is a [`SweepApply::show_only`] column, where Alt plus the first press shows only that cell.
|
||||
|
||||
@@ -13,5 +13,5 @@ mod step;
|
||||
pub use leaf::colon_of;
|
||||
pub(crate) use place::{control_after, label_gap};
|
||||
pub(crate) use props::inside;
|
||||
pub use props::{CellWidth, FieldLayout, GlyphLabel, InsideLabel, LabelKind, LabelScheme, Scrub, SideLabel};
|
||||
pub use props::{CellWidth, FieldLayout, GlyphLabel, InsideLabel, LabelKind, LabelPress, LabelScheme, Scrub, SideLabel};
|
||||
pub(crate) use step::{LabelIn, LeafLabel, Trailing, flow_leaf, in_column, leaf, leaf_under, report_after_reach, run, show_leaf_in_flow};
|
||||
|
||||
@@ -172,6 +172,18 @@ pub(crate) fn inside(env: EnvView<'_>, side: &SideLabel, enabled: bool) -> Optio
|
||||
/// The width of a caption's cell.
|
||||
pub type CellWidth = ColumnWidth;
|
||||
|
||||
/// What a click on a control's side label does.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[non_exhaustive]
|
||||
pub enum LabelPress {
|
||||
/// A click focuses the control.
|
||||
#[default]
|
||||
Focus,
|
||||
/// The label shows in the link look, and a click reports to the control's host and leaves focus alone. It is no
|
||||
/// Tab stop of its own, and a drag still scrubs when `scrub` is on.
|
||||
Link,
|
||||
}
|
||||
|
||||
/// What `ContainerProps.label` holds: how the label is shown and what it does. The text is `Common.label`.
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
@@ -192,6 +204,8 @@ pub struct SideLabel {
|
||||
pub detail: Option<Label>,
|
||||
/// The label's tooltip, in place of its text: a hint a short or glyph label has no room for.
|
||||
pub tooltip: Option<Tooltip>,
|
||||
/// What a click on the label does.
|
||||
pub press: LabelPress,
|
||||
}
|
||||
|
||||
impl SideLabel {
|
||||
@@ -218,6 +232,7 @@ impl SideLabel {
|
||||
icon: None,
|
||||
detail: None,
|
||||
tooltip: None,
|
||||
press: LabelPress::Focus,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,6 +257,13 @@ impl SideLabel {
|
||||
self
|
||||
}
|
||||
|
||||
/// Shows the label as a link: a click reports to the control's host (`Cx::link_activated`) and leaves focus alone.
|
||||
#[must_use]
|
||||
pub const fn link(mut self) -> Self {
|
||||
self.press = LabelPress::Link;
|
||||
self
|
||||
}
|
||||
|
||||
/// Lets a drag on the label scrub the control's value.
|
||||
#[must_use]
|
||||
pub const fn scrub(mut self, on: bool) -> Self {
|
||||
|
||||
@@ -87,7 +87,7 @@ pub use items::put_toggle_names;
|
||||
pub use items::{ColumnCommands, SweepApply, SweepStep, item_part_open, request_rename, section_part};
|
||||
#[doc(hidden)]
|
||||
pub use label::colon_of;
|
||||
pub use label::{CellWidth, FieldLabelRole, FieldLayout, GlyphLabel, InsideLabel, LabelKind, LabelScheme, Scrub, SideLabel};
|
||||
pub use label::{CellWidth, FieldLabelRole, FieldLayout, GlyphLabel, InsideLabel, LabelKind, LabelPress, LabelScheme, Scrub, SideLabel};
|
||||
pub use lazy::Lazy;
|
||||
#[doc(hidden)]
|
||||
#[cfg(feature = "testing")]
|
||||
|
||||
@@ -56,6 +56,10 @@ pub enum Place {
|
||||
/// Beside the anchor, it lines up with the anchor's other end when that fits and the aligned end does not,
|
||||
/// instead of sliding inside the bounds: a submenu of a low row opens upward.
|
||||
flips_across: bool,
|
||||
/// Where the layer sits from the place it would take: shifts it by this much.
|
||||
offset: egui::Vec2,
|
||||
/// A rect the layer keeps clear of, in the layer's own space.
|
||||
clear: Option<egui::Rect>,
|
||||
},
|
||||
/// Free-standing.
|
||||
Float(FloatPlace),
|
||||
@@ -64,16 +68,28 @@ pub enum Place {
|
||||
impl Place {
|
||||
/// An anchored place.
|
||||
pub const fn anchored(anchor: Anchor, side: Side, align: Align) -> Self {
|
||||
Place::Anchored { anchor, side, align, flips_across: false }
|
||||
Place::Anchored { anchor, side, align, flips_across: false, offset: egui::Vec2::ZERO, clear: None }
|
||||
}
|
||||
|
||||
/// The place, beside its anchor, lining up with the anchor's other end when that fits and the aligned end does not.
|
||||
pub const fn flipping_across(self) -> Self {
|
||||
match self {
|
||||
Place::Anchored { anchor, side, align, .. } => Place::Anchored { anchor, side, align, flips_across: true },
|
||||
Place::Anchored { anchor, side, align, offset, clear, .. } => Place::Anchored { anchor, side, align, flips_across: true, offset, clear },
|
||||
float => float,
|
||||
}
|
||||
}
|
||||
|
||||
/// The place shifted by `by` from where it would sit; no change off `Anchored`.
|
||||
pub fn offset(self, by: egui::Vec2) -> Self {
|
||||
let _ = by;
|
||||
todo!("cv.F38")
|
||||
}
|
||||
|
||||
/// The place keeping clear of `rect`; no change off `Anchored`.
|
||||
pub fn clear_of(self, rect: egui::Rect) -> Self {
|
||||
let _ = rect;
|
||||
todo!("cv.F38")
|
||||
}
|
||||
}
|
||||
|
||||
/// A fraction of the viewport per axis.
|
||||
|
||||
@@ -6,6 +6,18 @@ use crate::runtime::keys::Intents;
|
||||
use craft_behavior::{Axis, Intent, NavOutline, keys};
|
||||
use egui::{Pos2, Rect};
|
||||
|
||||
/// Rows per second the view scrolls at when the pointer is a full edge band beyond the view's edge.
|
||||
pub(crate) const EDGE_ROWS_PER_SECOND: f32 = 4.0;
|
||||
|
||||
/// The scroll step, in the view's units, of a drag whose pointer is `at` from the view's top edge in a `view` tall
|
||||
/// view of `row` tall rows: the band is `row.min(view / 2.0)`, the step grows with the depth into it, and `dt` is the
|
||||
/// frame's time.
|
||||
#[allow(dead_code)] // P3(appearance-w1): ap.AP10
|
||||
pub(crate) fn edge_step(view: f32, row: f32, at: f32, dt: f32) -> f32 {
|
||||
let _ = (view, row, at, dt);
|
||||
todo!("ap.AP10")
|
||||
}
|
||||
|
||||
/// The gap a drop would land in.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
|
||||
@@ -1694,9 +1694,9 @@ fn measure_step(
|
||||
let ideal = steps::measure(style, &input, content, Vec2::ZERO, resolved).x;
|
||||
let whole = steps::whole(style, content, Vec2::ZERO, resolved);
|
||||
let least = ask(&mut *t, Proposal::Min, None, Vec2::ZERO).0.x;
|
||||
crate::layout::report_shrink(ctx, row, id, size.x, ideal, Some((whole, least)), t.cut_first());
|
||||
crate::layout::report_shrink(ctx, row, id, size.x, ideal, Some((whole, least)), t.cut_first(), None); // P3(chrome-w5): ch.K30
|
||||
}
|
||||
Some(crate::layout::Shrink::Count(row)) => crate::layout::report_shrink(ctx, row, id, size.x, size.x, None, false),
|
||||
Some(crate::layout::Shrink::Count(row)) => crate::layout::report_shrink(ctx, row, id, size.x, size.x, None, false, None), // P3(chrome-w5): ch.K30
|
||||
Some(crate::layout::Shrink::Least(row)) if shape == ShapeKind::Body => crate::layout::report_least(ctx, row, id, size.x),
|
||||
_ => {}
|
||||
}
|
||||
@@ -1704,7 +1704,7 @@ fn measure_step(
|
||||
// the units narrow to leave it, and it takes what they leave.
|
||||
if let Some(crate::layout::Shrink::Count(row)) = env.shrink.filter(|_| fill_body) {
|
||||
let content = measured.x + t.overflow();
|
||||
crate::layout::report_shrink(ctx, row, id, size.x.min(content), content, Some((content, content)), false);
|
||||
crate::layout::report_shrink(ctx, row, id, size.x.min(content), content, Some((content, content)), false, None); // P3(chrome-w5): ch.K30
|
||||
}
|
||||
// A component shown at a rect fills it: the rect is its size, and a leaf that measures nothing (a content
|
||||
// painter) still shows there.
|
||||
|
||||
@@ -21,9 +21,11 @@ pub(crate) fn before_finish(core: &mut CxCore<'_>, activated: bool, injected: Op
|
||||
if activated && let Some(command) = &core.command {
|
||||
match injected {
|
||||
Some(source) => {
|
||||
commands::fire_resolved(&core.ctx, command, source);
|
||||
// P3(shortcuts-w1): ap.AP9
|
||||
commands::fire_resolved(&core.ctx, command, source, craft_keymap::Mods::NONE);
|
||||
}
|
||||
None => commands::fire_bound(&core.ctx, command),
|
||||
// P3(shortcuts-w1): ap.AP9
|
||||
None => commands::fire_bound(&core.ctx, command, craft_keymap::Mods::NONE),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,6 +450,9 @@ pub struct EditResponse<T> {
|
||||
/// The modifiers of the Enter that submitted the value (Shift+Enter, Cmd+Enter); none unless `submitted` came
|
||||
/// from a key.
|
||||
pub submit_mods: craft_keymap::Mods,
|
||||
/// The modifiers held at the activation (click, Enter, Space) that applied this pass's value; a text Enter's stay
|
||||
/// in `submit_mods`.
|
||||
pub activation_mods: craft_keymap::Mods,
|
||||
/// Tab (`Some(true)`) or Shift+Tab (`Some(false)`) moved focus off the text part in this pass, which ended its
|
||||
/// edit; a list's rename continues on the next or previous row.
|
||||
pub left_by_tab: Option<bool>,
|
||||
@@ -476,6 +479,7 @@ impl<T> EditResponse<T> {
|
||||
events,
|
||||
submitted: false,
|
||||
submit_mods: craft_keymap::Mods::NONE,
|
||||
activation_mods: craft_keymap::Mods::NONE,
|
||||
left_by_tab: None,
|
||||
escaped: false,
|
||||
unparsed: false,
|
||||
@@ -495,6 +499,7 @@ impl<T> EditResponse<T> {
|
||||
events,
|
||||
submitted: false,
|
||||
submit_mods: craft_keymap::Mods::NONE,
|
||||
activation_mods: craft_keymap::Mods::NONE,
|
||||
left_by_tab: None,
|
||||
escaped: false,
|
||||
unparsed: false,
|
||||
@@ -532,6 +537,7 @@ impl<T: Clone> EditResponse<T> {
|
||||
events: self.events.map(&f),
|
||||
submitted: self.submitted,
|
||||
submit_mods: self.submit_mods,
|
||||
activation_mods: self.activation_mods,
|
||||
left_by_tab: self.left_by_tab,
|
||||
escaped: self.escaped,
|
||||
unparsed: self.unparsed,
|
||||
|
||||
@@ -302,6 +302,8 @@ struct Reported {
|
||||
whole: f32,
|
||||
body: bool,
|
||||
cut_first: bool,
|
||||
/// The rank by which the unit leaves whole before the cut-first drops; `None` never leaves by rank.
|
||||
rank: Option<u8>,
|
||||
}
|
||||
|
||||
/// The widths of a unit of a row that shrinks to fit: the width it asks for and the least it narrows to.
|
||||
@@ -331,10 +333,19 @@ pub(crate) struct LeastReports(IdMap<IdMap<f32>>);
|
||||
|
||||
/// Reports the widths of the unit `leaf` of the row `row` that counts them: a leaf's whole and least widths, or `None`
|
||||
/// for a body.
|
||||
pub(crate) fn report_shrink(ctx: &egui::Context, row: Id, leaf: Id, took: f32, ideal: f32, whole_least: Option<(f32, f32)>, cut_first: bool) {
|
||||
pub(crate) fn report_shrink(
|
||||
ctx: &egui::Context,
|
||||
row: Id,
|
||||
leaf: Id,
|
||||
took: f32,
|
||||
ideal: f32,
|
||||
whole_least: Option<(f32, f32)>,
|
||||
cut_first: bool,
|
||||
rank: Option<u8>,
|
||||
) {
|
||||
let (whole, least) = whole_least.map_or((ideal, ideal), |(whole, least)| (whole.min(ideal), least.min(ideal)));
|
||||
let widths = ShrinkUnit { ideal, least: least.min(whole) };
|
||||
let leaf = Reported { leaf, took, widths, whole, body: whole_least.is_none(), cut_first };
|
||||
let leaf = Reported { leaf, took, widths, whole, body: whole_least.is_none(), cut_first, rank };
|
||||
pass_state::with::<ShrinkReports, _>(ctx, |reports| reports.0.entry(row).or_default().push(leaf));
|
||||
}
|
||||
|
||||
@@ -442,11 +453,13 @@ fn shrink_or_drop(
|
||||
units: &[ShrinkUnit],
|
||||
whole: &[f32],
|
||||
first: &[bool],
|
||||
ranks: &[Option<u8>],
|
||||
(fixed, gap): (f32, f32),
|
||||
room: f32,
|
||||
order: ShrinkOrder,
|
||||
drops: bool,
|
||||
) -> Vec<ShrinkCap> {
|
||||
let _ = ranks; // P3(chrome-w5): ch.K30
|
||||
let mut kept = vec![true; units.len()];
|
||||
let mut fixed = fixed;
|
||||
// Half a point: less than a pixel shows at any scale the box runs.
|
||||
@@ -534,8 +547,9 @@ fn run_shrinking<R>(ui: &mut Ui, id: Id, mut body: impl FnMut(&mut Ui) -> R) ->
|
||||
let units: Vec<ShrinkUnit> = leaves.iter().map(|leaf| leaf.widths).collect();
|
||||
let whole: Vec<f32> = leaves.iter().map(|leaf| leaf.whole).collect();
|
||||
let first: Vec<bool> = leaves.iter().map(|leaf| leaf.cut_first).collect();
|
||||
let ranks: Vec<Option<u8>> = leaves.iter().map(|leaf| leaf.rank).collect();
|
||||
let widths = if room.is_finite() {
|
||||
shrink_or_drop(&units, &whole, &first, (fixed, gap), room, order, drops)
|
||||
shrink_or_drop(&units, &whole, &first, &ranks, (fixed, gap), room, order, drops)
|
||||
} else {
|
||||
units.iter().map(|unit| ShrinkCap { width: unit.ideal, dropped: false }).collect()
|
||||
};
|
||||
|
||||
@@ -370,7 +370,8 @@ impl<'a> Draw<'a> {
|
||||
self.initial(rect, letter, StyleColor(color));
|
||||
return;
|
||||
}
|
||||
_ => super::icon::paint(self.painter, self.env.tokens, self.env.direction, rect, icon),
|
||||
// P3(object-panels-w1): op.F3
|
||||
_ => super::icon::paint_icon(self.painter, self.env.tokens, self.env.direction, rect, icon),
|
||||
}
|
||||
if let Some(badge) = icon.badge {
|
||||
let radius = self.env.tokens.size.handle.sm / 2.0;
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
//! The one host painter a value carries.
|
||||
|
||||
use super::ContentPainterCx;
|
||||
use egui::Rect;
|
||||
use std::fmt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// The one host painter a value carries: two faces with one key are the same value.
|
||||
#[derive(Clone)]
|
||||
pub struct FacePaint {
|
||||
key: u64,
|
||||
#[allow(dead_code)] // P3(widgets-w6): wg.W04
|
||||
paint: Arc<dyn Fn(&ContentPainterCx<'_>, Rect) + Send + Sync>,
|
||||
}
|
||||
|
||||
impl FacePaint {
|
||||
/// A face identified by `key` that paints with `paint`.
|
||||
pub fn new(key: u64, paint: impl Fn(&ContentPainterCx<'_>, Rect) + Send + Sync + 'static) -> Self {
|
||||
let _ = (key, paint);
|
||||
todo!("wg.W04")
|
||||
}
|
||||
|
||||
/// The key that identifies the face.
|
||||
pub fn key(&self) -> u64 {
|
||||
todo!("wg.W04")
|
||||
}
|
||||
|
||||
/// Paints the face into `rect`.
|
||||
pub fn paint(&self, cx: &ContentPainterCx<'_>, rect: Rect) {
|
||||
let _ = (cx, rect);
|
||||
todo!("wg.W04")
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for FacePaint {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.key == other.key
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for FacePaint {}
|
||||
|
||||
impl Hash for FacePaint {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.key.hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for FacePaint {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_tuple("FacePaint").field(&self.key).finish()
|
||||
}
|
||||
}
|
||||
@@ -198,8 +198,9 @@ pub fn icon_names() -> &'static [&'static str] {
|
||||
svg_set::names()
|
||||
}
|
||||
|
||||
/// Paints `spec`'s glyph centred in the square of `rect`'s shorter side; `Draw::icon` adds the badge.
|
||||
pub(crate) fn paint(painter: &Painter, tokens: &UiTokens, direction: Direction, rect: Rect, spec: &IconSpec<'_>) {
|
||||
/// Paints `spec` centred in `rect` as components do, so a [`Glyph`] (which gets a raw `Painter`) can draw a set icon
|
||||
/// inside its own drawing. `Draw::icon` adds the badge.
|
||||
pub fn paint_icon(painter: &Painter, tokens: &UiTokens, direction: Direction, rect: Rect, spec: &IconSpec<'_>) {
|
||||
let color = spec.color_in(tokens);
|
||||
let rtl = direction == Direction::Rtl;
|
||||
let side = rect.width().min(rect.height());
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
pub mod backdrop;
|
||||
mod content;
|
||||
mod draw;
|
||||
mod face;
|
||||
mod faces;
|
||||
mod focus_ring;
|
||||
#[doc(hidden)]
|
||||
@@ -33,11 +34,12 @@ mod tool;
|
||||
|
||||
pub use content::{ContentPainterCx, DocRun, DocText};
|
||||
pub use draw::{Dashes, DataStrokeWidth, DataWidth, Draw, PaintShape, StrokeColor, StrokeWidth};
|
||||
pub use face::FacePaint;
|
||||
pub use faces::FacesCx;
|
||||
pub use focus_ring::{FocusKind, FocusRing};
|
||||
pub use handle::{Handle, HandleShape};
|
||||
pub(crate) use icon::SvgIcon;
|
||||
pub use icon::{Glyph, IconSet, IconSource, IconSpec, Mirror, has_icon, icon_names};
|
||||
pub use icon::{Glyph, IconSet, IconSource, IconSpec, Mirror, has_icon, icon_names, paint_icon};
|
||||
pub use ime_surface::ImeSurface;
|
||||
pub use kit::{
|
||||
Checker, CheckerArea, GridAxis, GridInk, GridLines, GridLook, GridStroke, MAX_LINES, Tick, TickEdge, TickRank, dashed, drop_mark, ellipse,
|
||||
|
||||
@@ -18,12 +18,20 @@ pub struct AppIcons {
|
||||
pub stroke_width: Option<f32>,
|
||||
/// Each icon's name and SVG document.
|
||||
pub icons: &'static [(&'static str, &'static [u8])],
|
||||
/// For each icon name, an SVG document drawn under the icon in a fixed sRGBA colour; the icon itself stays tinted.
|
||||
pub fills: &'static [(&'static str, &'static [u8], [u8; 4])],
|
||||
}
|
||||
|
||||
impl AppIcons {
|
||||
/// The set `name` of `icons`, each an icon name and its SVG document, drawn with `stroke_width` when it is `Some`.
|
||||
pub const fn new(name: &'static str, stroke_width: Option<f32>, icons: &'static [(&'static str, &'static [u8])]) -> Self {
|
||||
Self { name, stroke_width, icons }
|
||||
Self { name, stroke_width, icons, fills: &[] }
|
||||
}
|
||||
|
||||
/// The set with `fills`: for each icon name, an SVG drawn under the icon in a fixed sRGBA colour.
|
||||
pub const fn with_fills(mut self, fills: &'static [(&'static str, &'static [u8], [u8; 4])]) -> Self {
|
||||
self.fills = fills;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,8 @@ pub struct TextRun<'a> {
|
||||
/// The angle the run is painted at, in radians clockwise about the top-left corner of its layout. Layout and
|
||||
/// measure see the unrotated run.
|
||||
pub rotation: f32,
|
||||
/// The colour of the link spans; `None` takes the link look's.
|
||||
pub link_color: Option<Color32>,
|
||||
}
|
||||
|
||||
impl<'a> TextRun<'a> {
|
||||
@@ -94,12 +96,13 @@ impl<'a> TextRun<'a> {
|
||||
ltr: false,
|
||||
align: HAlign::Start,
|
||||
rotation: 0.0,
|
||||
link_color: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// A run of `spans`.
|
||||
pub fn spans(spans: Vec<Span<'a>>) -> Self {
|
||||
TextRun { spans, role: TypeRole::Label, color: None, wrap: Wrap::Line, ltr: false, align: HAlign::Start, rotation: 0.0 }
|
||||
TextRun { spans, role: TypeRole::Label, color: None, wrap: Wrap::Line, ltr: false, align: HAlign::Start, rotation: 0.0, link_color: None }
|
||||
}
|
||||
|
||||
/// `text` with its character `at` underlined, as a mnemonic shows while it is in use; all of `text` plain when
|
||||
@@ -117,6 +120,12 @@ impl<'a> TextRun<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the colour of the run's link spans.
|
||||
pub fn link_color(self, color: Color32) -> Self {
|
||||
let _ = color;
|
||||
todo!("dp.R2")
|
||||
}
|
||||
|
||||
/// Sets the colour.
|
||||
pub fn color(mut self, color: StyleColor) -> Self {
|
||||
self.color = Some(color);
|
||||
|
||||
@@ -97,6 +97,9 @@ pub struct TextOptions {
|
||||
/// A press on a part declared `holds_drafts`, or on a popup layer above the field, leaves the focused draft
|
||||
/// unapplied.
|
||||
pub holds_drafts: bool,
|
||||
/// Set from the codec by `Cx::text`, never by hosts: a pasted text, trimmed, that this says is whole replaces all
|
||||
/// the text instead of the selection.
|
||||
pub whole_paste: Option<std::sync::Arc<dyn Fn(&str) -> bool + Send + Sync>>,
|
||||
}
|
||||
|
||||
impl Default for TextOptions {
|
||||
@@ -127,6 +130,7 @@ impl Default for TextOptions {
|
||||
own_menu: false,
|
||||
tab_rewrites: false,
|
||||
holds_drafts: false,
|
||||
whole_paste: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,7 +478,8 @@ fn paint_placeholder(cx: &ContentPainterCx<'_>, rect: Rect, paper: Option<DataCo
|
||||
fn paint_failure(cx: &ContentPainterCx<'_>, rect: Rect) {
|
||||
let side = cx.tokens.size.icon.sm.min(rect.width().min(rect.height()));
|
||||
let icon = Rect::from_center_size(rect.center(), vec2(side, side));
|
||||
crate::primitives::icon::paint(&cx.painter, cx.tokens, cx.direction, icon, &IconSpec::svg(IconId::new("warning")));
|
||||
// P3(object-panels-w1): op.F3
|
||||
crate::primitives::icon::paint_icon(&cx.painter, cx.tokens, cx.direction, icon, &IconSpec::svg(IconId::new("warning")));
|
||||
}
|
||||
|
||||
/// A [`ThumbSource`] for stories and tests in every crate: pictures made from the key and a revision the test sets,
|
||||
|
||||
@@ -24,6 +24,8 @@ use std::collections::{HashMap, HashSet};
|
||||
use std::sync::Arc;
|
||||
|
||||
type StateKey = (u32, Option<Id>);
|
||||
/// The key of an app-scope state: the command number and, for a ref with params, its `CommandRef::key`.
|
||||
type AppStateKey = (u32, Option<String>);
|
||||
|
||||
/// How a command with `ModalRule::Declared` reaches into the top modal layer.
|
||||
#[derive(Clone, Copy)]
|
||||
@@ -130,7 +132,7 @@ pub(crate) struct Board {
|
||||
/// Command ids by number, so a state lookup allocates nothing.
|
||||
numbers: HashMap<String, u32>,
|
||||
/// The app-scope states of the app's `Tracked<CommandStates>`, by command number, and the revision they are of.
|
||||
app_states: HashMap<u32, CommandState>,
|
||||
app_states: HashMap<AppStateKey, CommandState>,
|
||||
app_revision: Option<Revision>,
|
||||
/// The states instances published this frame and last frame; a resolution reads this frame's, else last frame's.
|
||||
this: HashMap<StateKey, CommandState>,
|
||||
@@ -625,14 +627,14 @@ impl Board {
|
||||
self.instances.get(id).is_some_and(|i| self.live(ctx, i))
|
||||
}
|
||||
|
||||
/// The definition of the command `id`: the linked sets', else the frame's app catalog's.
|
||||
fn def(&self, id: &str) -> Option<&CommandDef> {
|
||||
self.registry.get(id).or_else(|| self.app.as_ref()?.get(id))
|
||||
/// The definition of `command`: the linked sets' by id, else the frame's app catalog's.
|
||||
fn def(&self, command: &CommandRef) -> Option<&CommandDef> {
|
||||
self.registry.get(&command.id).or_else(|| self.app.as_ref()?.get(command))
|
||||
}
|
||||
|
||||
/// The scope name of `command`; commands no definition names belong to the application.
|
||||
fn scope_of(&self, command: &CommandRef) -> &str {
|
||||
self.def(&command.id).map_or(CommandScope::APP.name(), |def| def.scope.as_str())
|
||||
self.def(command).map_or(CommandScope::APP.name(), |def| def.scope.as_str()) // P3(shortcuts-w1): kb.C3
|
||||
}
|
||||
|
||||
fn state_key(&self, command: &CommandRef, instance: Option<Id>) -> Option<StateKey> {
|
||||
@@ -725,7 +727,7 @@ impl Board {
|
||||
from: &Vantage,
|
||||
reads: &mut Reads,
|
||||
) -> (ResolvedCommand, Option<StateKey>) {
|
||||
let def = self.def(&command.id);
|
||||
let def = self.def(command); // P3(shortcuts-w1): kb.C3
|
||||
let app = self.to_app(self.scope_of(command));
|
||||
let instance = if app { None } else { instance };
|
||||
let dialog_open = from.modal_open || from.dialog_keys;
|
||||
@@ -746,7 +748,8 @@ impl Board {
|
||||
};
|
||||
// An app-scope state is the app's held one; an instance's is this frame's publish, else last frame's.
|
||||
let (this, last) = match key {
|
||||
Some((number, None)) => (self.app_states.get(&number), None),
|
||||
// P3(shortcuts-w1): op.F9
|
||||
Some((number, None)) => (self.app_states.get(&(number, None)), None),
|
||||
Some(key) => (self.this.get(&key), self.last.get(&key)),
|
||||
None => (None, None),
|
||||
};
|
||||
@@ -938,7 +941,8 @@ fn build_keymap(registry: ®istry::Registry, app: Option<&AppCatalog>, platfor
|
||||
.iter()
|
||||
.filter_map(|def| WindowShortcut::of(&def.command).map(|key| (key, &def.command)))
|
||||
.flat_map(|(key, command)| {
|
||||
keymap.bindings(command).into_iter().filter(|binding| !binding.trigger.double).map(move |binding| (key, binding.trigger.chord))
|
||||
// P3(shortcuts-w1): kb.C13b
|
||||
keymap.bindings(command).into_iter().filter(|binding| !binding.trigger.is_double()).map(move |binding| (key, binding.trigger.chord))
|
||||
})
|
||||
.collect();
|
||||
let edit_chords = registry
|
||||
@@ -948,7 +952,8 @@ fn build_keymap(registry: ®istry::Registry, app: Option<&AppCatalog>, platfor
|
||||
// Delete's keys (Delete, Backspace) stay a focused text part's own deletion, which also deletes one character.
|
||||
.filter(|(edit, _)| *edit != EditCommand::Delete)
|
||||
.flat_map(|(edit, command)| {
|
||||
keymap.bindings(command).into_iter().filter(|binding| !binding.trigger.double).map(move |binding| (edit, binding.trigger.chord))
|
||||
// P3(shortcuts-w1): kb.C13b
|
||||
keymap.bindings(command).into_iter().filter(|binding| !binding.trigger.is_double()).map(move |binding| (edit, binding.trigger.chord))
|
||||
})
|
||||
.collect();
|
||||
let mut shown_text = HashMap::new();
|
||||
@@ -1030,13 +1035,15 @@ pub(crate) fn set_input(ctx: &Context, input: &CommandInput) {
|
||||
board.app_revision = revision;
|
||||
let mut states = HashMap::new();
|
||||
for (command, state) in input.states.iter().flat_map(|(_, states)| states.iter()) {
|
||||
states.insert(board.number(&command.id), state.clone());
|
||||
// P3(shortcuts-w1): op.F9
|
||||
states.insert((board.number(&command.id), None), state.clone());
|
||||
}
|
||||
let changed: Vec<u32> = states
|
||||
.iter()
|
||||
.filter(|(number, state)| board.app_states.get(number) != Some(*state))
|
||||
.map(|(number, _)| *number)
|
||||
.chain(board.app_states.keys().filter(|number| !states.contains_key(number)).copied())
|
||||
// P3(shortcuts-w1): op.F9
|
||||
.filter(|(key, state)| board.app_states.get(*key) != Some(*state))
|
||||
.map(|(key, _)| key.0)
|
||||
.chain(board.app_states.keys().filter(|key| !states.contains_key(*key)).map(|key| key.0))
|
||||
.collect();
|
||||
board.app_states = states;
|
||||
for number in changed {
|
||||
@@ -1231,7 +1238,7 @@ fn resolve_in(
|
||||
mut reads: Reads,
|
||||
) -> (ResolvedCommand, ResolveKey) {
|
||||
let (resolved, key, first_unknown) = with(ctx, |board| {
|
||||
let first_unknown = board.def(&command.id).is_none() && board.unknown.insert(command.id.clone());
|
||||
let first_unknown = board.def(command).is_none() && board.unknown.insert(command.id.clone()); // P3(shortcuts-w1): kb.C3
|
||||
// A command no state named yet has a key too, so a state given later reaches the regions that read it.
|
||||
board.number(&command.id);
|
||||
let (mut resolved, state) = board.resolve(ctx, command, instance, reach, from.unwrap_or(&board.here), &mut reads);
|
||||
@@ -1513,12 +1520,13 @@ pub(crate) fn fall_through(ctx: &Context, command: craft_behavior::EditCommand)
|
||||
}
|
||||
|
||||
/// Step 17: the command of a component that was activated and enabled.
|
||||
pub(crate) fn fire_bound(ctx: &Context, command: &ResolvedCommand) {
|
||||
fire_resolved(ctx, command, FireSource::Pointer);
|
||||
pub(crate) fn fire_bound(ctx: &Context, command: &ResolvedCommand, mods: craft_keymap::Mods) {
|
||||
fire_resolved(ctx, command, FireSource::Pointer, mods);
|
||||
}
|
||||
|
||||
/// Queues `command` for its instance with `source`; false when disabled.
|
||||
pub(crate) fn fire_resolved(ctx: &Context, command: &ResolvedCommand, source: FireSource) -> bool {
|
||||
pub(crate) fn fire_resolved(ctx: &Context, command: &ResolvedCommand, source: FireSource, mods: craft_keymap::Mods) -> bool {
|
||||
let _ = mods; // P3(shortcuts-w1): ap.AP9
|
||||
if !command.enabled || !crate::runtime::measure::effect(ctx, "board::fire_resolved") {
|
||||
return false;
|
||||
}
|
||||
@@ -1569,7 +1577,7 @@ pub(crate) fn publish(ctx: &Context, chain: &CommandChain, command: &CommandRef,
|
||||
);
|
||||
let changed = with(ctx, |board| {
|
||||
let scope = board.scope_of(command);
|
||||
let declared = board.def(&command.id).is_some_and(|def| def.modal == ModalRule::Declared);
|
||||
let declared = board.def(command).is_some_and(|def| def.modal == ModalRule::Declared); // P3(shortcuts-w1): kb.C3
|
||||
debug_assert!(
|
||||
!is_app(scope) || declared,
|
||||
"{command} is an app-scope command: its state comes from `FrameInput.commands`, unless the command is declared by an instance"
|
||||
@@ -1824,6 +1832,7 @@ pub(crate) fn begin(ctx: &Context) {
|
||||
phase: FirePhase::Release,
|
||||
cycle: false,
|
||||
alt_variant: false,
|
||||
mods: craft_keymap::Mods::NONE, // P3(shortcuts-w1): ap.AP9
|
||||
time,
|
||||
});
|
||||
}
|
||||
@@ -1843,7 +1852,8 @@ pub(crate) fn begin(ctx: &Context) {
|
||||
let key = shortcut.input.physical.or(shortcut.input.typed);
|
||||
with(ctx, |board| {
|
||||
if let Some(key) = key.filter(|_| {
|
||||
board.def(&hit.command.id).is_some_and(|def| matches!(def.kind, CommandKind::Momentary | CommandKind::Tool { .. }))
|
||||
// P3(shortcuts-w1): kb.C3
|
||||
board.def(&hit.command).is_some_and(|def| matches!(def.kind, CommandKind::Momentary | CommandKind::Tool { .. }))
|
||||
}) {
|
||||
board.held.retain(|held| held.key != key);
|
||||
board.held.push(Held { key, command: hit.command.clone(), target });
|
||||
@@ -1856,6 +1866,7 @@ pub(crate) fn begin(ctx: &Context) {
|
||||
phase: FirePhase::Press,
|
||||
cycle: hit.cycle.len() > 1,
|
||||
alt_variant: hit.alt_variant,
|
||||
mods: craft_keymap::Mods::NONE, // P3(shortcuts-w1): ap.AP9
|
||||
time,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -74,8 +74,10 @@ impl AppCatalog {
|
||||
&self.defs
|
||||
}
|
||||
|
||||
pub(crate) fn get(&self, id: &str) -> Option<&CommandDef> {
|
||||
self.index.get(id).and_then(|&at| self.defs.get(at))
|
||||
/// The def with the command's key, else the def with the bare id.
|
||||
pub(crate) fn get(&self, command: &CommandRef) -> Option<&CommandDef> {
|
||||
// P3(shortcuts-w1): kb.C2
|
||||
self.index.get(command.id.as_str()).and_then(|&at| self.defs.get(at))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,13 +140,22 @@ pub struct Fired {
|
||||
/// release arrived, also when the runtime held the event back to a later frame; the pass time for the other
|
||||
/// sources. A key's hold is the time between its press and its release, however late a frame runs them.
|
||||
pub time: f64,
|
||||
/// The modifiers the firing input carried: a key's chord, a component's activation, the frame's held modifiers for
|
||||
/// an injected activation. Automation and the palette carry none.
|
||||
pub mods: craft_keymap::Mods,
|
||||
}
|
||||
|
||||
impl Fired {
|
||||
/// `command` fired from `source` in `phase` at the input time `time`, for the app scope (no target), without a group
|
||||
/// cycle or the Alt variant.
|
||||
pub fn new(command: CommandRef, source: FireSource, phase: FirePhase, time: f64) -> Fired {
|
||||
Fired { command, target: None, source, phase, cycle: false, alt_variant: false, time }
|
||||
Fired { command, target: None, source, phase, cycle: false, alt_variant: false, time, mods: craft_keymap::Mods::NONE }
|
||||
}
|
||||
|
||||
/// The command with `mods` as the modifiers its firing input carried.
|
||||
pub fn mods(self, mods: craft_keymap::Mods) -> Fired {
|
||||
let _ = mods;
|
||||
todo!("ap.AP9")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,6 +392,14 @@ impl CommandInput {
|
||||
self
|
||||
}
|
||||
|
||||
/// Turns hold bindings on with the app's hold delay in seconds, `Some(delay)`; `None`, the default, turns them off.
|
||||
/// The keymap is rebuilt when this changes.
|
||||
#[must_use]
|
||||
pub fn holds(self, delay: Option<f64>) -> Self {
|
||||
let _ = delay;
|
||||
todo!("kb.C14")
|
||||
}
|
||||
|
||||
/// The frame's app catalog; the keymap is rebuilt when the platform, the overrides or the catalog's generation change.
|
||||
#[must_use]
|
||||
pub fn catalog(mut self, catalog: AppCatalog) -> Self {
|
||||
@@ -538,6 +557,41 @@ pub fn holder(ctx: &Context, chord: &Chord) -> Option<CommandRef> {
|
||||
board::holder(ctx, chord)
|
||||
}
|
||||
|
||||
/// The runtime's keymap: the linked sets and the app catalog on the window's platform, under the overrides, with the
|
||||
/// system chords reserved. `None` before the first frame.
|
||||
pub fn keymap(ctx: &Context) -> Option<Arc<craft_keymap::Keymap>> {
|
||||
let _ = ctx;
|
||||
todo!("kb.C4")
|
||||
}
|
||||
|
||||
/// Records that a container at `rect` holds `commands`, for this pass and viewport. Not [`CommandInput::holds`], which
|
||||
/// turns hold bindings on.
|
||||
pub fn holds(ctx: &Context, rect: egui::Rect, commands: &[CommandRef], label: crate::runtime::env::Label) {
|
||||
let _ = (ctx, rect, commands, label);
|
||||
todo!("mn.M36")
|
||||
}
|
||||
|
||||
/// Where `command` was shown in the last pass: a bound component's clipped rect or a holder's rect. `None` unless it
|
||||
/// was wholly in view and not under another window.
|
||||
pub fn shown(ctx: &Context, command: &CommandRef) -> Option<Shown> {
|
||||
let _ = (ctx, command);
|
||||
todo!("mn.M37")
|
||||
}
|
||||
|
||||
/// Where a command was shown, from [`shown`].
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub struct Shown {
|
||||
/// The rect it was shown in.
|
||||
pub rect: egui::Rect,
|
||||
/// The viewport it was shown in.
|
||||
pub viewport: ViewportId,
|
||||
/// The label it was shown with.
|
||||
pub label: crate::runtime::env::Label,
|
||||
/// Whether the rect is a holder's rather than a bound component's.
|
||||
pub holder: bool,
|
||||
}
|
||||
|
||||
/// `command` as [`resolve`] shows it, from the window under the modal layer whose body is running, as that window is
|
||||
/// once the layer closes: for a surface that closes before its command runs (the command palette), whose own layer
|
||||
/// does not block the command. Outside a modal layer it is [`resolve`].
|
||||
|
||||
@@ -116,6 +116,41 @@ impl RemovalWatch {
|
||||
}
|
||||
}
|
||||
|
||||
/// The preview watch of a component with a live preview, kept in its shown memory. When eviction drops an armed
|
||||
/// watch it notes the ended preview (`FrameOutput::ended_previews`) and requests a repaint.
|
||||
#[derive(Default)]
|
||||
pub struct PreviewWatch {
|
||||
armed: Option<(Context, Id)>,
|
||||
}
|
||||
|
||||
impl PreviewWatch {
|
||||
/// Arms the watch for the component `owner`.
|
||||
pub fn arm(&mut self, ctx: &Context, owner: Id) {
|
||||
let _ = (ctx, owner);
|
||||
todo!("ty.X2")
|
||||
}
|
||||
|
||||
/// Disarms the watch: its drop notes nothing.
|
||||
pub fn disarm(&mut self) {
|
||||
todo!("ty.X2")
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for PreviewWatch {
|
||||
fn clone(&self) -> Self {
|
||||
PreviewWatch::default()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for PreviewWatch {
|
||||
fn drop(&mut self) {
|
||||
if let Some((ctx, id)) = self.armed.take() {
|
||||
super::frame::note_ended_preview(&ctx, id);
|
||||
repaint::request(&ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for RemovalWatch {
|
||||
fn clone(&self) -> Self {
|
||||
RemovalWatch::default()
|
||||
|
||||
@@ -6,7 +6,6 @@ mod node;
|
||||
mod patch;
|
||||
mod roles;
|
||||
mod text;
|
||||
#[cfg(feature = "testing")]
|
||||
mod tree;
|
||||
|
||||
use crate::runtime::pass_state;
|
||||
@@ -20,8 +19,7 @@ pub(crate) use patch::{write_label_patch, write_merge_patch, write_status};
|
||||
pub(crate) use text::{
|
||||
NodeEnd, RunLink, RunNode, TextNode, fold_widget, is_text_request, requested_selection, requested_value, write_run, write_selection, write_text,
|
||||
};
|
||||
#[cfg(feature = "testing")]
|
||||
pub use tree::{AccessTree, Declared, NodeKey};
|
||||
pub use tree::{AccessTree, Declared, NodeKey, is_interactive, name};
|
||||
|
||||
/// The rect `id`'s response had in the last finished pass, converted as the node's bounds are; `None` when absent,
|
||||
/// without area, or behind the open modal. The ids it answers are component and item widget ids; parts have none.
|
||||
|
||||
@@ -6,6 +6,19 @@ use accesskit::{Action, Node, NodeId, TreeUpdate};
|
||||
use egui::Id;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
/// The accessible name of the node, when it has a non-empty one: its own, else the first non-empty name of the nodes
|
||||
/// that label it (`labelled_by`).
|
||||
pub fn name(tree: &AccessTree, key: NodeKey) -> Option<&str> {
|
||||
let _ = (tree, key);
|
||||
todo!("wg.W14")
|
||||
}
|
||||
|
||||
/// Whether the node declares an action a user can take: focus, click or a value change.
|
||||
pub fn is_interactive(tree: &AccessTree, key: NodeKey) -> bool {
|
||||
let _ = (tree, key);
|
||||
todo!("wg.W14")
|
||||
}
|
||||
|
||||
/// A node's number in the tree.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct NodeKey(u64);
|
||||
@@ -364,13 +377,13 @@ impl AccessTree {
|
||||
}
|
||||
|
||||
impl AccessTree {
|
||||
/// The root node, when the frame made a tree.
|
||||
pub(crate) fn root_key(&self) -> Option<NodeKey> {
|
||||
/// The root node, when the frame made a tree: where reading order starts.
|
||||
pub fn root_key(&self) -> Option<NodeKey> {
|
||||
self.update.tree.as_ref().map(|tree| NodeKey(tree.root.0))
|
||||
}
|
||||
|
||||
/// The node AccessKit reports as focused.
|
||||
pub(crate) fn focused_key(&self) -> NodeKey {
|
||||
pub fn focused_key(&self) -> NodeKey {
|
||||
NodeKey(self.update.focus.0)
|
||||
}
|
||||
|
||||
|
||||
@@ -153,8 +153,13 @@ pub(crate) enum KeyEvent {
|
||||
Release { input: KeyInput },
|
||||
/// Typed text.
|
||||
Text(String),
|
||||
/// egui's own clipboard events; a paste carries its text.
|
||||
Clip { command: craft_behavior::EditCommand, text: Option<String> },
|
||||
/// egui's own clipboard events; a paste carries its text. `mods` are the modifiers held at the event.
|
||||
Clip {
|
||||
command: craft_behavior::EditCommand,
|
||||
text: Option<String>,
|
||||
#[allow(dead_code)] // P3(canvas-w2): kb.C10a
|
||||
mods: craft_keymap::Mods,
|
||||
},
|
||||
/// A pointer press, which ends keyboard modality.
|
||||
PointerPress,
|
||||
/// An AccessKit action request.
|
||||
@@ -186,9 +191,10 @@ pub(crate) fn key_event(event: &Event, os: Os, latin: &[(egui::Key, char)]) -> K
|
||||
Event::Key { pressed: false, .. } => read(event).map_or(KeyEvent::Other, |input| KeyEvent::Release { input }),
|
||||
Event::Text(text) => KeyEvent::Text(text.clone()),
|
||||
Event::ModifiersChanged(modifiers) => KeyEvent::Modifiers(Mods::from_egui(modifiers, os)),
|
||||
Event::Copy => KeyEvent::Clip { command: craft_behavior::EditCommand::Copy, text: None },
|
||||
Event::Cut => KeyEvent::Clip { command: craft_behavior::EditCommand::Cut, text: None },
|
||||
Event::Paste(text) => KeyEvent::Clip { command: craft_behavior::EditCommand::Paste, text: Some(text.clone()) },
|
||||
// P3(canvas-w2): kb.C10a
|
||||
Event::Copy => KeyEvent::Clip { command: craft_behavior::EditCommand::Copy, text: None, mods: Mods::NONE },
|
||||
Event::Cut => KeyEvent::Clip { command: craft_behavior::EditCommand::Cut, text: None, mods: Mods::NONE },
|
||||
Event::Paste(text) => KeyEvent::Clip { command: craft_behavior::EditCommand::Paste, text: Some(text.clone()), mods: Mods::NONE },
|
||||
Event::PointerButton { pressed: true, .. } => KeyEvent::PointerPress,
|
||||
Event::AccessKitActionRequest(request) => KeyEvent::Access(Action(request.clone())),
|
||||
_ => KeyEvent::Other,
|
||||
@@ -259,6 +265,9 @@ pub(crate) struct PointerRead {
|
||||
pub buttons: Buttons,
|
||||
/// The button that went up last in the pass, any button.
|
||||
pub release: Option<PointerButton>,
|
||||
/// The modifiers of the pass's last button release.
|
||||
#[allow(dead_code)] // P3(canvas-w2): ap.AP8
|
||||
pub release_mods: Option<Mods>,
|
||||
/// The last press of a button other than the primary one: the button and where it went down.
|
||||
pub other_press: Option<(PointerButton, Pos2)>,
|
||||
/// Whether the primary button went down in this pass.
|
||||
@@ -416,6 +425,7 @@ pub(crate) fn pointer_read(ctx: &Context) -> PointerRead {
|
||||
primary_down: input.pointer.primary_down() && !barrel_press,
|
||||
buttons,
|
||||
release,
|
||||
release_mods: None, // P3(canvas-w2): ap.AP8
|
||||
other_press,
|
||||
primary_pressed: input.pointer.primary_pressed() && !barrel_pressed,
|
||||
mods: Mods::from_egui(&input.modifiers, os),
|
||||
|
||||
@@ -36,6 +36,7 @@ mod app_values;
|
||||
mod host_words;
|
||||
mod overrides;
|
||||
mod root;
|
||||
mod scrub;
|
||||
pub(crate) mod system;
|
||||
pub(crate) mod tokens;
|
||||
mod values;
|
||||
@@ -46,6 +47,7 @@ pub use craft_platform::appearance::SystemReader;
|
||||
use host_words::{host_dates, host_format, host_words};
|
||||
pub use overrides::{Overrides, ThemeScope, WheelScope, WordsOverride, with_env};
|
||||
pub use root::{ResolvedRoot, RootEnv};
|
||||
pub use scrub::ScrubDrags;
|
||||
pub use system::{SystemState, system_appearance};
|
||||
pub(crate) use tokens::TokenInputs;
|
||||
#[cfg(feature = "testing")]
|
||||
|
||||
+7
@@ -141,6 +141,13 @@ impl RootEnv {
|
||||
self
|
||||
}
|
||||
|
||||
/// Overrides `seeds.accent` of whichever theme resolves, built-in or library, in both modes; the accent ramp derives
|
||||
/// from the seed. `None` keeps the theme's own.
|
||||
pub fn accent(self, seed: Option<craft_theme::Rgba>) -> Self {
|
||||
let _ = seed;
|
||||
todo!("sh.K20")
|
||||
}
|
||||
|
||||
/// What the choices resolve to on `ctx`'s pass: the one place `System` is replaced by the OS's answer, as
|
||||
/// [`system_appearance`](super::system_appearance) reads it. A value the OS reports none for resolves to light,
|
||||
/// standard contrast and full motion.
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
//! Which drags scrub a value.
|
||||
|
||||
use super::EnvValue;
|
||||
|
||||
/// Which drags scrub a value, an `AppValues` env value.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[non_exhaustive]
|
||||
pub enum ScrubDrags {
|
||||
/// The body of a field not in edit and a scrubbing side label scrub.
|
||||
#[default]
|
||||
FieldAndLabel,
|
||||
/// The side label only scrubs; a drag on the body selects text.
|
||||
LabelOnly,
|
||||
/// Neither scrubs. A component's own scrub parts (a popup slider's chevron) are not affected.
|
||||
Off,
|
||||
}
|
||||
|
||||
impl EnvValue for ScrubDrags {
|
||||
fn root() -> Self {
|
||||
ScrubDrags::default()
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -243,9 +243,10 @@ impl ShellCx {
|
||||
self.inner.panels_hidden
|
||||
}
|
||||
|
||||
/// Whether the dock shows: in normal mode, during the Tab reveal and during the end-edge reveal, unless the panels
|
||||
/// are hidden.
|
||||
pub fn dock_visible(&self) -> bool {
|
||||
/// Whether the dock at `edge` shows: in normal mode, during the Tab reveal and, for the `Start` and `End` edges,
|
||||
/// while that edge's reveal is on, unless the panels are hidden.
|
||||
pub fn dock_visible(&self, edge: super::PaneEdge) -> bool {
|
||||
let _ = edge; // P3(chrome-w2): ch.K1
|
||||
!self.inner.panels_hidden && (self.inner.mode == BodyMode::Normal || self.inner.tab_reveal || self.edge_revealed(RevealEdge::End))
|
||||
}
|
||||
|
||||
|
||||
+49
-2
@@ -27,6 +27,11 @@ craft_ui::words! {
|
||||
pixels_per_centimetre: unit "units.pixelsPerCentimetre" = "{n} ppcm";
|
||||
lines_per_inch: unit "units.linesPerInch" = "{n} lpi";
|
||||
lines_per_centimetre: unit "units.linesPerCentimetre" = "{n} lpcm";
|
||||
feet: unit "units.feet" = "{n} ft";
|
||||
yards: unit "units.yards" = "{n} yd";
|
||||
metres: unit "units.metres" = "{n} m";
|
||||
q: unit "units.q" = "{n} Q";
|
||||
ha: unit "units.ha" = "{n} H";
|
||||
minutes: unit "units.minutes" = "{n} min";
|
||||
columns: unit "units.columns" = "{n} col";
|
||||
pixels_name: "units.pixelsName" = "Pixels";
|
||||
@@ -44,6 +49,11 @@ craft_ui::words! {
|
||||
columns_name: "units.columnsName" = "Columns";
|
||||
lines_per_inch_name: "units.linesPerInchName" = "Lines/Inch";
|
||||
lines_per_centimetre_name: "units.linesPerCentimetreName" = "Lines/Centimetre";
|
||||
feet_name: "units.feetName" = "Feet";
|
||||
yards_name: "units.yardsName" = "Yards";
|
||||
metres_name: "units.metresName" = "Metres";
|
||||
q_name: "units.qName" = "Q";
|
||||
ha_name: "units.haName" = "H";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +89,12 @@ impl EnvValue for PointSize {
|
||||
}
|
||||
}
|
||||
|
||||
impl EnvValue for craft_behavior::ZoomScheme {
|
||||
fn root() -> Self {
|
||||
craft_behavior::ZoomScheme::PHOTOSHOP
|
||||
}
|
||||
}
|
||||
|
||||
/// What a number counts.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@@ -114,6 +130,16 @@ pub enum UnitKind {
|
||||
LinesPerInch,
|
||||
/// `{n} lpcm`: a halftone screen's frequency.
|
||||
LinesPerCentimetre,
|
||||
/// `{n} ft`.
|
||||
Feet,
|
||||
/// `{n} yd`.
|
||||
Yards,
|
||||
/// `{n} m`.
|
||||
Metres,
|
||||
/// `{n} Q`.
|
||||
Q,
|
||||
/// `{n} H`.
|
||||
Ha,
|
||||
}
|
||||
|
||||
impl UnitKind {
|
||||
@@ -126,7 +152,7 @@ impl UnitKind {
|
||||
Self::ALL.get(tag as usize).copied()
|
||||
}
|
||||
|
||||
const ALL: [UnitKind; 15] = [
|
||||
const ALL: [UnitKind; 20] = [
|
||||
UnitKind::Pixels,
|
||||
UnitKind::Percent,
|
||||
UnitKind::Degrees,
|
||||
@@ -142,6 +168,11 @@ impl UnitKind {
|
||||
UnitKind::Columns,
|
||||
UnitKind::LinesPerInch,
|
||||
UnitKind::LinesPerCentimetre,
|
||||
UnitKind::Feet,
|
||||
UnitKind::Yards,
|
||||
UnitKind::Metres,
|
||||
UnitKind::Q,
|
||||
UnitKind::Ha,
|
||||
];
|
||||
|
||||
/// The digits after the decimal mark a number of this kind shows by default, at most.
|
||||
@@ -149,6 +180,8 @@ impl UnitKind {
|
||||
match self {
|
||||
UnitKind::Pixels | UnitKind::Minutes => 0..=0,
|
||||
UnitKind::Percent | UnitKind::Degrees | UnitKind::Points => 0..=1,
|
||||
UnitKind::Q | UnitKind::Ha => 0..=2,
|
||||
UnitKind::Feet | UnitKind::Yards | UnitKind::Metres => 0..=4,
|
||||
UnitKind::Times
|
||||
| UnitKind::Centimetres
|
||||
| UnitKind::Millimetres
|
||||
@@ -165,7 +198,7 @@ impl UnitKind {
|
||||
/// the kind steps by the kind's rule.
|
||||
pub const fn step(self) -> f64 {
|
||||
match self {
|
||||
UnitKind::Times | UnitKind::Inches | UnitKind::Centimetres => 0.1,
|
||||
UnitKind::Times | UnitKind::Inches | UnitKind::Centimetres | UnitKind::Feet | UnitKind::Yards | UnitKind::Metres => 0.1,
|
||||
_ => 1.0,
|
||||
}
|
||||
}
|
||||
@@ -182,6 +215,10 @@ impl UnitKind {
|
||||
UnitKind::Millimetres => Some(25.4),
|
||||
UnitKind::Points => Some(points_per_inch),
|
||||
UnitKind::Picas => Some(points_per_inch / 12.0),
|
||||
UnitKind::Feet => Some(1.0 / 12.0),
|
||||
UnitKind::Yards => Some(1.0 / 36.0),
|
||||
UnitKind::Metres => Some(0.0254),
|
||||
UnitKind::Q | UnitKind::Ha => Some(101.6),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -355,6 +392,11 @@ impl Units {
|
||||
UnitKind::Columns => words.columns.as_str(),
|
||||
UnitKind::LinesPerInch => words.lines_per_inch.as_str(),
|
||||
UnitKind::LinesPerCentimetre => words.lines_per_centimetre.as_str(),
|
||||
UnitKind::Feet => words.feet.as_str(),
|
||||
UnitKind::Yards => words.yards.as_str(),
|
||||
UnitKind::Metres => words.metres.as_str(),
|
||||
UnitKind::Q => words.q.as_str(),
|
||||
UnitKind::Ha => words.ha.as_str(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,6 +419,11 @@ impl Units {
|
||||
UnitKind::Columns => &words.columns_name,
|
||||
UnitKind::LinesPerInch => &words.lines_per_inch_name,
|
||||
UnitKind::LinesPerCentimetre => &words.lines_per_centimetre_name,
|
||||
UnitKind::Feet => &words.feet_name,
|
||||
UnitKind::Yards => &words.yards_name,
|
||||
UnitKind::Metres => &words.metres_name,
|
||||
UnitKind::Q => &words.q_name,
|
||||
UnitKind::Ha => &words.ha_name,
|
||||
};
|
||||
name.clone()
|
||||
}
|
||||
|
||||
@@ -68,6 +68,10 @@ pub enum ChromeToggle {
|
||||
Panels,
|
||||
/// Every panel of the window except the tools.
|
||||
PanelsKeepTools,
|
||||
/// Ends Tab and Shift+Tab hiding the panels; nothing when they are shown.
|
||||
ShowPanels,
|
||||
/// Reveals the edge while the window is body-only or its panels are hidden; `None` ends the reveal.
|
||||
Reveal(Option<super::env::RevealEdge>),
|
||||
}
|
||||
|
||||
/// A step of the outer gesture of a container whose `ContainerProps::outer_edit` is on: one undo step over the edits of
|
||||
@@ -120,6 +124,9 @@ pub struct FrameOutput {
|
||||
pub outer_edits: Vec<OuterEdit>,
|
||||
/// Whether a component refused this pass's input since the last call (`frame::refuse`): the app plays its alert.
|
||||
pub refused: bool,
|
||||
/// The components whose live preview ended because they stopped showing; the host ends the preview it holds for
|
||||
/// each id.
|
||||
pub ended_previews: Vec<egui::Id>,
|
||||
}
|
||||
|
||||
/// The per-frame and per-context state of the frame loop.
|
||||
@@ -391,6 +398,12 @@ pub(crate) fn note_removed_gesture(ctx: &Context, id: GestureId) {
|
||||
pass_state::with::<FrameState, _>(ctx, |state| state.output.removed_gestures.push(id));
|
||||
}
|
||||
|
||||
/// Adds a component whose live preview ended to the next `FrameOutput`.
|
||||
pub(crate) fn note_ended_preview(ctx: &Context, id: Id) {
|
||||
let _ = (ctx, id);
|
||||
todo!("ty.X1")
|
||||
}
|
||||
|
||||
/// Adds a step of an outer gesture to the next `FrameOutput`.
|
||||
#[doc(hidden)]
|
||||
pub fn note_outer_edit(ctx: &Context, edit: OuterEdit) {
|
||||
@@ -463,7 +476,7 @@ pub(crate) fn shell_root(ctx: &Context, viewport: ViewportId) -> Option<Id> {
|
||||
|
||||
/// Adds a chrome toggle of `viewport` to the next `FrameOutput` and aims it at the window of the viewport that holds
|
||||
/// focus, or at the first shell that asks when none does.
|
||||
pub(crate) fn request_chrome_toggle(ctx: &Context, viewport: ViewportId, toggle: ChromeToggle) {
|
||||
pub fn request_chrome_toggle(ctx: &Context, viewport: ViewportId, toggle: ChromeToggle) {
|
||||
queue_toggle(ctx, viewport, toggle);
|
||||
pass_state::with::<FrameState, _>(ctx, |state| state.output.chrome_toggles.push((viewport, toggle)));
|
||||
}
|
||||
|
||||
@@ -85,6 +85,13 @@ pub(crate) fn input_hook(ctx: &Context, events: &mut Vec<Arrived>, viewport: Vie
|
||||
});
|
||||
}
|
||||
|
||||
/// Whether the engine's last `interrupt` asks the platform to discard the marked text: once for each interrupt.
|
||||
#[allow(dead_code)] // P3(type-w1): ty.X5
|
||||
pub(crate) fn take_discard(ctx: &Context) -> bool {
|
||||
let _ = ctx;
|
||||
todo!("ty.X5")
|
||||
}
|
||||
|
||||
/// The begin hook, after pending focus moves are applied: resolves the owner and turns the queue into edits.
|
||||
pub(crate) fn begin(ctx: &Context, owner: Option<Id>) {
|
||||
current(ctx, |engine| {
|
||||
|
||||
@@ -24,8 +24,11 @@ pub use claims::claim;
|
||||
pub(crate) use claims::hold_escape;
|
||||
#[doc(hidden)]
|
||||
pub use claims::take_claimed;
|
||||
#[doc(hidden)]
|
||||
pub use claims::{claim_alt_tap, take_alt_tap};
|
||||
/// The types `Intents` reads and returns, for an app that reads the window's intents (`with_window_intents`).
|
||||
pub use craft_behavior::{AccessRequest, Intent, MoveMods, NavMove, PartRef};
|
||||
pub use input::held;
|
||||
#[doc(hidden)]
|
||||
pub use input::{down, keyed};
|
||||
pub(crate) use input::{input_hook, queue_nav, take_menu_keys, take_nav};
|
||||
@@ -47,6 +50,12 @@ pub(crate) use nodes::{redirect_node, register_expanded, register_node};
|
||||
pub use route::focus_holds;
|
||||
pub(crate) use route::{activated_member, begin, layout_of, owner_at, pasted_text, queue_edit, routed_to, take_shortcuts};
|
||||
|
||||
/// The Alt and Shift held at the press of the pass's last Escape that became a `Cancel`; `None` when the pass had none.
|
||||
pub fn escape_mods(ctx: &Context) -> Option<Mods> {
|
||||
let _ = ctx;
|
||||
todo!("kb.C6")
|
||||
}
|
||||
|
||||
/// A menu-bar key of an in-window bar (spec 9.7). F10 reaches the bar on every OS; Alt keys only off a Mac.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum MenuKey {
|
||||
@@ -116,6 +125,12 @@ pub(crate) struct Shortcuts {
|
||||
pub(crate) dialog: bool,
|
||||
/// The layout that reads the presses.
|
||||
pub(crate) layout: Layout,
|
||||
/// Each change of Cmd, Ctrl or Alt in the pass, with the index into `keys` of the first entry after it.
|
||||
#[allow(dead_code)] // P3(shortcuts-w2): kb.C8
|
||||
pub(crate) mods: Vec<(usize, craft_keymap::Mods)>,
|
||||
/// The pass's input had `WindowFocused(false)`.
|
||||
#[allow(dead_code)] // P3(shortcuts-w2): kb.C8
|
||||
pub(crate) focus_lost: bool,
|
||||
}
|
||||
|
||||
/// What the input hook recorded for the next pass's begin hook.
|
||||
|
||||
@@ -32,6 +32,20 @@ pub fn claim(ctx: &Context, owner: Id, chord: Chord) {
|
||||
current(ctx, |stage| stage.claims.push((owner, chord)));
|
||||
}
|
||||
|
||||
/// The tool host claims the next pass's lone Alt tap for `owner` at the end of a pass, as it claims chords.
|
||||
#[doc(hidden)]
|
||||
pub fn claim_alt_tap(ctx: &Context, owner: Id) {
|
||||
let _ = (ctx, owner);
|
||||
todo!("kb.C11c")
|
||||
}
|
||||
|
||||
/// Reads this pass's lone Alt tap for the claimer `owner`.
|
||||
#[doc(hidden)]
|
||||
pub fn take_alt_tap(ctx: &Context, owner: Id) -> bool {
|
||||
let _ = (ctx, owner);
|
||||
todo!("kb.C11c")
|
||||
}
|
||||
|
||||
/// Holds `chord` for `owner` from the next input hook on, whichever component has focus: the key stage withholds
|
||||
/// it from every component and `take_claimed` reads it. Used while a container is in a mode that owns the arrow
|
||||
/// keys, Enter and Escape (the window move and size modes, 16.3); the claim lapses when it is not renewed.
|
||||
|
||||
@@ -125,7 +125,8 @@ impl Strip<'_> {
|
||||
batch.egui_texts += 1;
|
||||
true
|
||||
}
|
||||
KeyEvent::Clip { command, text } if (self.edits)(command) => {
|
||||
// P3(shortcuts-w2): kb.C10a
|
||||
KeyEvent::Clip { command, text, .. } if (self.edits)(command) => {
|
||||
batch.clips.push(command);
|
||||
if text.is_some() {
|
||||
batch.paste = text;
|
||||
@@ -525,6 +526,14 @@ pub fn down(ctx: &Context) -> Vec<Key> {
|
||||
current(ctx, |stage| stage.down.clone())
|
||||
}
|
||||
|
||||
/// The keys down in the running viewport this pass: the key stage's `down` (withheld presses included), plus each key
|
||||
/// automation holds there that is not already listed. It gives the same answer on every pass of a frame, and is a
|
||||
/// guard, never an event.
|
||||
pub fn held(ctx: &egui::Context) -> Vec<egui::Key> {
|
||||
let _ = ctx;
|
||||
todo!("pl.F1")
|
||||
}
|
||||
|
||||
/// Whether the running viewport's input hook read a key press, typed text or a clipboard event in this pass, the ones
|
||||
/// the key stage took from egui's input included: an app that redraws state after input asks this, not egui's events.
|
||||
pub fn keyed(ctx: &Context) -> bool {
|
||||
|
||||
@@ -214,7 +214,7 @@ fn owned_shortcuts(ctx: &Context, target: Option<&StopRec>, batch: &Batch, consu
|
||||
})
|
||||
.copied()
|
||||
.collect();
|
||||
(Shortcuts { keys, typing, dialog, layout: Layout::default() }, held)
|
||||
(Shortcuts { keys, typing, dialog, layout: Layout::default(), mods: Vec::new(), focus_lost: false }, held) // P3(shortcuts-w2): kb.C8
|
||||
}
|
||||
|
||||
/// Whether the focused stop `target`, whose keys `owner` owns, holds `press`: the press is its own and reaches neither
|
||||
|
||||
@@ -287,6 +287,30 @@ pub(crate) fn forget(ctx: &Context, id: Id) {
|
||||
forget_tier(ctx, id, SESSION);
|
||||
}
|
||||
|
||||
/// How long a remembered value lives.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[non_exhaustive]
|
||||
pub enum Lifetime {
|
||||
/// The value goes through the host's saved state (the `SaveKey` tier).
|
||||
#[default]
|
||||
Saved,
|
||||
/// The value lasts until the app quits.
|
||||
Run,
|
||||
}
|
||||
|
||||
/// The run-only value under `key`, in the session tier. It never reaches the host. It gives the default until a value
|
||||
/// is set, and it is readable outside a pass, as [`saved_value`] is.
|
||||
pub fn run_value<T: Slot>(ctx: &Context, key: &SaveKey) -> T {
|
||||
let _ = (ctx, key);
|
||||
todo!("od.OD2")
|
||||
}
|
||||
|
||||
/// Sets the run-only value under `key`; see [`run_value`].
|
||||
pub fn set_run_value<T: Slot>(ctx: &Context, key: &SaveKey, value: T) {
|
||||
let _ = (ctx, key, value);
|
||||
todo!("od.OD2")
|
||||
}
|
||||
|
||||
/// The saved value under `key`, outside a dialog: an app reads one SAVED value through the same store the dialogs'
|
||||
/// remembered fields use.
|
||||
pub fn saved_value<T: Savable>(ctx: &Context, key: &SaveKey) -> T {
|
||||
|
||||
@@ -44,6 +44,11 @@ pub struct PointerFrame {
|
||||
/// The modifiers held, with the ones the app latches for the user (a Modifier Keys panel) added: the app holds
|
||||
/// them down for every press and drag. Key chords read the keyboard's own modifiers instead.
|
||||
pub mods: Mods,
|
||||
/// The modifiers of the pass's last button release, with the latched ones added; the held `mods` in a pass with no
|
||||
/// release and in a rerun pass. The one source of a pick's and a drop's modifiers.
|
||||
pub pick_mods: Mods,
|
||||
/// The tap a per-viewport recognizer reports when the last finger lifts, in the frame's first pass only.
|
||||
pub multi_tap: Option<craft_behavior::MultiTap>,
|
||||
/// The pass's time in seconds.
|
||||
pub time: f64,
|
||||
/// The device.
|
||||
@@ -84,7 +89,7 @@ pub struct PassPointer {
|
||||
pub primary_down: bool,
|
||||
pub press_targets: PressTargets,
|
||||
pub focus_lost: bool,
|
||||
/// Whether the real pointer moved or entered, or its modifiers changed, in the pass.
|
||||
/// Whether the real pointer moved or entered, or a held modifier or key changed, in the pass.
|
||||
pub stirred: bool,
|
||||
}
|
||||
|
||||
@@ -198,6 +203,8 @@ pub(crate) fn begin(ctx: &Context, hit: HitSizes, latched: craft_keymap::Mods) {
|
||||
press,
|
||||
release: read.release,
|
||||
mods,
|
||||
pick_mods: mods, // P3(canvas-w2): ap.AP8
|
||||
multi_tap: None, // P3(canvas-w2): cv.F16
|
||||
time: read.time,
|
||||
kind: read.kind,
|
||||
sample: read.sample,
|
||||
@@ -292,6 +299,8 @@ pub fn frame(ctx: &Context) -> PointerFrame {
|
||||
press: None,
|
||||
release: None,
|
||||
mods: Mods::NONE,
|
||||
pick_mods: Mods::NONE,
|
||||
multi_tap: None,
|
||||
time: 0.0,
|
||||
kind: PointerKind::Mouse,
|
||||
sample: None,
|
||||
|
||||
@@ -138,11 +138,25 @@ impl WindowHost {
|
||||
injected::inject_key(&self.ctx, viewport, key, mods, hold);
|
||||
}
|
||||
|
||||
/// Queues a move to `at`, then a wheel turn of `delta` points with `mods` held. A non-finite `delta` queues nothing.
|
||||
pub fn inject_wheel(&self, viewport: ViewportId, at: Pos2, delta: Vec2, mods: Mods) {
|
||||
/// Queues a move to `at`, then a wheel turn of `delta` in `unit` with `mods` held. A non-finite `delta` queues
|
||||
/// nothing.
|
||||
pub fn inject_wheel(&self, viewport: ViewportId, at: Pos2, delta: Vec2, unit: egui::MouseWheelUnit, mods: Mods) {
|
||||
let _ = unit; // P3(widgets-w8): sh.K4
|
||||
injected::inject_wheel(&self.ctx, viewport, at, delta, mods);
|
||||
}
|
||||
|
||||
/// Turns AccessKit on, idempotent and off by default; from then the tree of every finished pass is kept per
|
||||
/// viewport (`access_tree`).
|
||||
pub fn keep_access_trees(&self) {
|
||||
todo!("wg.W16")
|
||||
}
|
||||
|
||||
/// The last kept access tree of `viewport`, `None` before the first.
|
||||
pub fn access_tree(&self, viewport: ViewportId) -> Option<std::sync::Arc<crate::runtime::egui::access::AccessTree>> {
|
||||
let _ = viewport;
|
||||
todo!("wg.W16")
|
||||
}
|
||||
|
||||
/// Queues the release of what `released` names, at `at` or where the injected pointer is.
|
||||
pub fn inject_release(&self, viewport: ViewportId, at: Option<Pos2>, released: Released) {
|
||||
injected::inject_release(&self.ctx, viewport, at, released);
|
||||
|
||||
@@ -188,6 +188,19 @@ impl<'a> StyleCx<'a> {
|
||||
f(&StyleCx::of_env(ctx, &env))
|
||||
}
|
||||
|
||||
/// Runs `f` with the root style at the tokens `scope` resolves, for code that has a context and no `Ui`.
|
||||
pub fn with_root_scoped<R>(ctx: &Context, scope: &crate::runtime::env::ThemeScope, f: impl FnOnce(&StyleCx<'_>) -> R) -> R {
|
||||
let _ = (ctx, scope, f);
|
||||
todo!("ch.K19")
|
||||
}
|
||||
|
||||
/// The one link look: body role, underlined, `accent.solid` (`accent.text` at high contrast), `text.disabled` when
|
||||
/// not `enabled`.
|
||||
pub fn link_look(&self, enabled: bool) -> super::look::TextLook {
|
||||
let _ = enabled;
|
||||
todo!("wg.W07")
|
||||
}
|
||||
|
||||
/// The same context with another variant.
|
||||
#[doc(hidden)]
|
||||
pub fn with_variant(&self, variant: Variant) -> StyleCx<'a> {
|
||||
|
||||
@@ -24,6 +24,8 @@ pub struct Span<'a> {
|
||||
pub underline: bool,
|
||||
/// The role's semibold face, at the role's size.
|
||||
pub strong: bool,
|
||||
/// A link in a paragraph: drawn in the run's link colour, and the only part of the paragraph that takes the pointer.
|
||||
pub link: bool,
|
||||
}
|
||||
|
||||
impl<'a> Span<'a> {
|
||||
@@ -39,9 +41,15 @@ impl<'a> Span<'a> {
|
||||
highlight: false,
|
||||
underline: false,
|
||||
strong: false,
|
||||
link: false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Makes the span a link: it takes the run's link colour and the pointer.
|
||||
pub fn link(self) -> Self {
|
||||
todo!("dp.R2")
|
||||
}
|
||||
|
||||
/// Italic.
|
||||
pub fn italic(mut self) -> Self {
|
||||
self.italic = true;
|
||||
|
||||
@@ -17,8 +17,18 @@ const DISC: &[u8] = b"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24
|
||||
const SQUARE: &[u8] =
|
||||
b"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" fill=\"black\"/></svg>";
|
||||
|
||||
const FIRST_SET: AppIcons = AppIcons { name: "t10-first", stroke_width: None, icons: &[(FIRST_NAME, DISC), (CATALOG_NAME, DISC)] };
|
||||
const SECOND_SET: AppIcons = AppIcons { name: "t10-second", stroke_width: None, icons: &[(FIRST_NAME, SQUARE), (SECOND_NAME, SQUARE)] };
|
||||
const FIRST_SET: AppIcons = AppIcons {
|
||||
name: "t10-first",
|
||||
stroke_width: None,
|
||||
icons: &[(FIRST_NAME, DISC), (CATALOG_NAME, DISC)],
|
||||
fills: &[], /* P3(shell-w2): sh.K10 */
|
||||
};
|
||||
const SECOND_SET: AppIcons = AppIcons {
|
||||
name: "t10-second",
|
||||
stroke_width: None,
|
||||
icons: &[(FIRST_NAME, SQUARE), (SECOND_NAME, SQUARE)],
|
||||
fills: &[], /* P3(shell-w2): sh.K10 */
|
||||
};
|
||||
|
||||
fn icon(name: &'static str) -> Option<SvgIcon> {
|
||||
let tokens = style::tokens(Mode::Light, Contrast::Standard);
|
||||
|
||||
@@ -481,7 +481,8 @@ fn non_finite_injected_points_queue_nothing_and_a_release_there_lets_go() {
|
||||
let nan = Pos2::new(f32::NAN, 10.0);
|
||||
host.inject_click(ViewportId::ROOT, nan, PointerButton::Primary, 1, Mods::NONE, false);
|
||||
host.inject_move(ViewportId::ROOT, Pos2::new(f32::INFINITY, 0.0), Mods::NONE, 0.0);
|
||||
host.inject_wheel(ViewportId::ROOT, Pos2::new(20.0, 20.0), Vec2::new(0.0, f32::NAN), Mods::NONE);
|
||||
// P3(shell-w1): sh.K4
|
||||
host.inject_wheel(ViewportId::ROOT, Pos2::new(20.0, 20.0), Vec2::new(0.0, f32::NAN), egui::MouseWheelUnit::Point, Mods::NONE);
|
||||
host.inject_pointer(ViewportId::ROOT, InjectedPointer::down(PointerButton::Primary, nan, Mods::NONE, None));
|
||||
frames(6);
|
||||
assert_eq!(presses.get(), 0, "no non-finite press reaches egui");
|
||||
|
||||
@@ -145,6 +145,13 @@ impl<'a> Bar<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
/// Lays out the members as a row that wraps instead of scrolling under an overlay bar: no horizontal scroll, no row
|
||||
/// cap; a member wider than the bar narrows and elides by the shared rules.
|
||||
#[must_use]
|
||||
pub fn wrap(self) -> Self {
|
||||
todo!("cv.F37")
|
||||
}
|
||||
|
||||
/// Makes each member its own Tab stop, in reading order, as media controls are; the arrows no longer move between
|
||||
/// them.
|
||||
#[must_use]
|
||||
|
||||
@@ -79,6 +79,9 @@ pub struct ButtonOutput {
|
||||
/// The modifiers held at the activation (with the click for a pointer one); none when the button was not
|
||||
/// activated.
|
||||
pub mods: Mods,
|
||||
/// True in every pass from the pointer press on the button to its release or cancel, also after the pointer leaves
|
||||
/// the button or the window. A key or AccessKit activation never sets it.
|
||||
pub held: bool,
|
||||
}
|
||||
|
||||
impl ButtonOutput {
|
||||
@@ -93,7 +96,7 @@ impl ButtonOutput {
|
||||
(true, Some(activation)) => activation.mods,
|
||||
_ => Mods::NONE,
|
||||
};
|
||||
ButtonOutput { response: cx.response.clone(), clicks, mods }
|
||||
ButtonOutput { response: cx.response.clone(), clicks, mods, held: false } // P3(shell-w2): op.F1
|
||||
}
|
||||
|
||||
/// Whether the button was clicked this pass, by pointer or by key, by the framework's click rule. It stands in
|
||||
@@ -119,6 +122,18 @@ impl Outcome for ButtonOutput {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a command button shows its command's chord.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum ButtonChord {
|
||||
/// No chord.
|
||||
#[default]
|
||||
Hidden,
|
||||
/// The command's chord after the label, in the `Kbd` notation; a command with no chord shows none. The chord is
|
||||
/// dropped first when room is short.
|
||||
Trailing,
|
||||
}
|
||||
|
||||
/// A push button. A label wider than the room is cut with an ellipsis and shown whole in a tooltip. While `loading`
|
||||
/// a spinner takes the place of the icon (of the label, without an icon) at the same width, the button ignores
|
||||
/// activation, keeps focus and reports busy.
|
||||
@@ -152,6 +167,15 @@ pub struct Button<'a> {
|
||||
/// that names an item at the reading start).
|
||||
#[prop]
|
||||
align: HAlign,
|
||||
/// A muted caption-role second line, wrapped under the icon and label. The face grows to fit it. It is the
|
||||
/// accessible description unless `description` is set.
|
||||
#[prop(into)]
|
||||
#[allow(dead_code)] // P3(shell-w2): dp.R3
|
||||
detail: Option<Label>,
|
||||
/// Whether a command button shows its command's chord after the label.
|
||||
#[prop]
|
||||
#[allow(dead_code)] // P3(shell-w2): sh.K13
|
||||
chord: ButtonChord,
|
||||
}
|
||||
|
||||
impl<'a> Button<'a> {
|
||||
@@ -166,6 +190,8 @@ impl<'a> Button<'a> {
|
||||
tint: None,
|
||||
least_width: None,
|
||||
align: HAlign::Center,
|
||||
detail: None,
|
||||
chord: ButtonChord::Hidden,
|
||||
}
|
||||
.label(label)
|
||||
}
|
||||
@@ -185,6 +211,7 @@ impl<'a> Button<'a> {
|
||||
loading: self.loading,
|
||||
mnemonic: None,
|
||||
align: self.align,
|
||||
chord: None, // P3(shell-w2): sh.K13
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,9 @@ pub(crate) struct FaceSpec<'a> {
|
||||
pub mnemonic: Option<usize>,
|
||||
/// Where the icons and the label sit along the area when it is wider than they are.
|
||||
pub align: HAlign,
|
||||
/// The command's chord, shown after the label and dropped before the label elides.
|
||||
#[allow(dead_code)] // P3(shell-w2): sh.K13
|
||||
pub chord: Option<&'a str>,
|
||||
}
|
||||
|
||||
impl FaceSpec<'_> {
|
||||
|
||||
@@ -52,6 +52,14 @@ impl Link {
|
||||
Link { common: Common::new(), url: None, role: TypeRole::Body, wrap: Wrap::Line, tone: None }.label(label)
|
||||
}
|
||||
|
||||
/// Sets the link in a wrapped paragraph `before` + the label + `after`, in the body ink. Only the link's characters
|
||||
/// take the pointer. It is one Tab stop, and click, Enter and Space activate it.
|
||||
#[must_use]
|
||||
pub fn in_sentence(self, before: impl Into<crate::runtime::env::Label>, after: impl Into<crate::runtime::env::Label>) -> Self {
|
||||
let _ = (before, after);
|
||||
todo!("dp.R2")
|
||||
}
|
||||
|
||||
fn run<'a>(&self, label: &'a str) -> TextRun<'a> {
|
||||
TextRun::spans(vec![Span::new(label).underline()]).role(self.role).wrap(self.wrap)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ mod stories;
|
||||
pub mod toggle_button;
|
||||
mod words;
|
||||
|
||||
pub use button::{Button, ButtonOutput, ButtonStyle};
|
||||
pub use button::{Button, ButtonChord, ButtonOutput, ButtonStyle};
|
||||
pub use icon_button::{IconButton, IconButtonStyle, PopupMark};
|
||||
pub use link::{Link, LinkStyle};
|
||||
pub use split_button::{SplitButton, SplitButtonStyle, SplitOutput};
|
||||
|
||||
@@ -102,6 +102,7 @@ impl<'a, T: Value + 'static> SplitButton<'a, T> {
|
||||
loading: false,
|
||||
mnemonic: None,
|
||||
align: crate::primitives::HAlign::Center,
|
||||
chord: None, // P3(shell-w2): sh.K13
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,7 @@ impl<'a> ToggleButton<'a> {
|
||||
loading: false,
|
||||
mnemonic: None,
|
||||
align: crate::primitives::HAlign::Center,
|
||||
chord: None, // P3(shell-w2): sh.K13
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ pub use segmented::{Segmented, SegmentedStyle};
|
||||
pub use switch::{Switch, SwitchStyle};
|
||||
pub use words::ChoiceWords;
|
||||
|
||||
pub use swatch::{Swatch, SwatchFace, SwatchMetrics, SwatchOutput, SwatchStyle};
|
||||
pub use swatch_table::{SwatchRows, SwatchTable, SwatchTableOutput, SwatchTableStyle};
|
||||
pub use swatch::{CellMarks, Swatch, SwatchFace, SwatchMetrics, SwatchOutput, SwatchStyle, paint_ring};
|
||||
pub use swatch_table::{RowMarks, SwatchRows, SwatchSpacing, SwatchTable, SwatchTableOutput, SwatchTableStyle};
|
||||
|
||||
/// The well of a check box, radio button or switch track with `radius` corners: the sunken surface, so a bevelled theme
|
||||
/// draws its bevel, filled with the off fill or the on accent. A flat theme draws the outline as its edge, in the failure
|
||||
|
||||
@@ -167,6 +167,13 @@ impl<T: Value + 'static> Radio<T> {
|
||||
pub fn new(value: T) -> Self {
|
||||
Radio { common: Common::new(), value, checked: false, invalid: false }
|
||||
}
|
||||
|
||||
/// A dimmed line under the label (muted text role, small text token), inside the radio's hit area.
|
||||
#[must_use]
|
||||
pub fn detail(self, text: impl Into<crate::runtime::env::Label>) -> Self {
|
||||
let _ = text;
|
||||
todo!("co.K26")
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Value + 'static> Component for Radio<T> {
|
||||
|
||||
@@ -192,6 +192,7 @@ impl Segment {
|
||||
loading: false,
|
||||
mnemonic: None,
|
||||
align: crate::primitives::HAlign::Center,
|
||||
chord: None, // P3(shell-w2): sh.K13
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +143,15 @@ pub struct Swatch<T: Value + 'static = ()> {
|
||||
/// A thin edge in the text colour just inside the outline.
|
||||
#[prop(flag)]
|
||||
marked: bool,
|
||||
/// The well shows its colour as a ring: a band of the colour round the edge, open in the middle.
|
||||
#[style_key]
|
||||
#[prop(flag)]
|
||||
#[allow(dead_code)] // P3(widgets-w6): cv.F40
|
||||
stroke: bool,
|
||||
/// The face the well shows over its checker instead of the colour; ring, mark and mixed look unchanged.
|
||||
#[prop]
|
||||
#[allow(dead_code)] // P3(widgets-w6): wg.W33
|
||||
face: Option<crate::primitives::FacePaint>,
|
||||
/// The key of the `ColorRequest` a click files.
|
||||
#[prop(into)]
|
||||
picker: Option<String>,
|
||||
@@ -160,6 +169,8 @@ impl Swatch<()> {
|
||||
cell: false,
|
||||
well: false,
|
||||
marked: false,
|
||||
stroke: false,
|
||||
face: None,
|
||||
picker: None,
|
||||
checked: false,
|
||||
activation: None,
|
||||
@@ -178,11 +189,82 @@ impl<T: Value + 'static> Swatch<T> {
|
||||
cell: self.cell,
|
||||
well: self.well,
|
||||
marked: self.marked,
|
||||
stroke: self.stroke,
|
||||
face: self.face,
|
||||
picker: self.picker,
|
||||
checked: false,
|
||||
activation: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Paints the marks of `marks` on the well: the edge mark, a locked corner square, a web-safe centre diamond, the
|
||||
/// transparent checker half and the source-colour corner triangle, each from tokens.
|
||||
#[must_use]
|
||||
pub fn marks(self, marks: CellMarks) -> Self {
|
||||
let _ = marks;
|
||||
todo!("ex.E19")
|
||||
}
|
||||
}
|
||||
|
||||
/// The marks of a swatch cell: each is painted from tokens. Other crates build them with the builders, as
|
||||
/// `#[non_exhaustive]` forbids a struct literal outside this crate.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub struct CellMarks {
|
||||
/// A thin edge in the text colour just inside the outline.
|
||||
pub edge: bool,
|
||||
/// A locked corner square.
|
||||
pub locked: bool,
|
||||
/// A web-safe centre diamond.
|
||||
pub web_safe: bool,
|
||||
/// The transparent checker half.
|
||||
pub transparent: bool,
|
||||
/// The source-colour corner triangle.
|
||||
pub source: Option<Srgba>,
|
||||
}
|
||||
|
||||
impl CellMarks {
|
||||
/// Sets the edge mark.
|
||||
#[must_use]
|
||||
pub fn edge(self, on: bool) -> Self {
|
||||
let _ = on;
|
||||
todo!("ex.E19")
|
||||
}
|
||||
|
||||
/// Sets the locked mark.
|
||||
#[must_use]
|
||||
pub fn locked(self, on: bool) -> Self {
|
||||
let _ = on;
|
||||
todo!("ex.E19")
|
||||
}
|
||||
|
||||
/// Sets the web-safe mark.
|
||||
#[must_use]
|
||||
pub fn web_safe(self, on: bool) -> Self {
|
||||
let _ = on;
|
||||
todo!("ex.E19")
|
||||
}
|
||||
|
||||
/// Sets the transparent mark.
|
||||
#[must_use]
|
||||
pub fn transparent(self, on: bool) -> Self {
|
||||
let _ = on;
|
||||
todo!("ex.E19")
|
||||
}
|
||||
|
||||
/// Sets the source-colour mark.
|
||||
#[must_use]
|
||||
pub fn source(self, color: Srgba) -> Self {
|
||||
let _ = color;
|
||||
todo!("ex.E19")
|
||||
}
|
||||
}
|
||||
|
||||
/// Paints `color` as a ring in `well`: a band of the colour round the edge, open in the middle, each side with the
|
||||
/// edge and the inner edge (`SwatchStyle::inner_edge`) that stand out from the colour, in `state`.
|
||||
pub fn paint_ring(draw: &Draw<'_>, well: Rect, color: Srgba, style: &SwatchStyle, state: &StateSet) {
|
||||
let _ = (draw, well, color, style, state);
|
||||
todo!("cv.F40")
|
||||
}
|
||||
|
||||
impl<T: Value + 'static> Component for Swatch<T> {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//! `SwatchTable`: a table of touching cells selected by index, for a colour table whose entries may repeat a colour.
|
||||
|
||||
use super::{Swatch, SwatchMetrics};
|
||||
use super::{CellMarks, Swatch, SwatchMetrics};
|
||||
use crate::contract::{
|
||||
ActivateOn, Bind, BindMut, Collection, CollectionEvent, CollectionProps, Common, Component, ContainerProps, Cx, NoValue, Outcome, Props, Role,
|
||||
SelectMode, ShowCollection as _, Sizing,
|
||||
ActivateOn, Bind, BindMut, Collection, CollectionEvent, CollectionProps, Common, Component, ContainerProps, Cx, ListDrag, NoValue, Outcome,
|
||||
Props, Role, SelectMode, ShowCollection as _, Sizing,
|
||||
};
|
||||
use crate::list::RowTest;
|
||||
use crate::runtime::env::Label;
|
||||
@@ -46,6 +46,27 @@ impl DisplayOrder<usize> for SwatchRows<'_> {
|
||||
|
||||
impl ItemSource<usize> for SwatchRows<'_> {}
|
||||
|
||||
/// How the cells of a [`SwatchTable`] sit.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum SwatchSpacing {
|
||||
/// The cells touch.
|
||||
#[default]
|
||||
Touching,
|
||||
/// The theme's item gap (`space.gap.item`) lies between the cells.
|
||||
Spaced,
|
||||
}
|
||||
|
||||
/// The marks of the cell of a key: `SwatchTable::marks`.
|
||||
pub struct RowMarks<'a, K>(#[allow(dead_code)] Box<dyn Fn(&K) -> CellMarks + 'a>); // P3(color-w1): ex.E20
|
||||
|
||||
impl<'a, K> RowMarks<'a, K> {
|
||||
/// The marks `marks` gives.
|
||||
pub fn new(marks: impl Fn(&K) -> CellMarks + 'a) -> Self {
|
||||
RowMarks(Box::new(marks))
|
||||
}
|
||||
}
|
||||
|
||||
/// What a [`SwatchTable`] reports.
|
||||
#[derive(Debug)]
|
||||
#[non_exhaustive]
|
||||
@@ -59,6 +80,8 @@ pub struct SwatchTableOutput {
|
||||
pub chosen: Vec<usize>,
|
||||
/// The entry a double click or Enter asked to edit this pass.
|
||||
pub open: Option<usize>,
|
||||
/// Delete or Backspace was pressed on the selection this pass (`CollectionEvent::Delete`).
|
||||
pub delete: bool,
|
||||
}
|
||||
|
||||
impl Outcome for SwatchTableOutput {
|
||||
@@ -106,6 +129,14 @@ pub struct SwatchTable<'a> {
|
||||
/// Whether the cells are wells at the control height, as a palette's swatches are, instead of small touching cells.
|
||||
#[prop]
|
||||
wells: bool,
|
||||
/// How the cells sit: touching, or the theme's item gap apart.
|
||||
#[prop]
|
||||
#[allow(dead_code)] // P3(color-w1): co.K5
|
||||
spacing: SwatchSpacing,
|
||||
/// The marks of each cell, by index, given to the cell's `Swatch::marks`; in place of `marked`.
|
||||
#[prop(func = "Fn(&usize) -> CellMarks")]
|
||||
#[allow(dead_code)] // P3(color-w1): ex.E20
|
||||
marks: Option<RowMarks<'a, usize>>,
|
||||
}
|
||||
|
||||
impl<'a> SwatchTable<'a> {
|
||||
@@ -128,10 +159,19 @@ impl<'a> SwatchTable<'a> {
|
||||
marked: None,
|
||||
tips: false,
|
||||
wells: false,
|
||||
spacing: SwatchSpacing::Touching,
|
||||
marks: None,
|
||||
}
|
||||
.label(label)
|
||||
}
|
||||
|
||||
/// Hands the drag of the cells to the host as `map` gives its payload, as `TileGrid::drag_payload` does.
|
||||
#[must_use]
|
||||
pub fn drag_payload<P: Send + Sync + 'static>(self, map: impl Fn(&ListDrag<usize>) -> Option<P> + Send + Sync + 'static) -> Self {
|
||||
let _ = map;
|
||||
todo!("co.K6")
|
||||
}
|
||||
|
||||
/// Whether Shift or Cmd adds cells to the selection.
|
||||
#[must_use]
|
||||
pub fn multiple(mut self, on: bool) -> Self {
|
||||
@@ -180,7 +220,7 @@ impl Component for SwatchTable<'_> {
|
||||
_ => None,
|
||||
});
|
||||
let changed = response.events.iter().any(|event| matches!(event, CollectionEvent::Selection(_)));
|
||||
SwatchTableOutput { response: response.response, selected: selection.lead.filter(|_| changed), chosen: selection.items, open }
|
||||
SwatchTableOutput { response: response.response, selected: selection.lead.filter(|_| changed), chosen: selection.items, open, delete: false } // P3(color-w1): ex.E20
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,8 @@ impl Kbd {
|
||||
}
|
||||
None => one,
|
||||
};
|
||||
if trigger.double { format!("{one} {one}") } else { one }
|
||||
// P3(shortcuts-w3): kb.C13b
|
||||
if trigger.is_double() { format!("{one} {one}") } else { one }
|
||||
}
|
||||
|
||||
/// The name of `key` alone for `os`, in the language of `words`: its word when it has one, else the key as the
|
||||
|
||||
@@ -97,6 +97,13 @@ impl Text {
|
||||
text
|
||||
}
|
||||
|
||||
/// Sets the text's ideal and least width to those of `sample`, so a readout keeps its width while its value changes.
|
||||
#[must_use]
|
||||
pub fn sample(self, sample: impl Into<Label>) -> Self {
|
||||
let _ = sample;
|
||||
todo!("ch.K33")
|
||||
}
|
||||
|
||||
/// Sets the text in italics: a value set apart from the words around it.
|
||||
pub fn italic(mut self) -> Self {
|
||||
self.italic = true;
|
||||
|
||||
@@ -152,6 +152,20 @@ impl<'a> SliderField<'a> {
|
||||
.label(label)
|
||||
}
|
||||
|
||||
/// Values the field's slider snaps to, drawn as marks under the track: [`Slider::marks`].
|
||||
#[must_use]
|
||||
pub fn marks(self, marks: &[f64]) -> Self {
|
||||
let _ = marks;
|
||||
todo!("wg.W31")
|
||||
}
|
||||
|
||||
/// [`marks`](Self::marks) at the values, each with a caption centred under its mark: [`Slider::marks_labelled`].
|
||||
#[must_use]
|
||||
pub fn marks_labelled<L: Into<Label>>(self, marks: impl IntoIterator<Item = (f64, L)>) -> Self {
|
||||
let _ = marks;
|
||||
todo!("wg.W31")
|
||||
}
|
||||
|
||||
/// What the children are built from, apart from the binding and the track face.
|
||||
fn look(&self) -> Look {
|
||||
Look {
|
||||
|
||||
@@ -302,6 +302,14 @@ impl Row {
|
||||
self.props.layout = std::mem::replace(&mut self.props.layout, BodyLayout::Stack).align(align);
|
||||
self
|
||||
}
|
||||
|
||||
/// The rank by which the row leaves a shrinking row whole: the row reports its members' ranks to the shrink
|
||||
/// that drops units, the lowest rank first.
|
||||
#[must_use]
|
||||
pub fn fit_rank(self, rank: u8) -> Self {
|
||||
let _ = rank;
|
||||
todo!("ch.K31")
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Row {
|
||||
|
||||
@@ -21,8 +21,8 @@ pub use findings::{Finding, Findings, FindingsList, FindingsListStyle, FindingsS
|
||||
pub use predicate::{DropTest, RowTest, RowText};
|
||||
pub(crate) use row::RowThumb;
|
||||
pub use row::{
|
||||
ListRow, ListRowStyle, RowDragSpot, RowEvent, RowInk, RowOutput, RowStyleCx, ThumbAspect, ThumbPaint, ThumbSize, ThumbTarget, ThumbTargets,
|
||||
TrailingFace, TrailingPart, label_color_label, tree_steps,
|
||||
LabelUnderline, ListRow, ListRowStyle, RowDragSpot, RowEvent, RowInk, RowOutput, RowRun, RowStyleCx, ThumbAspect, ThumbPaint, ThumbSize,
|
||||
ThumbTarget, ThumbTargets, TrailingFace, TrailingPart, label_color_label, tree_steps,
|
||||
};
|
||||
pub use toggle::{ToggleCell, ToggleFace, ToggleState};
|
||||
pub use tree::OpenSet;
|
||||
|
||||
@@ -56,6 +56,33 @@ pub enum RowDragSpot {
|
||||
Trailing(TrailingPart),
|
||||
}
|
||||
|
||||
/// Where a row sits in a run of rows that share one outline ([`ListRow::run`]).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum RowRun {
|
||||
/// A run of one row: outlined on every side.
|
||||
Alone,
|
||||
/// The first row of a run.
|
||||
First,
|
||||
/// A row inside a run.
|
||||
Middle,
|
||||
/// The last row of a run.
|
||||
Last,
|
||||
}
|
||||
|
||||
/// The line under a row's label.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[non_exhaustive]
|
||||
pub enum LabelUnderline {
|
||||
/// No line.
|
||||
#[default]
|
||||
None,
|
||||
/// A solid line.
|
||||
Solid,
|
||||
/// A dashed line.
|
||||
Dashed,
|
||||
}
|
||||
|
||||
/// The name of a label colour, or of no label, in the language of `words`.
|
||||
pub fn label_color_label(color: Option<LabelColor>, words: &ListWords) -> Label {
|
||||
let word = match color {
|
||||
@@ -166,6 +193,20 @@ pub struct ListRow<'a> {
|
||||
/// The label in italics.
|
||||
#[prop]
|
||||
pub(super) italic: bool,
|
||||
/// The line under the row's label: `Solid` underlines the label span, `Dashed` draws a dashed line under it.
|
||||
#[prop]
|
||||
#[allow(dead_code)] // P3(document-panels-w1): dp.C2
|
||||
pub(super) underline: LabelUnderline,
|
||||
/// A filled right triangle in the row's trailing top corner, in the label's ink: it marks the list's current row
|
||||
/// and mirrors.
|
||||
#[prop]
|
||||
#[allow(dead_code)] // P3(document-panels-w1): dp.C4
|
||||
pub(super) corner_mark: bool,
|
||||
/// The row is its thumbnails and their link glyphs, with no label band, and as wide and high as they are. The label
|
||||
/// stays the accessible name.
|
||||
#[prop(flag)]
|
||||
#[allow(dead_code)] // P3(document-panels-w1): ap.AP13
|
||||
pub(super) thumbnails_only: bool,
|
||||
/// The hover look without the pointer (the canvas hovers the layer).
|
||||
#[prop]
|
||||
pub(super) highlight: bool,
|
||||
@@ -280,6 +321,30 @@ pub struct ListRow<'a> {
|
||||
}
|
||||
|
||||
impl<'a> ListRow<'a> {
|
||||
/// One outline per run in the divider stroke and `radius.control`, inside each row's rect, for the row at `run`'s
|
||||
/// place in a run of rows.
|
||||
#[must_use]
|
||||
pub fn run(self, run: RowRun) -> Self {
|
||||
let _ = run;
|
||||
todo!("ch.K24")
|
||||
}
|
||||
|
||||
/// A full-height bar at the start of the row's content, after its toggle cells and before the indent. It takes no
|
||||
/// room from the label and mirrors in right-to-left. It is not the `striped` list tint.
|
||||
#[must_use]
|
||||
pub fn stripe(self, color: crate::style::DataColor, width: crate::primitives::StrokeWidth) -> Self {
|
||||
let _ = (color, width);
|
||||
todo!("dp.C3")
|
||||
}
|
||||
|
||||
/// The row is as tall as a row with a `size` thumbnail and draws no thumbnail; its icon stands in the thumbnail's
|
||||
/// place.
|
||||
#[must_use]
|
||||
pub fn thumb_height(self, size: ThumbSize) -> Self {
|
||||
let _ = size;
|
||||
todo!("dp.C5")
|
||||
}
|
||||
|
||||
/// A row showing `label`, which also names it for a screen reader.
|
||||
pub fn new(label: impl Into<Label>) -> Self {
|
||||
use crate::contract::Props as _;
|
||||
@@ -301,6 +366,9 @@ impl<'a> ListRow<'a> {
|
||||
sub_steps: 0,
|
||||
divider_below: true,
|
||||
italic: false,
|
||||
underline: LabelUnderline::None,
|
||||
corner_mark: false,
|
||||
thumbnails_only: false,
|
||||
highlight: false,
|
||||
clipped: false,
|
||||
rule: false,
|
||||
|
||||
@@ -83,6 +83,15 @@ pub struct List<'a, K: Clone + Eq + Hash + Send + Sync + 'static> {
|
||||
/// The kept rows are in order of how well they match the query.
|
||||
#[prop]
|
||||
ranked: bool,
|
||||
/// Which end of the rows the list stays at while rows are added: `End` follows the newest row as long as the user
|
||||
/// left the scroll at the end.
|
||||
#[prop]
|
||||
#[allow(dead_code)] // P3(appearance-w2): dp.C6
|
||||
scroll_anchor: crate::contract::ScrollAnchor,
|
||||
/// Whether every group after the first starts below a full-width divider row instead of a titled group row.
|
||||
#[prop]
|
||||
#[allow(dead_code)] // P3(appearance-w2): ap.AP6
|
||||
group_heads: crate::tile_grid::GroupHeads,
|
||||
}
|
||||
|
||||
impl<'a, K: Clone + Eq + Hash + Send + Sync + 'static> List<'a, K> {
|
||||
@@ -106,6 +115,8 @@ impl<'a, K: Clone + Eq + Hash + Send + Sync + 'static> List<'a, K> {
|
||||
row_menu: false,
|
||||
filter: None,
|
||||
ranked: false,
|
||||
scroll_anchor: crate::contract::ScrollAnchor::Start,
|
||||
group_heads: crate::tile_grid::GroupHeads::Titled,
|
||||
}
|
||||
.label(label)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//! `Alternate`: the command a row runs while modifiers are held as it is chosen.
|
||||
|
||||
use crate::runtime::commands::CommandRef;
|
||||
use craft_keymap::Mods;
|
||||
|
||||
/// The command a row runs while `mods` are held as it is chosen (Alt on Merge Visible runs Stamp Visible).
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub struct Alternate {
|
||||
/// The modifiers that select the alternate.
|
||||
pub mods: Mods,
|
||||
/// The command a pick runs while they are held.
|
||||
pub command: CommandRef,
|
||||
}
|
||||
|
||||
impl Alternate {
|
||||
/// The alternate that runs `command` while `mods` are held.
|
||||
pub fn new(mods: Mods, command: impl Into<CommandRef>) -> Alternate {
|
||||
Alternate { mods, command: command.into() }
|
||||
}
|
||||
|
||||
/// Whether `held` includes every modifier of the alternate. The one rule the in-window row and the native
|
||||
/// dispatch share.
|
||||
pub fn selected_by(&self, held: Mods) -> bool {
|
||||
let m = self.mods;
|
||||
(!m.cmd || held.cmd) && (!m.ctrl || held.ctrl) && (!m.alt || held.alt) && (!m.shift || held.shift)
|
||||
}
|
||||
}
|
||||
@@ -121,6 +121,7 @@ impl Component for TitleFace {
|
||||
loading: false,
|
||||
mnemonic: None,
|
||||
align: crate::primitives::HAlign::Center,
|
||||
chord: None, // P3(menus-w2): sh.K13
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -142,6 +143,7 @@ impl Component for TitleFace {
|
||||
loading: false,
|
||||
mnemonic: self.mnemonic,
|
||||
align: crate::primitives::HAlign::Center,
|
||||
chord: None, // P3(menus-w2): sh.K13
|
||||
};
|
||||
face::paint(ui, cx, (&cx.style.text, &cx.style.icon), &cx.style.face, &spec, cx.content_rect);
|
||||
}
|
||||
@@ -170,6 +172,13 @@ impl<'a> MenuTitle<'a> {
|
||||
pub fn new(label: impl Into<Label>, body: impl FnMut(&mut Ui) + 'a) -> Self {
|
||||
MenuTitle { label: label.into(), body: Box::new(body) }
|
||||
}
|
||||
|
||||
/// Records the title's rect for `commands` with `commands::holds` in every pass it is shown.
|
||||
#[must_use]
|
||||
pub fn holds(self, commands: Vec<crate::runtime::commands::CommandRef>) -> Self {
|
||||
let _ = commands;
|
||||
todo!("mn.M15")
|
||||
}
|
||||
}
|
||||
|
||||
/// The Help menu's search: the index of the menu that starts with the field, and the commands it searches.
|
||||
@@ -205,6 +214,9 @@ pub struct MenuBarOutput {
|
||||
pub open: bool,
|
||||
/// The titles alone (with "…" when it shows), from the first title's reading start to the last title's end.
|
||||
pub titles: Rect,
|
||||
/// True in the one pass where a menu of the bar opened while no menu of the bar was open when the pass began. A
|
||||
/// rerun pass in the same frame and a switch from one open title to another report false.
|
||||
pub opened: bool,
|
||||
}
|
||||
|
||||
impl Outcome for MenuBarOutput {
|
||||
@@ -675,6 +687,6 @@ impl Component for MenuBar<'_> {
|
||||
let rects = Self::slots(found).into_iter().filter_map(|slot| cx.part_if_declared(Self::slot_part(slot)).map(|result| result.rect));
|
||||
let start = if cx.flow.is_rtl() { cx.rect.right_top() } else { cx.rect.left_top() };
|
||||
let titles = rects.reduce(Rect::union).unwrap_or_else(|| Rect::from_min_size(start, Vec2::ZERO));
|
||||
MenuBarOutput { response: cx.response.clone(), open: self.open, titles }
|
||||
MenuBarOutput { response: cx.response.clone(), open: self.open, titles, opened: false } // P3(menus-w2): mn.M16
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,6 +193,8 @@ pub struct MenuItem<'a> {
|
||||
/// The checked state of the entry the row shows: a radio mark in a value menu, a check mark elsewhere while true.
|
||||
#[prop(name = "entry_checked")]
|
||||
entry: Option<bool>,
|
||||
#[allow(dead_code)] // P3(menus-w1): mn.M14
|
||||
sample: Option<(crate::list::ThumbAspect, crate::primitives::FacePaint)>,
|
||||
ran: bool,
|
||||
opens: bool,
|
||||
open: bool,
|
||||
@@ -216,6 +218,7 @@ impl<'a> MenuItem<'a> {
|
||||
shortcut: None,
|
||||
keep_open: false,
|
||||
entry: None,
|
||||
sample: None,
|
||||
ran: false,
|
||||
opens: false,
|
||||
open: false,
|
||||
@@ -224,6 +227,14 @@ impl<'a> MenuItem<'a> {
|
||||
.label(label)
|
||||
}
|
||||
|
||||
/// A content-painted cell after the label and before the shortcut, in a column shared by the level's rows: as high
|
||||
/// as the row's text line and as wide as that height times `aspect`.
|
||||
#[must_use]
|
||||
pub fn sample(self, aspect: crate::list::ThumbAspect, face: crate::primitives::FacePaint) -> Self {
|
||||
let _ = (aspect, face);
|
||||
todo!("mn.M14")
|
||||
}
|
||||
|
||||
/// A row bound to `command`: its label, chord, enabled state and checked state follow the command, and running it
|
||||
/// fires the command.
|
||||
pub fn command(command: impl Into<CommandRef>) -> Self {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! Menu presets with `MenuItem` rows, menu-bar keys and mnemonics.
|
||||
|
||||
mod alternate;
|
||||
pub mod bar;
|
||||
mod edit;
|
||||
pub(crate) mod item;
|
||||
@@ -12,6 +13,7 @@ pub mod search;
|
||||
mod stories;
|
||||
mod words;
|
||||
|
||||
pub use alternate::Alternate;
|
||||
pub use bar::{MenuBar, MenuBarOutput, MenuBarStyle, MenuHelp, MenuTitle};
|
||||
pub(crate) use edit::text_menu;
|
||||
pub use edit::{EditMenu, EditMenuOutput};
|
||||
@@ -22,6 +24,6 @@ pub use popup::entry_rows;
|
||||
#[doc(hidden)]
|
||||
pub use popup::layer;
|
||||
pub(crate) use popup::pick_values_from;
|
||||
pub use popup::{Menu, MenuOutput, MenuPick, MenuStep, MenuStyle};
|
||||
pub use search::HelpEntry;
|
||||
pub use popup::{Menu, MenuOutput, MenuPick, MenuRow, MenuStep, MenuStyle, menu_rows};
|
||||
pub use search::{HelpEntry, SearchIndex, SearchWords, Synonyms, rank};
|
||||
pub use words::MenuWords;
|
||||
|
||||
@@ -32,6 +32,8 @@ pub enum PanelRow {
|
||||
Item(Entry<GroupItem>),
|
||||
/// A row that opens a submenu.
|
||||
Submenu(Label, Vec<PanelRow>),
|
||||
/// A command row that runs its alternate's command while the alternate's modifiers are held, as the bar's rows do.
|
||||
Alternated(CommandRef, super::Alternate),
|
||||
/// A separator.
|
||||
Separator,
|
||||
}
|
||||
@@ -83,6 +85,7 @@ impl PanelMenu {
|
||||
PanelRow::Submenu(label, rows) => {
|
||||
Menu::submenu_row(ui, label.clone(), |ui, _| Self::rows(ui, rows, picked));
|
||||
}
|
||||
PanelRow::Alternated(..) => todo!("mn.B10"),
|
||||
PanelRow::Separator => {
|
||||
Divider::horizontal().show(ui);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,29 @@ pub fn layer(submenu: bool) -> Overlay {
|
||||
base.dismiss(Dismiss::new().outside(Outside::Absorb).on_activate(true)).focus(FocusPolicy::MENU.initial(Initial::Default))
|
||||
}
|
||||
|
||||
/// A row of a menu that picks a caller's value: an entry, or a submenu of rows.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub enum MenuRow<T> {
|
||||
/// An entry, shown as [`entry_rows`] shows it.
|
||||
Entry(Entry<T>),
|
||||
/// A submenu row of the label that shows `rows`, recursively; a submenu with no enabled row is disabled.
|
||||
Submenu(Label, Vec<MenuRow<T>>),
|
||||
}
|
||||
|
||||
impl<T> From<Entry<T>> for MenuRow<T> {
|
||||
fn from(entry: Entry<T>) -> Self {
|
||||
MenuRow::Entry(entry)
|
||||
}
|
||||
}
|
||||
|
||||
/// Shows `rows` as `entry_rows` shows entries, a submenu as `Menu::submenu_row_enabled`, and returns the value picked at
|
||||
/// any depth.
|
||||
pub fn menu_rows<T: Clone>(ui: &mut Ui, rows: &[MenuRow<T>]) -> Option<T> {
|
||||
let _ = (ui, rows);
|
||||
todo!("dp.C7")
|
||||
}
|
||||
|
||||
/// Shows one row per entry, a caption for a heading, a rule for a separator, and returns the index of the entry that
|
||||
/// ran. In a value menu
|
||||
/// ([`Menu::values`]) every row is a radio item and the checked entry carries the mark; elsewhere a checked entry
|
||||
|
||||
@@ -6,6 +6,12 @@ use crate::runtime::env::Label;
|
||||
use craft_i18n::Folder;
|
||||
use craft_i18n::matcher::Matcher;
|
||||
|
||||
mod index;
|
||||
mod synonyms;
|
||||
|
||||
pub use index::{SearchIndex, rank};
|
||||
pub use synonyms::{SearchWords, Synonyms};
|
||||
|
||||
/// The most matches the help search lists.
|
||||
pub const MAX_RESULTS: usize = 15;
|
||||
|
||||
@@ -17,12 +23,16 @@ pub struct HelpEntry {
|
||||
label: Label,
|
||||
english: Option<Label>,
|
||||
path: Vec<Label>,
|
||||
#[allow(dead_code)] // P3(menus-w2): mn.M17
|
||||
home: Option<Label>,
|
||||
#[allow(dead_code)] // P3(menus-w2): mn.M18
|
||||
words: Option<String>,
|
||||
}
|
||||
|
||||
impl HelpEntry {
|
||||
/// A command found by `label`, the label its menu row shows.
|
||||
pub fn new(command: impl Into<CommandRef>, label: impl Into<Label>) -> Self {
|
||||
HelpEntry { command: command.into(), label: label.into(), english: None, path: Vec::new() }
|
||||
HelpEntry { command: command.into(), label: label.into(), english: None, path: Vec::new(), home: None, words: None }
|
||||
}
|
||||
|
||||
/// The English label, which matches too.
|
||||
@@ -39,6 +49,32 @@ impl HelpEntry {
|
||||
self
|
||||
}
|
||||
|
||||
/// The label shown in place of the path. It is not searched.
|
||||
#[must_use]
|
||||
pub fn with_home(self, home: impl Into<Label>) -> Self {
|
||||
let _ = home;
|
||||
todo!("mn.M17")
|
||||
}
|
||||
|
||||
/// The label shown in place of the path, if any.
|
||||
#[must_use]
|
||||
pub fn home(&self) -> Option<&Label> {
|
||||
todo!("mn.M17")
|
||||
}
|
||||
|
||||
/// The command id and description words: searched (word index, description tier), never shown.
|
||||
#[must_use]
|
||||
pub fn with_words(self, words: impl Into<String>) -> Self {
|
||||
let _ = words;
|
||||
todo!("mn.M18")
|
||||
}
|
||||
|
||||
/// The searched words, if any.
|
||||
#[must_use]
|
||||
pub fn words(&self) -> Option<&str> {
|
||||
todo!("mn.M18")
|
||||
}
|
||||
|
||||
/// The command the entry runs.
|
||||
#[must_use]
|
||||
pub fn command(&self) -> &CommandRef {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//! The command search's word index and its ranking.
|
||||
|
||||
use super::{HelpEntry, Synonyms};
|
||||
use craft_i18n::Folder;
|
||||
|
||||
/// The word index of the help search: the words of each entry's label, English label, path, id and words, English
|
||||
/// stems, a typo bound and synonym expansion.
|
||||
pub struct SearchIndex {}
|
||||
|
||||
impl SearchIndex {
|
||||
/// The index of `entries`, folded by `folder`, with `synonyms` expanding each word.
|
||||
pub fn new(folder: &Folder, entries: &[HelpEntry], synonyms: &Synonyms) -> Self {
|
||||
let _ = (folder, entries, synonyms);
|
||||
todo!("mn.M19")
|
||||
}
|
||||
}
|
||||
|
||||
/// The entries of `index` matching `query`, best first, as indexes into the entries it was built from: tiers, grades
|
||||
/// from `uses` (`ilog2(min(count, 999) + 1)`), `recent` places and a substring fallback for long queries. It does not
|
||||
/// cap the list.
|
||||
pub fn rank(index: &SearchIndex, query: &str, recent: &[usize], uses: &dyn Fn(usize) -> u32) -> Vec<usize> {
|
||||
let _ = (index, query, recent, uses);
|
||||
todo!("mn.M20")
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
//! The groups of words that mean the same thing when searching commands.
|
||||
|
||||
use crate::runtime::env::Env;
|
||||
|
||||
craft_ui::words! {
|
||||
/// The synonym groups of the command search: each row is the group's English words joined by ", "; a catalog may
|
||||
/// add the group's words in its language the same way.
|
||||
pub struct SearchWords {
|
||||
remove: "search.remove" = "remove, delete, erase, clear";
|
||||
background: "search.background" = "background, bg";
|
||||
image: "search.image" = "image, picture, photo, img, bitmap";
|
||||
text: "search.text" = "text, type";
|
||||
reflect: "search.reflect" = "reflect, flip";
|
||||
unite: "search.unite" = "unite, combine";
|
||||
trace: "search.trace" = "trace, vectorize";
|
||||
color: "search.color" = "color, colour";
|
||||
gray: "search.gray" = "gray, grey";
|
||||
grayscale: "search.grayscale" = "grayscale, greyscale";
|
||||
center: "search.center" = "center, centre";
|
||||
duplicate: "search.duplicate" = "duplicate, clone";
|
||||
zoom: "search.zoom" = "zoom, magnify";
|
||||
rotate: "search.rotate" = "rotate, turn, spin";
|
||||
scale: "search.scale" = "scale, resize";
|
||||
opacity: "search.opacity" = "opacity, transparency";
|
||||
font: "search.font" = "font, typeface";
|
||||
preferences: "search.preferences" = "preferences, settings, prefs";
|
||||
artboard: "search.artboard" = "artboard, canvas";
|
||||
swatch: "search.swatch" = "swatch, palette";
|
||||
eyedropper: "search.eyedropper" = "eyedropper, dropper";
|
||||
}
|
||||
}
|
||||
|
||||
/// The groups of words that mean the same thing, in English and in the UI language.
|
||||
pub struct Synonyms {}
|
||||
|
||||
impl Synonyms {
|
||||
/// The groups of `env`: the 21 English groups, each joined with its row in the UI language when a catalog has one.
|
||||
pub fn of(env: &Env) -> Synonyms {
|
||||
let _ = env;
|
||||
todo!("mn.M23")
|
||||
}
|
||||
}
|
||||
@@ -26,4 +26,4 @@ pub use tree_picker::{TreeEntry, TreePicker, TreePickerStyle};
|
||||
pub use unit_select::{UnitSelect, UnitSelectOutput, UnitSelectStyle};
|
||||
|
||||
pub use craft_behavior::Anchor9;
|
||||
pub use reference_point::{ReferencePoint, ReferencePointStyle};
|
||||
pub use reference_point::{ReferencePoint, ReferencePointLook, ReferencePointStyle};
|
||||
|
||||
@@ -62,6 +62,18 @@ pub struct ReferencePointStyle {
|
||||
arrow_ink: Stateful<StyleColor>,
|
||||
}
|
||||
|
||||
/// How a [`ReferencePoint`] draws its nine points.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, crate::contract::MemoProps)]
|
||||
#[non_exhaustive]
|
||||
pub enum ReferencePointLook {
|
||||
/// A dot for each point, the pick's twice as wide.
|
||||
#[default]
|
||||
Dots,
|
||||
/// Eight outer squares joined by one line round the box and a lone centre square, the pick filled, with growth
|
||||
/// arrows in `Dots` only.
|
||||
Squares,
|
||||
}
|
||||
|
||||
/// The 3 by 3 picker of a box's nine points: the point a transform, a resize or a watermark works about. The nine
|
||||
/// points are one Tab stop; the arrows move the focus and stop at the grid's edges, and Space, Enter or a click picks
|
||||
/// the focused point. The arrows are directions in the box, so they do not mirror in a right-to-left interface and
|
||||
@@ -83,12 +95,17 @@ pub struct ReferencePoint<'a> {
|
||||
#[style_key]
|
||||
#[prop(flag)]
|
||||
compact: bool,
|
||||
/// How the nine points are drawn: dots, or squares joined by a line round the box.
|
||||
#[style_key]
|
||||
#[prop]
|
||||
#[allow(dead_code)] // P3(widgets-w3): wg.W32
|
||||
look: ReferencePointLook,
|
||||
}
|
||||
|
||||
impl<'a> ReferencePoint<'a> {
|
||||
/// A picker named `label` over `value`.
|
||||
pub fn new(label: impl Into<Label>, value: Bind<'a, Anchor9>) -> Self {
|
||||
ReferencePoint { common: Common::new(), value, growth: None, compact: false }.label(label)
|
||||
ReferencePoint { common: Common::new(), value, growth: None, compact: false, look: ReferencePointLook::Dots }.label(label)
|
||||
}
|
||||
|
||||
/// The direction of the arrow `cell` shows when the pick is `anchor`, in cell steps (each -1, 0 or 1): away from
|
||||
|
||||
@@ -86,6 +86,13 @@ impl<'a> Popover<'a> {
|
||||
Popover { common: Common::new(), props, open, closed: None }.label(label)
|
||||
}
|
||||
|
||||
/// The popover has no surface and no padding of its own: its content (a `Bar` with `surface(SurfaceKind::Floating)`)
|
||||
/// is the one surface.
|
||||
#[must_use]
|
||||
pub fn content_surface(self) -> Self {
|
||||
todo!("cv.F41")
|
||||
}
|
||||
|
||||
/// Changes the layer the popover shows in, for the settings without a setter of their own: the size a
|
||||
/// [resizable](Popover::resizable) popover has until the user resizes it (`Overlay::size`) and the least it may be
|
||||
/// resized to (`Overlay::min_size`).
|
||||
|
||||
@@ -20,6 +20,9 @@ pub struct Adornment {
|
||||
enum Kind {
|
||||
Glyph(IconSpec<'static>),
|
||||
Button(PartKey, IconSpec<'static>, Label),
|
||||
/// The up and down step halves of a number field's leading arrows, by their part keys.
|
||||
#[allow(dead_code)] // P3(widgets-w2): wg.W28
|
||||
Steps(PartKey, PartKey),
|
||||
/// Text in the line, of `role`, monospace with `mono`, the gap kept before the text with `apart`; `size` is its
|
||||
/// measured run, zero until [`Adornment::measured`].
|
||||
Text {
|
||||
@@ -106,6 +109,7 @@ impl Adornment {
|
||||
match &self.kind {
|
||||
Kind::Glyph(_) => Vec2::splat(style.glyph.side),
|
||||
Kind::Button(..) => Vec2::splat(style.button),
|
||||
Kind::Steps(..) => todo!("wg.W28"),
|
||||
Kind::Text { size, .. } => *size,
|
||||
}
|
||||
}
|
||||
@@ -130,6 +134,7 @@ impl Adornment {
|
||||
Kind::Button(part, icon, name) => {
|
||||
ui.face(*part, IconButton::new(Self::spec(icon, None)).label(name.clone()).focusable(false).size(ControlSize::Sm))
|
||||
}
|
||||
Kind::Steps(..) => todo!("wg.W28"),
|
||||
Kind::Text { label, role, mono, .. } => {
|
||||
ui.draw().text_on_line(rect, &Self::run(label, *role, *mono).color(color), line);
|
||||
}
|
||||
|
||||
@@ -102,6 +102,11 @@ impl Codec for HexCodec {
|
||||
fn sample(&self, _current: &Rgba) -> Cow<'_, str> {
|
||||
Cow::Owned("0".repeat(self.digits * self.channels()))
|
||||
}
|
||||
|
||||
fn whole_paste(&self, pasted: &str) -> bool {
|
||||
let _ = pasted;
|
||||
todo!("wg.W34")
|
||||
}
|
||||
}
|
||||
|
||||
/// A text field over a colour's hexadecimal digits.
|
||||
|
||||
@@ -158,6 +158,11 @@ pub struct LinkedFields<'a, const N: usize> {
|
||||
/// `units.shown`. `range` is then in the stored unit.
|
||||
#[prop]
|
||||
lengths: Option<LengthUnits>,
|
||||
/// Every field without `lengths` shows its numbers in this unit (`NumberField::unit_kind`); `lengths` wins when both
|
||||
/// are set.
|
||||
#[prop]
|
||||
#[allow(dead_code)] // P3(widgets-w2): ap.AP16
|
||||
unit_kind: Option<crate::runtime::env::UnitKind>,
|
||||
}
|
||||
|
||||
impl<'a, const N: usize> LinkedFields<'a, N> {
|
||||
@@ -174,6 +179,7 @@ impl<'a, const N: usize> LinkedFields<'a, N> {
|
||||
captions: None,
|
||||
ranges: None,
|
||||
lengths: None,
|
||||
unit_kind: None,
|
||||
}
|
||||
.label(label)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@ pub use alt_text::{AltText, AltTextField, AltTextFieldStyle, AltTextWords};
|
||||
pub use chips::{ChipCodec, ChipField, ChipFieldOutput, ChipFieldStyle, ChipWords, PartialChips};
|
||||
pub use hex::{HexCodec, HexField};
|
||||
pub use linked::{LinkMode, LinkedFields, LinkedFieldsStyle, LinkedLayout, LinkedOutput, LinkedWords, follow_equal, follow_ratio, link_toggle};
|
||||
pub use number::{NamedOr, NumberField, NumberName, NumberOutput, NumberPick, NumberStepper, NumberStyle, NumberValue, RangeAlert, UnitPlacement};
|
||||
pub use number::{
|
||||
NamedOr, NumberField, NumberName, NumberOutput, NumberPick, NumberStepper, NumberStyle, NumberValue, RangeAlert, StepArrows, UnitPlacement,
|
||||
};
|
||||
pub use selectable_text::{SelectableStyle, SelectableText};
|
||||
pub use text_field::TextField;
|
||||
pub use words::TextWords;
|
||||
@@ -94,7 +96,7 @@ fn text_part<V>() -> TextKey<V> {
|
||||
|
||||
/// The text field every collection's `rename_editor` shows over an item's label: it selects the name on focus, so
|
||||
/// typing replaces it.
|
||||
pub(crate) fn rename_field(ui: &mut egui::Ui, draft: Bind<'_, String>, label: egui::Rect, name: &str) -> EditResponse<String> {
|
||||
pub fn rename_field(ui: &mut egui::Ui, draft: Bind<'_, String>, label: egui::Rect, name: &str) -> EditResponse<String> {
|
||||
use crate::contract::Show as _;
|
||||
TextField::new(name.to_owned(), draft).select_on_focus().show_at(ui, label)
|
||||
}
|
||||
|
||||
@@ -55,6 +55,18 @@ pub enum UnitPlacement {
|
||||
After,
|
||||
}
|
||||
|
||||
/// Whether a number field shows step arrows.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum StepArrows {
|
||||
/// No arrows.
|
||||
#[default]
|
||||
Hidden,
|
||||
/// Up and down halves at the start edge. A press steps once as ArrowUp or ArrowDown, one edit step each; a held
|
||||
/// press repeats after the hold delay at the hold interval; disabled or read-only arrows take no press.
|
||||
Leading,
|
||||
}
|
||||
|
||||
/// The placeholder of a mixed field.
|
||||
const BLANK: &str = "\u{2014}";
|
||||
|
||||
@@ -120,7 +132,7 @@ pub struct NumberField<'a, V: NumberValue + 'static = Option<f64>> {
|
||||
step: Option<f64>,
|
||||
/// Where an arrow press, a Page key and a wheel notch go from the current value, for values on a ladder (the zoom
|
||||
/// ladder); the step is ignored for them. The range still holds the result.
|
||||
#[prop(func = "Fn(f64, i32) -> f64")]
|
||||
#[prop(func = "Fn(f64, i32, f64) -> f64")]
|
||||
stepper: Option<NumberStepper<'a>>,
|
||||
/// A unit shown after the number.
|
||||
#[prop(into)]
|
||||
@@ -128,6 +140,10 @@ pub struct NumberField<'a, V: NumberValue + 'static = Option<f64>> {
|
||||
/// Whether the unit is drawn inside the field or left to the host to draw after it.
|
||||
#[prop]
|
||||
unit_placement: UnitPlacement,
|
||||
/// Up and down step halves at the start edge: a press steps once, a held press repeats; no Tab stop.
|
||||
#[prop]
|
||||
#[allow(dead_code)] // P3(widgets-w2): wg.W27
|
||||
step_arrows: StepArrows,
|
||||
/// The rows of the list a chevron after the field opens; Alt+Down opens it too.
|
||||
#[prop]
|
||||
presets: Option<&'a [Entry<NumberPick>]>,
|
||||
@@ -200,6 +216,7 @@ impl<'a, V: NumberValue + 'static> NumberField<'a, V> {
|
||||
stepper: None,
|
||||
unit: None,
|
||||
unit_placement: UnitPlacement::Inside,
|
||||
step_arrows: StepArrows::Hidden,
|
||||
presets: None,
|
||||
popup_slider: None,
|
||||
snap_typed: false,
|
||||
@@ -652,6 +669,7 @@ impl<V: NumberValue + 'static> Component for NumberField<'_, V> {
|
||||
typed_unit: committed.and_then(|note| note.unit).and_then(UnitKind::from_tag),
|
||||
out_of_range,
|
||||
cut: committed.is_some_and(|note| note.cut),
|
||||
link: false, // P3(widgets-w2): wg.W29
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,16 +10,17 @@ use std::ops::RangeInclusive;
|
||||
|
||||
/// The value one step from a value in a direction: the up arrow, the wheel and the Page keys of a field whose values
|
||||
/// lie on a ladder instead of a grid (`NumberField::stepper`). The direction is `1` up and `-1` down.
|
||||
pub struct NumberStepper<'a>(Box<dyn Fn(f64, i32) -> f64 + 'a>);
|
||||
pub struct NumberStepper<'a>(Box<dyn Fn(f64, i32, f64) -> f64 + 'a>);
|
||||
|
||||
impl<'a> NumberStepper<'a> {
|
||||
/// The stepper that runs `next`.
|
||||
pub fn new(next: impl Fn(f64, i32) -> f64 + 'a) -> Self {
|
||||
/// The stepper that runs `next(from, direction, scale)`: `scale` is 1 for a plain arrow, wheel notch or AccessKit
|
||||
/// step, `LARGE_STEPS` with Shift or a Page key, and a tenth with Alt where the field has one.
|
||||
pub fn new(next: impl Fn(f64, i32, f64) -> f64 + 'a) -> Self {
|
||||
NumberStepper(Box::new(next))
|
||||
}
|
||||
|
||||
pub(super) fn next(&self, from: f64, direction: i32) -> f64 {
|
||||
(self.0)(from, direction)
|
||||
(self.0)(from, direction, 1.0) // P3(appearance-w3): ap.AP15
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,8 @@ fn number_field(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
NumberField::new("Zoom", Bind::bound(data.value("zoom", Some(100.0))))
|
||||
.range(0.1..=12_800.0)
|
||||
.unit("%")
|
||||
.stepper(zoom_step)
|
||||
// P3(widgets-w2): ap.AP15
|
||||
.stepper(|value, direction, _scale| zoom_step(value, direction))
|
||||
.size(size)
|
||||
.show(ui);
|
||||
});
|
||||
|
||||
@@ -139,6 +139,8 @@ pub struct NumberOutput<V: NumberValue = Option<f64>> {
|
||||
pub out_of_range: Option<RangeAlert>,
|
||||
/// The committed text held more than the codec reads, in the pass it committed.
|
||||
pub cut: bool,
|
||||
/// The field's link label was clicked in this pass (`Cx::link_activated`).
|
||||
pub link: bool,
|
||||
}
|
||||
|
||||
/// A typed value the field clamped to its range, in shown units.
|
||||
|
||||
@@ -28,10 +28,10 @@ pub struct SelectableStyle {
|
||||
/// Read-only text the user focuses with a press to select and copy, which Tab passes over. Its node is a label named
|
||||
/// by `label`, with the text as its value.
|
||||
#[derive(crate::contract::Component, crate::contract::Props)]
|
||||
pub struct SelectableText {
|
||||
pub struct SelectableText<'a> {
|
||||
#[common]
|
||||
common: Common,
|
||||
text: String,
|
||||
spans: Vec<Span<'a>>,
|
||||
wrap: Wrap,
|
||||
mono: bool,
|
||||
/// The text is inset by the control padding, as the text of a field.
|
||||
@@ -40,10 +40,16 @@ pub struct SelectableText {
|
||||
field_inset: bool,
|
||||
}
|
||||
|
||||
impl SelectableText {
|
||||
/// Selectable `text` named `label`.
|
||||
pub fn new(label: impl Into<Label>, text: &str) -> Self {
|
||||
SelectableText { common: Common::new(), text: text.to_owned(), wrap: Wrap::Line, mono: false, field_inset: false }.label(label)
|
||||
impl<'a> SelectableText<'a> {
|
||||
/// Selectable `text` named `label`: one plain span, not copied.
|
||||
pub fn new(label: impl Into<Label>, text: &'a str) -> Self {
|
||||
SelectableText { common: Common::new(), spans: vec![Span::new(text)], wrap: Wrap::Line, mono: false, field_inset: false }.label(label)
|
||||
}
|
||||
|
||||
/// Selectable text of styled `spans` named `label`, selected, copied and named as one text.
|
||||
pub fn spans(label: impl Into<Label>, spans: Vec<Span<'a>>) -> Self {
|
||||
let _ = (label, spans);
|
||||
todo!("op.F10")
|
||||
}
|
||||
|
||||
/// The text wraps over several lines.
|
||||
@@ -61,12 +67,12 @@ impl SelectableText {
|
||||
}
|
||||
|
||||
fn run(&self, role: TypeRole) -> TextRun<'_> {
|
||||
let span = if self.mono { Span::new(self.text.as_str()).mono() } else { Span::new(self.text.as_str()) };
|
||||
TextRun::spans(vec![span]).role(role).wrap(self.wrap)
|
||||
let spans = if self.mono { self.spans.iter().cloned().map(Span::mono).collect() } else { self.spans.clone() };
|
||||
TextRun::spans(spans).role(role).wrap(self.wrap)
|
||||
}
|
||||
}
|
||||
|
||||
impl Component for SelectableText {
|
||||
impl Component for SelectableText<'_> {
|
||||
const ROLE: Role = Role::LABEL;
|
||||
const INPUT: crate::contract::Input = crate::contract::Input::Display;
|
||||
const OVERLAYS: bool = false;
|
||||
@@ -94,7 +100,7 @@ impl Component for SelectableText {
|
||||
}
|
||||
|
||||
fn access(&self, access: &mut Access, _: &Cx<'_, Self>) {
|
||||
access.value(self.text.clone());
|
||||
access.value(self.run(TypeRole::Body).full_text()); // P3(object-panels-w2): op.F10
|
||||
}
|
||||
|
||||
fn paint(&mut self, ui: &mut PaintUi<'_>, cx: &Cx<'_, Self>) {
|
||||
|
||||
@@ -7,12 +7,14 @@ use egui::Ui;
|
||||
|
||||
const LONG: &str = "A name that runs on well past the end of the field, so the field scrolls its text under the caret";
|
||||
|
||||
#[story(SelectableText, covers = [Default], drive = Drive::Never)]
|
||||
// P3(object-panels-w2): op.F10
|
||||
#[story(SelectableText<'static>, covers = [Default], drive = Drive::Never)]
|
||||
fn selectable_text(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
|
||||
SelectableText::new("Path", "/projects/poster.indd").show(ui).into()
|
||||
}
|
||||
|
||||
#[story(SelectableText, covers = [LongText], drive = Drive::Never)]
|
||||
// P3(object-panels-w2): op.F10
|
||||
#[story(SelectableText<'static>, covers = [LongText], drive = Drive::Never)]
|
||||
fn selectable_text_long(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
|
||||
SelectableText::new("Path", LONG).show(ui).into()
|
||||
}
|
||||
|
||||
@@ -78,7 +78,8 @@ impl ZoomField {
|
||||
field = field.range(range);
|
||||
}
|
||||
if self.stepper {
|
||||
field = field.stepper(move |percent: f64, dir: i32| ZoomLadder::step(percent / 100.0, dir, document) * 100.0);
|
||||
// P3(canvas-w1): ap.AP15
|
||||
field = field.stepper(move |percent: f64, dir: i32, _scale: f64| ZoomLadder::step(percent / 100.0, dir, document) * 100.0);
|
||||
}
|
||||
if self.scrub {
|
||||
field = field.scrub_by_label();
|
||||
@@ -90,7 +91,12 @@ impl ZoomField {
|
||||
.edit
|
||||
.events
|
||||
.clone()
|
||||
.map(|percent| percent.map_or(current, |percent| zoom::with_device(¤t, percent / 100.0, document, pixels_per_point))),
|
||||
// P3(canvas-w1): cv.F3
|
||||
.map(|percent| {
|
||||
percent.map_or(current, |percent| {
|
||||
zoom::with_device(¤t, percent / 100.0, document, pixels_per_point, &craft_behavior::ZoomScheme::PHOTOSHOP)
|
||||
})
|
||||
}),
|
||||
None => EditEvents::new(),
|
||||
};
|
||||
ZoomFieldOutput { response: shown.edit.response.clone(), view, invalid_zoom }
|
||||
|
||||
@@ -269,6 +269,11 @@ pub struct TileGrid<'a, K: Clone + Eq + Hash + Send + Sync + 'static> {
|
||||
/// dragged tiles would go.
|
||||
#[prop(func = "Fn(&ListDrag<K>, Option<&K>, usize) -> bool")]
|
||||
accepts: Option<DropTest<'a, K>>,
|
||||
/// How the groups are set apart: `Rule` starts every group after the first below a full-width divider row in place
|
||||
/// of its titled head.
|
||||
#[prop]
|
||||
#[allow(dead_code)] // P3(appearance-w2): ap.AP6
|
||||
group_heads: GroupHeads,
|
||||
/// The layout of this pass, kept for the headers' parts and paint.
|
||||
laid: RefCell<Option<GridLayout>>,
|
||||
/// The headers this pass shows, in the grid's layer space: the group, its rect and whether it is pinned.
|
||||
@@ -280,6 +285,18 @@ pub struct TileGrid<'a, K: Clone + Eq + Hash + Send + Sync + 'static> {
|
||||
events: Vec<GridEvent<K>>,
|
||||
}
|
||||
|
||||
/// How the groups of a grid or a list are set apart.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[non_exhaustive]
|
||||
pub enum GroupHeads {
|
||||
/// Every group has its titled head.
|
||||
#[default]
|
||||
Titled,
|
||||
/// Every group after the first starts below a full-width divider row with no title, no disclosure and no Tab
|
||||
/// stop; the group is always open.
|
||||
Rule,
|
||||
}
|
||||
|
||||
/// A group header as it shows this pass.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
struct Placed {
|
||||
@@ -321,6 +338,7 @@ impl<'a, K: Clone + Eq + Hash + Send + Sync + 'static> TileGrid<'a, K> {
|
||||
can_drag: None,
|
||||
drops: Vec::new(),
|
||||
accepts: None,
|
||||
group_heads: GroupHeads::Titled,
|
||||
laid: RefCell::new(None),
|
||||
placed: Vec::new(),
|
||||
placed_tail: Vec::new(),
|
||||
|
||||
@@ -16,7 +16,7 @@ use crate::runtime::env::Label;
|
||||
use craft_behavior::IconId;
|
||||
use craft_theme::variant::Tone;
|
||||
|
||||
pub use grid::{GridEvent, RatingKeys, TileGrid, TileGridOutput, TileGridStyle};
|
||||
pub use grid::{GridEvent, GroupHeads, RatingKeys, TileGrid, TileGridOutput, TileGridStyle};
|
||||
pub use layout::{Around, ArrangeSpacing, GridLayout, TailRow, TileArrangement, TileGroup, TileRow, Tiling, arrange, aspects_of};
|
||||
pub use slider::{ThumbnailSlider, ThumbnailSliderStyle, TileZoom, ZoomStep};
|
||||
pub use tile::{Tile, TileOutput, TilePartEvent, TileStyle};
|
||||
|
||||
Reference in New Issue
Block a user