blob: 323361adc234c52656445d87202550f233e3eee6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
//! 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::transform::Transform;
use crate::transformable::NonRigidTransformable;
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_non_rigid(&self) -> Option<&dyn NonRigidTransformable> {
None
}
fn as_non_rigid_mut(&mut self) -> Option<&mut dyn NonRigidTransformable> {
None
}
}
|