View

Trait View 

Source
pub trait View: Sealed + 'static {
    // Required methods
    fn size(&self, proposed: Size) -> Size;
    fn render(
        &self,
        id: &mut ViewId,
        context: Context,
        state: &mut AppState,
        buffer: &mut Buffer,
    );
}
Expand description

§Syntax Examples

Example of a VStack with nested HStacks

use altar::*;
let view = vstack((
    hstack((text("1."), text("Eggs"))),
    hstack((text("2."), text("Powders"))),
    hstack((text("3."), text("Milk"))),
)).border();

let expected = vec![
    "┌────────────┐",
    "│ 1. Eggs    │",
    "│ 2. Powders │",
    "│ 3. Milk    │",
    "└────────────┘",
].join("\n");

assert_eq!(expected, view.as_plain_str());

Required Methods§

Source

fn size(&self, proposed: Size) -> Size

Source

fn render( &self, id: &mut ViewId, context: Context, state: &mut AppState, buffer: &mut Buffer, )

Implementations on Foreign Types§

Source§

impl View for &'static str

Source§

fn size(&self, proposed: Size) -> Size

Source§

fn render( &self, id: &mut ViewId, context: Context, _state: &mut AppState, buffer: &mut Buffer, )

Source§

impl View for String

Source§

fn size(&self, proposed: Size) -> Size

Source§

fn render( &self, id: &mut ViewId, context: Context, _state: &mut AppState, buffer: &mut Buffer, )

Source§

impl<V: View> View for Option<V>

Source§

fn size(&self, proposed: Size) -> Size

Source§

fn render( &self, id: &mut ViewId, context: Context, state: &mut AppState, buffer: &mut Buffer, )

Implementors§

Source§

impl View for AnyView

Source§

impl View for FillColor

Source§

impl View for EmptyView

Source§

impl View for RenderCounter

Source§

impl View for Text

Source§

impl<F, V: View> View for GeometryReader<F>
where F: Fn(Size) -> V + 'static,

Source§

impl<T: View, F: View> View for IfThenView<T, F>

Source§

impl<V: View> View for Border<V>

Source§

impl<V: View> View for ContextModifier<V>

Source§

impl<V: View> View for Frame<V>

Source§

impl<V: View> View for IdentifiedView<V>

Source§

impl<V: View> View for Padding<V>

Source§

impl<V: View, BG: View> View for Background<V, BG>

Source§

impl<VT: ViewTuple + 'static> View for HStack<VT>

Source§

impl<VT: ViewTuple + 'static> View for VStack<VT>

Source§

impl<VT: ViewTuple + 'static> View for ZStack<VT>