pub struct PathItem { /* private fields */ }Expand description
An arbitrary vector path with optional fill and stroke, in local item coordinates.
The path’s commands are evaluated in local space. A logical stroke scales
with the view zoom; a stroke_cosmetic stroke
holds a constant device-pixel width at any zoom (crisp connectors). The
item’s local_bounds — the rectangle the spatial index buckets on — is
derived from the geometry and the stroke, so it always encloses what
the item can be clicked on.
Implementations§
Source§impl PathItem
impl PathItem
Sourcepub fn new(path: Path) -> Self
pub fn new(path: Path) -> Self
A path in local coordinates — (0, 0) is the item’s anchor.
local_bounds is derived from the path (and re-derived whenever the
stroke or hit band changes), so it always encloses the clickable area.
Sourcepub fn fill(self, color: impl Into<ColorProp>) -> Self
pub fn fill(self, color: impl Into<ColorProp>) -> Self
Fill colour. Accepts a plain [Color], a theme role, a
Signal<Color>, or a Signal<Role> — resolved against the active
theme at paint time.
Sourcepub fn fill_rule(self, rule: FillRule) -> Self
pub fn fill_rule(self, rule: FillRule) -> Self
The [FillRule] used for both painting the fill and hit-testing
the interior.
[FillRule::EvenOdd] gives a ring authored as two subpaths a real
hole — one that is transparent and clicks through. There is
deliberately no hit-only fill rule: a shape that paints as a disc and
hit-tests as a ring is the two-sources-of-truth bug this whole type
exists to prevent.
Sourcepub fn stroke(self, color: impl Into<ColorProp>, width: f32) -> Self
pub fn stroke(self, color: impl Into<ColorProp>, width: f32) -> Self
Stroke colour and width in scene-coordinate pixels — the stroke scales with the view zoom.
Sourcepub fn stroke_cosmetic(self, color: impl Into<ColorProp>, width: f32) -> Self
pub fn stroke_cosmetic(self, color: impl Into<ColorProp>, width: f32) -> Self
Cosmetic stroke: the connector holds a constant device-pixel width at any zoom (it never thins out or thickens). The renderer keeps the path body sharp at the current zoom, so joins/caps stay correct.
Sourcepub fn stroke_styled(
self,
color: impl Into<ColorProp>,
style: StrokeStyle,
) -> Self
pub fn stroke_styled( self, color: impl Into<ColorProp>, style: StrokeStyle, ) -> Self
Stroke with an explicit [StrokeStyle] — dashed, dotted, or custom caps
/ joins. E.g. .stroke_styled(color, StrokeStyle::dashed(2.0, 6.0, 4.0))
distinguishes a pending connector from a solid confirmed one. The style
is stored verbatim (dash pattern/offset, Logical vs Device space).
Sourcepub fn hit_stroke_width(self, width: f32) -> Self
pub fn hit_stroke_width(self, width: f32) -> Self
Widen the clickable band without widening the drawn line (Konva’s
hitStrokeWidth): a 1 dp wire, 12 dp grabbable. In local units, so it
is a target size rather than a rendered thickness. Also widens the
derived local_bounds, so the broad phase keeps up with it.
Sourcepub fn access_label(self, label: impl Into<LocalizedString>) -> Self
pub fn access_label(self, label: impl Into<LocalizedString>) -> Self
Override the AT name announced for this item. Accepts
anything convertible into LocalizedString — most
commonly tr!(...) for translated labels, or any plain
string (which auto-converts via From<String>).
Sourcepub fn access_description(self, description: impl Into<LocalizedString>) -> Self
pub fn access_description(self, description: impl Into<LocalizedString>) -> Self
Long-form context appended to the item’s announcement.
Sourcepub fn access_role(self, role: Role) -> Self
pub fn access_role(self, role: Role) -> Self
Override the AccessKit role for this item.
Hide this item from the AT tree.
Sourcepub fn access_subtree(self, mode: AccessSubtreeMode) -> Self
pub fn access_subtree(self, mode: AccessSubtreeMode) -> Self
Set the AT subtree mode. Merge collapses descendants
into this item’s AT node; Exclude prunes them; the
default Inherit lets them emit normally.
Sourcepub fn access_merge_subtree(self) -> Self
pub fn access_merge_subtree(self) -> Self
Convenience: collapse all descendants into this item’s AT node so the subtree reads as one element.
Sourcepub fn access_exclude_subtree(self) -> Self
pub fn access_exclude_subtree(self) -> Self
Convenience: prune all descendants from the AT tree.
Sourcepub fn access_value(self, value: impl Into<LocalizedString>) -> Self
pub fn access_value(self, value: impl Into<LocalizedString>) -> Self
Announce a string value for this item (e.g. a formatted data
reading like "42 %"). Mirrors the widget-tier .access_value.
Sourcepub fn access_numeric_value(self, value: f64) -> Self
pub fn access_numeric_value(self, value: f64) -> Self
Announce a numeric value for this item, for slider/gauge-like data
marks whose magnitude assistive tech should describe. Pair with
access_numeric_range /
access_numeric_step for full
range semantics.
Sourcepub fn access_numeric_range(self, min: f64, max: f64) -> Self
pub fn access_numeric_range(self, min: f64, max: f64) -> Self
Announce the numeric min/max bounds for this item.
Sourcepub fn access_numeric_step(self, step: f64) -> Self
pub fn access_numeric_step(self, step: f64) -> Self
Announce the numeric step (per-arrow increment) for this item.
Trait Implementations§
Source§impl SceneItem for PathItem
impl SceneItem for PathItem
Source§fn set_local_bounds(&mut self, bounds: Rect)
fn set_local_bounds(&mut self, bounds: Rect)
Fit the path to bounds — a translate and a scale — and re-derive the
box from the moved geometry.
§It aims at the geometry, not at the box
The requested rectangle is the whole clickable box, band included, so
the fit targets bounds deflated by the band’s half-width and the
re-derived box then lands back on bounds exactly. Mapping the old box
onto the new one instead would re-add the band to a rectangle that
already contained it, overshooting by the band on every call: asking
three times for the same rectangle used to give three different
answers, each closer than the last and none of them the one asked for,
and each one re-bucketed the spatial index and emitted an
ItemChange::LocalBoundsChanged with a new value. Idempotent now: the
second identical call finds the fit is the identity and returns without
touching the geometry — which also keeps the memoised flattening that
ShapeGeometry exists for, instead of throwing it away per call.
§What it cannot honour
An axis the path has no extent on — a perfectly horizontal stroke, a
single point — cannot be stretched to fill one, so the box stays the
band’s own thickness there however tall a rectangle is asked for. That
is reported rather than hidden: Scene::set_local_bounds
reads the item’s box back and stores what the item settled on.
Source§fn shape(&self) -> ItemShape
fn shape(&self) -> ItemShape
The union of whatever the item actually draws: its filled interior
under PathItem::fill_rule when it has a fill, and a stroke band
when it has a stroke (or an explicit
hit_stroke_width).
A path with neither falls back to its local AABB. It draws nothing,
so there is no silhouette to derive one from, and an invisible
rectangle that still catches clicks is a legitimate use — an enlarged
grab area parked behind a thin connector. An item that wants clicks to
fall through says so with ItemShape::none, which is what a
logical-only GroupItem returns.
Source§fn local_bounds(&self) -> Rect
fn local_bounds(&self) -> Rect
scene_transform to compute its scene-space AABB for the
spatial index.Source§fn paint(&self, canvas: &mut Canvas, ctx: &SceneItemPaintContext<'_>)
fn paint(&self, canvas: &mut Canvas, ctx: &SceneItemPaintContext<'_>)
scene_transform (parent chain × view) pushed, so
coordinates are in local item space — (0, 0) is the
item’s anchor. Read moreSource§fn set_fill(&mut self, fill: Option<ColorProp>) -> AppearanceWrite<ColorProp>
fn set_fill(&mut self, fill: Option<ColorProp>) -> AppearanceWrite<ColorProp>
SceneModel::set_item_fill /
clear_item_fill. Rectangles,
paths, and groups set their fill; text items map it onto their
foreground colour (so a None is rejected — text always has a colour);
image items have no fill. Default:
AppearanceWrite::Refused. Read moreSource§fn set_stroke(
&mut self,
stroke: Option<(ColorProp, StrokeStyle)>,
) -> AppearanceWrite<(ColorProp, StrokeStyle)>
fn set_stroke( &mut self, stroke: Option<(ColorProp, StrokeStyle)>, ) -> AppearanceWrite<(ColorProp, StrokeStyle)>
StrokeStyle]), returning what was there
before. Backs
SceneModel::set_item_stroke /
clear_item_stroke. Rectangles,
paths, and groups accept it; text and image items refuse. Default:
AppearanceWrite::Refused. Read moreSource§fn register_bindings(&self, ctx: &mut BuildContext<'_>, view_id: WidgetId)
fn register_bindings(&self, ctx: &mut BuildContext<'_>, view_id: WidgetId)
SceneView::build for every item in
the scene, with the SceneView’s WidgetId as view_id. Items
with signal-bound state bind their signals here at the
appropriate BindingLevel.Source§fn thumbnail_color(&self) -> Color
fn thumbnail_color(&self) -> Color
RectItem
returns its fill, PathItem
returns stroke or fill, GroupItem
returns fill or stroke and paints a logical group fully
transparent. ImageItem does not
override — it keeps the neutral grey. Read moreSource§fn label(&self) -> Option<String>
fn label(&self) -> Option<String>
SceneItem::accessibility impl as
the AT name when an item author hasn’t overridden it via the
per-item .access_label(...) chain.Source§fn initial_flags(&self) -> ItemFlags
fn initial_flags(&self) -> ItemFlags
ItemFlags::default() — visible, enabled,
selectable. Built-ins read their accumulated builder state
(e.g. .draggable(true) flips IS_DRAGGABLE); custom items
override this to opt into hover acceptance, focus, clipping,
or IGNORES_TRANSFORMATIONS. Read moreSource§fn access_subtree_mode(&self) -> AccessSubtreeMode
fn access_subtree_mode(&self) -> AccessSubtreeMode
Source§fn accessibility(
&self,
builder: &mut AccessNodeBuilder,
_ctx: &SceneItemA11yContext,
)
fn accessibility( &self, builder: &mut AccessNodeBuilder, _ctx: &SceneItemA11yContext, )
Role::GraphicsObject] plus the SceneItem::label as the
AT name if set. The per-item .access_* builder chain layers
overrides on top of whatever this method writes.Source§fn cache_mode(&self) -> CacheMode
fn cache_mode(&self) -> CacheMode
CacheMode::None: the
item’s paint runs every frame. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for PathItem
impl !Send for PathItem
impl !Sync for PathItem
impl !UnwindSafe for PathItem
impl Freeze for PathItem
impl Unpin for PathItem
impl UnsafeUnpin for PathItem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more