Skip to content

Commit 8d1680f

Browse files
Ralithcmyr
authored andcommitted
Implement Data for some primitive kurbo types
Simplifies e.g. tracking cursor position
1 parent 77ce415 commit 8d1680f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

druid/src/data.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use std::rc::Rc;
1818
use std::sync::Arc;
1919

20+
use crate::kurbo;
21+
2022
pub use druid_derive::Data;
2123

2224
/// A trait used to represent value types.
@@ -232,3 +234,21 @@ impl<T0: Data, T1: Data, T2: Data, T3: Data, T4: Data, T5: Data> Data for (T0, T
232234
&& self.5.same(&other.5)
233235
}
234236
}
237+
238+
impl Data for kurbo::Point {
239+
fn same(&self, other: &Self) -> bool {
240+
self.x.same(&other.x) && self.y.same(&other.y)
241+
}
242+
}
243+
244+
impl Data for kurbo::Vec2 {
245+
fn same(&self, other: &Self) -> bool {
246+
self.x.same(&other.x) && self.y.same(&other.y)
247+
}
248+
}
249+
250+
impl Data for kurbo::Size {
251+
fn same(&self, other: &Self) -> bool {
252+
self.width.same(&other.width) && self.height.same(&other.height)
253+
}
254+
}

0 commit comments

Comments
 (0)