diff options
Diffstat (limited to 'core/src/solving.rs')
-rw-r--r-- | core/src/solving.rs | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/core/src/solving.rs b/core/src/solving.rs index 4760611..261b4d4 100644 --- a/core/src/solving.rs +++ b/core/src/solving.rs | |||
@@ -1,4 +1,5 @@ | |||
1 | use super::core_shapes::*; | 1 | use crate::core_shapes::{CoreDrawable, CoreShape, DefinedCoreDrawable, DefinedCoreShape}; |
2 | |||
2 | use super::styles::*; | 3 | use super::styles::*; |
3 | use super::text::*; | 4 | use super::text::*; |
4 | use super::types::{Bool, Float}; | 5 | use super::types::{Bool, Float}; |
@@ -147,6 +148,17 @@ pub trait Constrainable { | |||
147 | fn fixate(&self, model: &dyn SolverModel) -> Option<Self::Fixated>; | 148 | fn fixate(&self, model: &dyn SolverModel) -> Option<Self::Fixated>; |
148 | } | 149 | } |
149 | 150 | ||
151 | impl Constrainable for CoreShape { | ||
152 | type Fixated = DefinedCoreShape; | ||
153 | |||
154 | fn fixate(&self, model: &dyn SolverModel) -> Option<Self::Fixated> { | ||
155 | match self { | ||
156 | CoreShape::Rectangle(r) => Some(DefinedCoreShape::Rectangle(*r)), | ||
157 | CoreShape::Text(t) => t.fixate(model).map(DefinedCoreShape::Text), | ||
158 | } | ||
159 | } | ||
160 | } | ||
161 | |||
150 | impl Constrainable for Float { | 162 | impl Constrainable for Float { |
151 | type Fixated = f64; | 163 | type Fixated = f64; |
152 | 164 | ||
@@ -218,11 +230,22 @@ impl Constrainable for DashStyle { | |||
218 | } | 230 | } |
219 | } | 231 | } |
220 | 232 | ||
221 | impl Constrainable for ShapeContext { | 233 | impl Constrainable for CoreDrawable { |
222 | type Fixated = DefinedShapeContext; | 234 | type Fixated = DefinedCoreDrawable; |
235 | |||
236 | fn fixate(&self, model: &dyn SolverModel) -> Option<Self::Fixated> { | ||
237 | Some(DefinedCoreDrawable { | ||
238 | shape: self.shape.fixate(model)?, | ||
239 | context: self.context.fixate(model)?, | ||
240 | }) | ||
241 | } | ||
242 | } | ||
243 | |||
244 | impl Constrainable for CoreShapeContext { | ||
245 | type Fixated = DefinedCoreShapeContext; | ||
223 | 246 | ||
224 | fn fixate(&self, model: &dyn SolverModel) -> Option<Self::Fixated> { | 247 | fn fixate(&self, model: &dyn SolverModel) -> Option<Self::Fixated> { |
225 | Some(DefinedShapeContext { | 248 | Some(DefinedCoreShapeContext { |
226 | bounds: self.bounds.fixate(model)?, | 249 | bounds: self.bounds.fixate(model)?, |
227 | fill: self.fill.clone(), | 250 | fill: self.fill.clone(), |
228 | stroke: self.stroke.fixate(model)?, | 251 | stroke: self.stroke.fixate(model)?, |
@@ -265,15 +288,15 @@ impl Constrainable for Text { | |||
265 | } | 288 | } |
266 | } | 289 | } |
267 | 290 | ||
268 | impl Constrainable for StraightPath { | 291 | // impl Constrainable for StraightPath { |
269 | type Fixated = DefinedStraightPath; | 292 | // type Fixated = DefinedStraightPath; |
270 | 293 | // | |
271 | fn fixate(&self, model: &dyn SolverModel) -> Option<Self::Fixated> { | 294 | // fn fixate(&self, model: &dyn SolverModel) -> Option<Self::Fixated> { |
272 | let points: Option<_> = self | 295 | // let points: Option<_> = self |
273 | .points | 296 | // .points |
274 | .iter() | 297 | // .iter() |
275 | .map(|point| point.fixate(model)) | 298 | // .map(|point| point.fixate(model)) |
276 | .collect(); | 299 | // .collect(); |
277 | Some(DefinedStraightPath { points: points? }) | 300 | // Some(DefinedStraightPath { points: points? }) |
278 | } | 301 | // } |
279 | } | 302 | // } |