forked from 1b-agent/opencadstudio-upstream
feat(statusbar): customizable pills with coordinates and clean screen
Add a customization menu (far-right handle) that lists every status-bar pill with a check mark; toggling a row shows or hides that pill, and the choice persists across sessions in the config dir. New pills: - Coordinates: live cursor readout (re-adds the model-space world offset so it shows true drawing coordinates), updated on every move rather than only while a command is active. - Clean Screen: hide the ribbon and side panels for a full canvas. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
edc8cbc969
commit
d829f80a04
7 files changed
+482
-33
No files matched your search
@@ -171,6 +171,12 @@ pub(super) struct OpenCADStudio {
|
||||
snapper: Snapper,
|
||||
snap_popup_open: bool,
|
||||
scale_popup_open: bool,
|
||||
/// True while the status-bar customization menu is open.
|
||||
statusbar_menu_open: bool,
|
||||
/// Clean-screen mode: hide ribbon and side panels for a full canvas.
|
||||
clean_screen: bool,
|
||||
/// Which status-bar pills the user has chosen to show (persisted).
|
||||
statusbar_config: crate::ui::statusbar_config::StatusBarConfig,
|
||||
/// Whether Tangent snap was enabled before a tangent-pick command started.
|
||||
pre_cmd_tangent: Option<bool>,
|
||||
/// Orthogonal drawing constraint (F8): constrains picks to 0°/90°/180°/270°.
|
||||
@@ -732,6 +738,14 @@ pub enum Message {
|
||||
ToggleScalePopup,
|
||||
/// Close the scale picker popup.
|
||||
CloseScalePopup,
|
||||
/// Toggle the status-bar customization menu open/closed.
|
||||
ToggleStatusBarMenu,
|
||||
/// Close the status-bar customization menu.
|
||||
CloseStatusBarMenu,
|
||||
/// Show/hide a single status-bar pill.
|
||||
ToggleStatusPill(crate::ui::statusbar_config::StatusPill),
|
||||
/// Toggle clean-screen mode (hide ribbon + side panels).
|
||||
ToggleCleanScreen,
|
||||
/// Toggle dynamic input overlay (F12).
|
||||
ToggleDynInput,
|
||||
/// Toggle object snap tracking (F11).
|
||||
@@ -1188,6 +1202,9 @@ impl OpenCADStudio {
|
||||
snapper: Snapper::default(),
|
||||
snap_popup_open: false,
|
||||
scale_popup_open: false,
|
||||
statusbar_menu_open: false,
|
||||
statusbar_config: crate::ui::statusbar_config::StatusBarConfig::load(),
|
||||
clean_screen: false,
|
||||
pre_cmd_tangent: None,
|
||||
ortho_mode: false,
|
||||
polar_mode: false,
|
||||
|
||||
@@ -2130,6 +2130,39 @@ impl OpenCADStudio {
|
||||
return Task::none();
|
||||
}
|
||||
|
||||
// Keep the coordinate readout live on every move, even with no
|
||||
// active command. When a command is running the snap path below
|
||||
// overwrites this with the snapped point.
|
||||
{
|
||||
let bounds = iced::Rectangle {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
width: vp_size.0,
|
||||
height: vp_size.1,
|
||||
};
|
||||
let paper = if let Some(ref ucs) = self.tabs[i].active_ucs {
|
||||
let origin = glam::Vec3::new(
|
||||
ucs.origin.x as f32,
|
||||
ucs.origin.y as f32,
|
||||
ucs.origin.z as f32,
|
||||
);
|
||||
let normal = ucs_z_axis(ucs);
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.camera
|
||||
.borrow()
|
||||
.pick_on_plane(p, bounds, normal, origin)
|
||||
} else {
|
||||
self.tabs[i]
|
||||
.scene
|
||||
.camera
|
||||
.borrow()
|
||||
.pick_on_target_plane(p, bounds)
|
||||
};
|
||||
let world = self.tabs[i].scene.paper_to_model(paper);
|
||||
self.tabs[i].last_cursor_world = world;
|
||||
}
|
||||
|
||||
if self.tabs[i].active_cmd.is_some() {
|
||||
let (vw, vh) = vp_size;
|
||||
let bounds = iced::Rectangle {
|
||||
@@ -3530,6 +3563,23 @@ impl OpenCADStudio {
|
||||
self.scale_popup_open = false;
|
||||
Task::none()
|
||||
}
|
||||
Message::ToggleStatusBarMenu => {
|
||||
self.statusbar_menu_open ^= true;
|
||||
Task::none()
|
||||
}
|
||||
Message::CloseStatusBarMenu => {
|
||||
self.statusbar_menu_open = false;
|
||||
Task::none()
|
||||
}
|
||||
Message::ToggleStatusPill(pill) => {
|
||||
// Keep the menu open so several pills can be toggled in a row.
|
||||
self.statusbar_config.toggle(pill);
|
||||
Task::none()
|
||||
}
|
||||
Message::ToggleCleanScreen => {
|
||||
self.clean_screen ^= true;
|
||||
Task::none()
|
||||
}
|
||||
Message::ToggleSnap(t) => {
|
||||
self.snapper.toggle(t);
|
||||
Task::none()
|
||||
|
||||
+37
-6
@@ -1057,7 +1057,7 @@ impl OpenCADStudio {
|
||||
// Replace the properties panel with a Recent Documents list there.
|
||||
let properties_el: Element<'_, Message> = if tab.is_start {
|
||||
recent_files_panel(&self.app_menu.recent)
|
||||
} else if self.show_properties {
|
||||
} else if self.show_properties && !self.clean_screen {
|
||||
tab.properties.view()
|
||||
} else {
|
||||
Space::new().into()
|
||||
@@ -1100,11 +1100,16 @@ impl OpenCADStudio {
|
||||
.height(Fill);
|
||||
|
||||
let main_ui = container({
|
||||
let mut col = column![self.ribbon.view(
|
||||
is_paper,
|
||||
self.tabs[self.active_tab].history.undo_stack.len(),
|
||||
self.tabs[self.active_tab].history.redo_stack.len(),
|
||||
)];
|
||||
// Clean-screen mode drops the ribbon for a full-canvas view; the
|
||||
// status bar stays so the mode can be toggled back off.
|
||||
let mut col = column![];
|
||||
if !self.clean_screen {
|
||||
col = col.push(self.ribbon.view(
|
||||
is_paper,
|
||||
self.tabs[self.active_tab].history.undo_stack.len(),
|
||||
self.tabs[self.active_tab].history.redo_stack.len(),
|
||||
));
|
||||
}
|
||||
if self.show_file_tabs {
|
||||
col = col.push(doc_tab_bar(&self.tabs, self.active_tab));
|
||||
}
|
||||
@@ -1114,6 +1119,22 @@ impl OpenCADStudio {
|
||||
let scale_pill_enabled = is_model
|
||||
|| tab.scene.active_viewport.is_some()
|
||||
|| tab.scene.has_selected_viewport();
|
||||
// The cursor is tracked in local render space; re-add the
|
||||
// model-space world offset so the readout shows true
|
||||
// drawing coordinates (paper space carries no offset).
|
||||
let cursor_coord = {
|
||||
let lc = tab.last_cursor_world;
|
||||
if is_model {
|
||||
let wo = tab.scene.world_offset;
|
||||
glam::Vec3::new(
|
||||
lc.x + wo[0] as f32,
|
||||
lc.y + wo[1] as f32,
|
||||
lc.z + wo[2] as f32,
|
||||
)
|
||||
} else {
|
||||
lc
|
||||
}
|
||||
};
|
||||
self.status_bar.view(
|
||||
&self.snapper,
|
||||
self.snap_popup_open,
|
||||
@@ -1134,6 +1155,9 @@ impl OpenCADStudio {
|
||||
self.scale_popup_open,
|
||||
scale_pill_enabled,
|
||||
tab.scene.document.header.lineweight_display,
|
||||
cursor_coord,
|
||||
self.clean_screen,
|
||||
&self.statusbar_config,
|
||||
)
|
||||
})
|
||||
.width(Fill)
|
||||
@@ -1169,6 +1193,12 @@ impl OpenCADStudio {
|
||||
iced::widget::Space::new().width(0).height(0).into()
|
||||
};
|
||||
|
||||
let statusbar_menu_layer: Element<'_, Message> = if self.statusbar_menu_open {
|
||||
crate::ui::statusbar_menu::statusbar_menu_overlay(&self.statusbar_config)
|
||||
} else {
|
||||
iced::widget::Space::new().width(0).height(0).into()
|
||||
};
|
||||
|
||||
let dropdown_layer: Element<'_, Message> = self
|
||||
.ribbon
|
||||
.dropdown_overlay(
|
||||
@@ -1204,6 +1234,7 @@ impl OpenCADStudio {
|
||||
self.app_menu.view(),
|
||||
snap_layer,
|
||||
scale_layer,
|
||||
statusbar_menu_layer,
|
||||
dropdown_layer,
|
||||
layout_ctx_layer,
|
||||
qselect_layer,
|
||||
|
||||
Reference in new issue
Block a user