refactor(props): key active fields by a typed enum, not a sentinel string
The \\\x01attr\\x01…\ sentinel-prefixed string was used to tell geometry fields (\&'static str\ names) apart from block attribute rows (runtime tags) in \ctive_field\ and \dit_buf\. Replace it with a \FieldKey\ enum (\Geom(&'static str)\ / \Attr(String)\), so the two namespaces can't collide by construction: \dit_buf\ is now \HashMap<FieldKey, String>\, \ctive_field\ is \Option<FieldKey>\, and the sentinel decoding in \ctive_key_id\ is replaced by \FieldKey::widget_id\. While touching the key plumbing, replace \prop_field_key_for_id\'s per-event scan of every section x prop (with a \String\ format per candidate) with an O(1) precomputed \HashMap<iced::widget::Id, FieldKey>\ (\ield_key_by_id\), built once in \ efresh_properties\ alongside the sections — and rebuilt after \make_sections_read_only\ so rows demoted to read-only stop mapping. \PropSyncActive\ now does a single map lookup per event.
This commit is contained in:
parent
eead4eb5f0
commit
c3e3132b39
4 changed files with 114 additions and 83 deletions
|
|
@ -2005,7 +2005,10 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
|||
// selected inserts to the picked definition. A stale
|
||||
// typed value in the text buffer would mask the pick,
|
||||
// so drop it; the pick also closes the list.
|
||||
self.tabs[i].properties.edit_buf.remove("block");
|
||||
self.tabs[i]
|
||||
.properties
|
||||
.edit_buf
|
||||
.remove(&crate::ui::properties::FieldKey::Geom("block"));
|
||||
self.tabs[i].properties.edit_choice_open = false;
|
||||
let canon = self.tabs[i]
|
||||
.scene
|
||||
|
|
@ -2144,7 +2147,11 @@ pub(super) fn on_tab_close(&mut self, idx: usize) -> Task<Message> {
|
|||
self.tabs[i].properties.active_field = None;
|
||||
let handles = self.property_target_handles(i);
|
||||
if !handles.is_empty() {
|
||||
if let Some(raw_val) = self.tabs[i].properties.edit_buf.remove(field) {
|
||||
if let Some(raw_val) = self.tabs[i]
|
||||
.properties
|
||||
.edit_buf
|
||||
.remove(&crate::ui::properties::FieldKey::Geom(field))
|
||||
{
|
||||
// Block names are free-form text — a name like "10-5"
|
||||
// must not be arithmetic-evaluated.
|
||||
let val = if field == "block" {
|
||||
|
|
|
|||
Loading…
Reference in a new issue