Trait widgetry::widgets::WidgetImpl[][src]

pub trait WidgetImpl: Downcast {
    fn get_dims(&self) -> ScreenDims;
fn set_pos(&mut self, top_left: ScreenPt);
fn event(&mut self, ctx: &mut EventCtx<'_>, output: &mut WidgetOutput);
fn draw(&self, g: &mut GfxCtx<'_>); fn can_restore(&self) -> bool { ... }
fn restore(&mut self, _: &mut EventCtx<'_>, _prev: &Box<dyn WidgetImpl>) { ... } }

Create a new widget by implementing this trait. You can instantiate your widget by calling Widget::new(Box::new(instance of your new widget)), which gives you the usual style options.

Required methods

fn get_dims(&self) -> ScreenDims[src]

What width and height does the widget occupy? If this changes, be sure to set redo_layout to true in event.

fn set_pos(&mut self, top_left: ScreenPt)[src]

Your widget’s top left corner should be here. Handle mouse events and draw appropriately.

fn event(&mut self, ctx: &mut EventCtx<'_>, output: &mut WidgetOutput)[src]

Your chance to react to an event. Any side effects outside of this widget are communicated through the output.

fn draw(&self, g: &mut GfxCtx<'_>)[src]

Draw the widget. Be sure to draw relative to the top-left specified by set_pos.

Loading content...

Provided methods

fn can_restore(&self) -> bool[src]

If a new Panel is being created to replace an older one, all widgets have the chance to preserve state from the previous version.

fn restore(&mut self, _: &mut EventCtx<'_>, _prev: &Box<dyn WidgetImpl>)[src]

Restore state from the previous version of this widget, with the same ID. Implementors must downcast.

Loading content...

Implementations

impl dyn WidgetImpl[src]

pub fn is<__T: WidgetImpl>(&self) -> bool[src]

Returns true if the trait object wraps an object of type __T.

pub fn downcast<__T: WidgetImpl>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>[src]

Returns a boxed object from a boxed trait object if the underlying object is of type __T. Returns the original boxed trait if it isn’t.

pub fn downcast_rc<__T: WidgetImpl>(self: Rc<Self>) -> Result<Rc<__T>, Rc<Self>>[src]

Returns an Rc-ed object from an Rc-ed trait object if the underlying object is of type __T. Returns the original Rc-ed trait if it isn’t.

pub fn downcast_ref<__T: WidgetImpl>(&self) -> Option<&__T>[src]

Returns a reference to the object within the trait object if it is of type __T, or None if it isn’t.

pub fn downcast_mut<__T: WidgetImpl>(&mut self) -> Option<&mut __T>[src]

Returns a mutable reference to the object within the trait object if it is of type __T, or None if it isn’t.

Implementors

impl WidgetImpl for Button[src]

impl WidgetImpl for MultiButton[src]

impl WidgetImpl for CompareTimes[src]

impl WidgetImpl for Container[src]

impl WidgetImpl for Nothing[src]

impl WidgetImpl for FanChart[src]

impl WidgetImpl for Filler[src]

impl WidgetImpl for DeferDraw[src]

impl WidgetImpl for DrawWithTooltips[src]

impl WidgetImpl for JustDraw[src]

impl WidgetImpl for ScatterPlot[src]

impl WidgetImpl for Slider[src]

impl WidgetImpl for TextBox[src]

impl WidgetImpl for Toggle[src]

impl<T: 'static + SpinnerValue> WidgetImpl for Spinner<T>[src]

impl<T: 'static + Clone + PartialEq> WidgetImpl for PersistentSplit<T>[src]

impl<T: 'static + Clone> WidgetImpl for Autocomplete<T>[src]

impl<T: 'static + Clone> WidgetImpl for Dropdown<T>[src]

impl<T: 'static> WidgetImpl for Menu<T>[src]

impl<T: 'static> WidgetImpl for Stash<T>[src]

impl<X: Axis<X>, Y: Axis<Y>> WidgetImpl for LinePlot<X, Y>[src]

Loading content...