[−][src]Struct druid::BaseState
Generic state for all widgets in the hierarchy.
This struct contains the widget's layout rect, flags indicating when the widget is active or focused, and other state necessary for the widget to participate in event flow.
It is provided to paint calls as a non-mutable reference,
largely so a widget can know its size, also because active
and focus state can affect the widget's appearance. Other than
that, widgets will generally not interact with it directly,
but it is an important part of the WidgetPod struct.
Fields
layout_rect: Rectneeds_inval: boolis_hot: boolis_active: boolhas_active: boolAny descendant is active.
request_anim: boolAny descendant has requested an animation frame.
request_timer: boolAny descendant has requested a timer.
Note: we don't have any way of clearing this request, as it's likely not worth the complexity.
has_focus: boolThis widget or a descendant has focus.
request_focus: boolThis widget or a descendant has requested focus.
Methods
impl BaseState[src]
pub fn is_hot(&self) -> bool[src]
The "hot" (aka hover) status of a widget.
A widget is "hot" when the mouse is hovered over it. Widgets will often change their appearance as a visual indication that they will respond to mouse interaction.
The hot status is computed from the widget's layout rect. In a container hierarchy, all widgets with layout rects containing the mouse position have hot status.
Discussion: there is currently some confusion about whether a widget can be considered hot when some other widget is active (for example, when clicking to one widget and dragging to the next). The documentation should clearly state the resolution.
pub fn is_active(&self) -> bool[src]
The active status of a widget.
Active status generally corresponds to a mouse button down. Widgets
with behavior similar to a button will call set_active on mouse
down and then up.
When a widget is active, it gets mouse events even when the mouse is dragged away.
pub fn has_focus(&self) -> bool[src]
The focus status of a widget.
Focus means that the widget receives keyboard events.
A widget can request focus using the request_focus method.
This will generally result in a separate event propagation of
a FocusChanged method, including sending false to the previous
widget that held focus.
Only one leaf widget at a time has focus. However, in a container
hierarchy, all ancestors of that leaf widget are also invoked with
FocusChanged(true).
Discussion question: is "is_focused" a better name?
pub fn size(&self) -> Size[src]
The layout size.
This is the layout size as ultimately determined by the parent
container. Generally it will be the same as the size returned by
the child widget's layout method.
Trait Implementations
impl Clone for BaseState[src]
fn clone(&self) -> BaseState[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Copy for BaseState[src]
impl Default for BaseState[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> RoundFrom<T> for T[src]
fn round_from(x: T) -> T[src]
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>, [src]
U: RoundFrom<T>,
fn round_into(self) -> U[src]
impl<T> Same<T> for T[src]
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,