use crate::objects::SlideObject;
use crate::types::{Coord, PositionProps};
#[derive(Debug, Clone)]
pub struct GroupObject {
pub object_name: String,
pub position: PositionProps,
pub child_offset: (i64, i64),
pub child_extent: (i64, i64),
pub children: Vec<SlideObject>,
}
#[derive(Debug, Clone)]
pub struct GroupOptions {
pub position: PositionProps,
pub child_offset: (i64, i64),
pub child_extent: Option<(i64, i64)>,
}
impl Default for GroupOptions {
fn default() -> Self {
GroupOptions {
position: PositionProps::default(),
child_offset: (0, 0),
child_extent: None,
}
}
}
pub struct GroupOptionsBuilder {
opts: GroupOptions,
}
impl GroupOptionsBuilder {
pub fn new() -> Self {
GroupOptionsBuilder { opts: GroupOptions::default() }
}
pub fn x(mut self, v: f64) -> Self { self.opts.position.x = Some(Coord::Inches(v)); self }
pub fn y(mut self, v: f64) -> Self { self.opts.position.y = Some(Coord::Inches(v)); self }
pub fn w(mut self, v: f64) -> Self { self.opts.position.w = Some(Coord::Inches(v)); self }
pub fn h(mut self, v: f64) -> Self { self.opts.position.h = Some(Coord::Inches(v)); self }
pub fn pos(self, x: f64, y: f64) -> Self { self.x(x).y(y) }
pub fn size(self, w: f64, h: f64) -> Self { self.w(w).h(h) }
pub fn rect(self, r: crate::layout::CellRect) -> Self {
self.pos(r.x, r.y).size(r.w, r.h)
}
pub fn bounds(self, x: f64, y: f64, w: f64, h: f64) -> Self {
self.pos(x, y).size(w, h)
}
pub fn child_offset(mut self, x: i64, y: i64) -> Self {
self.opts.child_offset = (x, y);
self
}
pub fn child_extent(mut self, cx: i64, cy: i64) -> Self {
self.opts.child_extent = Some((cx, cy));
self
}
pub fn build(self) -> GroupOptions {
self.opts
}
}
impl Default for GroupOptionsBuilder {
fn default() -> Self {
Self::new()
}
}