aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorArne Dußin2021-01-05 12:43:46 +0100
committerArne Dußin2021-01-05 12:43:46 +0100
commit99107c0be8675177547e7a25263da0c0dffb66f3 (patch)
tree92cc295b43ba89f0e6bd51e1e32411e42d0d6c81 /src/gui
parentb42ddaa4bf86b782bdbc619f7d66ded41c909465 (diff)
parent9b5762cf3716503819e2cf06f3c335bbfd3b0a3c (diff)
downloadgraf_karto-99107c0be8675177547e7a25263da0c0dffb66f3.tar.gz
graf_karto-99107c0be8675177547e7a25263da0c0dffb66f3.zip
Merge branch 'master' into snapping
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/mod.rs2
-rw-r--r--src/gui/position_indicator.rs31
2 files changed, 33 insertions, 0 deletions
diff --git a/src/gui/mod.rs b/src/gui/mod.rs
index c73d243..62173ec 100644
--- a/src/gui/mod.rs
+++ b/src/gui/mod.rs
@@ -9,8 +9,10 @@
pub mod decimal_num_box;
pub mod dimension_indicator;
+pub mod position_indicator;
pub mod tool_sidebar;
pub use self::decimal_num_box::*;
pub use self::dimension_indicator::*;
+pub use self::position_indicator::*;
pub use self::tool_sidebar::*;
diff --git a/src/gui/position_indicator.rs b/src/gui/position_indicator.rs
new file mode 100644
index 0000000..b6d0dac
--- /dev/null
+++ b/src/gui/position_indicator.rs
@@ -0,0 +1,31 @@
+//! The position indicator shows the mouse position on the map
+//!
+//! The exact position the mouse is currently on is shown unless hidden by the user (TODO). This
+//! helps to place things exactly where they should be on the map and let the user know where they
+//! are looking and where relative to them other things should be easily at all times. Currently, this
+//! is a simple HUD so it doesn't interact with anything in the world, but that may change in the
+//! future.
+
+use crate::colours::DEFAULT_COLOURS;
+use crate::math::Vec2;
+use crate::transform::Transform;
+use raylib::drawing::{RaylibDraw, RaylibDrawHandle};
+
+/// Function to draw a dot at the mouse position and the coordinates associated with it.
+// TODO: Snap this, when the user wants to snap, don't if they don't want to.
+pub fn position_indicator_draw(
+ rld: &mut RaylibDrawHandle,
+ mouse_pos_px: Vec2<f64>,
+ transform: &Transform,
+) {
+ let mouse_pos_m = transform.point_px_to_m(&mouse_pos_px);
+
+ rld.draw_circle_v(mouse_pos_px, 2., DEFAULT_COLOURS.position_indicator);
+ rld.draw_text(
+ &format!("({:.3}m, {:.3}m)", mouse_pos_m.x, mouse_pos_m.y),
+ mouse_pos_px.x as i32 - 30,
+ mouse_pos_px.y as i32 - 30,
+ 20,
+ DEFAULT_COLOURS.position_text,
+ );
+}