forked from 1b-agent/opencadstudio-upstream
refactor(properties): entity property groups return Vec<PropSection>
Groundwork for making the Properties panel conform to the per-entity group/row spec (PROPERTIES.md). The panel already renders a Vec of sections, but each entity could only express a single geometry section. Change PropertyEditable::geometry_properties (and the EntityTypeOps enum dispatch) to return Vec<PropSection>, update the two impl macros, and flatten in properties_sectioned so the panel shows [General] + the entity's groups. Every entity builder is wrapped to return its existing section as a one-element Vec — pure mechanical change, no rows or titles altered, panel output identical. Enables Phase 2: rewriting each entity's groups/rows to match the spec. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
8164e14a19
commit
b2b2bfb246
31 files changed
+147
-139
No files matched your search
@@ -246,7 +246,7 @@ impl Scene {
|
||||
.filter_map(|h| self.document.get_entity(h))
|
||||
.find(|e| entity_type_name(e) == t);
|
||||
if let Some(sample) = sample {
|
||||
if let Some(section) = sample.geometry_properties(&text_style_names) {
|
||||
for section in sample.geometry_properties(&text_style_names) {
|
||||
for prop in section.props {
|
||||
// Skip rows that don't sensibly compare via
|
||||
// `entity_property_value` (read-only labels are
|
||||
@@ -284,8 +284,11 @@ impl Scene {
|
||||
.iter()
|
||||
.map(|s| s.name.clone())
|
||||
.collect();
|
||||
let section = entity.geometry_properties(&text_style_names)?;
|
||||
let prop = section.props.into_iter().find(|p| p.field == field)?;
|
||||
let prop = entity
|
||||
.geometry_properties(&text_style_names)
|
||||
.into_iter()
|
||||
.flat_map(|s| s.props)
|
||||
.find(|p| p.field == field)?;
|
||||
Some(match prop.value {
|
||||
PropValue::ReadOnly(s) | PropValue::EditText(s) => s,
|
||||
PropValue::LayerChoice(s) => s,
|
||||
|
||||
@@ -17,11 +17,14 @@ pub fn properties_sectioned(
|
||||
entity: &EntityType,
|
||||
text_style_names: &[String],
|
||||
) -> Vec<PropSection> {
|
||||
let general = properties::general_section(entity);
|
||||
let geometry = entity
|
||||
.geometry_properties(text_style_names)
|
||||
.unwrap_or_else(|| properties::fallback_properties(handle, entity));
|
||||
vec![general, geometry]
|
||||
let mut sections = vec![properties::general_section(entity)];
|
||||
let groups = entity.geometry_properties(text_style_names);
|
||||
if groups.is_empty() {
|
||||
sections.push(properties::fallback_properties(handle, entity));
|
||||
} else {
|
||||
sections.extend(groups);
|
||||
}
|
||||
sections
|
||||
}
|
||||
|
||||
pub fn apply_common_prop(entity: &mut EntityType, field: &str, value: &str) {
|
||||
|
||||
Reference in new issue
Block a user