Skip to content

Commit d91da7f

Browse files
Pratik AgrawalPratik Agrawal
authored andcommitted
adapted to the RadioEntryData
1 parent c3b7d87 commit d91da7f

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

editor/src/messages/dialog/preferences_dialog/preferences_dialog_message_handler.rs

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use crate::messages::layout::utility_types::widget_prelude::*;
1+
use std::sync::Arc;
2+
3+
use crate::messages::layout::utility_types::{layout_widget, widget_prelude::*};
24
use crate::messages::preferences::SelectionMode;
35
use crate::messages::prelude::*;
46

@@ -63,42 +65,40 @@ impl PreferencesDialogMessageHandler {
6365
.widget_holder(),
6466
];
6567

66-
let selection_mode_tooltip = "Choose the selection mode for objects in the editor";
67-
68-
let selection_mode_checkboxes = vec![
69-
CheckboxInput::new(matches!(preferences.selection_mode, SelectionMode::Touched))
68+
let selection_section = vec![TextLabel::new("Selection Mode").italic(true).widget_holder()];
69+
let selection_mode = RadioInput::new(vec![
70+
RadioEntryData::new("touched")
71+
.label("Touched")
7072
.tooltip("Select objects that are touched by the selection area")
71-
.on_update(|_| {
73+
.on_update(move |_| {
7274
PreferencesMessage::SelectionMode {
7375
selection_mode: SelectionMode::Touched,
7476
}
7577
.into()
76-
})
77-
.widget_holder(),
78-
TextLabel::new("Touched").table_align(true).widget_holder(),
79-
Separator::new(SeparatorType::Unrelated).widget_holder(),
80-
CheckboxInput::new(matches!(preferences.selection_mode, SelectionMode::Contained))
78+
}),
79+
RadioEntryData::new("contained")
80+
.label("Contained")
8181
.tooltip("Select objects that are fully contained within the selection area")
82-
.on_update(|_| {
82+
.on_update(move |_| {
8383
PreferencesMessage::SelectionMode {
8484
selection_mode: SelectionMode::Contained,
8585
}
8686
.into()
87-
})
88-
.widget_holder(),
89-
TextLabel::new("Contained").table_align(true).widget_holder(),
90-
Separator::new(SeparatorType::Unrelated).widget_holder(),
91-
CheckboxInput::new(matches!(preferences.selection_mode, SelectionMode::ByDragDirection))
87+
}),
88+
RadioEntryData::new("by_drag_direction")
89+
.label("By Drag Direction")
9290
.tooltip("Select objects based on the drag direction of the selection area")
93-
.on_update(|_| {
91+
.on_update(move |_| {
9492
PreferencesMessage::SelectionMode {
9593
selection_mode: SelectionMode::ByDragDirection,
9694
}
9795
.into()
98-
})
99-
.widget_holder(),
100-
TextLabel::new("By Drag Direction").table_align(true).widget_holder(),
101-
];
96+
}),
97+
])
98+
.selected_index(Some(
99+
(preferences.selection_mode == SelectionMode::ByDragDirection) as u32, // Accessing selection_mode correctly
100+
))
101+
.widget_holder();
102102

103103
// TODO: Reenable when Imaginate is restored
104104
// let imaginate_server_hostname = vec![
@@ -128,10 +128,8 @@ impl PreferencesDialogMessageHandler {
128128
LayoutGroup::Row { widgets: zoom_with_scroll },
129129
LayoutGroup::Row { widgets: renderer_section },
130130
LayoutGroup::Row { widgets: use_vello },
131-
LayoutGroup::Row {
132-
widgets: vec![TextLabel::new("Selection Mode").italic(true).widget_holder()],
133-
},
134-
LayoutGroup::Row { widgets: selection_mode_checkboxes },
131+
LayoutGroup::Row { widgets: selection_section },
132+
LayoutGroup::Row { widgets: vec![selection_mode] },
135133
// LayoutGroup::Row { widgets: imaginate_server_hostname },
136134
// LayoutGroup::Row { widgets: imaginate_refresh_frequency },
137135
]))

editor/src/messages/preferences/preferences_message_handler.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ impl MessageHandler<PreferencesMessage, ()> for PreferencesMessageHandler {
101101
responses.add(KeyMappingMessage::ModifyMapping(variant));
102102
responses.add(FrontendMessage::UpdateZoomWithScroll { zoom_with_scroll });
103103
}
104-
PreferencesMessage::SelectionMode { selection_mode } => todo!(),
104+
PreferencesMessage::SelectionMode { selection_mode } => {
105+
log::info!("Setting selection mode: {:?}", selection_mode);
106+
self.selection_mode = selection_mode;
107+
}
105108
}
106-
107109
responses.add(FrontendMessage::TriggerSavePreferences { preferences: self.clone() });
108110
}
109111

0 commit comments

Comments
 (0)