mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-27 06:58:11 +08:00
Desktop: UI scale preference (#3475)
* ui scale preference * cleanup * add update ui scale message to SIDE_EFFECT_FREE_MESSAGES * fix mac title bar height * hide UI preference section on web * set % as unit of ui scale
This commit is contained in:
+247
-214
@@ -1,4 +1,4 @@
|
||||
use crate::consts::{VIEWPORT_ZOOM_WHEEL_RATE, VIEWPORT_ZOOM_WHEEL_RATE_CHANGE};
|
||||
use crate::consts::{UI_SCALE_DEFAULT, UI_SCALE_MAX, UI_SCALE_MIN, VIEWPORT_ZOOM_WHEEL_RATE, VIEWPORT_ZOOM_WHEEL_RATE_CHANGE};
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::portfolio::document::utility_types::wires::GraphWireStyle;
|
||||
use crate::messages::preferences::SelectionMode;
|
||||
@@ -36,250 +36,273 @@ impl PreferencesDialogMessageHandler {
|
||||
const TITLE: &'static str = "Editor Preferences";
|
||||
|
||||
fn layout(&self, preferences: &PreferencesMessageHandler) -> Layout {
|
||||
let mut rows = Vec::new();
|
||||
|
||||
// ==========
|
||||
// NAVIGATION
|
||||
// ==========
|
||||
{
|
||||
let header = vec![TextLabel::new("Navigation").italic(true).widget_instance()];
|
||||
|
||||
let navigation_header = vec![TextLabel::new("Navigation").italic(true).widget_instance()];
|
||||
let zoom_rate_description = "Adjust how fast zooming occurs when using the scroll wheel or pinch gesture (relative to a default of 50).";
|
||||
let zoom_rate_label = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextLabel::new("Zoom Rate").tooltip_label("Zoom Rate").tooltip_description(zoom_rate_description).widget_instance(),
|
||||
];
|
||||
let zoom_rate = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(map_zoom_rate_to_display(preferences.viewport_zoom_wheel_rate)))
|
||||
.tooltip_label("Zoom Rate")
|
||||
.tooltip_description(zoom_rate_description)
|
||||
.mode_range()
|
||||
.int()
|
||||
.min(1.)
|
||||
.max(100.)
|
||||
.on_update(|number_input: &NumberInput| {
|
||||
if let Some(display_value) = number_input.value {
|
||||
let actual_rate = map_display_to_zoom_rate(display_value);
|
||||
PreferencesMessage::ViewportZoomWheelRate { rate: actual_rate }.into()
|
||||
} else {
|
||||
PreferencesMessage::ViewportZoomWheelRate { rate: VIEWPORT_ZOOM_WHEEL_RATE }.into()
|
||||
}
|
||||
})
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
let zoom_rate_description = "Adjust how fast zooming occurs when using the scroll wheel or pinch gesture (relative to a default of 50).";
|
||||
let zoom_rate_label = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextLabel::new("Zoom Rate").tooltip_label("Zoom Rate").tooltip_description(zoom_rate_description).widget_instance(),
|
||||
];
|
||||
let zoom_rate = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(map_zoom_rate_to_display(preferences.viewport_zoom_wheel_rate)))
|
||||
.tooltip_label("Zoom Rate")
|
||||
.tooltip_description(zoom_rate_description)
|
||||
.mode_range()
|
||||
.int()
|
||||
.min(1.)
|
||||
.max(100.)
|
||||
.on_update(|number_input: &NumberInput| {
|
||||
if let Some(display_value) = number_input.value {
|
||||
let actual_rate = map_display_to_zoom_rate(display_value);
|
||||
PreferencesMessage::ViewportZoomWheelRate { rate: actual_rate }.into()
|
||||
} else {
|
||||
PreferencesMessage::ViewportZoomWheelRate { rate: VIEWPORT_ZOOM_WHEEL_RATE }.into()
|
||||
}
|
||||
})
|
||||
.widget_instance(),
|
||||
];
|
||||
let checkbox_id = CheckboxId::new();
|
||||
let zoom_with_scroll_description = "Use the scroll wheel for zooming instead of vertically panning (not recommended for trackpads).";
|
||||
let zoom_with_scroll = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(preferences.zoom_with_scroll)
|
||||
.tooltip_label("Zoom with Scroll")
|
||||
.tooltip_description(zoom_with_scroll_description)
|
||||
.on_update(|checkbox_input: &CheckboxInput| {
|
||||
PreferencesMessage::ModifyLayout {
|
||||
zoom_with_scroll: checkbox_input.checked,
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Zoom with Scroll")
|
||||
.tooltip_label("Zoom with Scroll")
|
||||
.tooltip_description(zoom_with_scroll_description)
|
||||
.for_checkbox(checkbox_id)
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
let checkbox_id = CheckboxId::new();
|
||||
let zoom_with_scroll_description = "Use the scroll wheel for zooming instead of vertically panning (not recommended for trackpads).";
|
||||
let zoom_with_scroll = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(preferences.zoom_with_scroll)
|
||||
.tooltip_label("Zoom with Scroll")
|
||||
.tooltip_description(zoom_with_scroll_description)
|
||||
.on_update(|checkbox_input: &CheckboxInput| {
|
||||
PreferencesMessage::ModifyLayout {
|
||||
zoom_with_scroll: checkbox_input.checked,
|
||||
}
|
||||
.into()
|
||||
})
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Zoom with Scroll")
|
||||
.tooltip_label("Zoom with Scroll")
|
||||
.tooltip_description(zoom_with_scroll_description)
|
||||
.for_checkbox(checkbox_id)
|
||||
.widget_instance(),
|
||||
];
|
||||
rows.extend_from_slice(&[header, zoom_rate_label, zoom_rate, zoom_with_scroll]);
|
||||
}
|
||||
|
||||
// =======
|
||||
// EDITING
|
||||
// =======
|
||||
{
|
||||
let header = vec![TextLabel::new("Editing").italic(true).widget_instance()];
|
||||
|
||||
let editing_header = vec![TextLabel::new("Editing").italic(true).widget_instance()];
|
||||
let selection_label = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextLabel::new("Selection")
|
||||
.tooltip_label("Selection")
|
||||
.tooltip_description("Choose how targets are selected within dragged rectangular and lasso areas.")
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
let selection_label = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextLabel::new("Selection")
|
||||
.tooltip_label("Selection")
|
||||
.tooltip_description("Choose how targets are selected within dragged rectangular and lasso areas.")
|
||||
.widget_instance(),
|
||||
];
|
||||
let selection_mode = RadioInput::new(vec![
|
||||
RadioEntryData::new(SelectionMode::Touched.to_string())
|
||||
.label(SelectionMode::Touched.to_string())
|
||||
.tooltip_label(SelectionMode::Touched.to_string())
|
||||
.tooltip_description(SelectionMode::Touched.tooltip_description())
|
||||
.on_update(move |_| {
|
||||
PreferencesMessage::SelectionMode {
|
||||
selection_mode: SelectionMode::Touched,
|
||||
}
|
||||
.into()
|
||||
}),
|
||||
RadioEntryData::new(SelectionMode::Enclosed.to_string())
|
||||
.label(SelectionMode::Enclosed.to_string())
|
||||
.tooltip_label(SelectionMode::Enclosed.to_string())
|
||||
.tooltip_description(SelectionMode::Enclosed.tooltip_description())
|
||||
.on_update(move |_| {
|
||||
PreferencesMessage::SelectionMode {
|
||||
selection_mode: SelectionMode::Enclosed,
|
||||
}
|
||||
.into()
|
||||
}),
|
||||
RadioEntryData::new(SelectionMode::Directional.to_string())
|
||||
.label(SelectionMode::Directional.to_string())
|
||||
.tooltip_label(SelectionMode::Directional.to_string())
|
||||
.tooltip_description(SelectionMode::Directional.tooltip_description())
|
||||
.on_update(move |_| {
|
||||
PreferencesMessage::SelectionMode {
|
||||
selection_mode: SelectionMode::Directional,
|
||||
}
|
||||
.into()
|
||||
}),
|
||||
])
|
||||
.selected_index(Some(preferences.selection_mode as u32))
|
||||
.widget_instance();
|
||||
let selection_mode = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
selection_mode,
|
||||
];
|
||||
|
||||
let selection_mode = RadioInput::new(vec![
|
||||
RadioEntryData::new(SelectionMode::Touched.to_string())
|
||||
.label(SelectionMode::Touched.to_string())
|
||||
.tooltip_label(SelectionMode::Touched.to_string())
|
||||
.tooltip_description(SelectionMode::Touched.tooltip_description())
|
||||
.on_update(move |_| {
|
||||
PreferencesMessage::SelectionMode {
|
||||
selection_mode: SelectionMode::Touched,
|
||||
}
|
||||
.into()
|
||||
}),
|
||||
RadioEntryData::new(SelectionMode::Enclosed.to_string())
|
||||
.label(SelectionMode::Enclosed.to_string())
|
||||
.tooltip_label(SelectionMode::Enclosed.to_string())
|
||||
.tooltip_description(SelectionMode::Enclosed.tooltip_description())
|
||||
.on_update(move |_| {
|
||||
PreferencesMessage::SelectionMode {
|
||||
selection_mode: SelectionMode::Enclosed,
|
||||
}
|
||||
.into()
|
||||
}),
|
||||
RadioEntryData::new(SelectionMode::Directional.to_string())
|
||||
.label(SelectionMode::Directional.to_string())
|
||||
.tooltip_label(SelectionMode::Directional.to_string())
|
||||
.tooltip_description(SelectionMode::Directional.tooltip_description())
|
||||
.on_update(move |_| {
|
||||
PreferencesMessage::SelectionMode {
|
||||
selection_mode: SelectionMode::Directional,
|
||||
}
|
||||
.into()
|
||||
}),
|
||||
])
|
||||
.selected_index(Some(preferences.selection_mode as u32))
|
||||
.widget_instance();
|
||||
let selection_mode = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
selection_mode,
|
||||
];
|
||||
rows.extend_from_slice(&[header, selection_label, selection_mode]);
|
||||
}
|
||||
|
||||
// ==========
|
||||
// UI
|
||||
// ==========
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
{
|
||||
let header = vec![TextLabel::new("UI").italic(true).widget_instance()];
|
||||
|
||||
let scale_description = "Adjust the scale of the user interface (100 is default).";
|
||||
let scale_label = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextLabel::new("Scale").tooltip_label("Scale").tooltip_description(scale_description).widget_instance(),
|
||||
];
|
||||
let scale = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
NumberInput::new(Some(ui_scale_to_display(preferences.ui_scale)))
|
||||
.tooltip_label("Scale")
|
||||
.tooltip_description(scale_description)
|
||||
.mode_range()
|
||||
.int()
|
||||
.min(ui_scale_to_display(UI_SCALE_MIN))
|
||||
.max(ui_scale_to_display(UI_SCALE_MAX))
|
||||
.unit("%")
|
||||
.on_update(|number_input: &NumberInput| {
|
||||
if let Some(display_value) = number_input.value {
|
||||
let scale = map_display_to_ui_scale(display_value);
|
||||
PreferencesMessage::UIScale { scale }.into()
|
||||
} else {
|
||||
PreferencesMessage::UIScale { scale: UI_SCALE_DEFAULT }.into()
|
||||
}
|
||||
})
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
rows.extend_from_slice(&[header, scale_label, scale]);
|
||||
}
|
||||
|
||||
// ============
|
||||
// EXPERIMENTAL
|
||||
// ============
|
||||
{
|
||||
let header = vec![TextLabel::new("Experimental").italic(true).widget_instance()];
|
||||
|
||||
let experimental_header = vec![TextLabel::new("Experimental").italic(true).widget_instance()];
|
||||
let node_graph_section_description = "Configure the appearance of the wires running between node connections in the graph.";
|
||||
let node_graph_wires_label = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextLabel::new("Node Graph Wires")
|
||||
.tooltip_label("Node Graph Wires")
|
||||
.tooltip_description(node_graph_section_description)
|
||||
.widget_instance(),
|
||||
];
|
||||
let graph_wire_style = RadioInput::new(vec![
|
||||
RadioEntryData::new(GraphWireStyle::Direct.to_string())
|
||||
.label(GraphWireStyle::Direct.to_string())
|
||||
.tooltip_label(GraphWireStyle::Direct.to_string())
|
||||
.tooltip_description(GraphWireStyle::Direct.tooltip_description())
|
||||
.on_update(move |_| PreferencesMessage::GraphWireStyle { style: GraphWireStyle::Direct }.into()),
|
||||
RadioEntryData::new(GraphWireStyle::GridAligned.to_string())
|
||||
.label(GraphWireStyle::GridAligned.to_string())
|
||||
.tooltip_label(GraphWireStyle::GridAligned.to_string())
|
||||
.tooltip_description(GraphWireStyle::GridAligned.tooltip_description())
|
||||
.on_update(move |_| PreferencesMessage::GraphWireStyle { style: GraphWireStyle::GridAligned }.into()),
|
||||
])
|
||||
.selected_index(Some(preferences.graph_wire_style as u32))
|
||||
.widget_instance();
|
||||
let graph_wire_style = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
graph_wire_style,
|
||||
];
|
||||
|
||||
let node_graph_section_description = "Configure the appearance of the wires running between node connections in the graph.";
|
||||
let node_graph_wires_label = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
TextLabel::new("Node Graph Wires")
|
||||
.tooltip_label("Node Graph Wires")
|
||||
.tooltip_description(node_graph_section_description)
|
||||
.widget_instance(),
|
||||
];
|
||||
let graph_wire_style = RadioInput::new(vec![
|
||||
RadioEntryData::new(GraphWireStyle::Direct.to_string())
|
||||
.label(GraphWireStyle::Direct.to_string())
|
||||
.tooltip_label(GraphWireStyle::Direct.to_string())
|
||||
.tooltip_description(GraphWireStyle::Direct.tooltip_description())
|
||||
.on_update(move |_| PreferencesMessage::GraphWireStyle { style: GraphWireStyle::Direct }.into()),
|
||||
RadioEntryData::new(GraphWireStyle::GridAligned.to_string())
|
||||
.label(GraphWireStyle::GridAligned.to_string())
|
||||
.tooltip_label(GraphWireStyle::GridAligned.to_string())
|
||||
.tooltip_description(GraphWireStyle::GridAligned.tooltip_description())
|
||||
.on_update(move |_| PreferencesMessage::GraphWireStyle { style: GraphWireStyle::GridAligned }.into()),
|
||||
])
|
||||
.selected_index(Some(preferences.graph_wire_style as u32))
|
||||
.widget_instance();
|
||||
let graph_wire_style = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
graph_wire_style,
|
||||
];
|
||||
let checkbox_id = CheckboxId::new();
|
||||
let vello_description = "Use the experimental Vello renderer instead of SVG-based rendering.".to_string();
|
||||
#[cfg(target_family = "wasm")]
|
||||
let mut vello_description = vello_description;
|
||||
#[cfg(target_family = "wasm")]
|
||||
vello_description.push_str("\n\n(Your browser must support WebGPU.)");
|
||||
|
||||
let checkbox_id = CheckboxId::new();
|
||||
let vello_description = "Use the experimental Vello renderer instead of SVG-based rendering.".to_string();
|
||||
#[cfg(target_family = "wasm")]
|
||||
let mut vello_description = vello_description;
|
||||
#[cfg(target_family = "wasm")]
|
||||
vello_description.push_str("\n\n(Your browser must support WebGPU.)");
|
||||
let use_vello = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(preferences.use_vello && preferences.supports_wgpu())
|
||||
.tooltip_label("Vello Renderer")
|
||||
.tooltip_description(vello_description.clone())
|
||||
.disabled(!preferences.supports_wgpu())
|
||||
.on_update(|checkbox_input: &CheckboxInput| PreferencesMessage::UseVello { use_vello: checkbox_input.checked }.into())
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Vello Renderer")
|
||||
.tooltip_label("Vello Renderer")
|
||||
.tooltip_description(vello_description)
|
||||
.disabled(!preferences.supports_wgpu())
|
||||
.for_checkbox(checkbox_id)
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
let use_vello = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(preferences.use_vello && preferences.supports_wgpu())
|
||||
.tooltip_label("Vello Renderer")
|
||||
.tooltip_description(vello_description.clone())
|
||||
.disabled(!preferences.supports_wgpu())
|
||||
.on_update(|checkbox_input: &CheckboxInput| PreferencesMessage::UseVello { use_vello: checkbox_input.checked }.into())
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Vello Renderer")
|
||||
.tooltip_label("Vello Renderer")
|
||||
.tooltip_description(vello_description)
|
||||
.disabled(!preferences.supports_wgpu())
|
||||
.for_checkbox(checkbox_id)
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
let checkbox_id = CheckboxId::new();
|
||||
let vector_mesh_description = "
|
||||
let checkbox_id = CheckboxId::new();
|
||||
let vector_mesh_description = "
|
||||
Allow the Pen tool to produce branching geometry, where more than two segments may be connected to one anchor point.\n\
|
||||
\n\
|
||||
Currently, vector meshes do not properly render strokes (branching joins) and fills (multiple regions).
|
||||
"
|
||||
.trim();
|
||||
let vector_meshes = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(preferences.vector_meshes)
|
||||
.tooltip_label("Vector Meshes")
|
||||
.tooltip_description(vector_mesh_description)
|
||||
.on_update(|checkbox_input: &CheckboxInput| PreferencesMessage::VectorMeshes { enabled: checkbox_input.checked }.into())
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Vector Meshes")
|
||||
.tooltip_label("Vector Meshes")
|
||||
.tooltip_description(vector_mesh_description)
|
||||
.for_checkbox(checkbox_id)
|
||||
.widget_instance(),
|
||||
];
|
||||
.trim();
|
||||
let vector_meshes = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(preferences.vector_meshes)
|
||||
.tooltip_label("Vector Meshes")
|
||||
.tooltip_description(vector_mesh_description)
|
||||
.on_update(|checkbox_input: &CheckboxInput| PreferencesMessage::VectorMeshes { enabled: checkbox_input.checked }.into())
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Vector Meshes")
|
||||
.tooltip_label("Vector Meshes")
|
||||
.tooltip_description(vector_mesh_description)
|
||||
.for_checkbox(checkbox_id)
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
let checkbox_id = CheckboxId::new();
|
||||
let brush_tool_description = "
|
||||
let checkbox_id = CheckboxId::new();
|
||||
let brush_tool_description = "
|
||||
Enable the Brush tool to support basic raster-based layer painting.\n\
|
||||
\n\
|
||||
This legacy tool has performance and quality limitations and is slated for replacement in future versions of Graphite that will focus on raster graphics editing.
|
||||
"
|
||||
.trim();
|
||||
let brush_tool = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(preferences.brush_tool)
|
||||
.tooltip_label("Brush Tool")
|
||||
.tooltip_description(brush_tool_description)
|
||||
.on_update(|checkbox_input: &CheckboxInput| PreferencesMessage::BrushTool { enabled: checkbox_input.checked }.into())
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Brush Tool")
|
||||
.tooltip_label("Brush Tool")
|
||||
.tooltip_description(brush_tool_description)
|
||||
.for_checkbox(checkbox_id)
|
||||
.widget_instance(),
|
||||
];
|
||||
.trim();
|
||||
let brush_tool = vec![
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_instance(),
|
||||
CheckboxInput::new(preferences.brush_tool)
|
||||
.tooltip_label("Brush Tool")
|
||||
.tooltip_description(brush_tool_description)
|
||||
.on_update(|checkbox_input: &CheckboxInput| PreferencesMessage::BrushTool { enabled: checkbox_input.checked }.into())
|
||||
.for_label(checkbox_id)
|
||||
.widget_instance(),
|
||||
TextLabel::new("Brush Tool")
|
||||
.tooltip_label("Brush Tool")
|
||||
.tooltip_description(brush_tool_description)
|
||||
.for_checkbox(checkbox_id)
|
||||
.widget_instance(),
|
||||
];
|
||||
|
||||
Layout(vec![
|
||||
// NAVIGATION
|
||||
LayoutGroup::Row { widgets: navigation_header },
|
||||
// Navigation: Zoom Rate
|
||||
LayoutGroup::Row { widgets: zoom_rate_label },
|
||||
LayoutGroup::Row { widgets: zoom_rate },
|
||||
// Navigation: Zoom with Scroll
|
||||
LayoutGroup::Row { widgets: zoom_with_scroll },
|
||||
//
|
||||
// EDITING
|
||||
LayoutGroup::Row { widgets: editing_header },
|
||||
// Editing: Selection
|
||||
LayoutGroup::Row { widgets: selection_label },
|
||||
LayoutGroup::Row { widgets: selection_mode },
|
||||
//
|
||||
// EXPERIMENTAL
|
||||
LayoutGroup::Row { widgets: experimental_header },
|
||||
// Experimental: Node Graph Wires
|
||||
LayoutGroup::Row { widgets: node_graph_wires_label },
|
||||
LayoutGroup::Row { widgets: graph_wire_style },
|
||||
// Experimental: Vello Renderer
|
||||
LayoutGroup::Row { widgets: use_vello },
|
||||
// Experimental: Vector Meshes
|
||||
LayoutGroup::Row { widgets: vector_meshes },
|
||||
// Experimental: Brush Tool
|
||||
LayoutGroup::Row { widgets: brush_tool },
|
||||
])
|
||||
rows.extend_from_slice(&[header, node_graph_wires_label, graph_wire_style, use_vello, vector_meshes, brush_tool]);
|
||||
}
|
||||
|
||||
Layout(rows.into_iter().map(|r| LayoutGroup::Row { widgets: r }).collect())
|
||||
}
|
||||
|
||||
pub fn send_layout(&self, responses: &mut VecDeque<Message>, layout_target: LayoutTarget, preferences: &PreferencesMessageHandler) {
|
||||
@@ -351,3 +374,13 @@ fn map_zoom_rate_to_display(rate: f64) -> f64 {
|
||||
let display = 50. + distance_from_reference;
|
||||
display.clamp(1., 100.).round()
|
||||
}
|
||||
|
||||
/// Maps display values in percent to actual ui scale.
|
||||
fn map_display_to_ui_scale(display: f64) -> f64 {
|
||||
display / 100.
|
||||
}
|
||||
|
||||
/// Maps actual ui scale back to display values in percent.
|
||||
fn ui_scale_to_display(scale: f64) -> f64 {
|
||||
scale * 100.
|
||||
}
|
||||
|
||||
@@ -338,6 +338,9 @@ pub enum FrontendMessage {
|
||||
width: f64,
|
||||
height: f64,
|
||||
},
|
||||
UpdateUIScale {
|
||||
scale: f64,
|
||||
},
|
||||
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
RenderOverlays {
|
||||
|
||||
@@ -17,4 +17,5 @@ pub enum PreferencesMessage {
|
||||
ModifyLayout { zoom_with_scroll: bool },
|
||||
GraphWireStyle { style: GraphWireStyle },
|
||||
ViewportZoomWheelRate { rate: f64 },
|
||||
UIScale { scale: f64 },
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::consts::VIEWPORT_ZOOM_WHEEL_RATE;
|
||||
use crate::consts::{UI_SCALE_DEFAULT, VIEWPORT_ZOOM_WHEEL_RATE};
|
||||
use crate::messages::input_mapper::key_mapping::MappingVariant;
|
||||
use crate::messages::portfolio::document::utility_types::wires::GraphWireStyle;
|
||||
use crate::messages::preferences::SelectionMode;
|
||||
@@ -14,6 +14,7 @@ pub struct PreferencesMessageHandler {
|
||||
pub brush_tool: bool,
|
||||
pub graph_wire_style: GraphWireStyle,
|
||||
pub viewport_zoom_wheel_rate: f64,
|
||||
pub ui_scale: f64,
|
||||
}
|
||||
|
||||
impl PreferencesMessageHandler {
|
||||
@@ -42,6 +43,7 @@ impl Default for PreferencesMessageHandler {
|
||||
brush_tool: false,
|
||||
graph_wire_style: GraphWireStyle::default(),
|
||||
viewport_zoom_wheel_rate: VIEWPORT_ZOOM_WHEEL_RATE,
|
||||
ui_scale: UI_SCALE_DEFAULT,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,6 +63,7 @@ impl MessageHandler<PreferencesMessage, ()> for PreferencesMessageHandler {
|
||||
responses.add(PreferencesMessage::ModifyLayout {
|
||||
zoom_with_scroll: self.zoom_with_scroll,
|
||||
});
|
||||
responses.add(FrontendMessage::UpdateUIScale { scale: self.ui_scale });
|
||||
}
|
||||
PreferencesMessage::ResetToDefaults => {
|
||||
refresh_dialog(responses);
|
||||
@@ -99,6 +102,10 @@ impl MessageHandler<PreferencesMessage, ()> for PreferencesMessageHandler {
|
||||
PreferencesMessage::ViewportZoomWheelRate { rate } => {
|
||||
self.viewport_zoom_wheel_rate = rate;
|
||||
}
|
||||
PreferencesMessage::UIScale { scale } => {
|
||||
self.ui_scale = scale;
|
||||
responses.add(FrontendMessage::UpdateUIScale { scale: self.ui_scale });
|
||||
}
|
||||
}
|
||||
|
||||
responses.add(FrontendMessage::TriggerSavePreferences { preferences: self.clone() });
|
||||
|
||||
Reference in New Issue
Block a user