diff options
author | Minijackson <minijackson@riseup.net> | 2023-01-04 09:35:17 +0100 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2023-01-04 09:35:17 +0100 |
commit | c407a7772e5354bbd13447f7e217e526d662d6cb (patch) | |
tree | 4dc0f8f7896c4a1ced8fbdd4a003f1153fed9e2b /core/src/core_shapes.rs | |
parent | 119e437cb0ef543cf4652bbb7700870b49ac9227 (diff) | |
download | diaphragm-c407a7772e5354bbd13447f7e217e526d662d6cb.tar.gz diaphragm-c407a7772e5354bbd13447f7e217e526d662d6cb.zip |
core: re-add StraightPath core shape
Diffstat (limited to 'core/src/core_shapes.rs')
-rw-r--r-- | core/src/core_shapes.rs | 42 |
1 files changed, 24 insertions, 18 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) |