pub struct SceneSelection { /* private fields */ }Expand description
Reactive selection state for a Scene.
Cheap-to-clone via Rc internals — all clones share the same
underlying signal. Pass clones into widget closures or item
register_bindings impls without worrying about ownership.
Implementations§
Source§impl SceneSelection
impl SceneSelection
Sourcepub fn new(mode: SceneSelectionMode) -> Self
pub fn new(mode: SceneSelectionMode) -> Self
New selection model with the given mode. Initially empty, no anchor.
Sourcepub fn mode(&self) -> SceneSelectionMode
pub fn mode(&self) -> SceneSelectionMode
The configured selection mode.
Sourcepub fn selection_signal(&self) -> Signal<BTreeSet<ItemId>>
pub fn selection_signal(&self) -> Signal<BTreeSet<ItemId>>
Live selection signal. Bind reactive consumers (item paint, status-bar item-count labels) to this.
Sourcepub fn is_selected(&self, id: ItemId) -> bool
pub fn is_selected(&self, id: ItemId) -> bool
Whether the given item id is currently selected.
Sourcepub fn clear(&self)
pub fn clear(&self)
Clear the selection. The anchor is also cleared so a subsequent Shift+click extends from a fresh starting point.
Sourcepub fn select_one(&self, id: ItemId)
pub fn select_one(&self, id: ItemId)
Replace the selection with a single item; sets the anchor
for subsequent range extension. No-op in None mode.
Sourcepub fn toggle(&self, id: ItemId)
pub fn toggle(&self, id: ItemId)
Toggle membership for the given id (Ctrl+click semantic).
Sets the anchor on toggle-on; leaves it unchanged on
toggle-off. No-op in None mode; in Single mode behaves
like select_one if the item is currently unselected, or
clear if it is.
Sourcepub fn replace(&self, ids: impl IntoIterator<Item = ItemId>)
pub fn replace(&self, ids: impl IntoIterator<Item = ItemId>)
Replace the selection with the given set of ids. Used by
marquee on commit. Anchor is cleared. No-op in None
mode; in Single mode keeps at most one (the first id in
ids).
Sourcepub fn extend(&self, ids: impl IntoIterator<Item = ItemId>)
pub fn extend(&self, ids: impl IntoIterator<Item = ItemId>)
Add ids to the existing selection (marquee with
Ctrl-modifier — additive box-select). No-op in None mode;
in Single mode reduces to select_one(last).
Sourcepub fn commit_marquee(&self, scene: &Scene, marquee_rect: Rect, additive: bool)
pub fn commit_marquee(&self, scene: &Scene, marquee_rect: Rect, additive: bool)
Marquee commit helper: replace (or extend, if additive)
the selection with every selectable scene item the rectangle picks up.
Sugar for commit_marquee_region with a
rectangular region, ItemSelectionMode::IntersectsItemShape and unit
view scale.
§Behaviour change
This used to be a pure AABB query. It now consults each item’s
shape, so a band that merely grazes a
connector’s bounding box no longer selects the connector — it has to
cross the stroke. For an item with an identity transform and the
default box shape the result is unchanged; for a rotated or scaled
item it is tighter, because the shape test happens in the item’s own
frame rather than against its enlarged scene-space hull. Pass
ItemSelectionMode::IntersectsItemBoundingRect to
commit_marquee_region to get the old rule back.
Sourcepub fn commit_marquee_region(
&self,
scene: &Scene,
region: &SceneRegion,
mode: ItemSelectionMode,
view_scale: f32,
additive: bool,
)
pub fn commit_marquee_region( &self, scene: &Scene, region: &SceneRegion, mode: ItemSelectionMode, view_scale: f32, additive: bool, )
Marquee commit over an arbitrary SceneRegion and
ItemSelectionMode — the rotated-view rubber band (an exact
quadrilateral) and the freehand lasso both arrive here.
Lightweight items and heavyweight widget entries are both candidates —
the spatial index returns ids regardless of kind, and a widget entry’s
shape is its box (see
Scene::item_shape). view_scale is the
live zoom, consulted only by a cosmetic stroke band.
Trait Implementations§
Source§impl Clone for SceneSelection
impl Clone for SceneSelection
Source§fn clone(&self) -> SceneSelection
fn clone(&self) -> SceneSelection
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for SceneSelection
impl !Send for SceneSelection
impl !Sync for SceneSelection
impl !UnwindSafe for SceneSelection
impl Freeze for SceneSelection
impl Unpin for SceneSelection
impl UnsafeUnpin for SceneSelection
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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