Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl LayoutHolder for ExportDialogMessageHandler {
DropdownInput::new(entries).selected_index(Some(index as u32)).widget_holder(),
];

let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("export-transparency");
let transparent_background = vec![
TextLabel::new("Transparency").table_align(true).min_width("100px").for_checkbox(checkbox_id).widget_holder(),
Separator::new(SeparatorType::Unrelated).widget_holder(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl LayoutHolder for NewDocumentDialogMessageHandler {
.widget_holder(),
];

let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("new-doc-infinite-canvas");
let infinite = vec![
TextLabel::new("Infinite Canvas").table_align(true).min_width("90px").for_checkbox(checkbox_id).widget_holder(),
Separator::new(SeparatorType::Unrelated).widget_holder(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl PreferencesDialogMessageHandler {
.widget_holder(),
];

let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("pref-zoom-with-scroll");
let zoom_with_scroll_tooltip = "Use the scroll wheel for zooming instead of vertically panning (not recommended for trackpads)";
let zoom_with_scroll = vec![
Separator::new(SeparatorType::Unrelated).widget_holder(),
Expand Down Expand Up @@ -169,7 +169,7 @@ impl PreferencesDialogMessageHandler {
graph_wire_style,
];

let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("pref-vello-renderer");
let vello_tooltip = "Use the experimental Vello renderer (your browser must support WebGPU)";
let use_vello = vec![
Separator::new(SeparatorType::Unrelated).widget_holder(),
Expand All @@ -188,7 +188,7 @@ impl PreferencesDialogMessageHandler {
.widget_holder(),
];

let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("pref-vector-meshes");
let vector_mesh_tooltip =
"Allow tools to produce vector meshes, where more than two segments can connect to an anchor point.\n\nCurrently this does not properly handle stroke joins and fills.";
let vector_meshes = vec![
Expand Down
11 changes: 11 additions & 0 deletions editor/src/messages/layout/utility_types/widgets/input_widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ impl CheckboxId {
pub fn new() -> Self {
Self(graphene_std::uuid::generate_uuid())
}

/// Create a stable CheckboxId from a string identifier.
/// This ensures the same string always produces the same ID, preventing ID mismatches during layout updates.
pub fn from_string(s: &str) -> Self {
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};

let mut hasher = DefaultHasher::new();
s.hash(&mut hasher);
Self(hasher.finish())
}
}
impl Default for CheckboxId {
fn default() -> Self {
Expand Down
28 changes: 14 additions & 14 deletions editor/src/messages/portfolio/document/document_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2245,7 +2245,7 @@ impl DocumentMessageHandler {
},
LayoutGroup::Row {
widgets: {
let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("overlay-artboard-name");
vec![
CheckboxInput::new(self.overlays_visibility_settings.artboard_name)
.on_update(|optional_input: &CheckboxInput| {
Expand All @@ -2263,7 +2263,7 @@ impl DocumentMessageHandler {
},
LayoutGroup::Row {
widgets: {
let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("overlay-transform-measurement");
vec![
CheckboxInput::new(self.overlays_visibility_settings.transform_measurement)
.on_update(|optional_input: &CheckboxInput| {
Expand All @@ -2284,7 +2284,7 @@ impl DocumentMessageHandler {
},
LayoutGroup::Row {
widgets: {
let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("overlay-quick-measurement");
vec![
CheckboxInput::new(self.overlays_visibility_settings.quick_measurement)
.on_update(|optional_input: &CheckboxInput| {
Expand All @@ -2302,7 +2302,7 @@ impl DocumentMessageHandler {
},
LayoutGroup::Row {
widgets: {
let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("overlay-transform-cage");
vec![
CheckboxInput::new(self.overlays_visibility_settings.transform_cage)
.on_update(|optional_input: &CheckboxInput| {
Expand All @@ -2320,7 +2320,7 @@ impl DocumentMessageHandler {
},
LayoutGroup::Row {
widgets: {
let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("overlay-compass-rose");
vec![
CheckboxInput::new(self.overlays_visibility_settings.compass_rose)
.on_update(|optional_input: &CheckboxInput| {
Expand All @@ -2338,7 +2338,7 @@ impl DocumentMessageHandler {
},
LayoutGroup::Row {
widgets: {
let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("overlay-pivot");
vec![
CheckboxInput::new(self.overlays_visibility_settings.pivot)
.on_update(|optional_input: &CheckboxInput| {
Expand All @@ -2356,7 +2356,7 @@ impl DocumentMessageHandler {
},
LayoutGroup::Row {
widgets: {
let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("overlay-origin");
vec![
CheckboxInput::new(self.overlays_visibility_settings.pivot)
.on_update(|optional_input: &CheckboxInput| {
Expand All @@ -2374,7 +2374,7 @@ impl DocumentMessageHandler {
},
LayoutGroup::Row {
widgets: {
let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("overlay-hover-outline");
vec![
CheckboxInput::new(self.overlays_visibility_settings.hover_outline)
.on_update(|optional_input: &CheckboxInput| {
Expand All @@ -2392,7 +2392,7 @@ impl DocumentMessageHandler {
},
LayoutGroup::Row {
widgets: {
let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("overlay-selection-outline");
vec![
CheckboxInput::new(self.overlays_visibility_settings.selection_outline)
.on_update(|optional_input: &CheckboxInput| {
Expand All @@ -2413,7 +2413,7 @@ impl DocumentMessageHandler {
},
LayoutGroup::Row {
widgets: {
let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("overlay-path");
vec![
CheckboxInput::new(self.overlays_visibility_settings.path)
.on_update(|optional_input: &CheckboxInput| {
Expand All @@ -2431,7 +2431,7 @@ impl DocumentMessageHandler {
},
LayoutGroup::Row {
widgets: {
let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("overlay-anchors");
vec![
CheckboxInput::new(self.overlays_visibility_settings.anchors)
.on_update(|optional_input: &CheckboxInput| {
Expand All @@ -2449,7 +2449,7 @@ impl DocumentMessageHandler {
},
LayoutGroup::Row {
widgets: {
let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("overlay-handles");
vec![
CheckboxInput::new(self.overlays_visibility_settings.handles)
.disabled(!self.overlays_visibility_settings.anchors)
Expand Down Expand Up @@ -2497,7 +2497,7 @@ impl DocumentMessageHandler {
.into_iter()
.chain(SNAP_FUNCTIONS_FOR_BOUNDING_BOXES.into_iter().map(|(name, closure, tooltip)| LayoutGroup::Row {
widgets: {
let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string(&format!("snap-bbox-{}", name.to_lowercase().replace(' ', "-")));
vec![
CheckboxInput::new(*closure(&mut snapping_state))
.on_update(move |input: &CheckboxInput| {
Expand All @@ -2519,7 +2519,7 @@ impl DocumentMessageHandler {
}])
.chain(SNAP_FUNCTIONS_FOR_PATHS.into_iter().map(|(name, closure, tooltip)| LayoutGroup::Row {
widgets: {
let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string(&format!("snap-path-{}", name.to_lowercase().replace(' ', "-")));
vec![
CheckboxInput::new(*closure(&mut snapping_state2))
.on_update(move |input: &CheckboxInput| {
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/path_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl LayoutHolder for PathTool {
})
// TODO: Remove `unwrap_or_default` once checkboxes are capable of displaying a mixed state
.unwrap_or_default();
let checkbox_id = CheckboxId::new();
let checkbox_id = CheckboxId::from_string("path-tool-colinear-handles");
let colinear_handle_checkbox = CheckboxInput::new(colinear_handles_state)
.disabled(!self.tool_data.can_toggle_colinearity)
.on_update(|&CheckboxInput { checked, .. }| {
Expand Down
Loading