Struct kas_widgets::GripPart
source · 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 do this.Layout::set_rect
sets the track within which this grip may move; the parent should always callGripPart::set_size_and_offset
afterwards to set the grip position.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 identifiers
as the parent widget).
Implementations§
source§impl GripPart
impl GripPart
sourcepub fn set_size_and_offset(&mut self, size: Size, offset: Offset) -> Action
pub fn set_size_and_offset(&mut self, size: Size, offset: Offset) -> Action
Set a new grip size and position
Returns Action::REDRAW
if a redraw is required.
sourcepub fn max_offset(&self) -> Offset
pub fn max_offset(&self) -> Offset
Get the maximum allowed offset
The grip position is clamped between ZERO
and this offset relative to
the track. This value depends on size of the grip and the track.
sourcepub fn set_offset(&mut self, offset: Offset) -> (Offset, Action)
pub fn set_offset(&mut self, offset: Offset) -> (Offset, Action)
Set a new grip position
Returns the new position (after clamping input) and an action: empty if
the grip hasn’t moved; REDRAW
if it has (though this widget is
not directly responsible for drawing, so this may not be accurate).
sourcepub fn handle_press_on_track(
&mut self,
mgr: &mut EventMgr<'_>,
press: &Press
) -> Offset
pub fn handle_press_on_track( &mut self, mgr: &mut EventMgr<'_>, press: &Press ) -> 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 Layout for GripPart
impl Layout for GripPart
This implementation is unusual in that:
size_rules
always returnsSizeRules::EMPTY
set_rect
sets the track within which this grip may move; the parent should callGripPart::set_size_and_offset
afterset_rect
(otherwise the grip’s position will not be updated)draw
does nothing: the parent is expected to do all drawing
source§impl Widget for GripPart
impl Widget for GripPart
source§fn translation(&self) -> Offset
fn translation(&self) -> Offset
source§fn steal_event(
&mut self,
mgr: &mut EventMgr<'_>,
id: &WidgetId,
event: &Event
) -> Response
fn steal_event( &mut self, mgr: &mut EventMgr<'_>, id: &WidgetId, event: &Event ) -> Response
source§fn handle_unused(&mut self, mgr: &mut EventMgr<'_>, event: Event) -> Response
fn handle_unused(&mut self, mgr: &mut EventMgr<'_>, event: Event) -> Response
index
but left unhandled Read moresource§fn handle_message(&mut self, mgr: &mut EventMgr<'_>)
fn handle_message(&mut self, mgr: &mut EventMgr<'_>)
source§impl WidgetChildren for GripPart
impl WidgetChildren for GripPart
source§fn num_children(&self) -> usize
fn num_children(&self) -> usize
source§fn get_child(&self, _index: usize) -> Option<&dyn Widget>
fn get_child(&self, _index: usize) -> Option<&dyn Widget>
None
if the index is
out of bounds. Read moresource§fn get_child_mut(&mut self, _index: usize) -> Option<&mut dyn Widget>
fn get_child_mut(&mut self, _index: usize) -> Option<&mut dyn Widget>
source§impl WidgetCore for GripPart
impl WidgetCore for GripPart
source§fn widget_name(&self) -> &'static str
fn widget_name(&self) -> &'static str
source§fn as_widget_mut(&mut self) -> &mut dyn Widget
fn as_widget_mut(&mut self) -> &mut dyn Widget
Auto Trait Implementations§
impl RefUnwindSafe for GripPart
impl !Send for GripPart
impl !Sync for GripPart
impl Unpin for GripPart
impl UnwindSafe for GripPart
Blanket Implementations§
§impl<S, T> Cast<T> for Swhere
T: Conv<S>,
impl<S, T> Cast<T> for Swhere T: Conv<S>,
§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere T: ConvApprox<S>,
§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
§fn cast_approx(self) -> T
fn cast_approx(self) -> T
§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere T: ConvFloat<S>,
§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
§fn cast_floor(self) -> T
fn cast_floor(self) -> T
§fn try_cast_trunc(self) -> Result<T, Error>
fn try_cast_trunc(self) -> Result<T, Error>
§fn try_cast_nearest(self) -> Result<T, Error>
fn try_cast_nearest(self) -> Result<T, Error>
§fn try_cast_floor(self) -> Result<T, Error>
fn try_cast_floor(self) -> Result<T, Error>
§fn try_cast_ceil(self) -> Result<T, Error>
fn try_cast_ceil(self) -> Result<T, Error>
source§impl<W> WidgetExt for Wwhere
W: Widget + ?Sized,
impl<W> WidgetExt for Wwhere W: Widget + ?Sized,
source§fn eq_id<T>(&self, rhs: T) -> boolwhere
WidgetId: PartialEq<T>,
fn eq_id<T>(&self, rhs: T) -> boolwhere WidgetId: PartialEq<T>,
source§fn identify(&self) -> IdentifyWidget
fn identify(&self) -> IdentifyWidget
source§fn is_ancestor_of(&self, id: &WidgetId) -> bool
fn is_ancestor_of(&self, id: &WidgetId) -> bool
id
is self or a descendant Read moresource§fn is_strict_ancestor_of(&self, id: &WidgetId) -> bool
fn is_strict_ancestor_of(&self, id: &WidgetId) -> bool
id
is not self and is a descendant Read more