Trait widgetry::SimpleState[][src]

pub trait SimpleState<A> {
    fn on_click(
        &mut self,
        ctx: &mut EventCtx<'_>,
        app: &mut A,
        action: &str,
        panel: &Panel
    ) -> Transition<A>; fn panel_changed(
        &mut self,
        _: &mut EventCtx<'_>,
        _: &mut A,
        _: &mut Panel
    ) -> Option<Transition<A>> { ... }
fn on_mouseover(&mut self, _: &mut EventCtx<'_>, _: &mut A) { ... }
fn other_event(&mut self, _: &mut EventCtx<'_>, _: &mut A) -> Transition<A> { ... }
fn draw(&self, _: &mut GfxCtx<'_>, _: &A) { ... }
fn draw_baselayer(&self) -> DrawBaselayer { ... } }

Many states fit a pattern of managing a single panel, handling mouseover events, and other interactions on the map. Implementing this instead of State reduces some boilerplate.

Required methods

fn on_click(
    &mut self,
    ctx: &mut EventCtx<'_>,
    app: &mut A,
    action: &str,
    panel: &Panel
) -> Transition<A>
[src]

Called when something on the panel has been clicked. Since the action is just a string, the fallback case can just use unreachable!().

Loading content...

Provided methods

fn panel_changed(
    &mut self,
    _: &mut EventCtx<'_>,
    _: &mut A,
    _: &mut Panel
) -> Option<Transition<A>>
[src]

Called when something on the panel has changed. If a transition is returned, stop handling the event and immediately apply the transition.

fn on_mouseover(&mut self, _: &mut EventCtx<'_>, _: &mut A)[src]

Called when the mouse has moved.

fn other_event(&mut self, _: &mut EventCtx<'_>, _: &mut A) -> Transition<A>[src]

If a panel on_click event didn’t occur and panel_changed didn’t return transition, then call this to handle all other events.

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

fn draw_baselayer(&self) -> DrawBaselayer[src]

Loading content...

Implementations

impl<A: 'static> dyn SimpleState<A>[src]

pub fn new_state(
    panel: Panel,
    inner: Box<dyn SimpleState<A>>
) -> Box<dyn State<A>>
[src]

Implementors

Loading content...