aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorArne Dußin2021-01-05 12:44:02 +0100
committerArne Dußin2021-01-05 12:44:02 +0100
commit1c81d7c70fe891e6ded49d49d6a09f04ce74dd6e (patch)
treeb1174fed1738ac75c59760d61a2a248033163379 /src/gui
parent99107c0be8675177547e7a25263da0c0dffb66f3 (diff)
downloadgraf_karto-1c81d7c70fe891e6ded49d49d6a09f04ce74dd6e.tar.gz
graf_karto-1c81d7c70fe891e6ded49d49d6a09f04ce74dd6e.zip
Position indicator is now dependent on current snapping
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/position_indicator.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/gui/position_indicator.rs b/src/gui/position_indicator.rs
index b6d0dac..737a427 100644
--- a/src/gui/position_indicator.rs
+++ b/src/gui/position_indicator.rs
@@ -8,6 +8,7 @@
use crate::colours::DEFAULT_COLOURS;
use crate::math::Vec2;
+use crate::snapping::Snapper;
use crate::transform::Transform;
use raylib::drawing::{RaylibDraw, RaylibDrawHandle};
@@ -17,14 +18,19 @@ pub fn position_indicator_draw(
rld: &mut RaylibDrawHandle,
mouse_pos_px: Vec2<f64>,
transform: &Transform,
+ snapper: &Snapper,
) {
- let mouse_pos_m = transform.point_px_to_m(&mouse_pos_px);
+ let mouse_pos_snapped_m = snapper.snap(transform.point_px_to_m(&mouse_pos_px));
+ let mouse_pos_snapped_px = transform.point_m_to_px(&mouse_pos_snapped_m);
- rld.draw_circle_v(mouse_pos_px, 2., DEFAULT_COLOURS.position_indicator);
+ rld.draw_circle_v(mouse_pos_snapped_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,
+ &format!(
+ "({:.3}m, {:.3}m)",
+ mouse_pos_snapped_m.x, mouse_pos_snapped_m.y
+ ),
+ mouse_pos_snapped_px.x as i32 - 30,
+ mouse_pos_snapped_px.y as i32 - 30,
20,
DEFAULT_COLOURS.position_text,
);