yuno 0.2.0

Multimedia UI layout and rendering framework powered by Skia.
pub mod sprites;
// drawing.rs

use anyhow::Result;
use skia_safe::{Canvas, Rect};

#[derive(Copy, Clone, Debug, PartialEq)]
pub enum Plan {
    FillNegative, // Whatever, give as much as you like.
    Fit(f32),     // I need this much space.
    FillPositive, // Give me as much space as you can; give me all the space others don't want.
}

pub trait Drawable: HasPlanner {
    fn draw(&self, canvas: &Canvas) -> Result<()>;
    // The control can specify how much space it needs (but the planner may not follow), which is important for planners like Row and Column.
    // Note that this is the control's own declaration;
    // its implementation must not call `get_planned_drawing_area`, because `measure_child` itself may depend on `get_*_plan`.
    // If a control doesn't know its own size, it delegates this decision to its parent layout manager, and `get_*_plan` should return `FillNegative` or `FillPositive`.
    fn get_horizontal_plan(&self) -> Plan;
    fn get_vertical_plan(&self) -> Plan;
    fn replan(&self);
    fn get_planned_drawing_area(&self, canvas: &Canvas) -> Rect {
        if let Some(p) = self.planner().borrow().as_ref() {
            return p.measure_child(self.as_drawable(), canvas);
        }

        Rect {
            left: 0.0,
            top: 0.0,
            right: canvas.image_info().width() as f32,
            bottom: canvas.image_info().height() as f32,
        }
    }
    fn try_to_interactive(&self) -> Option<&dyn Interactive> {
        None
    }
    fn is_enabled(&self) -> bool;
    fn set_enabled(&self, e: bool);
    fn as_drawable(&self) -> &dyn Drawable;
}

use crate::interacting::Interactive;
use crate::layouts::HasPlanner;
#[allow(unused)]
pub use sprites::RoundedRectangle;