Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/properties_freestyle.py
| Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | def draw(self, context): | ||||
| row.prop(rd, "line_thickness_mode", expand=True) | row.prop(rd, "line_thickness_mode", expand=True) | ||||
| if (rd.line_thickness_mode == 'ABSOLUTE'): | if (rd.line_thickness_mode == 'ABSOLUTE'): | ||||
| layout.prop(rd, "line_thickness") | layout.prop(rd, "line_thickness") | ||||
| # Render layer properties | # Render layer properties | ||||
| class RenderLayerFreestyleButtonsPanel: | class ViewLayerFreestyleButtonsPanel: | ||||
| bl_space_type = 'PROPERTIES' | bl_space_type = 'PROPERTIES' | ||||
| bl_region_type = 'WINDOW' | bl_region_type = 'WINDOW' | ||||
| bl_context = "render_layer" | bl_context = "view_layer" | ||||
| # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| scene = context.scene | scene = context.scene | ||||
| rd = context.scene.render | rd = context.scene.render | ||||
| with_freestyle = bpy.app.build_options.freestyle | with_freestyle = bpy.app.build_options.freestyle | ||||
| return (scene and with_freestyle and rd.use_freestyle and | return (scene and with_freestyle and rd.use_freestyle and | ||||
| scene.render_layers.active and(scene.view_render.engine in cls.COMPAT_ENGINES)) | scene.view_layers.active and(scene.view_render.engine in cls.COMPAT_ENGINES)) | ||||
| class RenderLayerFreestyleEditorButtonsPanel(RenderLayerFreestyleButtonsPanel): | class ViewLayerFreestyleEditorButtonsPanel(ViewLayerFreestyleButtonsPanel): | ||||
| # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here | ||||
| @classmethod | @classmethod | ||||
| def poll(cls, context): | def poll(cls, context): | ||||
| if not super().poll(context): | if not super().poll(context): | ||||
| return False | return False | ||||
| rl = context.scene.render_layers.active | view_layer = context.scene.view_layers.active | ||||
| return rl and rl.freestyle_settings.mode == 'EDITOR' | return view_layer and view_layer.freestyle_settings.mode == 'EDITOR' | ||||
| class RENDERLAYER_UL_linesets(UIList): | class VIEWLAYER_UL_linesets(UIList): | ||||
| def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): | def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index): | ||||
| lineset = item | lineset = item | ||||
| if self.layout_type in {'DEFAULT', 'COMPACT'}: | if self.layout_type in {'DEFAULT', 'COMPACT'}: | ||||
| layout.prop(lineset, "name", text="", emboss=False, icon_value=icon) | layout.prop(lineset, "name", text="", emboss=False, icon_value=icon) | ||||
| layout.prop(lineset, "show_render", text="", index=index) | layout.prop(lineset, "show_render", text="", index=index) | ||||
| elif self.layout_type == 'GRID': | elif self.layout_type == 'GRID': | ||||
| layout.alignment = 'CENTER' | layout.alignment = 'CENTER' | ||||
| layout.label("", icon_value=icon) | layout.label("", icon_value=icon) | ||||
| class RENDER_MT_lineset_specials(Menu): | class RENDER_MT_lineset_specials(Menu): | ||||
| bl_label = "Lineset Specials" | bl_label = "Lineset Specials" | ||||
| def draw(self, context): | def draw(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| layout.operator("scene.freestyle_lineset_copy", icon='COPYDOWN') | layout.operator("scene.freestyle_lineset_copy", icon='COPYDOWN') | ||||
| layout.operator("scene.freestyle_lineset_paste", icon='PASTEDOWN') | layout.operator("scene.freestyle_lineset_paste", icon='PASTEDOWN') | ||||
| class RENDERLAYER_PT_freestyle(RenderLayerFreestyleButtonsPanel, Panel): | class VIEWLAYER_PT_freestyle(ViewLayerFreestyleButtonsPanel, Panel): | ||||
| bl_label = "Freestyle" | bl_label = "Freestyle" | ||||
| COMPAT_ENGINES = {'BLENDER_RENDER'} | COMPAT_ENGINES = {'BLENDER_RENDER'} | ||||
| def draw(self, context): | def draw(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| scene = context.scene | scene = context.scene | ||||
| rl = scene.render_layers.active | view_layer = scene.view_layers.active | ||||
| freestyle = rl.freestyle_settings | freestyle = view_layer.freestyle_settings | ||||
| layout.active = rl.use_freestyle | layout.active = view_layer.use_freestyle | ||||
| row = layout.row() | row = layout.row() | ||||
| layout.prop(freestyle, "mode", text="Control Mode") | layout.prop(freestyle, "mode", text="Control Mode") | ||||
| layout.prop(freestyle, "use_view_map_cache", text="View Map Cache") | layout.prop(freestyle, "use_view_map_cache", text="View Map Cache") | ||||
| layout.label(text="Edge Detection Options:") | layout.label(text="Edge Detection Options:") | ||||
| split = layout.split() | split = layout.split() | ||||
| Show All 28 Lines | def draw(self, context): | ||||
| row.prop(module, "use", text="") | row.prop(module, "use", text="") | ||||
| row.prop(module, "script", text="") | row.prop(module, "script", text="") | ||||
| row.operator("scene.freestyle_module_open", icon='FILESEL', text="") | row.operator("scene.freestyle_module_open", icon='FILESEL', text="") | ||||
| row.operator("scene.freestyle_module_remove", icon='X', text="") | row.operator("scene.freestyle_module_remove", icon='X', text="") | ||||
| row.operator("scene.freestyle_module_move", icon='TRIA_UP', text="").direction = 'UP' | row.operator("scene.freestyle_module_move", icon='TRIA_UP', text="").direction = 'UP' | ||||
| row.operator("scene.freestyle_module_move", icon='TRIA_DOWN', text="").direction = 'DOWN' | row.operator("scene.freestyle_module_move", icon='TRIA_DOWN', text="").direction = 'DOWN' | ||||
| class RENDERLAYER_PT_freestyle_lineset(RenderLayerFreestyleEditorButtonsPanel, Panel): | class VIEWLAYER_PT_freestyle_lineset(ViewLayerFreestyleEditorButtonsPanel, Panel): | ||||
| bl_label = "Freestyle Line Set" | bl_label = "Freestyle Line Set" | ||||
| COMPAT_ENGINES = {'BLENDER_RENDER'} | COMPAT_ENGINES = {'BLENDER_RENDER'} | ||||
| def draw_edge_type_buttons(self, box, lineset, edge_type): | def draw_edge_type_buttons(self, box, lineset, edge_type): | ||||
| # property names | # property names | ||||
| select_edge_type = "select_" + edge_type | select_edge_type = "select_" + edge_type | ||||
| exclude_edge_type = "exclude_" + edge_type | exclude_edge_type = "exclude_" + edge_type | ||||
| # draw edge type buttons | # draw edge type buttons | ||||
| row = box.row(align=True) | row = box.row(align=True) | ||||
| row.prop(lineset, select_edge_type) | row.prop(lineset, select_edge_type) | ||||
| sub = row.column(align=True) | sub = row.column(align=True) | ||||
| sub.prop(lineset, exclude_edge_type, text="") | sub.prop(lineset, exclude_edge_type, text="") | ||||
| sub.active = getattr(lineset, select_edge_type) | sub.active = getattr(lineset, select_edge_type) | ||||
| def draw(self, context): | def draw(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| scene = context.scene | scene = context.scene | ||||
| rd = scene.render | rd = scene.render | ||||
| view_render = scene.view_render | view_render = scene.view_render | ||||
| rl = scene.render_layers.active | view_layer = scene.view_layers.active | ||||
| freestyle = rl.freestyle_settings | freestyle = view_layer.freestyle_settings | ||||
| lineset = freestyle.linesets.active | lineset = freestyle.linesets.active | ||||
| layout.active = rl.use_freestyle | layout.active = view_layer.use_freestyle | ||||
| row = layout.row() | row = layout.row() | ||||
| rows = 4 if lineset else 2 | rows = 4 if lineset else 2 | ||||
| row.template_list("RENDERLAYER_UL_linesets", "", freestyle, "linesets", freestyle.linesets, "active_index", rows=rows) | row.template_list("VIEWLAYER_UL_linesets", "", freestyle, "linesets", freestyle.linesets, "active_index", rows=rows) | ||||
| sub = row.column(align=True) | sub = row.column(align=True) | ||||
| sub.operator("scene.freestyle_lineset_add", icon='ZOOMIN', text="") | sub.operator("scene.freestyle_lineset_add", icon='ZOOMIN', text="") | ||||
| sub.operator("scene.freestyle_lineset_remove", icon='ZOOMOUT', text="") | sub.operator("scene.freestyle_lineset_remove", icon='ZOOMOUT', text="") | ||||
| sub.menu("RENDER_MT_lineset_specials", icon='DOWNARROW_HLT', text="") | sub.menu("RENDER_MT_lineset_specials", icon='DOWNARROW_HLT', text="") | ||||
| if lineset: | if lineset: | ||||
| sub.separator() | sub.separator() | ||||
| sub.separator() | sub.separator() | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | def draw(self, context): | ||||
| if lineset.select_by_group: | if lineset.select_by_group: | ||||
| col.label(text="Group:") | col.label(text="Group:") | ||||
| row = col.row() | row = col.row() | ||||
| row.prop(lineset, "group", text="") | row.prop(lineset, "group", text="") | ||||
| row.prop(lineset, "group_negation", expand=True) | row.prop(lineset, "group_negation", expand=True) | ||||
| class RENDERLAYER_PT_freestyle_linestyle(RenderLayerFreestyleEditorButtonsPanel, Panel): | class VIEWLAYER_PT_freestyle_linestyle(ViewLayerFreestyleEditorButtonsPanel, Panel): | ||||
| bl_label = "Freestyle Line Style" | bl_label = "Freestyle Line Style" | ||||
| bl_options = {'DEFAULT_CLOSED'} | bl_options = {'DEFAULT_CLOSED'} | ||||
| COMPAT_ENGINES = {'BLENDER_RENDER'} | COMPAT_ENGINES = {'BLENDER_RENDER'} | ||||
| def draw_modifier_box_header(self, box, modifier): | def draw_modifier_box_header(self, box, modifier): | ||||
| row = box.row() | row = box.row() | ||||
| row.context_pointer_set("modifier", modifier) | row.context_pointer_set("modifier", modifier) | ||||
| if modifier.expanded: | if modifier.expanded: | ||||
| ▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | def draw_color_modifier(self, context, modifier): | ||||
| row.prop(modifier, "angle_min") | row.prop(modifier, "angle_min") | ||||
| row.prop(modifier, "angle_max") | row.prop(modifier, "angle_max") | ||||
| elif modifier.type == 'CURVATURE_3D': | elif modifier.type == 'CURVATURE_3D': | ||||
| self.draw_modifier_color_ramp_common(box, modifier, False) | self.draw_modifier_color_ramp_common(box, modifier, False) | ||||
| row = box.row(align=True) | row = box.row(align=True) | ||||
| row.prop(modifier, "curvature_min") | row.prop(modifier, "curvature_min") | ||||
| row.prop(modifier, "curvature_max") | row.prop(modifier, "curvature_max") | ||||
| freestyle = context.scene.render_layers.active.freestyle_settings | freestyle = context.scene.view_layers.active.freestyle_settings | ||||
| if not freestyle.use_smoothness: | if not freestyle.use_smoothness: | ||||
| message = "Enable Face Smoothness to use this modifier" | message = "Enable Face Smoothness to use this modifier" | ||||
| self.draw_modifier_box_error(col.box(), modifier, message) | self.draw_modifier_box_error(col.box(), modifier, message) | ||||
| def draw_alpha_modifier(self, context, modifier): | def draw_alpha_modifier(self, context, modifier): | ||||
| layout = self.layout | layout = self.layout | ||||
| col = layout.column(align=True) | col = layout.column(align=True) | ||||
| Show All 38 Lines | def draw_alpha_modifier(self, context, modifier): | ||||
| row.prop(modifier, "angle_min") | row.prop(modifier, "angle_min") | ||||
| row.prop(modifier, "angle_max") | row.prop(modifier, "angle_max") | ||||
| elif modifier.type == 'CURVATURE_3D': | elif modifier.type == 'CURVATURE_3D': | ||||
| self.draw_modifier_curve_common(box, modifier, False, False) | self.draw_modifier_curve_common(box, modifier, False, False) | ||||
| row = box.row(align=True) | row = box.row(align=True) | ||||
| row.prop(modifier, "curvature_min") | row.prop(modifier, "curvature_min") | ||||
| row.prop(modifier, "curvature_max") | row.prop(modifier, "curvature_max") | ||||
| freestyle = context.scene.render_layers.active.freestyle_settings | freestyle = context.scene.view_layers.active.freestyle_settings | ||||
| if not freestyle.use_smoothness: | if not freestyle.use_smoothness: | ||||
| message = "Enable Face Smoothness to use this modifier" | message = "Enable Face Smoothness to use this modifier" | ||||
| self.draw_modifier_box_error(col.box(), modifier, message) | self.draw_modifier_box_error(col.box(), modifier, message) | ||||
| def draw_thickness_modifier(self, context, modifier): | def draw_thickness_modifier(self, context, modifier): | ||||
| layout = self.layout | layout = self.layout | ||||
| col = layout.column(align=True) | col = layout.column(align=True) | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | def draw_thickness_modifier(self, context, modifier): | ||||
| elif modifier.type == 'CURVATURE_3D': | elif modifier.type == 'CURVATURE_3D': | ||||
| self.draw_modifier_curve_common(box, modifier, False, False) | self.draw_modifier_curve_common(box, modifier, False, False) | ||||
| row = box.row(align=True) | row = box.row(align=True) | ||||
| row.prop(modifier, "thickness_min") | row.prop(modifier, "thickness_min") | ||||
| row.prop(modifier, "thickness_max") | row.prop(modifier, "thickness_max") | ||||
| row = box.row(align=True) | row = box.row(align=True) | ||||
| row.prop(modifier, "curvature_min") | row.prop(modifier, "curvature_min") | ||||
| row.prop(modifier, "curvature_max") | row.prop(modifier, "curvature_max") | ||||
| freestyle = context.scene.render_layers.active.freestyle_settings | freestyle = context.scene.view_layers.active.freestyle_settings | ||||
| if not freestyle.use_smoothness: | if not freestyle.use_smoothness: | ||||
| message = "Enable Face Smoothness to use this modifier" | message = "Enable Face Smoothness to use this modifier" | ||||
| self.draw_modifier_box_error(col.box(), modifier, message) | self.draw_modifier_box_error(col.box(), modifier, message) | ||||
| def draw_geometry_modifier(self, context, modifier): | def draw_geometry_modifier(self, context, modifier): | ||||
| layout = self.layout | layout = self.layout | ||||
| col = layout.column(align=True) | col = layout.column(align=True) | ||||
| ▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | def draw_geometry_modifier(self, context, modifier): | ||||
| elif modifier.type == 'SIMPLIFICATION': | elif modifier.type == 'SIMPLIFICATION': | ||||
| box.prop(modifier, "tolerance") | box.prop(modifier, "tolerance") | ||||
| def draw(self, context): | def draw(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| scene = context.scene | scene = context.scene | ||||
| rl = scene.render_layers.active | view_layer = scene.view_layers.active | ||||
| lineset = rl.freestyle_settings.linesets.active | lineset = view_layer.freestyle_settings.linesets.active | ||||
| layout.active = rl.use_freestyle | layout.active = view_layer.use_freestyle | ||||
| if lineset is None: | if lineset is None: | ||||
| return | return | ||||
| linestyle = lineset.linestyle | linestyle = lineset.linestyle | ||||
| layout.template_ID(lineset, "linestyle", new="scene.freestyle_linestyle_new") | layout.template_ID(lineset, "linestyle", new="scene.freestyle_linestyle_new") | ||||
| if linestyle is None: | if linestyle is None: | ||||
| return | return | ||||
| ▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | def draw(self, context): | ||||
| row = layout.row() | row = layout.row() | ||||
| row.prop(mat, "line_color", text="") | row.prop(mat, "line_color", text="") | ||||
| row.prop(mat, "line_priority", text="Priority") | row.prop(mat, "line_priority", text="Priority") | ||||
| classes = ( | classes = ( | ||||
| RENDER_PT_freestyle, | RENDER_PT_freestyle, | ||||
| RENDERLAYER_UL_linesets, | VIEWLAYER_UL_linesets, | ||||
| RENDER_MT_lineset_specials, | RENDER_MT_lineset_specials, | ||||
| RENDERLAYER_PT_freestyle, | VIEWLAYER_PT_freestyle, | ||||
| RENDERLAYER_PT_freestyle_lineset, | VIEWLAYER_PT_freestyle_lineset, | ||||
| RENDERLAYER_PT_freestyle_linestyle, | VIEWLAYER_PT_freestyle_linestyle, | ||||
| MATERIAL_PT_freestyle_line, | MATERIAL_PT_freestyle_line, | ||||
| ) | ) | ||||
| if __name__ == "__main__": # only for live edit. | if __name__ == "__main__": # only for live edit. | ||||
| from bpy.utils import register_class | from bpy.utils import register_class | ||||
| for cls in classes: | for cls in classes: | ||||
| register_class(cls) | register_class(cls) | ||||