use super::{
geometry::{Point, Position},
style::StyleAttr,
};
pub trait Visible {
fn position(&self) -> Position;
fn position_mut(&mut self) -> &mut Position;
fn is_connector(&self) -> bool;
fn transpose(&mut self);
fn resize(&mut self);
}
pub trait Renderable {
fn render(&self, debug: bool, canvas: &mut dyn RenderBackend);
fn get_connector_location(
&self,
from: Point,
force: f64,
port: &Option<String>,
) -> (Point, Point);
fn get_passthrough_path(
&self,
from: Point,
to: Point,
force: f64,
) -> (Point, Point);
}
pub type ClipHandle = usize;
pub trait RenderBackend {
fn draw_rect(
&mut self,
xy: Point,
size: Point,
look: &StyleAttr,
properties: Option<String>,
clip: Option<ClipHandle>,
);
fn draw_line(
&mut self,
start: Point,
stop: Point,
look: &StyleAttr,
properties: Option<String>,
);
fn draw_circle(
&mut self,
xy: Point,
size: Point,
look: &StyleAttr,
properties: Option<String>,
);
fn draw_text(&mut self, xy: Point, text: &str, look: &StyleAttr);
fn draw_arrow(
&mut self,
path: &[(Point, Point)],
dashed: bool,
head: (bool, bool),
look: &StyleAttr,
properties: Option<String>,
text: &str,
);
fn create_clip(
&mut self,
xy: Point,
size: Point,
rounded_px: usize,
) -> ClipHandle;
}