feat: add style selector comboboxes to Annotate ribbon tab
New StyleComboGroup RibbonItem renders a dropdown combobox for selecting text style, dimension style, multileader style, or table style. Ribbon groups in the Annotate tab now match the reference layout: each group has a large tool on the left and a style combobox with tool rows on the right. Each combobox shows the active style name, opens a scrollable item list on click, and has an optional "Manage…" row that fires the style manager command (STYLE / DIMSTYLE / MLEADERSTYLE / TABLESTYLE). Style state is synced from the document on every layer refresh via sync_ribbon_styles(). RibbonStyleChanged message propagates selections back to the acadrust document header and the active_mleader_style field. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
08b9a21d31
commit
bd68114bde
7 changed files with 431 additions and 36 deletions
|
|
@ -39,5 +39,53 @@ impl H7CAD {
|
|||
.collect();
|
||||
self.tabs[i].layers.sync_linetypes(lt_items.clone());
|
||||
self.ribbon.set_available_linetypes(lt_items);
|
||||
self.sync_ribbon_styles();
|
||||
}
|
||||
|
||||
pub(super) fn sync_ribbon_styles(&mut self) {
|
||||
let i = self.active_tab;
|
||||
let doc = &self.tabs[i].scene.document;
|
||||
|
||||
let text_names: Vec<String> = doc.text_styles.iter().map(|s| s.name.clone()).collect();
|
||||
let active_text = doc.header.current_text_style_name.clone();
|
||||
let active_text = if text_names.contains(&active_text) { active_text } else {
|
||||
text_names.first().cloned().unwrap_or_else(|| "Standard".to_string())
|
||||
};
|
||||
|
||||
let dim_names: Vec<String> = doc.dim_styles.iter().map(|s| s.name.clone()).collect();
|
||||
let active_dim = doc.header.current_dimstyle_name.clone();
|
||||
let active_dim = if dim_names.contains(&active_dim) { active_dim } else {
|
||||
dim_names.first().cloned().unwrap_or_else(|| "Standard".to_string())
|
||||
};
|
||||
|
||||
let mleader_names: Vec<String> = doc.objects.values().filter_map(|o| {
|
||||
if let acadrust::objects::ObjectType::MultiLeaderStyle(mls) = o {
|
||||
Some(mls.name.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}).collect();
|
||||
let active_mleader = self.tabs[i].active_mleader_style.clone();
|
||||
let active_mleader = if mleader_names.contains(&active_mleader) { active_mleader } else {
|
||||
mleader_names.first().cloned().unwrap_or_else(|| "Standard".to_string())
|
||||
};
|
||||
|
||||
let table_names: Vec<String> = doc.objects.values().filter_map(|o| {
|
||||
if let acadrust::objects::ObjectType::TableStyle(ts) = o {
|
||||
Some(ts.name.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}).collect();
|
||||
let active_table = table_names.first().cloned().unwrap_or_else(|| "Standard".to_string());
|
||||
|
||||
let active_mleader2 = active_mleader.clone();
|
||||
let active_table2 = active_table.clone();
|
||||
self.ribbon.set_styles(
|
||||
text_names, &active_text,
|
||||
dim_names, &active_dim,
|
||||
mleader_names, &active_mleader2,
|
||||
table_names, &active_table2,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,6 +295,8 @@ pub enum Message {
|
|||
RibbonLinetypeChanged(String),
|
||||
/// User changed the active lineweight in the Properties toolbar.
|
||||
RibbonLineweightChanged(LineWeight),
|
||||
/// User selected a style from a style combobox in the ribbon.
|
||||
RibbonStyleChanged { key: crate::modules::StyleKey, name: String },
|
||||
|
||||
// ── Properties panel ──────────────────────────────────────────────────
|
||||
/// User selected a layer from the layer pick_list in the Properties panel.
|
||||
|
|
|
|||
|
|
@ -1929,6 +1929,43 @@ impl H7CAD {
|
|||
Task::none()
|
||||
}
|
||||
|
||||
Message::RibbonStyleChanged { key, name } => {
|
||||
use crate::modules::StyleKey;
|
||||
self.ribbon.close_dropdown();
|
||||
match key {
|
||||
StyleKey::TextStyle => {
|
||||
self.ribbon.active_text_style = name.clone();
|
||||
let i = self.active_tab;
|
||||
let found = self.tabs[i].scene.document.text_styles.iter()
|
||||
.find(|s| s.name == name)
|
||||
.map(|ts| ts.handle);
|
||||
if let Some(h) = found {
|
||||
self.tabs[i].scene.document.header.current_text_style_handle = h;
|
||||
self.tabs[i].scene.document.header.current_text_style_name = name;
|
||||
}
|
||||
}
|
||||
StyleKey::DimStyle => {
|
||||
self.ribbon.active_dim_style = name.clone();
|
||||
let i = self.active_tab;
|
||||
let found = self.tabs[i].scene.document.dim_styles.get(&name)
|
||||
.map(|ds| ds.handle);
|
||||
if let Some(h) = found {
|
||||
self.tabs[i].scene.document.header.current_dimstyle_handle = h;
|
||||
self.tabs[i].scene.document.header.current_dimstyle_name = name;
|
||||
}
|
||||
}
|
||||
StyleKey::MLeaderStyle => {
|
||||
self.ribbon.active_mleader_style = name.clone();
|
||||
let i = self.active_tab;
|
||||
self.tabs[i].active_mleader_style = name;
|
||||
}
|
||||
StyleKey::TableStyle => {
|
||||
self.ribbon.active_table_style = name;
|
||||
}
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
|
||||
Message::PropLayerChanged(layer) => {
|
||||
let i = self.active_tab;
|
||||
let handles = self.property_target_handles(i);
|
||||
|
|
|
|||
Loading…
Reference in a new issue