diff options
| author | Arne Dußin | 2020-12-21 21:12:01 +0100 |
|---|---|---|
| committer | GitHub | 2020-12-21 21:12:01 +0100 |
| commit | c435f278eddcada279fdc424120e4a1448843c20 (patch) | |
| tree | be9a5601e99608966d4ccd146c3bfb3a70c7fc02 /src/map/mappable.rs | |
| parent | 3bc690803fb59493ea8180fd630d65b3e26642d0 (diff) | |
| parent | 82d11b7d3e15d8175accf7579db1fbe528fc6583 (diff) | |
| download | graf_karto-c435f278eddcada279fdc424120e4a1448843c20.tar.gz graf_karto-c435f278eddcada279fdc424120e4a1448843c20.zip | |
Merge pull request #24 from LordSentox/refactor
Refactor to make interaction between tools easier
Diffstat (limited to 'src/map/mappable.rs')
| -rw-r--r-- | src/map/mappable.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/map/mappable.rs b/src/map/mappable.rs new file mode 100644 index 0000000..b348c4b --- /dev/null +++ b/src/map/mappable.rs @@ -0,0 +1,27 @@ +//! Something that's mappable can be placed on the map and drawn at a specific position. It has a +//! dimension on the map and may be scaleable + +use crate::math::Rect; +use crate::scaleable::Scaleable; +use crate::transform::Transform; +use raylib::drawing::RaylibDrawHandle; + +pub trait Mappable { + /// Draw this to `rld` with the transform. An item that cannot be drawn is not mappable, so + /// this must always be implemented. + fn draw(&self, rld: &mut RaylibDrawHandle, transform: &Transform); + + /// Set the selection status of this item. If it is selected, actions that concern all selected + /// items will be applied to this item as well. + fn set_selected(&mut self, selected: bool); + + /// Get if this item is currently selected. + fn selected(&self) -> bool; + + /// Get the rectangle that contains the mappable object in its entirety without excess. + fn bounding_rect(&self) -> Rect<f64>; + + fn as_scaleable(&self) -> Option<&dyn Scaleable> { + None + } +} |
