Skip to content

Commit ebdd300

Browse files
committed
feat: implement variable frame and viewport widgets for smartprop editor
1 parent 839b753 commit ebdd300

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/editors/smartprop_editor/variable_frame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ def _sync_with_end_widget(self):
547547
if found_start and isinstance(w, CategoryFrame) and w.is_end and w.category_hash == self.category_hash:
548548
w.pre_change.emit()
549549
w.name = f"hammer5tools_category_{self.category_hash}_end"
550-
w.var_visible_in_editor = self.var_visible_in_editor
550+
w.var_visible_in_editor = False
551551
w.content_changed.emit()
552552
break
553553

src/editors/smartprop_editor/variables_viewport.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,10 @@ def duplicate_variable(self, __data, __index):
151151
unique_hash = ''.join(random.choices(string.ascii_lowercase + string.digits, k=3))
152152
if name.endswith('_start'):
153153
name = f"hammer5tools_category_{unique_hash}_start"
154+
self.add_category(name, __data[3], __data[4], __index)
154155
elif name.endswith('_end'):
155156
name = f"hammer5tools_category_{unique_hash}_end"
156-
self.add_category(name, __data[3], __data[4], __index)
157+
self.add_category(name, False, __data[4], __index)
157158
else:
158159
# For regular variables, unique name generation is handled on focus out,
159160
# but let's make it unique initially to avoid collision.
@@ -210,6 +211,8 @@ def add_new_variable(self):
210211
self._sync_committed_state()
211212

212213
def add_category(self, name, var_visible_in_editor, var_display_name, index=None, expanded=True):
214+
if name.endswith('_end'):
215+
var_visible_in_editor = False
213216
category = CategoryFrame(
214217
name=name,
215218
var_visible_in_editor=var_visible_in_editor,
@@ -253,7 +256,7 @@ def add_new_category(self):
253256
self.add_category(start_name, var_visible, f" ----===={display_name}===------")
254257
# Add End
255258
end_name = f"hammer5tools_category_{unique_hash}_end"
256-
self.add_category(end_name, var_visible, " ")
259+
self.add_category(end_name, False, " ")
257260

258261
new_state = self._snapshot()
259262
from src.editors.smartprop_editor.commands import VariablesSnapshotCommand

0 commit comments

Comments
 (0)