[][src]Struct druid::BaseState

pub struct BaseState {
    layout_rect: Rect,
    needs_inval: bool,
    is_hot: bool,
    is_active: bool,
    has_active: bool,
    request_anim: bool,
    request_timer: bool,
    has_focus: bool,
    request_focus: bool,
}

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: bool

Any descendant is active.

request_anim: bool

Any descendant has requested an animation frame.

request_timer: bool

Any 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: bool

This widget or a descendant has focus.

request_focus: bool

This 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]

impl Copy for BaseState[src]

impl Default for BaseState[src]

Auto Trait Implementations

impl Send for BaseState

impl Sync for BaseState

impl Unpin for BaseState

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T[src]

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 
[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]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.