|
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::*}; |
2 | 4 | use crate::messages::preferences::SelectionMode; |
3 | 5 | use crate::messages::prelude::*; |
4 | 6 |
|
@@ -63,42 +65,40 @@ impl PreferencesDialogMessageHandler { |
63 | 65 | .widget_holder(), |
64 | 66 | ]; |
65 | 67 |
|
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") |
70 | 72 | .tooltip("Select objects that are touched by the selection area") |
71 | | - .on_update(|_| { |
| 73 | + .on_update(move |_| { |
72 | 74 | PreferencesMessage::SelectionMode { |
73 | 75 | selection_mode: SelectionMode::Touched, |
74 | 76 | } |
75 | 77 | .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") |
81 | 81 | .tooltip("Select objects that are fully contained within the selection area") |
82 | | - .on_update(|_| { |
| 82 | + .on_update(move |_| { |
83 | 83 | PreferencesMessage::SelectionMode { |
84 | 84 | selection_mode: SelectionMode::Contained, |
85 | 85 | } |
86 | 86 | .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") |
92 | 90 | .tooltip("Select objects based on the drag direction of the selection area") |
93 | | - .on_update(|_| { |
| 91 | + .on_update(move |_| { |
94 | 92 | PreferencesMessage::SelectionMode { |
95 | 93 | selection_mode: SelectionMode::ByDragDirection, |
96 | 94 | } |
97 | 95 | .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(); |
102 | 102 |
|
103 | 103 | // TODO: Reenable when Imaginate is restored |
104 | 104 | // let imaginate_server_hostname = vec![ |
@@ -128,10 +128,8 @@ impl PreferencesDialogMessageHandler { |
128 | 128 | LayoutGroup::Row { widgets: zoom_with_scroll }, |
129 | 129 | LayoutGroup::Row { widgets: renderer_section }, |
130 | 130 | 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] }, |
135 | 133 | // LayoutGroup::Row { widgets: imaginate_server_hostname }, |
136 | 134 | // LayoutGroup::Row { widgets: imaginate_refresh_frequency }, |
137 | 135 | ])) |
|
0 commit comments