diff options
| author | Arne Dußin | 2020-12-16 13:34:56 +0100 |
|---|---|---|
| committer | Arne Dußin | 2020-12-16 13:34:56 +0100 |
| commit | 82d11b7d3e15d8175accf7579db1fbe528fc6583 (patch) | |
| tree | be9a5601e99608966d4ccd146c3bfb3a70c7fc02 /src/map/icon.rs | |
| parent | 9799d3c6a8f0c242668203a1c70d7b6cfed3e855 (diff) | |
| download | graf_karto-82d11b7d3e15d8175accf7579db1fbe528fc6583.tar.gz graf_karto-82d11b7d3e15d8175accf7579db1fbe528fc6583.zip | |
Add constant for default colours and selection tool
Diffstat (limited to 'src/map/icon.rs')
| -rw-r--r-- | src/map/icon.rs | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/map/icon.rs b/src/map/icon.rs index 50e1906..f623c98 100644 --- a/src/map/icon.rs +++ b/src/map/icon.rs @@ -1,9 +1,9 @@ use super::icon_renderer::IconRenderer; +use crate::colours::DEFAULT_COLOURS; use crate::map::Mappable; -use crate::math::{Vec2, Rect}; +use crate::math::{Rect, Vec2}; use crate::transform::Transform; use raylib::core::drawing::{RaylibDraw, RaylibDrawHandle}; -use raylib::ffi::Color; use serde::{Deserialize, Serialize}; use std::ops::{Deref, DerefMut}; use std::rc::Rc; @@ -21,6 +21,7 @@ pub struct IconData { #[derive(Clone)] pub struct Icon { data: IconData, + selected: bool, renderer: Rc<IconRenderer>, } @@ -37,7 +38,11 @@ impl Icon { } pub fn from_data(data: IconData, renderer: Rc<IconRenderer>) -> Self { - Self { data, renderer } + Self { + data, + selected: false, + renderer, + } } } @@ -54,15 +59,22 @@ impl Mappable for Icon { position_px, self.rotation as f32, (transform.pixels_per_m() / info.pixels_per_m) as f32, - Color { - r: 255, - g: 255, - b: 255, - a: 255, + if self.selected() { + DEFAULT_COLOURS.icon_selected + } else { + DEFAULT_COLOURS.icon_normal }, ); } + fn set_selected(&mut self, selected: bool) { + self.selected = selected; + } + + fn selected(&self) -> bool { + self.selected + } + fn bounding_rect(&self) -> Rect<f64> { Rect::new(self.data.position.x, self.data.position.y, 0., 0.) } |
