[][src]Trait titik::Widget

pub trait Widget<MSG> where
    Self: Debug
{ fn style(&self) -> Style;
fn layout(&self) -> Option<&Layout>;
fn set_layout(&mut self, layout: Layout);
fn draw(&self, but: &mut Buffer) -> Vec<Cmd>;
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
fn set_size(&mut self, width: Option<f32>, height: Option<f32>);
fn set_id(&mut self, id: &str);
fn get_id(&self) -> &Option<String>; fn get_offset(&self) -> (f32, f32) { ... }
fn add_child(&mut self, _child: Box<dyn Widget<MSG>>) -> bool { ... }
fn children(&self) -> Option<&[Box<dyn Widget<MSG>>]> { ... }
fn children_mut(&mut self) -> Option<&mut [Box<dyn Widget<MSG>>]> { ... }
fn child_mut(&mut self, _index: usize) -> Option<&mut Box<dyn Widget<MSG>>> { ... }
fn style_node(&self, stretch: &mut Stretch) -> Option<Node> { ... }
fn set_focused(&mut self, _focused: bool) { ... }
fn as_mut(&mut self) -> Option<&mut Self>
    where
        Self: Sized + 'static
, { ... }
fn process_event(&mut self, _event: Event) -> Vec<MSG> { ... }
fn take_child(&mut self, _index: usize) -> Option<Box<dyn Widget<MSG>>> { ... } }

All widgets must implement the Widget trait

Required methods

fn style(&self) -> Style

return the style of this widget

fn layout(&self) -> Option<&Layout>

return the layout of thiswidget

fn set_layout(&mut self, layout: Layout)

fn draw(&self, but: &mut Buffer) -> Vec<Cmd>

this is called in the render loop in the renderer where the widget writes into the buffer. The result will then be written into the stdout terminal.

fn as_any(&self) -> &dyn Any

get an Any reference

fn as_any_mut(&mut self) -> &mut dyn Any

get an Any mutable reference for casting purposed

fn set_size(&mut self, width: Option<f32>, height: Option<f32>)

set the size of the widget

fn set_id(&mut self, id: &str)

set the id of this widget

fn get_id(&self) -> &Option<String>

get the id of this widget

Loading content...

Provided methods

fn get_offset(&self) -> (f32, f32)

return the offset of the parent, this before any of it's children to be drawn

fn add_child(&mut self, _child: Box<dyn Widget<MSG>>) -> bool

add a child to this widget returns true if it can accept a child, false otherwise

fn children(&self) -> Option<&[Box<dyn Widget<MSG>>]>

get a referemce tp the children of this widget

fn children_mut(&mut self) -> Option<&mut [Box<dyn Widget<MSG>>]>

get a mutable reference to the children of this widget

fn child_mut(&mut self, _index: usize) -> Option<&mut Box<dyn Widget<MSG>>>

return a mutable reference to a child at index location

fn style_node(&self, stretch: &mut Stretch) -> Option<Node>

build a node with styles from this widget and its children The Layout tree is then calculated see layout::compute_layout

fn set_focused(&mut self, _focused: bool)

set the widget as focused

fn as_mut(&mut self) -> Option<&mut Self> where
    Self: Sized + 'static, 

get a mutable reference of this widget

fn process_event(&mut self, _event: Event) -> Vec<MSG>

this process the event and all callbacks attached to the widgets will be dispatched.

fn take_child(&mut self, _index: usize) -> Option<Box<dyn Widget<MSG>>>

take the children at this index location

Loading content...

Implementors

impl<MSG> Widget<MSG> for Button<MSG> where
    MSG: 'static, 
[src]

fn draw(&self, buf: &mut Buffer) -> Vec<Cmd>[src]

draw this button to the buffer, with the given computed layout

impl<MSG> Widget<MSG> for FlexBox<MSG> where
    MSG: Debug + 'static, 
[src]

impl<MSG> Widget<MSG> for GroupBox<MSG> where
    MSG: Debug + 'static, 
[src]

impl<MSG> Widget<MSG> for Image<MSG> where
    MSG: 'static, 
[src]

fn draw(&self, buf: &mut Buffer) -> Vec<Cmd>[src]

draw this button to the buffer, with the given computed layout

impl<MSG> Widget<MSG> for Link[src]

fn draw(&self, buf: &mut Buffer) -> Vec<Cmd>[src]

draw this button to the buffer, with the given computed layout

impl<MSG> Widget<MSG> for ListBox<MSG> where
    MSG: Debug + 'static, 
[src]

impl<MSG> Widget<MSG> for Slider<MSG> where
    MSG: Debug + 'static, 
[src]

impl<MSG> Widget<MSG> for TabBox<MSG> where
    MSG: Debug + 'static, 
[src]

fn get_offset(&self) -> (f32, f32)[src]

the tab box has an offset of 2 from the top before drawing the child components

fn add_child(&mut self, child: Box<dyn Widget<MSG>>) -> bool[src]

add a child widget to the current active tab

impl<MSG> Widget<MSG> for TextArea<MSG> where
    MSG: Debug + 'static, 
[src]

fn draw(&self, buf: &mut Buffer) -> Vec<Cmd>[src]

draw this button to the buffer, with the given computed layout

impl<MSG> Widget<MSG> for TextInput[src]

fn draw(&self, buf: &mut Buffer) -> Vec<Cmd>[src]

draw this button to the buffer, with the given computed layout

impl<MSG> Widget<MSG> for TextLabel[src]

fn draw(&self, buf: &mut Buffer) -> Vec<Cmd>[src]

draw this button to the buffer, with the given computed layout

impl<MSG: 'static> Widget<MSG> for Checkbox<MSG>[src]

fn draw(&self, buf: &mut Buffer) -> Vec<Cmd>[src]

draw this button to the buffer, with the given computed layout

impl<MSG: 'static> Widget<MSG> for Radio<MSG>[src]

fn draw(&self, buf: &mut Buffer) -> Vec<Cmd>[src]

draw this button to the buffer, with the given computed layout

Loading content...