Skip to main content

WidgetCore

Struct WidgetCore 

Source
pub struct WidgetCore { /* private fields */ }
Expand description

The state that every Widget shares.

Store one WidgetCore in each Widget structure and return it from Widget::core and Widget::core_mut; every getter and setter on the Widget trait works against it. It holds the Widget’s ID and parent ID (assigned by the WidgetCache), its origin relative to its parent, its size, its background color, its Behavior flags (including hidden) and VisualState flags, its Appearance (a style per state), its EventMask, whether it needs repainting, and the texture its backend paints it into.

§Examples

use pushrod::geometry::{point, size};
use pushrod::widget::WidgetCore;

let core = WidgetCore::new(point(10, 20), size(100, 30));

Implementations§

Source§

impl WidgetCore

Source

pub fn set_event_mask(&mut self, mask: EventMask)

Sets the event mask the Widget reports from Widget::event_mask.

Use it while building a Widget. To change a mask after the Widget is in a window, use WidgetCache::set_event_mask, which also emits the change.

§Arguments
  • mask - The classes of events the Widget wants.
Source

pub fn add_controller(&mut self, controller: impl Controller + 'static)

Adds an input controller, and adds the event classes it needs to the event mask.

The default Widget::handle_event feeds every event to the controllers. Call WidgetCore::set_event_mask before this, not after, or the added classes are replaced.

§Arguments
Source

pub fn new(origin: Point, size: Size) -> Self

Creates the shared state for a new Widget.

The Widget starts visible, invalidated (so it is painted on the first frame), with a transparent white background color. Its ID and parent are assigned later, when it is added to a WidgetCache.

§Arguments
  • origin - The upper left-hand corner of the Widget, relative to its parent.
  • size - The width and height of the Widget in pixels.
§Returns

A new WidgetCore, to be stored in a Widget structure.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.