(On Hold) Rework Properties UI Editor #159
@ -295,24 +295,47 @@ class UIElementAddMixin:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def ensure_parent_elements(self, rig, ui_element):
|
def ensure_parent_elements(self, rig, ui_element):
|
||||||
|
"""Of the specified Panel, Label, and Row names,
|
||||||
|
create any that don't already exist.
|
||||||
|
If no Row name was provided, create one based on the UI element name.
|
||||||
|
"""
|
||||||
parent = None
|
parent = None
|
||||||
|
|
||||||
|
root_panels = {elem.display_name: elem for elem in rig.cloudrig_ui if not elem.parent and elem.element_type == 'PANEL'}
|
||||||
|
|
||||||
if self.create_new_ui:
|
if self.create_new_ui:
|
||||||
if self.new_panel_name:
|
if self.new_panel_name:
|
||||||
parent = rig.cloudrig_ui.add()
|
if self.new_panel_name not in root_panels:
|
||||||
parent.element_type = 'PANEL'
|
parent = rig.cloudrig_ui.add()
|
||||||
parent.display_name = self.new_panel_name
|
parent.element_type = 'PANEL'
|
||||||
if self.new_label_name:
|
parent.display_name = self.new_panel_name
|
||||||
label = rig.cloudrig_ui.add()
|
else:
|
||||||
label.parent = parent
|
parent = root_panels[self.new_panel_name]
|
||||||
label.element_type = 'LABEL'
|
|
||||||
label.display_name = self.new_label_name
|
panel_labels = {elem.display_name : elem for elem in parent.children if elem.element_type == 'LABEL'}
|
||||||
parent = label
|
if self.new_label_name:
|
||||||
|
if self.new_label_name not in panel_labels:
|
||||||
|
label = rig.cloudrig_ui.add()
|
||||||
|
label.parent = parent
|
||||||
|
label.element_type = 'LABEL'
|
||||||
|
label.display_name = self.new_label_name
|
||||||
|
parent = label
|
||||||
|
else:
|
||||||
|
parent = panel_labels[self.new_label_name]
|
||||||
|
|
||||||
|
parent_rows = {elem.display_name : elem for elem in parent.children if elem.element_type == 'ROW'}
|
||||||
|
|
||||||
|
if not self.new_row_name:
|
||||||
|
self.new_row_name = "Row: " + ui_element.display_name
|
||||||
|
if self.new_row_name not in parent_rows:
|
||||||
|
row = rig.cloudrig_ui.add()
|
||||||
|
row.parent = parent
|
||||||
|
row.element_type = 'ROW'
|
||||||
|
row.display_name = self.new_row_name or ui_element.prop_name
|
||||||
|
parent = row
|
||||||
|
else:
|
||||||
|
parent = parent_rows[self.new_row_name]
|
||||||
|
|
||||||
row = rig.cloudrig_ui.add()
|
|
||||||
row.parent = parent
|
|
||||||
row.element_type = 'ROW'
|
|
||||||
row.display_name = self.new_row_name or ui_element.prop_name
|
|
||||||
parent = row
|
|
||||||
return parent
|
return parent
|
||||||
|
|
||||||
def init_temp_kmi(self, context):
|
def init_temp_kmi(self, context):
|
||||||
@ -355,10 +378,11 @@ class CLOUDRIG_OT_ui_element_add(UIElementAddMixin, Operator):
|
|||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
rig = find_cloudrig(context)
|
rig = find_cloudrig(context)
|
||||||
temp_ui_element = get_new_ui_element(context)
|
temp_ui_element = get_new_ui_element(context)
|
||||||
new_ui_element = rig.cloudrig_ui.add()
|
|
||||||
new_ui_element.copy_from(temp_ui_element)
|
|
||||||
|
|
||||||
parent = self.ensure_parent_elements(rig, temp_ui_element)
|
parent = self.ensure_parent_elements(rig, temp_ui_element)
|
||||||
|
|
||||||
|
new_ui_element = rig.cloudrig_ui.add()
|
||||||
|
new_ui_element.copy_from(temp_ui_element)
|
||||||
if parent:
|
if parent:
|
||||||
new_ui_element.parent = parent
|
new_ui_element.parent = parent
|
||||||
new_ui_element.element_type = self.element_type
|
new_ui_element.element_type = self.element_type
|
||||||
|
Loading…
Reference in New Issue
Block a user