Cleanup: assign variables & use 'match' to avoid redundant lookups
Also use more verbose names for RNA subtype enum variables.
This commit is contained in:
parent
5fa8f7746c
commit
2bb4abdc27
@ -43,9 +43,10 @@ def get_context_modifier(context):
|
|||||||
if context.area.type == 'PROPERTIES':
|
if context.area.type == 'PROPERTIES':
|
||||||
modifier = context.modifier
|
modifier = context.modifier
|
||||||
else:
|
else:
|
||||||
if context.object is None:
|
ob = context.object
|
||||||
|
if ob is None:
|
||||||
return False
|
return False
|
||||||
modifier = context.object.modifiers.active
|
modifier = ob.modifiers.active
|
||||||
if modifier is None or modifier.type != 'NODES':
|
if modifier is None or modifier.type != 'NODES':
|
||||||
return None
|
return None
|
||||||
return modifier
|
return modifier
|
||||||
@ -207,7 +208,8 @@ class NewGeometryNodesModifier(Operator):
|
|||||||
return geometry_modifier_poll(context)
|
return geometry_modifier_poll(context)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
modifier = context.object.modifiers.new(data_("GeometryNodes"), "NODES")
|
ob = context.object
|
||||||
|
modifier = ob.modifiers.new(data_("GeometryNodes"), 'NODES')
|
||||||
if not modifier:
|
if not modifier:
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
|
|
||||||
|
@ -1357,10 +1357,10 @@ rna_custom_property_type_items = (
|
|||||||
('PYTHON', "Python", "Edit a python value directly, for unsupported property types"),
|
('PYTHON', "Python", "Edit a python value directly, for unsupported property types"),
|
||||||
)
|
)
|
||||||
|
|
||||||
rna_generic_subtype_none_item = ('NONE', "Plain Data", "Data values without special behavior")
|
rna_custom_property_subtype_none_item = ('NONE', "Plain Data", "Data values without special behavior")
|
||||||
|
|
||||||
rna_number_subtype_items = (
|
rna_custom_property_subtype_number_items = (
|
||||||
rna_generic_subtype_none_item,
|
rna_custom_property_subtype_none_item,
|
||||||
('PIXEL', "Pixel", ""),
|
('PIXEL', "Pixel", ""),
|
||||||
('PERCENTAGE', "Percentage", ""),
|
('PERCENTAGE', "Percentage", ""),
|
||||||
('FACTOR', "Factor", ""),
|
('FACTOR', "Factor", ""),
|
||||||
@ -1371,8 +1371,8 @@ rna_number_subtype_items = (
|
|||||||
('TEMPERATURE', "Temperature", ""),
|
('TEMPERATURE', "Temperature", ""),
|
||||||
)
|
)
|
||||||
|
|
||||||
rna_vector_subtype_items = (
|
rna_custom_property_subtype_vector_items = (
|
||||||
rna_generic_subtype_none_item,
|
rna_custom_property_subtype_none_item,
|
||||||
('COLOR', "Linear Color", "Color in the linear space"),
|
('COLOR', "Linear Color", "Color in the linear space"),
|
||||||
('COLOR_GAMMA', "Gamma-Corrected Color", "Color in the gamma corrected space"),
|
('COLOR_GAMMA', "Gamma-Corrected Color", "Color in the gamma corrected space"),
|
||||||
('EULER', "Euler Angles", "Euler rotation angles in radians"),
|
('EULER', "Euler Angles", "Euler rotation angles in radians"),
|
||||||
@ -1388,11 +1388,12 @@ class WM_OT_properties_edit(Operator):
|
|||||||
bl_options = {'REGISTER', 'INTERNAL'}
|
bl_options = {'REGISTER', 'INTERNAL'}
|
||||||
|
|
||||||
def subtype_items_cb(self, context):
|
def subtype_items_cb(self, context):
|
||||||
if self.property_type == 'FLOAT':
|
match self.property_type:
|
||||||
return rna_number_subtype_items
|
case 'FLOAT':
|
||||||
elif self.property_type == 'FLOAT_ARRAY':
|
return rna_custom_property_subtype_number_items
|
||||||
return rna_vector_subtype_items
|
case 'FLOAT_ARRAY':
|
||||||
return []
|
return rna_custom_property_subtype_vector_items
|
||||||
|
return ()
|
||||||
|
|
||||||
def property_type_update_cb(self, context):
|
def property_type_update_cb(self, context):
|
||||||
self.subtype = 'NONE'
|
self.subtype = 'NONE'
|
||||||
|
@ -110,7 +110,8 @@ class DATA_PT_bone_groups(ArmatureButtonsPanel, Panel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return (context.object and context.object.type == 'ARMATURE' and context.object.pose)
|
ob = context.object
|
||||||
|
return (ob and ob.type == 'ARMATURE' and ob.pose)
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
@ -276,7 +276,7 @@ class OBJECT_PT_instancing_size(ObjectButtonsPanel, Panel):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
ob = context.object
|
ob = context.object
|
||||||
return ob.instance_type == 'FACES'
|
return (ob is not None) and (ob.instance_type == 'FACES')
|
||||||
|
|
||||||
def draw_header(self, context):
|
def draw_header(self, context):
|
||||||
|
|
||||||
@ -304,7 +304,8 @@ class OBJECT_PT_lineart(ObjectButtonsPanel, Panel):
|
|||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
lineart = context.object.lineart
|
ob = context.object
|
||||||
|
lineart = ob.lineart
|
||||||
|
|
||||||
layout.use_property_split = True
|
layout.use_property_split = True
|
||||||
|
|
||||||
@ -385,7 +386,7 @@ class OBJECT_PT_visibility(ObjectButtonsPanel, Panel):
|
|||||||
col.prop(ob, "hide_viewport", text="Viewports", toggle=False, invert_checkbox=True)
|
col.prop(ob, "hide_viewport", text="Viewports", toggle=False, invert_checkbox=True)
|
||||||
col.prop(ob, "hide_render", text="Renders", toggle=False, invert_checkbox=True)
|
col.prop(ob, "hide_render", text="Renders", toggle=False, invert_checkbox=True)
|
||||||
|
|
||||||
if context.object.type == 'GPENCIL':
|
if ob.type == 'GPENCIL':
|
||||||
col = layout.column(heading="Grease Pencil")
|
col = layout.column(heading="Grease Pencil")
|
||||||
col.prop(ob, "use_grease_pencil_lights", toggle=False)
|
col.prop(ob, "use_grease_pencil_lights", toggle=False)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user