forked from 1b-agent/opencadstudio-upstream
Annotative as a Yes/No list in Properties
The Annotative row of text, MText, blocks, leaders, hatches and dimensions is a Yes/No list, as the reference shows it; choosing a value drives the same per-object annotative toggle as before. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
1 parent
8b3c24927d
commit
bdcd24179b
2 files changed
+42
-8
No files matched your search
+12
-8
@@ -2160,13 +2160,12 @@ impl OpenCADStudio {
|
|||||||
// remaining style-only types stay read-only.
|
// remaining style-only types stay read-only.
|
||||||
if anno_field == "annotative" {
|
if anno_field == "annotative" {
|
||||||
match entity {
|
match entity {
|
||||||
|
// The reference offers Yes/No; the choice
|
||||||
|
// drives the same per-object toggle.
|
||||||
acadrust::EntityType::MText(t) => set_row_value(
|
acadrust::EntityType::MText(t) => set_row_value(
|
||||||
&mut sections,
|
&mut sections,
|
||||||
"annotative",
|
"annotative",
|
||||||
crate::scene::model::object::PropValue::BoolToggle {
|
yes_no_choice(t.is_annotative),
|
||||||
field: "is_annotative",
|
|
||||||
value: t.is_annotative,
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
acadrust::EntityType::Dimension(
|
acadrust::EntityType::Dimension(
|
||||||
acadrust::entities::Dimension::Arc(_),
|
acadrust::entities::Dimension::Arc(_),
|
||||||
@@ -2190,10 +2189,7 @@ impl OpenCADStudio {
|
|||||||
| acadrust::EntityType::Dimension(_) => set_row_value(
|
| acadrust::EntityType::Dimension(_) => set_row_value(
|
||||||
&mut sections,
|
&mut sections,
|
||||||
"annotative",
|
"annotative",
|
||||||
crate::scene::model::object::PropValue::BoolToggle {
|
yes_no_choice(is_anno),
|
||||||
field: "annotative_ctx",
|
|
||||||
value: is_anno,
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
_ => set_row(
|
_ => set_row(
|
||||||
&mut sections,
|
&mut sections,
|
||||||
@@ -3711,6 +3707,14 @@ fn set_row(sections: &mut [crate::scene::model::object::PropSection], field: &st
|
|||||||
/// A dimensional constraint's Properties as the reference shows them: the
|
/// A dimensional constraint's Properties as the reference shows them: the
|
||||||
/// Constraint rows, then only the text rotation for a dynamic dimension
|
/// Constraint rows, then only the text rotation for a dynamic dimension
|
||||||
/// and the full dimension sections for an annotational one.
|
/// and the full dimension sections for an annotational one.
|
||||||
|
/// A Yes/No list row, as the reference shows on/off object properties.
|
||||||
|
fn yes_no_choice(flag: bool) -> crate::scene::model::object::PropValue {
|
||||||
|
crate::scene::model::object::PropValue::Choice {
|
||||||
|
selected: if flag { t!("Yes") } else { t!("No") }.into_owned(),
|
||||||
|
options: vec![t!("Yes").into_owned(), t!("No").into_owned()],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn dynamic_dimension_sections(
|
fn dynamic_dimension_sections(
|
||||||
scene: &crate::scene::Scene,
|
scene: &crate::scene::Scene,
|
||||||
handle: Handle,
|
handle: Handle,
|
||||||
|
|||||||
@@ -2193,6 +2193,36 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
|||||||
}
|
}
|
||||||
let i = self.active_tab;
|
let i = self.active_tab;
|
||||||
let handles = self.property_target_handles(i);
|
let handles = self.property_target_handles(i);
|
||||||
|
// The Annotative Yes/No list drives the per-object annotative toggle
|
||||||
|
// (MTEXT's own flag, the annotation context for the rest).
|
||||||
|
if field == "annotative" {
|
||||||
|
let wanted = value == t!("Yes").as_ref() || value.eq_ignore_ascii_case("yes");
|
||||||
|
let Some(handle) = handles.first().copied() else {
|
||||||
|
return Task::none();
|
||||||
|
};
|
||||||
|
let document = &self.tabs[i].scene.document;
|
||||||
|
let (toggle, current) = match document.get_entity(handle) {
|
||||||
|
Some(acadrust::EntityType::MText(text)) => ("is_annotative", text.is_annotative),
|
||||||
|
Some(entity) => (
|
||||||
|
"annotative_ctx",
|
||||||
|
crate::scene::annotative::is_annotative(document, entity)
|
||||||
|
|| match entity {
|
||||||
|
acadrust::EntityType::Dimension(dimension) => {
|
||||||
|
crate::scene::annotative::dim_style_is_annotative(
|
||||||
|
document,
|
||||||
|
&dimension.base().style_name,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
_ => false,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
None => return Task::none(),
|
||||||
|
};
|
||||||
|
if wanted != current {
|
||||||
|
return self.update(Message::PropBoolToggle(toggle));
|
||||||
|
}
|
||||||
|
return Task::none();
|
||||||
|
}
|
||||||
|
|
||||||
if !handles.is_empty() {
|
if !handles.is_empty() {
|
||||||
if matches!(
|
if matches!(
|
||||||
|
|||||||
Reference in new issue
Block a user