[][src]Trait termcandy::Widget

pub trait Widget: Future {
    fn draw<'s, 'm>(&self, surface: &'m mut SurfaceMut<'s>);

    fn map_events<M: Fn(Event) -> Option<Event>>(
        self,
        map: M
    ) -> MapEvents<Self, M>
    where
        Self: Sized,
        M: Fn(Event) -> Option<Event> + Sync + Send
, { ... }
fn resize<M: Fn(u16, u16) -> Rect>(self, map: M) -> Resize<Self, M>
    where
        Self: Sized,
        M: Fn(u16, u16) -> Rect + Sync + Send
, { ... } }

A Widget is a Future that can be drawn.

The easiest way to create widgets is using the #[widget] attribute.

Required methods

fn draw<'s, 'm>(&self, surface: &'m mut SurfaceMut<'s>)

Draw the widget to the given surface.

Loading content...

Provided methods

fn map_events<M: Fn(Event) -> Option<Event>>(self, map: M) -> MapEvents<Self, M> where
    Self: Sized,
    M: Fn(Event) -> Option<Event> + Sync + Send

Filter and map all user input events arriving at the widget.

fn resize<M: Fn(u16, u16) -> Rect>(self, map: M) -> Resize<Self, M> where
    Self: Sized,
    M: Fn(u16, u16) -> Rect + Sync + Send

Resize the widget to the given region calculated from the width and height of the screen.

The widget will draw itself to the region you calculate, the position of mouse-click events will be mapped accordingly, and widget::screen_size() will report the given region when called from inside the widget.

Loading content...

Implementations on Foreign Types

impl<'a, W> Widget for &'a mut W where
    W: Widget
[src]

fn map_events<M: Fn(Event) -> Option<Event>>(self, map: M) -> MapEvents<Self, M> where
    Self: Sized,
    M: Fn(Event) -> Option<Event> + Sync + Send
[src]

fn resize<M: Fn(u16, u16) -> Rect>(self, map: M) -> Resize<Self, M> where
    Self: Sized,
    M: Fn(u16, u16) -> Rect + Sync + Send
[src]

Loading content...

Implementors

Loading content...