tuigui 0.23.0

An easy-to-use, highly extensible, and speedy TUI library.
Documentation
use crate::preludes::widget_creation::*;

/// Useful for when you need many different kinds of widgets
/// in the same array or vector or something
pub struct WidgetDyn {
    pub widget: Box<dyn Widget>,
    widget_data: WidgetData,
}

impl WidgetDyn {
    pub fn new(widget: Box<dyn Widget>) -> Self {
        Self {
            widget,
            widget_data: WidgetData::new(),
        }
    }
}

impl Widget for WidgetDyn {
    fn draw(&mut self, canvas: &mut Canvas, state_frame: Option<&EventStateFrame>) {
        self.widget.draw(canvas, state_frame);
    }

    fn widget_info(&self) -> WidgetInfo {
        return self.widget.widget_info();
    }

    fn widget_data(&mut self) -> &mut WidgetData {
        return &mut self.widget_data;
    }
}