pub struct GripPart { /* private fields */ }Expand description
A draggable grip part
Slider, ScrollBar and
Splitter all require a component which supports
click+drag behaviour. The appearance differs but event handling is the
same: this widget is its implementation.
§Layout
This widget is unusual in several ways:
Layout::size_rules does not request any size; the parent is expected
to determine the grip’s size.
(Calling size_rules is still required to comply with widget model.)
Layout::set_rect sets the grip’s rect directly.
Self::set_track must be called first.
Often it is preferable to use Self::set_size to set the grip’s size
then Self::set_offset to set the position.
(Calling set_rect is still required to comply with widget model.)
Layout::draw does nothing. The parent should handle all drawing.
§Event handling
This widget handles click/touch events on the widget, pushing a
GripMsg to allow the parent to implement further handling.
Optionally, the parent may call GripPart::handle_press_on_track
when a Event::PressStart occurs on the track area (which identifies
as being the parent widget).
Implementations§
Source§impl GripPart
impl GripPart
Sourcepub fn set_track(&mut self, track: Rect)
pub fn set_track(&mut self, track: Rect)
Set the track
The track is the region within which the grip may be moved.
This method must be called to set the track, presumably from the
parent widget’s Layout::set_rect method.
It is expected that GripPart::set_offset is called after this.
Sourcepub fn set_size(&mut self, size: Size)
pub fn set_size(&mut self, size: Size)
Set the grip’s size
It is expected that for each axis the size is no larger than the size
of the track (see GripPart::set_track). If equal, then the grip
may not be moved on this axis.
This method must be called at least once.
It is expected that GripPart::set_offset is called after this.
This size may be read via self.rect().size.
Sourcepub fn offset(&self) -> Offset
pub fn offset(&self) -> Offset
Get the current grip position
The position returned is relative to self.track().pos and is always
between Offset::ZERO and Self::max_offset.
Sourcepub fn max_offset(&self) -> Offset
pub fn max_offset(&self) -> Offset
Get the maximum allowed offset
This is the maximum allowed Self::offset, equal to the size of the
track minus the size of the grip.
Sourcepub fn set_offset(&mut self, cx: &mut EventState, offset: Offset) -> Offset
pub fn set_offset(&mut self, cx: &mut EventState, offset: Offset) -> Offset
Set a new grip position
The input offset is clamped between Offset::ZERO and
Self::max_offset.
The return value is a tuple of the new offest.
It is expected that Self::set_track and Self::set_size are
called before this method.
Sourcepub fn handle_press_on_track(
&mut self,
cx: &mut EventCx<'_>,
press: &PressStart,
) -> Offset
pub fn handle_press_on_track( &mut self, cx: &mut EventCx<'_>, press: &PressStart, ) -> Offset
Handle an event on the track itself
If it is desired to make the grip move when the track area is clicked,
then the parent widget should call this method when receiving
Event::PressStart.
Returns the new grip position relative to the track.
The grip position is not adjusted; the caller should also call
Self::set_offset to do so. This is separate to allow adjustment of
the posision; e.g. Slider pins the position to the nearest detent.
Trait Implementations§
Source§impl Events for GripPart
impl Events for GripPart
Source§const REDRAW_ON_MOUSE_OVER: bool = true
const REDRAW_ON_MOUSE_OVER: bool = true
Source§fn mouse_over_icon(&self) -> Option<CursorIcon>
fn mouse_over_icon(&self) -> Option<CursorIcon>
Source§fn handle_event(
&mut self,
cx: &mut EventCx<'_>,
_: &<GripPart as Widget>::Data,
event: Event<'_>,
) -> IsUsed
fn handle_event( &mut self, cx: &mut EventCx<'_>, _: &<GripPart as Widget>::Data, event: Event<'_>, ) -> IsUsed
Source§fn configure_recurse(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
fn configure_recurse(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
Source§fn update(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
fn update(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
Source§fn update_recurse(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
fn update_recurse(&mut self, cx: &mut ConfigCx<'_>, data: &Self::Data)
Source§fn handle_mouse_over(&mut self, cx: &mut EventCx<'_>, state: bool)
fn handle_mouse_over(&mut self, cx: &mut EventCx<'_>, state: bool)
Source§impl Layout for GripPart
This implementation is unusual (see GripPart documentation).
impl Layout for GripPart
This implementation is unusual (see GripPart documentation).
Source§impl Tile for GripPart
impl Tile for GripPart
Source§fn get_child(&self, index: usize) -> Option<&dyn Tile>
fn get_child(&self, index: usize) -> Option<&dyn Tile>
dyn Tile, if available Read moreSource§fn child_indices(&self) -> ChildIndices
fn child_indices(&self) -> ChildIndices
Source§fn role_child_properties(&self, cx: &mut dyn RoleCx, index: usize)
fn role_child_properties(&self, cx: &mut dyn RoleCx, index: usize)
index Read moreAuto Trait Implementations§
impl Freeze for GripPart
impl RefUnwindSafe for GripPart
impl !Send for GripPart
impl !Sync for GripPart
impl Unpin for GripPart
impl UnwindSafe for GripPart
Blanket Implementations§
Source§impl<W> AdaptWidget for Wwhere
W: Widget,
impl<W> AdaptWidget for Wwhere
W: Widget,
Source§fn pack(self, hints: AlignHints) -> Pack<Self>
fn pack(self, hints: AlignHints) -> Pack<Self>
Source§fn margins(self, dirs: Directions, style: MarginStyle) -> Margins<Self>
fn margins(self, dirs: Directions, style: MarginStyle) -> Margins<Self>
Source§fn on_configure<F>(self, f: F) -> AdaptEvents<Self>where
F: Fn(&mut AdaptConfigCx<'_, '_>, &mut Self) + 'static,
fn on_configure<F>(self, f: F) -> AdaptEvents<Self>where
F: Fn(&mut AdaptConfigCx<'_, '_>, &mut Self) + 'static,
Events::configure Read moreSource§fn on_update<F>(self, f: F) -> AdaptEvents<Self>
fn on_update<F>(self, f: F) -> AdaptEvents<Self>
Events::update Read moreSource§fn on_message<M, H>(self, handler: H) -> AdaptEvents<Self>
fn on_message<M, H>(self, handler: H) -> AdaptEvents<Self>
M Read moreSource§fn map_message<M, N, H>(self, handler: H) -> AdaptEvents<Self>
fn map_message<M, N, H>(self, handler: H) -> AdaptEvents<Self>
Source§fn on_messages<H>(self, handler: H) -> AdaptEvents<Self>
fn on_messages<H>(self, handler: H) -> AdaptEvents<Self>
Source§fn with_min_size_px(self, w: i32, h: i32) -> Reserve<Self>
fn with_min_size_px(self, w: i32, h: i32) -> Reserve<Self>
Source§fn with_min_size_em(self, w: f32, h: f32) -> Reserve<Self>
fn with_min_size_em(self, w: f32, h: f32) -> Reserve<Self>
Source§fn with_label<D, T>(self, direction: D, label: T) -> WithLabel<Self, D>
fn with_label<D, T>(self, direction: D, label: T) -> WithLabel<Self, D>
Source§impl<W> AdaptWidgetAny for W
impl<W> AdaptWidgetAny for W
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
Source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
Source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
Source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
Source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<W> TileExt for W
impl<W> TileExt for W
Source§fn is_strict_ancestor_of(&self, id: &Id) -> bool
fn is_strict_ancestor_of(&self, id: &Id) -> bool
id is not self and is a descendant Read more