diff options
-rw-r--r-- | core/src/core_shapes.rs | 42 | ||||
-rw-r--r-- | core/src/rendering.rs | 37 | ||||
-rw-r--r-- | core/src/solving.rs | 30 |
3 files changed, 60 insertions, 49 deletions
diff --git a/core/src/core_shapes.rs b/core/src/core_shapes.rs index d8017ab..e6d79c9 100644 --- a/core/src/core_shapes.rs +++ b/core/src/core_shapes.rs | |||
@@ -1,3 +1,7 @@ | |||
1 | use crate::types::{CoreShapeContext, DefinedCoreShapeContext, DefinedPoint2D, Point2D}; | ||
2 | |||
3 | pub use super::text::{DefinedText, Text}; | ||
4 | |||
1 | pub struct CoreDrawable { | 5 | pub struct CoreDrawable { |
2 | pub(crate) shape: CoreShape, | 6 | pub(crate) shape: CoreShape, |
3 | pub(crate) context: CoreShapeContext, | 7 | pub(crate) context: CoreShapeContext, |
@@ -12,7 +16,7 @@ impl CoreDrawable { | |||
12 | pub enum CoreShape { | 16 | pub enum CoreShape { |
13 | Rectangle(Rectangle), | 17 | Rectangle(Rectangle), |
14 | Text(Text), | 18 | Text(Text), |
15 | // StraightPath(StraightPath), | 19 | StraightPath(StraightPath), |
16 | } | 20 | } |
17 | 21 | ||
18 | impl From<Rectangle> for CoreShape { | 22 | impl From<Rectangle> for CoreShape { |
@@ -27,6 +31,12 @@ impl From<Text> for CoreShape { | |||
27 | } | 31 | } |
28 | } | 32 | } |
29 | 33 | ||
34 | impl From<StraightPath> for CoreShape { | ||
35 | fn from(path: StraightPath) -> Self { | ||
36 | CoreShape::StraightPath(path) | ||
37 | } | ||
38 | } | ||
39 | |||
30 | pub struct DefinedCoreDrawable { | 40 | pub struct DefinedCoreDrawable { |
31 | pub(crate) shape: DefinedCoreShape, | 41 | pub(crate) shape: DefinedCoreShape, |
32 | pub(crate) context: DefinedCoreShapeContext, | 42 | pub(crate) context: DefinedCoreShapeContext, |
@@ -35,7 +45,7 @@ pub struct DefinedCoreDrawable { | |||
35 | pub enum DefinedCoreShape { | 45 | pub enum DefinedCoreShape { |
36 | Rectangle(Rectangle), | 46 | Rectangle(Rectangle), |
37 | Text(DefinedText), | 47 | Text(DefinedText), |
38 | // StraightPath(StraightPath), | 48 | StraightPath(DefinedStraightPath), |
39 | } | 49 | } |
40 | 50 | ||
41 | /* | 51 | /* |
@@ -61,7 +71,6 @@ impl<T: CoreShape + Clone + 'static> ComplexShape for T { | |||
61 | } | 71 | } |
62 | */ | 72 | */ |
63 | 73 | ||
64 | // TODO: add default | ||
65 | #[derive(Copy, Clone, Debug, Default)] | 74 | #[derive(Copy, Clone, Debug, Default)] |
66 | pub struct Rectangle {} | 75 | pub struct Rectangle {} |
67 | 76 | ||
@@ -73,10 +82,7 @@ impl CoreShape for Rectangle { | |||
73 | } | 82 | } |
74 | */ | 83 | */ |
75 | 84 | ||
76 | use crate::types::{CoreShapeContext, DefinedCoreShapeContext}; | 85 | // TODO: re-enable this in some way |
77 | |||
78 | pub use super::text::{DefinedText, Text}; | ||
79 | |||
80 | /* | 86 | /* |
81 | impl CoreShape for Text { | 87 | impl CoreShape for Text { |
82 | fn constrain( | 88 | fn constrain( |
@@ -106,22 +112,22 @@ impl CoreShape for Text { | |||
106 | } | 112 | } |
107 | */ | 113 | */ |
108 | 114 | ||
109 | // #[derive(Clone, Debug, Default)] | 115 | #[derive(Clone, Debug, Default)] |
110 | // pub struct StraightPath { | 116 | pub struct StraightPath { |
111 | // pub(crate) points: Vec<Point2D>, | 117 | pub(crate) points: Vec<Point2D>, |
112 | // } | 118 | } |
113 | // | 119 | |
114 | // impl StraightPath { | 120 | impl StraightPath { |
115 | // pub fn new(points: Vec<Point2D>) -> Self { | 121 | pub fn new(points: Vec<Point2D>) -> Self { |
116 | // Self { points } | 122 | Self { points } |
117 | // } | 123 | } |
118 | // } | 124 | } |
119 | 125 | ||
120 | /* | ||
121 | pub struct DefinedStraightPath { | 126 | pub struct DefinedStraightPath { |
122 | pub(crate) points: Vec<DefinedPoint2D>, | 127 | pub(crate) points: Vec<DefinedPoint2D>, |
123 | } | 128 | } |
124 | 129 | ||
130 | /* | ||
125 | impl CoreShape for StraightPath { | 131 | impl CoreShape for StraightPath { |
126 | fn to_render(&self, model: &dyn SolverModel) -> Option<Box<dyn Render>> { | 132 | fn to_render(&self, model: &dyn SolverModel) -> Option<Box<dyn Render>> { |
127 | self.fixate(model) | 133 | self.fixate(model) |
diff --git a/core/src/rendering.rs b/core/src/rendering.rs index 9c9f9e4..3f2303b 100644 --- a/core/src/rendering.rs +++ b/core/src/rendering.rs | |||
@@ -28,6 +28,7 @@ impl Render for DefinedCoreShape { | |||
28 | match self { | 28 | match self { |
29 | Self::Rectangle(r) => r.render(context, renderer), | 29 | Self::Rectangle(r) => r.render(context, renderer), |
30 | Self::Text(t) => t.render(context, renderer), | 30 | Self::Text(t) => t.render(context, renderer), |
31 | Self::StraightPath(p) => p.render(context, renderer), | ||
31 | } | 32 | } |
32 | } | 33 | } |
33 | } | 34 | } |
@@ -75,21 +76,21 @@ impl Render for DefinedText { | |||
75 | } | 76 | } |
76 | } | 77 | } |
77 | 78 | ||
78 | // impl Render for DefinedStraightPath { | 79 | impl Render for DefinedStraightPath { |
79 | // fn render(&self, context: DefinedShapeContext, renderer: &mut dyn Renderer) { | 80 | fn render(&self, context: DefinedCoreShapeContext, renderer: &mut dyn Renderer) { |
80 | // let mut iter = self.points.iter(); | 81 | let mut iter = self.points.iter(); |
81 | // | 82 | |
82 | // let first_point = match iter.next() { | 83 | let first_point = match iter.next() { |
83 | // Some(point) => point, | 84 | Some(point) => point, |
84 | // None => return, | 85 | None => return, |
85 | // }; | 86 | }; |
86 | // | 87 | |
87 | // renderer.move_to(first_point.x, first_point.y); | 88 | renderer.move_to(first_point.x, first_point.y); |
88 | // | 89 | |
89 | // for point in iter { | 90 | for point in iter { |
90 | // renderer.line_to(point.x, point.y); | 91 | renderer.line_to(point.x, point.y); |
91 | // } | 92 | } |
92 | // | 93 | |
93 | // draw(&context.fill, &context.stroke, renderer); | 94 | draw(&context.fill, &context.stroke, renderer); |
94 | // } | 95 | } |
95 | // } | 96 | } |
diff --git a/core/src/solving.rs b/core/src/solving.rs index 261b4d4..bf5fe95 100644 --- a/core/src/solving.rs +++ b/core/src/solving.rs | |||
@@ -1,4 +1,7 @@ | |||
1 | use crate::core_shapes::{CoreDrawable, CoreShape, DefinedCoreDrawable, DefinedCoreShape}; | 1 | use crate::core_shapes::{ |
2 | CoreDrawable, CoreShape, DefinedCoreDrawable, DefinedCoreShape, DefinedStraightPath, | ||
3 | StraightPath, | ||
4 | }; | ||
2 | 5 | ||
3 | use super::styles::*; | 6 | use super::styles::*; |
4 | use super::text::*; | 7 | use super::text::*; |
@@ -155,6 +158,7 @@ impl Constrainable for CoreShape { | |||
155 | match self { | 158 | match self { |
156 | CoreShape::Rectangle(r) => Some(DefinedCoreShape::Rectangle(*r)), | 159 | CoreShape::Rectangle(r) => Some(DefinedCoreShape::Rectangle(*r)), |
157 | CoreShape::Text(t) => t.fixate(model).map(DefinedCoreShape::Text), | 160 | CoreShape::Text(t) => t.fixate(model).map(DefinedCoreShape::Text), |
161 | CoreShape::StraightPath(p) => p.fixate(model).map(DefinedCoreShape::StraightPath), | ||
158 | } | 162 | } |
159 | } | 163 | } |
160 | } | 164 | } |
@@ -288,15 +292,15 @@ impl Constrainable for Text { | |||
288 | } | 292 | } |
289 | } | 293 | } |
290 | 294 | ||
291 | // impl Constrainable for StraightPath { | 295 | impl Constrainable for StraightPath { |
292 | // type Fixated = DefinedStraightPath; | 296 | type Fixated = DefinedStraightPath; |
293 | // | 297 | |
294 | // fn fixate(&self, model: &dyn SolverModel) -> Option<Self::Fixated> { | 298 | fn fixate(&self, model: &dyn SolverModel) -> Option<Self::Fixated> { |
295 | // let points: Option<_> = self | 299 | let points: Option<_> = self |
296 | // .points | 300 | .points |
297 | // .iter() | 301 | .iter() |
298 | // .map(|point| point.fixate(model)) | 302 | .map(|point| point.fixate(model)) |
299 | // .collect(); | 303 | .collect(); |
300 | // Some(DefinedStraightPath { points: points? }) | 304 | Some(DefinedStraightPath { points: points? }) |
301 | // } | 305 | } |
302 | // } | 306 | } |