Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/properties_data_modifier.py
| Show First 20 Lines • Show All 1,850 Lines • ▼ Show 20 Lines | def draw(self, context): | ||||
| if box: | if box: | ||||
| # match enum type to our functions, avoids a lookup table. | # match enum type to our functions, avoids a lookup table. | ||||
| getattr(self, md.type)(box, ob, md) | getattr(self, md.type)(box, ob, md) | ||||
| # the mt.type enum is (ab)used for a lookup on function names | # the mt.type enum is (ab)used for a lookup on function names | ||||
| # ...to avoid lengthy if statements | # ...to avoid lengthy if statements | ||||
| # so each type must have a function here. | # so each type must have a function here. | ||||
| def gpencil_check_material(self, ob, material): | |||||
| for slot in ob.material_slots: | |||||
| if slot.material == material: | |||||
| return True | |||||
| return False | |||||
mont29: This can be done in a single line: `return material in (slot.material for slot in ob. | |||||
| def gpencil_masking(self, layout, ob, md, use_vertex, use_curve=False): | def gpencil_masking(self, layout, ob, md, use_vertex, use_curve=False): | ||||
| gpd = ob.data | gpd = ob.data | ||||
| layout.separator() | layout.separator() | ||||
| layout.label(text="Influence Filters:") | layout.label(text="Influence Filters:") | ||||
| split = layout.split(factor=0.25) | split = layout.split(factor=0.25) | ||||
| col1 = split.column() | col1 = split.column() | ||||
| Show All 12 Lines | def gpencil_masking(self, layout, ob, md, use_vertex, use_curve=False): | ||||
| row = split.row(align=True) | row = split.row(align=True) | ||||
| row.prop(md, "layer_pass", text="Pass") | row.prop(md, "layer_pass", text="Pass") | ||||
| row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT') | row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT') | ||||
| split = col2.split(factor=0.6) | split = col2.split(factor=0.6) | ||||
| row = split.row(align=True) | row = split.row(align=True) | ||||
| row.prop_search(md, "material", gpd, "materials", text="", icon='SHADING_TEXTURE') | |||||
| valid = self.gpencil_check_material(ob, md.material) | |||||
| if valid: | |||||
| icon = 'SHADING_TEXTURE' | |||||
| else: | |||||
| icon = 'ERROR' | |||||
| row.alert = not valid | |||||
| row.prop_search(md, "material", gpd, "materials", text="", icon=icon) | |||||
| row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT') | row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT') | ||||
| row = split.row(align=True) | row = split.row(align=True) | ||||
| row.prop(md, "pass_index", text="Pass") | row.prop(md, "pass_index", text="Pass") | ||||
| row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT') | row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT') | ||||
| if use_vertex: | if use_vertex: | ||||
| row = col2.row(align=True) | row = col2.row(align=True) | ||||
| ▲ Show 20 Lines • Show All 424 Lines • Show Last 20 Lines | |||||
This can be done in a single line: return material in (slot.material for slot in ob.material_slots). You do not even need the helper function then... ;)