Skip to content

Commit 07601a5

Browse files
committed
Improve snapping with better snap target names, tooltips, cleaner overlay labels, code cleanup
1 parent ae2637e commit 07601a5

File tree

12 files changed

+422
-206
lines changed

12 files changed

+422
-206
lines changed

editor/src/messages/portfolio/document/document_message_handler.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::node_graph::utility_types::Transform;
33
use super::overlays::utility_types::Pivot;
44
use super::utility_types::clipboards::Clipboard;
55
use super::utility_types::error::EditorError;
6-
use super::utility_types::misc::{SnappingOptions, SnappingState, GET_SNAP_BOX_FUNCTIONS, GET_SNAP_GEOMETRY_FUNCTIONS};
6+
use super::utility_types::misc::{SnappingOptions, SnappingState, SNAP_FUNCTIONS_FOR_BOUNDING_BOXES, SNAP_FUNCTIONS_FOR_PATHS};
77
use super::utility_types::network_interface::{self, NodeNetworkInterface, TransactionStatus};
88
use super::utility_types::nodes::{CollapsedLayers, SelectedNodes};
99
use crate::application::{generate_uuid, GRAPHITE_GIT_COMMIT_HASH};
@@ -1779,28 +1779,27 @@ impl DocumentMessageHandler {
17791779
},
17801780
]
17811781
.into_iter()
1782-
.chain(GET_SNAP_BOX_FUNCTIONS.into_iter().map(|(name, closure)| LayoutGroup::Row {
1782+
.chain(SNAP_FUNCTIONS_FOR_BOUNDING_BOXES.into_iter().map(|(name, closure, tooltip)| LayoutGroup::Row {
17831783
widgets: vec![
17841784
CheckboxInput::new(*closure(&mut snapping_state))
17851785
.on_update(move |input: &CheckboxInput| DocumentMessage::SetSnapping { closure: Some(closure), snapping_state: input.checked }.into())
1786+
.tooltip(tooltip)
17861787
.widget_holder(),
1787-
TextLabel::new(name).widget_holder(),
1788+
TextLabel::new(name).tooltip(tooltip).widget_holder(),
17881789
],
17891790
}))
1790-
.chain(
1791-
[LayoutGroup::Row {
1792-
widgets: vec![TextLabel::new(SnappingOptions::Geometry.to_string()).widget_holder()],
1793-
}]
1794-
.into_iter()
1795-
.chain(GET_SNAP_GEOMETRY_FUNCTIONS.into_iter().map(|(name, closure)| LayoutGroup::Row {
1796-
widgets: vec![
1791+
.chain([LayoutGroup::Row {
1792+
widgets: vec![TextLabel::new(SnappingOptions::Paths.to_string()).widget_holder()],
1793+
}])
1794+
.chain(SNAP_FUNCTIONS_FOR_PATHS.into_iter().map(|(name, closure, tooltip)| LayoutGroup::Row {
1795+
widgets: vec![
17971796
CheckboxInput::new(*closure(&mut snapping_state2))
17981797
.on_update(move |input: &CheckboxInput| DocumentMessage::SetSnapping { closure: Some(closure), snapping_state: input.checked }.into())
1798+
.tooltip(tooltip)
17991799
.widget_holder(),
1800-
TextLabel::new(name).widget_holder(),
1800+
TextLabel::new(name).tooltip(tooltip).widget_holder(),
18011801
],
1802-
})),
1803-
)
1802+
}))
18041803
.collect(),
18051804
)
18061805
.widget_holder(),

0 commit comments

Comments
 (0)