From b89689cd038290fc7913ea45d41cf3af25314a70 Mon Sep 17 00:00:00 2001 From: Karim Jerbi Date: Sun, 18 Oct 2026 12:25:29 +0100 Subject: [PATCH] refactor(statusbar): bundle view inputs --- src/app/view/mod.rs | 74 +++++++++++---------- src/ui/statusbar/mod.rs | 144 +++++++++++++++++++++++++--------------- 2 files changed, 129 insertions(+), 89 deletions(-) diff --git a/src/app/view/mod.rs b/src/app/view/mod.rs index 8cb6d833e..d6f4696ae 100644 --- a/src/app/view/mod.rs +++ b/src/app/view/mod.rs @@ -2541,40 +2541,46 @@ bg={bg_ms:.1}ms n={view_count}" }; self.status_bar.view( &self.snapper, - self.ortho_mode, - self.polar_mode, - self.polar_increment_deg, - self.dyn_input, - self.snapper.otrack_enabled, - self.isometric_drafting, - self.iso_plane, - layout_names, - block_tabs, - &tab.scene.current_layout, - active_block, - tab.is_start, - self.layout_rename_state.as_ref(), - tab.scene.first_viewport_scale(), - tab.scene.viewport_count(), - tab.scene.active_viewport.is_some(), - self.show_layout_tabs, - tab.scene.annotation_scale, - scale_pill_enabled, - tab.scene.annotation_all_visible(), - self.annotation_auto_scale > 0, - tab.scene.viewport_annotation_scale_synced(), - tab.scene.document.header.lineweight_display, - cursor_coord, - coords_mode, - last_coord, - picking, - self.clean_screen, - tab.scene.document.header.linear_unit_format, - tab.scene.is_isolation_active(), - tab.scene.transparency_display, - self.quick_properties, - tab.scene.selection_filter_active(), - self.selection_cycling, + crate::ui::statusbar::StatusBarLayoutState { + layouts: layout_names, + block_tabs, + current_layout: &tab.scene.current_layout, + active_block, + is_start: tab.is_start, + rename_state: self.layout_rename_state.as_ref(), + viewport_scale: tab.scene.first_viewport_scale(), + viewport_count: tab.scene.viewport_count(), + in_mspace: tab.scene.active_viewport.is_some(), + show_layout_tabs: self.show_layout_tabs, + annotation_scale: tab.scene.annotation_scale, + scale_pill_enabled, + annotation_all_visible: tab.scene.annotation_all_visible(), + annotation_auto_add: self.annotation_auto_scale > 0, + viewport_scale_synced: tab.scene.viewport_annotation_scale_synced(), + lineweight_display: tab.scene.document.header.lineweight_display, + }, + crate::ui::statusbar::StatusBarModes { + ortho_mode: self.ortho_mode, + polar_mode: self.polar_mode, + polar_increment_deg: self.polar_increment_deg, + dyn_input: self.dyn_input, + otrack: self.snapper.otrack_enabled, + isometric_drafting: self.isometric_drafting, + iso_plane: self.iso_plane, + clean_screen: self.clean_screen, + linear_format: tab.scene.document.header.linear_unit_format, + isolation_active: tab.scene.is_isolation_active(), + transparency_display: tab.scene.transparency_display, + quick_properties: self.quick_properties, + selection_filter_active: tab.scene.selection_filter_active(), + selection_cycling: self.selection_cycling, + }, + crate::ui::statusbar::StatusBarReadout { + cursor_world: cursor_coord, + coords_mode, + last_point: last_coord, + picking, + }, &self.statusbar_config, status_menu_data, tab.scene diff --git a/src/ui/statusbar/mod.rs b/src/ui/statusbar/mod.rs index 9afa4d8bc..ba897d710 100644 --- a/src/ui/statusbar/mod.rs +++ b/src/ui/statusbar/mod.rs @@ -52,6 +52,52 @@ pub struct StatusMenuData<'a> { pub tooltip_hidden: bool, } +/// Drawing/layout inputs used to build the status bar's layout and scale controls. +pub struct StatusBarLayoutState<'a> { + pub layouts: Arc>, + pub block_tabs: Vec, + pub current_layout: &'a str, + pub active_block: Option, + pub is_start: bool, + pub rename_state: Option<&'a (String, String)>, + pub viewport_scale: Option, + pub viewport_count: usize, + pub in_mspace: bool, + pub show_layout_tabs: bool, + pub annotation_scale: f32, + pub scale_pill_enabled: bool, + pub annotation_all_visible: bool, + pub annotation_auto_add: bool, + pub viewport_scale_synced: Option, + pub lineweight_display: bool, +} + +/// Drafting modes and document settings represented by status bar controls. +pub struct StatusBarModes { + pub ortho_mode: bool, + pub polar_mode: bool, + pub polar_increment_deg: f32, + pub dyn_input: bool, + pub otrack: bool, + pub isometric_drafting: bool, + pub iso_plane: crate::app::settings::IsoPlane, + pub clean_screen: bool, + pub linear_format: i16, + pub isolation_active: bool, + pub transparency_display: bool, + pub quick_properties: bool, + pub selection_filter_active: bool, + pub selection_cycling: bool, +} + +/// Cursor coordinate readout inputs. +pub struct StatusBarReadout { + pub cursor_world: glam::DVec3, + pub coords_mode: i16, + pub last_point: Option, + pub picking: bool, +} + #[derive(Clone, Default)] pub struct StatusBar { #[allow(dead_code)] @@ -68,61 +114,9 @@ impl StatusBar { pub fn view<'a>( &'a self, snapper: &'a Snapper, - ortho_mode: bool, - polar_mode: bool, - polar_increment_deg: f32, - dyn_input: bool, - otrack: bool, - isometric_drafting: bool, - iso_plane: crate::app::settings::IsoPlane, - layouts: Arc>, - block_tabs: Vec, - current_layout: &'a str, - active_block: Option, - // Start/welcome view has no drawing to own layouts. - is_start: bool, - // If `Some((original, edit_value))`, the named tab shows a text input. - rename_state: Option<&'a (String, String)>, - // Scale of the first user viewport in the active paper layout. - viewport_scale: Option, - // Number of user viewports in the current paper layout (0 = model space). - viewport_count: usize, - // True when the user is editing inside a paper-space viewport (MSPACE). - in_mspace: bool, - // Whether the layout tabs (Model/Paper) are visible (LAYOUTTAB). - show_layout_tabs: bool, - // Current annotation scale for model space (1.0 = 1:1, 50.0 = 1:50, etc.). - annotation_scale: f32, - // True when the scale pill is interactive (always model space; paper space only when a viewport is active/selected). - scale_pill_enabled: bool, - annotation_all_visible: bool, - annotation_auto_add: bool, - viewport_scale_synced: Option, - // LWDISPLAY header flag — controls lineweight visibility in the viewport. - lineweight_display: bool, - // Live cursor position in model coordinates, for the coordinate readout. - cursor_world: glam::DVec3, - // $COORDS readout mode: 0 = static (updates only on a pick), 1 = live - // absolute, 2 = polar (distance, - // True while a command is prompting for a point (enables the polar readout). - picking: bool, - // True while clean-screen mode hides the ribbon and side panels. - clean_screen: bool, - // LUNITS — how lengths are written, for the units pill. - linear_format: i16, - // True when objects are hidden by Isolate / Hide. - isolation_active: bool, - // Whether entity transparency is shown (Transparency pill state). - transparency_display: bool, - // Whether the Quick Properties floating panel is enabled. - quick_properties: bool, - // True when the selection filter is excluding at least one type. - selection_filter_active: bool, - // Whether selection cycling is enabled. - selection_cycling: bool, + layout: StatusBarLayoutState<'a>, + modes: StatusBarModes, + readout: StatusBarReadout, // Which pills the user has chosen to show on the bar. config: &'a StatusBarConfig, menu_data: StatusMenuData<'a>, @@ -140,6 +134,46 @@ impl StatusBar { gpu_status: &'a crate::scene::pipeline::GpuStatus, spacemouse: Option>, ) -> Element<'a, Message> { + let StatusBarLayoutState { + layouts, + block_tabs, + current_layout, + active_block, + is_start, + rename_state, + viewport_scale, + viewport_count, + in_mspace, + show_layout_tabs, + annotation_scale, + scale_pill_enabled, + annotation_all_visible, + annotation_auto_add, + viewport_scale_synced, + lineweight_display, + } = layout; + let StatusBarModes { + ortho_mode, + polar_mode, + polar_increment_deg, + dyn_input, + otrack, + isometric_drafting, + iso_plane, + clean_screen, + linear_format, + isolation_active, + transparency_display, + quick_properties, + selection_filter_active, + selection_cycling, + } = modes; + let StatusBarReadout { + cursor_world, + coords_mode, + last_point, + picking, + } = readout; let StatusMenuData { layout_names, polar_custom_input,