use super::{AxisInfo, RulesSetter, RulesSolver, SizeRules};
use crate::geom::Rect;
use kas::AlignHints;
pub struct SingleSolver {
axis: AxisInfo,
rules: SizeRules,
}
impl SingleSolver {
pub fn new(axis: AxisInfo, _dim: (), _storage: &mut ()) -> Self {
SingleSolver {
axis,
rules: SizeRules::EMPTY,
}
}
}
impl RulesSolver for SingleSolver {
type Storage = ();
type ChildInfo = ();
fn for_child<CR: FnOnce(AxisInfo) -> SizeRules>(
&mut self,
_storage: &mut Self::Storage,
_child_info: Self::ChildInfo,
child_rules: CR,
) {
self.rules = child_rules(self.axis);
}
fn finish(self, _storage: &mut Self::Storage) -> SizeRules {
self.rules
}
}
pub struct SingleSetter {
rect: Rect,
}
impl SingleSetter {
pub fn new(rect: Rect, _dim: (), _align: AlignHints, _storage: &mut ()) -> Self {
SingleSetter { rect }
}
}
impl RulesSetter for SingleSetter {
type Storage = ();
type ChildInfo = ();
fn child_rect(&mut self, _: &mut Self::Storage, _: Self::ChildInfo) -> Rect {
self.rect
}
fn maximal_rect_of(&mut self, _: &mut Self::Storage, _: Self::ChildInfo) -> Rect {
self.rect
}
}