fp_tui 0.2.2

A very basic tui library
Documentation
use std::rc::Rc;
use std::cell::RefCell;

use super::{PositioningAlgorithm, DisplayBuffer};
use crate::common::BoundingBox;

/// #### Description
/// Base interface for every element in the tui
/// 
/// Note that most concrete widgets are stored as [Rc]<[RefCell]<dyn [Widget]> 
/// so it can be helpful to have their constructors return such a value
/// 
pub trait Widget {
    /// #### Description
    /// Draws the widget to the display buffer
    /// 
    /// #### Arguments
    /// * `positioning_algorithm`: &[Box]<dyn [PositioningAlgorithm]> - The 
    /// positioning algorithm for the widget
    /// * `display_buffer`: &mut [DisplayBuffer] - The display buffer
    /// 
    fn draw(
        &mut self,
        positioning_algorithm: &Box<dyn PositioningAlgorithm>,
        display_buffer: &mut DisplayBuffer
    );

    /// #### Description
    /// Retrieves the bounding box of the widget
    /// 
    /// #### Returns
    /// [BoundingBox] - The bounding box of the widget
    /// 
    fn get_bounding_box(&self) -> BoundingBox;
}

/// #### Description
/// An interface for widgets that contain other widgets
/// 
pub trait ContainerWidget: Widget {
    /// #### Description
    /// Add a widget to the container
    ///
    /// #### Arguments
    /// * `positioning_algorithm`: &[Box]<dyn [PositioningAlgorithm]> - The 
    /// positioning algorithm for the widget
    /// * `widget`: [Rc]<[RefCell]<dyn [Widget]>> - The widget to add
    /// 
    fn add_child(
        &mut self,
        positioning_algorithm: Box<dyn PositioningAlgorithm>,
        widget: Rc<RefCell<dyn Widget>>
    );
}