forked from 1b-agent/opencadstudio-upstream
Merge PR #1086: add collapsible property sections
This commit is contained in:
commit
b0c0cbdf4a
4 files changed
+61
-4
No files matched your search
@@ -387,6 +387,10 @@ pub(super) struct OpenCADStudio {
|
||||
/// though the three factors are currently equal — the user unchecked the
|
||||
/// "Uniform scale" box for them (#427). Keyed by entity handle.
|
||||
props_asym_scale: std::collections::HashSet<u64>,
|
||||
/// Collapsed Properties-panel section titles. This belongs to the app,
|
||||
/// rather than an individual document tab, so the same view preference is
|
||||
/// used by every currently open drawing/project.
|
||||
collapsed_property_sections: rustc_hash::FxHashSet<String>,
|
||||
/// Which Start-page section is shown when the page is too narrow for all
|
||||
/// three side by side and falls back to a tab bar.
|
||||
start_section: StartSection,
|
||||
@@ -2558,6 +2562,8 @@ pub enum Message {
|
||||
/// Toggle a collapsed coordinate group ("Position", "Scale", …) open or
|
||||
/// closed in the Properties panel, keyed `section:base`.
|
||||
PropGroupToggle(String),
|
||||
/// Toggle an entire Properties-panel section, keyed by its title.
|
||||
PropSectionToggle(String),
|
||||
/// Toggle the editable-dropdown (block Name) option list open/closed.
|
||||
PropEditChoiceToggle,
|
||||
/// User is typing in a block-attribute value field (live buffer update),
|
||||
@@ -3314,6 +3320,7 @@ impl OpenCADStudio {
|
||||
discussions: Vec::new(),
|
||||
discussions_loading: false,
|
||||
props_asym_scale: std::collections::HashSet::new(),
|
||||
collapsed_property_sections: rustc_hash::FxHashSet::default(),
|
||||
start_section: StartSection::default(),
|
||||
start_action_w: std::sync::Arc::new(std::sync::atomic::AtomicU32::new(0)),
|
||||
history_content: iced::widget::text_editor::Content::new(),
|
||||
|
||||
@@ -47,6 +47,10 @@ impl OpenCADStudio {
|
||||
// Expanded coordinate groups persist across rebuilds AND selection
|
||||
// changes — it's a per-user view preference, not per-entity state.
|
||||
let expanded_groups = std::mem::take(&mut self.tabs[i].properties.expanded_groups);
|
||||
// Section state belongs to the app, not a drawing tab, so the user's
|
||||
// collapsed sections carry across every currently open drawing/project.
|
||||
// The empty app-level default keeps a first-run palette fully expanded.
|
||||
let collapsed_sections = self.collapsed_property_sections.clone();
|
||||
// Which entities the previous panel was built for — an uncommitted
|
||||
// edit buffer only survives a rebuild for the *same* selection.
|
||||
let prev_handles = std::mem::take(&mut self.tabs[i].properties.source_handles);
|
||||
@@ -2278,6 +2282,7 @@ impl OpenCADStudio {
|
||||
None
|
||||
};
|
||||
panel.expanded_groups = expanded_groups;
|
||||
panel.collapsed_sections = collapsed_sections;
|
||||
panel.source_handles = new_handles;
|
||||
panel.prop_vertex = prop_vertex;
|
||||
panel.prop_vertex_indicator_active = prop_vertex_indicator_active;
|
||||
|
||||
@@ -5104,6 +5104,20 @@ impl OpenCADStudio {
|
||||
Task::none()
|
||||
}
|
||||
|
||||
Message::PropSectionToggle(title) => {
|
||||
let sections = &mut self.collapsed_property_sections;
|
||||
if !sections.remove(&title) {
|
||||
sections.insert(title);
|
||||
}
|
||||
// Keep already-built panels in other open documents in sync,
|
||||
// rather than waiting for each one to rebuild on selection.
|
||||
let sections = self.collapsed_property_sections.clone();
|
||||
for tab in &mut self.tabs {
|
||||
tab.properties.collapsed_sections = sections.clone();
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
|
||||
Message::PropEditChoiceToggle => {
|
||||
let panel = &mut self.tabs[self.active_tab].properties;
|
||||
panel.edit_choice_open = !panel.edit_choice_open;
|
||||
|
||||
Reference in new issue
Block a user