Skip to content

Commit 2c21e1a

Browse files
committed
Desktop: Clean up the UI scale setting in the Preferences dialog
1 parent e99f30e commit 2c21e1a

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::consts::{UI_SCALE_DEFAULT, UI_SCALE_MAX, UI_SCALE_MIN, VIEWPORT_ZOOM_WHEEL_RATE, VIEWPORT_ZOOM_WHEEL_RATE_CHANGE};
1+
use crate::consts::{VIEWPORT_ZOOM_WHEEL_RATE, VIEWPORT_ZOOM_WHEEL_RATE_CHANGE};
22
use crate::messages::layout::utility_types::widget_prelude::*;
33
use crate::messages::portfolio::document::utility_types::wires::GraphWireStyle;
44
use crate::messages::preferences::SelectionMode;
@@ -155,14 +155,14 @@ impl PreferencesDialogMessageHandler {
155155
rows.extend_from_slice(&[header, selection_label, selection_mode]);
156156
}
157157

158-
// ==========
159-
// UI
160-
// ==========
158+
// =========
159+
// INTERFACE
160+
// =========
161161
#[cfg(not(target_family = "wasm"))]
162162
{
163-
let header = vec![TextLabel::new("UI").italic(true).widget_instance()];
163+
let header = vec![TextLabel::new("Interface").italic(true).widget_instance()];
164164

165-
let scale_description = "Adjust the scale of the user interface (100 is default).";
165+
let scale_description = "Adjust the scale of the entire user interface (100% is default).";
166166
let scale_label = vec![
167167
Separator::new(SeparatorType::Unrelated).widget_instance(),
168168
Separator::new(SeparatorType::Unrelated).widget_instance(),
@@ -176,15 +176,18 @@ impl PreferencesDialogMessageHandler {
176176
.tooltip_description(scale_description)
177177
.mode_range()
178178
.int()
179-
.min(ui_scale_to_display(UI_SCALE_MIN))
180-
.max(ui_scale_to_display(UI_SCALE_MAX))
179+
.min(ui_scale_to_display(crate::consts::UI_SCALE_MIN))
180+
.max(ui_scale_to_display(crate::consts::UI_SCALE_MAX))
181181
.unit("%")
182182
.on_update(|number_input: &NumberInput| {
183183
if let Some(display_value) = number_input.value {
184184
let scale = map_display_to_ui_scale(display_value);
185185
PreferencesMessage::UIScale { scale }.into()
186186
} else {
187-
PreferencesMessage::UIScale { scale: UI_SCALE_DEFAULT }.into()
187+
PreferencesMessage::UIScale {
188+
scale: crate::consts::UI_SCALE_DEFAULT,
189+
}
190+
.into()
188191
}
189192
})
190193
.widget_instance(),
@@ -376,11 +379,13 @@ fn map_zoom_rate_to_display(rate: f64) -> f64 {
376379
}
377380

378381
/// Maps display values in percent to actual ui scale.
382+
#[cfg(not(target_family = "wasm"))]
379383
fn map_display_to_ui_scale(display: f64) -> f64 {
380384
display / 100.
381385
}
382386

383387
/// Maps actual ui scale back to display values in percent.
388+
#[cfg(not(target_family = "wasm"))]
384389
fn ui_scale_to_display(scale: f64) -> f64 {
385390
scale * 100.
386391
}

editor/src/messages/preferences/preferences_message_handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::messages::prelude::*;
66
use graph_craft::wasm_application_io::EditorPreferences;
77

88
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, specta::Type, ExtractField)]
9+
#[serde(default)]
910
pub struct PreferencesMessageHandler {
1011
pub selection_mode: SelectionMode,
1112
pub zoom_with_scroll: bool,

0 commit comments

Comments
 (0)