summaryrefslogtreecommitdiffstats
path: root/core/src/core_shapes.rs
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2023-01-04 09:35:17 +0100
committerMinijackson <minijackson@riseup.net>2023-01-04 09:35:17 +0100
commitc407a7772e5354bbd13447f7e217e526d662d6cb (patch)
tree4dc0f8f7896c4a1ced8fbdd4a003f1153fed9e2b /core/src/core_shapes.rs
parent119e437cb0ef543cf4652bbb7700870b49ac9227 (diff)
downloaddiaphragm-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.rs42
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 @@
1use crate::types::{CoreShapeContext, DefinedCoreShapeContext, DefinedPoint2D, Point2D};
2
3pub use super::text::{DefinedText, Text};
4
1pub struct CoreDrawable { 5pub 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 {
12pub enum CoreShape { 16pub enum CoreShape {
13 Rectangle(Rectangle), 17 Rectangle(Rectangle),
14 Text(Text), 18 Text(Text),
15 // StraightPath(StraightPath), 19 StraightPath(StraightPath),
16} 20}
17 21
18impl From<Rectangle> for CoreShape { 22impl From<Rectangle> for CoreShape {
@@ -27,6 +31,12 @@ impl From<Text> for CoreShape {
27 } 31 }
28} 32}
29 33
34impl From<StraightPath> for CoreShape {
35 fn from(path: StraightPath) -> Self {
36 CoreShape::StraightPath(path)
37 }
38}
39
30pub struct DefinedCoreDrawable { 40pub 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 {
35pub enum DefinedCoreShape { 45pub 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)]
66pub struct Rectangle {} 75pub struct Rectangle {}
67 76
@@ -73,10 +82,7 @@ impl CoreShape for Rectangle {
73} 82}
74*/ 83*/
75 84
76use crate::types::{CoreShapeContext, DefinedCoreShapeContext}; 85// TODO: re-enable this in some way
77
78pub use super::text::{DefinedText, Text};
79
80/* 86/*
81impl CoreShape for Text { 87impl 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 { 116pub struct StraightPath {
111// pub(crate) points: Vec<Point2D>, 117 pub(crate) points: Vec<Point2D>,
112// } 118}
113// 119
114// impl StraightPath { 120impl 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/*
121pub struct DefinedStraightPath { 126pub struct DefinedStraightPath {
122 pub(crate) points: Vec<DefinedPoint2D>, 127 pub(crate) points: Vec<DefinedPoint2D>,
123} 128}
124 129
130/*
125impl CoreShape for StraightPath { 131impl 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)