Trait glyph_ui::View[][src]

pub trait View<T, M> {
    fn draw(&self, printer: &Printer<'_>, focused: bool);
fn width(&self) -> Size2D<u16, Cell>;
fn height(&self) -> Size2D<u16, Cell>;
fn layout(&self, constraint: Size2D<u16, Cell>) -> Size2D<u16, Cell>;
fn event(
        &mut self,
        event: &Event<T>,
        focused: bool
    ) -> Box<dyn Iterator<Item = M>>;
fn interactive(&self) -> bool; }

A UI element

Required methods

fn draw(&self, printer: &Printer<'_>, focused: bool)[src]

Draws this element

fn width(&self) -> Size2D<u16, Cell>[src]

Calculate the view's content-based size with minimum width

This is not necessarily the view's absolute minimum width; in most cases that would end up being zero, which isn't useful. Instead, the value computed is a sensible minimum that, if draw were called with this function's return value as the Printer's size, would produce a visually-acceptable result.

Examples

The text view finds the visual length of the visually-longest sequence of non-whitespace characters (or in other words, longest word including punctuation) and reports that length as its width. The height value is computed by textwraping with that width and reporting the amount of lines it would take to display the text.

fn height(&self) -> Size2D<u16, Cell>[src]

Calculate the view's content-based size with minimum height

This is not necessarily the view's absolute minimum height; in most cases that would end up being zero, which isn't useful. Instead, the value computed is a sensible minimum that, if draw were called with this function's return value as the Printer's size, would produce a visually-acceptable result.

Examples

The text view reports its height as the number of lines in its content and its width as the visual length of the visually longest line.

fn layout(&self, constraint: Size2D<u16, Cell>) -> Size2D<u16, Cell>[src]

Given a constraint, calculate the size of this view

fn event(
    &mut self,
    event: &Event<T>,
    focused: bool
) -> Box<dyn Iterator<Item = M>>
[src]

Process an event and optionally produce messages

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

Whether this element can be interacted with by the user

Returning false from this method does not opt the implementor out of receiving events, only from acquiring focus. In other words, the focused argument to event() will be false after returning false from this function. Also, returning true doesn't imply that focused will be true, only that it may eventually be true when the user focuses this element.

Loading content...

Implementors

impl<T, M> View<T, M> for glyph_ui::view::element::View<'_, T, M>[src]

impl<T, M> View<T, M> for glyph_ui::view::empty::View where
    M: 'static, 
[src]

impl<T, M> View<T, M> for glyph_ui::view::text::View<'_> where
    M: 'static, 
[src]

impl<T, M, D> View<T, M> for glyph_ui::view::linear::View<'_, T, M, D> where
    Self: Flex<T, M>,
    M: 'static, 
[src]

impl<T, M, F> View<T, M> for glyph_ui::view::input_line::View<'_, F> where
    F: Fn(String) -> M,
    M: 'static, 
[src]

impl<T, M, O, V, F> View<T, M> for glyph_ui::view::map::View<V, O, F> where
    V: ViewTrait<T, O>,
    F: Fn(O) -> M,
    F: Clone + 'static,
    M: 'static,
    O: 'static, 
[src]

impl<T, M, V> View<T, M> for glyph_ui::view::align::View<V> where
    V: ViewTrait<T, M>, 
[src]

impl<T, M, V> View<T, M> for glyph_ui::view::border::View<V> where
    V: ViewTrait<T, M>, 
[src]

impl<T, M, V> View<T, M> for glyph_ui::view::pad::View<V> where
    V: ViewTrait<T, M>, 
[src]

impl<T, V, F, M> View<T, M> for glyph_ui::view::on_event::View<V, F> where
    F: Fn(&Event<T>, bool) -> Box<dyn Iterator<Item = M>>,
    V: ViewTrait<T, M>, 
[src]

Loading content...