Ejemplo n.º 1
0
 def UV(context, layout, tool):
     if tool and tool.has_datablock:
         if context.mode == 'EDIT_MESH':
             tool_settings = context.tool_settings
             uv_sculpt = tool_settings.uv_sculpt
             brush = uv_sculpt.brush
             if brush:
                 UnifiedPaintPanel.prop_unified(
                     layout,
                     context,
                     brush,
                     "size",
                     pressure_name="use_pressure_size",
                     unified_name="use_unified_size",
                     slider=True,
                     header=True
                 )
                 UnifiedPaintPanel.prop_unified(
                     layout,
                     context,
                     brush,
                     "strength",
                     pressure_name="use_pressure_strength",
                     unified_name="use_unified_strength",
                     slider=True,
                     header=True
                 )
Ejemplo n.º 2
0
 def UV(context, layout, tool):
     if tool and tool.has_datablock:
         if context.mode == 'EDIT_MESH':
             tool_settings = context.tool_settings
             uv_sculpt = tool_settings.uv_sculpt
             brush = uv_sculpt.brush
             if brush:
                 # NOTE: We don't draw UnifiedPaintSettings in the header to reduce clutter. D5928#136281
                 UnifiedPaintPanel.prop_unified(layout, context, brush, "size", pressure_name="use_pressure_size", slider=True)
                 UnifiedPaintPanel.prop_unified(layout, context, brush, "strength", pressure_name="use_pressure_strength", slider=True)
 def slider_strength(parent):
     # strength, use_strength_pressure
     pressure_name = "use_pressure_strength" if parent.capabilities.has_strength_pressure else None
     UnifiedPaintPanel.prop_unified(parent.layout,
                                    parent.context,
                                    parent.brush,
                                    "strength",
                                    pressure_name=pressure_name,
                                    unified_name="use_unified_strength",
                                    text="Strength",
                                    header=True)
     return 7.75
    def slider_radius(parent):
        size = "size"
        size_owner = parent.ups if parent.ups.use_unified_size else parent.brush
        if size_owner.use_locked_size == 'SCENE':
            size = "unprojected_radius"

        UnifiedPaintPanel.prop_unified(parent.layout,
                                       parent.context,
                                       parent.brush,
                                       size,
                                       pressure_name="use_pressure_size",
                                       unified_name="use_unified_size",
                                       text="Radius",
                                       slider=True,
                                       header=True)
        return 7.3
    def stroke_curve_snap(parent):
        paint_settings = UnifiedPaintPanel.paint_settings(parent.context)
        if paint_settings:
            brush = paint_settings.brush
            if brush and hasattr(
                    brush, "stroke_method") and brush.stroke_method == 'CURVE':
                snap_items = ToolSettings.bl_rna.properties[
                    "snap_elements"].enum_items
                tool_settings = parent.context.tool_settings
                snap_elements = tool_settings.snap_elements
                if len(snap_elements) == 1:
                    text = ""
                    for elem in snap_elements:
                        icon = snap_items[elem].icon
                        break
                else:
                    text = "Mix"
                    icon = 'NONE'
                del snap_items, snap_elements

                row = parent.layout.row(align=True)
                row.prop(tool_settings, "use_snap", text="")

                sub = row.row(align=True)
                sub.popover(
                    panel="VIEW3D_PT_snapping",
                    icon=icon,
                    text=text,
                )
                return 2.6
        return -1  # Invalid
Ejemplo n.º 6
0
    def draw(self, context):
        layout = self.layout

        settings = UnifiedPaintPanel.paint_settings(context)
        brush = settings.brush

        pie = layout.menu_pie()
        pie.operator_enum("brush", "stroke_method")
Ejemplo n.º 7
0
    def draw(self, context):
        layout = self.layout
        settings = UnifiedPaintPanel.paint_settings(context)
        brush = settings.brush

        sculpt_tool = brush.sculpt_tool

        pie = layout.menu_pie()
        pie.operator_enum("brush.curve_preset", "shape")
Ejemplo n.º 8
0
    def poll(cls, context):
        settings = UnifiedPaintPanel.paint_settings(context)
        if not settings:
            return False

        brush = settings.brush
        tex_slot = brush.texture_slot

        return tex_slot.has_texture_angle and tex_slot.has_texture_angle_source
Ejemplo n.º 9
0
def palette_context_menu(self, context):
    layout = self.layout
    settings = context.tool_settings.image_paint
    capabilities = settings.brush.image_paint_capabilities
    if capabilities.has_color:
        split = layout.split(factor=0.1)
        column = split.column()
        UnifiedPaintPanel.prop_unified_color(column, context, settings.brush, "color", text="")
        UnifiedPaintPanel.prop_unified_color(column, context, settings.brush, "secondary_color", text="")
        column.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="", emboss=False)
        column.operator(PaletteGenerator.bl_idname, icon='MOD_OPACITY', text="", emboss=False)
        UnifiedPaintPanel.prop_unified_color_picker(split, context, settings.brush, "color", value_slider=True)
        layout.prop(settings.brush, "blend", text="")

    if capabilities.has_radius:
        UnifiedPaintPanel.prop_unified_size(layout, context, settings.brush, "size", slider=True)
    UnifiedPaintPanel.prop_unified_strength(layout, context, settings.brush, "strength")
    if settings.palette:
        layout.template_palette(settings, "palette", color=True)
 def brush_selector(parent):
     paint_settings = UnifiedPaintPanel.paint_settings(parent.context)
     if paint_settings:
         rows_cols = parent.prefs.brush_selector_grid_size
         parent.layout.template_ID_preview(paint_settings,
                                           "brush",
                                           rows=rows_cols[0],
                                           cols=rows_cols[1],
                                           hide_buttons=True)
         return 7.6
     return -1
Ejemplo n.º 11
0
    def draw(self, context):
        layout = self.layout
        settings = UnifiedPaintPanel.paint_settings(context)
        colum_n = utils_core.addon_settings(lists=False)

        if utils_core.addon_settings(lists=True) != 'popup':
            layout.label(text="Seems no active brush", icon="INFO")
            layout.label(text="in the Tool Shelf", icon="BACK")

        layout.template_ID_preview(settings, "brush",
                                   new="brush.add", rows=3, cols=colum_n)
Ejemplo n.º 12
0
    def draw(self, context):
        layout = self.layout
        settings = UnifiedPaintPanel.paint_settings(context)

        # check if brush exists (for instance, in paint mode before adding a slot)
        if hasattr(settings, 'brush'):
            brush = settings.brush
        else:
            brush = None

        if not brush:
            layout.label(text="No Brushes currently available", icon="INFO")
            return

        if not context.particle_edit_object:
            if UseBrushesLists():
                flow = layout.column_flow(columns=3)

                for brsh in bpy.data.brushes:
                    if (context.sculpt_object and brsh.use_paint_sculpt):
                        props = flow.operator("wm.context_set_id",
                                              text=brsh.name,
                                              icon_value=layout.icon(brsh))
                        props.data_path = "tool_settings.sculpt.brush"
                        props.value = brsh.name
                    elif (context.image_paint_object and brsh.use_paint_image):
                        props = flow.operator("wm.context_set_id",
                                              text=brsh.name,
                                              icon_value=layout.icon(brsh))
                        props.data_path = "tool_settings.image_paint.brush"
                        props.value = brsh.name
                    elif (context.vertex_paint_object
                          and brsh.use_paint_vertex):
                        props = flow.operator("wm.context_set_id",
                                              text=brsh.name,
                                              icon_value=layout.icon(brsh))
                        props.data_path = "tool_settings.vertex_paint.brush"
                        props.value = brsh.name
                    elif (context.weight_paint_object
                          and brsh.use_paint_weight):
                        props = flow.operator("wm.context_set_id",
                                              text=brsh.name,
                                              icon_value=layout.icon(brsh))
                        props.data_path = "tool_settings.weight_paint.brush"
                        props.value = brsh.name
            else:
                layout.template_ID_preview(settings,
                                           "brush",
                                           new="brush.add",
                                           rows=3,
                                           cols=8)
Ejemplo n.º 13
0
    def draw(self, context):
        layout = self.layout
        settings = UnifiedPaintPanel.paint_settings(context)
        colum_n = utils_core.addon_settings(lists=False)

        if utils_core.addon_settings(lists=True) != 'popup':
            layout.label(text="Seems no active brush", icon="INFO")
            layout.label(text="in the Tool Shelf", icon="BACK")

        layout.template_ID_preview(settings,
                                   "brush",
                                   new="brush.add",
                                   rows=3,
                                   cols=colum_n)
Ejemplo n.º 14
0
    def draw(self, context):
        layout = self.layout

        settings = UnifiedPaintPanel.paint_settings(context)
        brush = settings.brush

        flow = layout.column_flow(columns=2)
        for brush in bpy.data.brushes:
            if context.sculpt_object:
                if brush.use_paint_sculpt:

                    row = flow.row(1)
                    row.label(icon_value=row.icon(brush))

                    props = row.operator("wm.context_set_id", text=brush.name)
                    props.data_path = "tool_settings.sculpt.brush"
                    props.value = brush.name
Ejemplo n.º 15
0
    def draw(self, context):
        layout = self.layout

        settings = UnifiedPaintPanel.paint_settings(context)
        brush = settings.brush

        flow = layout.column_flow(columns=2)
        for brush in bpy.data.brushes:
            if context.sculpt_object:
                if brush.use_paint_sculpt:
                   
                    row = flow.row(1)
                    row.label(icon_value=row.icon(brush))
                   
                    props = row.operator("wm.context_set_id", text=brush.name)
                    props.data_path = "tool_settings.sculpt.brush"
                    props.value = brush.name
Ejemplo n.º 16
0
    def draw(self, context):
        layout = self.layout

        settings = UnifiedPaintPanel.paint_settings(context)
        brush = settings.brush

        sculpt = (context.sculpt_object is not None)

        tex_slot = brush.texture_slot

        layout.prop(tex_slot, "use_rake", text="Rake")

        if brush.brush_capabilities.has_random_texture_angle and tex_slot.has_random_texture_angle:
            if sculpt:
                if brush.sculpt_capabilities.has_random_texture_angle:
                    layout.prop(tex_slot, "use_random", text="Random")
            else:
                layout.prop(tex_slot, "use_random", text="Random")
Ejemplo n.º 17
0
    def draw(self, context):
        layout = self.layout
        settings = UnifiedPaintPanel.paint_settings(context)
        brush = getattr(settings, "brush", None)

        ups = context.tool_settings.unified_paint_settings
        layout.prop(ups, "use_unified_size", text="Unified Size")
        layout.prop(ups, "use_unified_strength", text="Unified Strength")
        if context.image_paint_object or context.vertex_paint_object:
            layout.prop(ups, "use_unified_color", text="Unified Color")
        layout.separator()

        if not brush:
            layout.label(text="No Brushes currently available", icon="INFO")
            return

        layout.menu("VIEW3D_MT_brush_paint_modes")

        if context.sculpt_object:
            sculpt_tool = brush.sculpt_tool

            layout.separator()
            layout.operator_menu_enum("brush.curve_preset",
                                      "shape",
                                      text="Curve Preset")
            layout.separator()

            if sculpt_tool != 'GRAB':
                layout.prop_menu_enum(brush, "stroke_method")

                if sculpt_tool in {
                        'DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'
                }:
                    layout.prop_menu_enum(brush, "direction")

                if sculpt_tool == 'LAYER':
                    layout.prop(brush, "use_persistent")
                    layout.operator("sculpt.set_persistent_base")
Ejemplo n.º 18
0
    def draw(self, context):
        if (context.mode != "SCULPT"):
            super().draw(context)
            return
        # Not a brush but a tool.
        elif not UnifiedPaintPanel.paint_settings(context):
            super().draw(context)
            return

        # self.layout.template_header() # to change region

        # VARIABLES
        self.act_obj = context.active_object
        toolsettings = context.tool_settings
        self.sculpt = toolsettings.sculpt
        self.brush = brush = self.sculpt.brush

        wm = context.window_manager
        scn = context.scene

        # Not a brush but a tool.
        if brush is None:
            return

        self.capabilities = self.brush.sculpt_capabilities
        self.ups = toolsettings.unified_paint_settings
        self.context = context

        self.prefs = context.preferences.addons[main_package].preferences
        self.sep = 5 * context.preferences.view.ui_scale

        self.props = scn.bas_custom_ui

        layout = self.layout

        for block in blocks:
            block(self)
Ejemplo n.º 19
0
def VIEW3D_HT_header_draw_new(self, context):
    if "BLEND4WEB" not in context.scene.render.engine:
        _VIEW3D_HT_header_draw(self, context)
    else:
        layout = self.layout

        view = context.space_data
        # mode_string = context.mode
        obj = context.active_object
        toolsettings = context.tool_settings

        row = layout.row(align=True)
        row.template_header()

        bpy.types.VIEW3D_MT_editor_menus.draw_collapsible(context, layout)

        # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode...
        row = layout
        layout.template_header_3D()

        if obj:
            mode = obj.mode
            # Particle edit
            if mode == 'PARTICLE_EDIT':
                row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True)

            # Occlude geometry
            if ((view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'} and (mode == 'PARTICLE_EDIT' or (mode == 'EDIT' and obj.type == 'MESH'))) or
                    (mode == 'WEIGHT_PAINT')):
                row.prop(view, "use_occlude_geometry", text="")

            # Proportional editing
            if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
                row = layout.row(align=True)
                row.prop(toolsettings, "proportional_edit", icon_only=True)
                if toolsettings.proportional_edit != 'DISABLED':
                    row.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
            elif mode in {'EDIT', 'PARTICLE_EDIT'}:
                row = layout.row(align=True)
                row.prop(toolsettings, "proportional_edit", icon_only=True)
                if toolsettings.proportional_edit != 'DISABLED':
                    row.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
            elif mode == 'OBJECT':
                row = layout.row(align=True)
                row.prop(toolsettings, "use_proportional_edit_objects", icon_only=True)
                if toolsettings.use_proportional_edit_objects:
                    row.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
        else:
            # Proportional editing
            if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
                row = layout.row(align=True)
                row.prop(toolsettings, "proportional_edit", icon_only=True)
                if toolsettings.proportional_edit != 'DISABLED':
                    row.prop(toolsettings, "proportional_edit_falloff", icon_only=True)

        # Snap
        show_snap = False
        if obj is None:
            show_snap = True
        else:
            if mode not in {'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT'}:
                show_snap = True
            else:
                paint_settings = UnifiedPaintPanel.paint_settings(context)
                if paint_settings:
                    brush = paint_settings.brush
                    if brush and brush.stroke_method == 'CURVE':
                        show_snap = True

        if show_snap:
            snap_element = toolsettings.snap_element
            row = layout.row(align=True)
            row.prop(toolsettings, "use_snap", text="")
            row.prop(toolsettings, "snap_element", icon_only=True)
            if snap_element == 'INCREMENT':
                row.prop(toolsettings, "use_snap_grid_absolute", text="")
            else:
                row.prop(toolsettings, "snap_target", text="")
                if obj:
                    if mode == 'EDIT':
                        row.prop(toolsettings, "use_snap_self", text="")
                    if mode in {'OBJECT', 'POSE', 'EDIT'} and snap_element != 'VOLUME':
                        row.prop(toolsettings, "use_snap_align_rotation", text="")

            if snap_element == 'VOLUME':
                row.prop(toolsettings, "use_snap_peel_object", text="")
            elif snap_element == 'FACE':
                row.prop(toolsettings, "use_snap_project", text="")

        # AutoMerge editing
        if obj:
            if (mode == 'EDIT' and obj.type == 'MESH'):
                layout.prop(toolsettings, "use_mesh_automerge", text="", icon='AUTOMERGE_ON')

        # Pose
        if obj and mode == 'POSE':
            row = layout.row(align=True)
            row.operator("pose.copy", text="", icon='COPYDOWN')
            row.operator("pose.paste", text="", icon='PASTEDOWN').flipped = False
            row.operator("pose.paste", text="", icon='PASTEFLIPDOWN').flipped = True

        # GPencil
        if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
            row = layout.row(align=True)
            row.operator("gpencil.copy", text="", icon='COPYDOWN')
            row.operator("gpencil.paste", text="", icon='PASTEDOWN')

            # XXX: icon
            layout.prop(context.gpencil_data, "use_onion_skinning", text="Onion Skins", icon='PARTICLE_PATH')

            row = layout.row(align=True)
            row.prop(context.tool_settings.gpencil_sculpt, "use_select_mask")
            row.prop(context.tool_settings.gpencil_sculpt, "selection_alpha", slider=True)
Ejemplo n.º 20
0
    def draw(self, context):
        datapath, icon = self.init()
        menu = utils_core.Menu(self)
        settings = UnifiedPaintPanel.paint_settings(context)
        colum_n = utils_core.addon_settings(lists=False)

        menu.add_item().label(text="Brush")
        menu.add_item().separator()

        has_brush = utils_core.get_brush_link(context, types="brush")
        current_brush = eval(
            "bpy.context.{}".format(datapath)) if has_brush else None

        # get the current brush's name
        if current_brush and utils_core.get_mode() != utils_core.particle_edit:
            current_brush = current_brush.name

        if utils_core.get_mode() == utils_core.particle_edit:
            particle_tools = [["None", 'NONE'], ["Comb", 'COMB'],
                              ["Smooth", 'SMOOTH'], ["Add", 'ADD'],
                              ["Length", 'LENGTH'], ["Puff", 'PUFF'],
                              ["Cut", 'CUT'], ["Weight", 'WEIGHT']]

            # if you are in particle edit mode add the menu items for particle mode
            for tool in particle_tools:
                utils_core.menuprop(menu.add_item(),
                                    tool[0],
                                    tool[1],
                                    datapath,
                                    icon='RADIOBUT_OFF',
                                    disable=True,
                                    disable_icon='RADIOBUT_ON')
        else:
            column_flow = menu.add_item("column_flow", columns=colum_n)
            if utils_core.addon_settings(lists=True) == 'template':
                self.layout.template_ID_preview(settings,
                                                "brush",
                                                new="brush.add",
                                                rows=3,
                                                cols=colum_n)
            else:
                # iterate over all the brushes
                for item in bpy.data.brushes:
                    if utils_core.get_mode() == utils_core.sculpt:
                        if item.use_paint_sculpt:
                            # if you are in sculpt mode and the brush
                            # is a sculpt brush add the brush to the menu
                            utils_core.menuprop(
                                menu.add_item(parent=column_flow),
                                item.name,
                                'bpy.data.brushes["%s"]' % item.name,
                                datapath,
                                icon=icon[item.sculpt_tool],
                                disable=True,
                                custom_disable_exp=[item.name, current_brush],
                                path=True)
                    if utils_core.get_mode() == utils_core.vertex_paint:
                        if item.use_paint_vertex:
                            # if you are in vertex paint mode and the brush
                            # is a vertex paint brush add the brush to the menu
                            utils_core.menuprop(
                                menu.add_item(parent=column_flow),
                                item.name,
                                'bpy.data.brushes["%s"]' % item.name,
                                datapath,
                                icon=icon[item.vertex_tool],
                                disable=True,
                                custom_disable_exp=[item.name, current_brush],
                                path=True)
                    if utils_core.get_mode() == utils_core.weight_paint:
                        if item.use_paint_weight:
                            # if you are in weight paint mode and the brush
                            # is a weight paint brush add the brush to the menu
                            utils_core.menuprop(
                                menu.add_item(parent=column_flow),
                                item.name,
                                'bpy.data.brushes["%s"]' % item.name,
                                datapath,
                                icon=icon[item.vertex_tool],
                                disable=True,
                                custom_disable_exp=[item.name, current_brush],
                                path=True)
                    if utils_core.get_mode() == utils_core.texture_paint:
                        if item.use_paint_image:
                            # if you are in texture paint mode and the brush
                            # is a texture paint brush add the brush to the menu
                            utils_core.menuprop(
                                menu.add_item(parent=column_flow),
                                item.name,
                                'bpy.data.brushes["%s"]' % item.name,
                                datapath,
                                icon=icon[item.image_tool],
                                disable=True,
                                custom_disable_exp=[item.name, current_brush],
                                path=True)
Ejemplo n.º 21
0
    def draw(self, context):
        mode = utils_core.get_mode()
        layout = self.layout
        settings = UnifiedPaintPanel.paint_settings(context)
        colum_n = utils_core.addon_settings(lists=False)

        layout.row().label(text="Brush")
        layout.row().separator()

        has_brush = utils_core.get_brush_link(context, types="brush")
        current_brush = eval("bpy.context.{}".format(
            brush_datapath[mode])) if has_brush else None

        # get the current brush's name
        if current_brush and utils_core.get_mode() != 'PARTICLE_EDIT':
            current_brush = current_brush.name

        if mode == 'PARTICLE_EDIT':
            # if you are in particle edit mode add the menu items for particle mode
            for tool in particle_tools:
                utils_core.menuprop(layout.row(),
                                    tool[0],
                                    tool[1],
                                    brush_datapath[mode],
                                    icon='RADIOBUT_OFF',
                                    disable=True,
                                    disable_icon='RADIOBUT_ON')
        else:
            column_flow = layout.column_flow(columns=colum_n)
            if utils_core.addon_settings(lists=True) == 'template':
                layout.template_ID_preview(settings,
                                           "brush",
                                           new="brush.add",
                                           rows=3,
                                           cols=colum_n)
            else:
                # iterate over all the brushes
                for item in bpy.data.brushes:
                    if mode == 'SCULPT':
                        if item.use_paint_sculpt:
                            # if you are in sculpt mode and the brush
                            # is a sculpt brush add the brush to the menu
                            utils_core.menuprop(
                                column_flow.row(),
                                item.name,
                                'bpy.data.brushes["%s"]' % item.name,
                                brush_datapath[mode],
                                icon=brush_icon[mode][item.sculpt_tool],
                                disable=True,
                                custom_disable_exp=(item.name, current_brush),
                                path=True)
                    if mode == 'VERTEX_PAINT':
                        if item.use_paint_vertex:
                            # if you are in vertex paint mode and the brush
                            # is a vertex paint brush add the brush to the menu
                            utils_core.menuprop(
                                column_flow.row(),
                                item.name,
                                'bpy.data.brushes["%s"]' % item.name,
                                brush_datapath[mode],
                                icon=brush_icon[mode][item.vertex_tool],
                                disable=True,
                                custom_disable_exp=(item.name, current_brush),
                                path=True)
                    if mode == 'WEIGHT_PAINT':
                        if item.use_paint_weight:
                            # if you are in weight paint mode and the brush
                            # is a weight paint brush add the brush to the menu
                            utils_core.menuprop(
                                column_flow.row(),
                                item.name,
                                'bpy.data.brushes["%s"]' % item.name,
                                brush_datapath[mode],
                                icon=brush_icon[mode][item.vertex_tool],
                                disable=True,
                                custom_disable_exp=(item.name, current_brush),
                                path=True)
                    if utils_core.get_mode() == 'TEXTURE_PAINT':
                        if item.use_paint_image:
                            # if you are in texture paint mode and the brush
                            # is a texture paint brush add the brush to the menu
                            utils_core.menuprop(
                                column_flow.row(),
                                item.name,
                                'bpy.data.brushes["%s"]' % item.name,
                                brush_datapath[mode],
                                icon=brush_icon[mode][item.image_tool],
                                disable=True,
                                custom_disable_exp=(item.name, current_brush),
                                path=True)
Ejemplo n.º 22
0
    def draw(self, context):
        mode = utils_core.get_mode()
        layout = self.layout
        settings = UnifiedPaintPanel.paint_settings(context)
        colum_n = utils_core.addon_settings(lists=False)

        layout.row().label(text="Brush")
        layout.row().separator()

        has_brush = utils_core.get_brush_link(context, types="brush")
        current_brush = eval("bpy.context.{}".format(brush_datapath[mode])) if has_brush else None

        # get the current brush's name
        if current_brush and utils_core.get_mode() != 'PARTICLE_EDIT':
            current_brush = current_brush.name

        if mode == 'PARTICLE_EDIT':
            # if you are in particle edit mode add the menu items for particle mode
            for tool in particle_tools:
                utils_core.menuprop(
                        layout.row(), tool[0], tool[1], brush_datapath[mode],
                        icon='RADIOBUT_OFF', disable=True,
                        disable_icon='RADIOBUT_ON'
                        )
        else:
            column_flow = layout.column_flow(columns=colum_n)
            if utils_core.addon_settings(lists=True) == 'template':
                layout.template_ID_preview(settings, "brush",
                                           new="brush.add", rows=3, cols=colum_n)
            else:
                # iterate over all the brushes
                for item in bpy.data.brushes:
                    if mode == 'SCULPT':
                        if item.use_paint_sculpt:
                            # if you are in sculpt mode and the brush
                            # is a sculpt brush add the brush to the menu
                            utils_core.menuprop(
                                    column_flow.row(), item.name,
                                    'bpy.data.brushes["%s"]' % item.name,
                                    brush_datapath[mode], icon=brush_icon[mode][item.sculpt_tool],
                                    disable=True, custom_disable_exp=(item.name, current_brush),
                                    path=True
                                    )
                    if mode == 'VERTEX_PAINT':
                        if item.use_paint_vertex:
                            # if you are in vertex paint mode and the brush
                            # is a vertex paint brush add the brush to the menu
                            utils_core.menuprop(
                                    column_flow.row(), item.name,
                                    'bpy.data.brushes["%s"]' % item.name,
                                    brush_datapath[mode], icon=brush_icon[mode][item.vertex_tool],
                                    disable=True, custom_disable_exp=(item.name, current_brush),
                                    path=True
                                    )
                    if mode == 'WEIGHT_PAINT':
                        if item.use_paint_weight:
                            # if you are in weight paint mode and the brush
                            # is a weight paint brush add the brush to the menu
                            utils_core.menuprop(
                                    column_flow.row(), item.name,
                                    'bpy.data.brushes["%s"]' % item.name,
                                    brush_datapath[mode], icon=brush_icon[mode][item.vertex_tool],
                                    disable=True, custom_disable_exp=(item.name, current_brush),
                                    path=True
                                    )
                    if utils_core.get_mode() == 'TEXTURE_PAINT':
                        if item.use_paint_image:
                            # if you are in texture paint mode and the brush
                            # is a texture paint brush add the brush to the menu
                            utils_core.menuprop(
                                    column_flow.row(), item.name,
                                    'bpy.data.brushes["%s"]' % item.name,
                                    brush_datapath[mode], icon=brush_icon[mode][item.image_tool],
                                    disable=True, custom_disable_exp=(item.name, current_brush),
                                    path=True
                                    )
Ejemplo n.º 23
0
def VIEW3D_HT_header_draw_new(self, context):
    if "BLEND4WEB" not in context.scene.render.engine:
        _VIEW3D_HT_header_draw(self, context)
    else:
        layout = self.layout

        view = context.space_data
        # mode_string = context.mode
        obj = context.active_object
        toolsettings = context.tool_settings

        row = layout.row(align=True)
        row.template_header()

        bpy.types.VIEW3D_MT_editor_menus.draw_collapsible(context, layout)

        # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode...
        row = layout
        layout.template_header_3D()

        if obj:
            mode = obj.mode
            # Particle edit
            if mode == 'PARTICLE_EDIT':
                row.prop(toolsettings.particle_edit,
                         "select_mode",
                         text="",
                         expand=True)

            # Occlude geometry
            if ((view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'} and
                 (mode == 'PARTICLE_EDIT' or
                  (mode == 'EDIT' and obj.type == 'MESH')))
                    or (mode == 'WEIGHT_PAINT')):
                row.prop(view, "use_occlude_geometry", text="")

            # Proportional editing
            if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
                row = layout.row(align=True)
                row.prop(toolsettings, "proportional_edit", icon_only=True)
                if toolsettings.proportional_edit != 'DISABLED':
                    row.prop(toolsettings,
                             "proportional_edit_falloff",
                             icon_only=True)
            elif mode in {'EDIT', 'PARTICLE_EDIT'}:
                row = layout.row(align=True)
                row.prop(toolsettings, "proportional_edit", icon_only=True)
                if toolsettings.proportional_edit != 'DISABLED':
                    row.prop(toolsettings,
                             "proportional_edit_falloff",
                             icon_only=True)
            elif mode == 'OBJECT':
                row = layout.row(align=True)
                row.prop(toolsettings,
                         "use_proportional_edit_objects",
                         icon_only=True)
                if toolsettings.use_proportional_edit_objects:
                    row.prop(toolsettings,
                             "proportional_edit_falloff",
                             icon_only=True)
        else:
            # Proportional editing
            if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
                row = layout.row(align=True)
                row.prop(toolsettings, "proportional_edit", icon_only=True)
                if toolsettings.proportional_edit != 'DISABLED':
                    row.prop(toolsettings,
                             "proportional_edit_falloff",
                             icon_only=True)

        # Snap
        show_snap = False
        if obj is None:
            show_snap = True
        else:
            if mode not in {
                    'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT'
            }:
                show_snap = True
            else:
                paint_settings = UnifiedPaintPanel.paint_settings(context)
                if paint_settings:
                    brush = paint_settings.brush
                    if brush and brush.stroke_method == 'CURVE':
                        show_snap = True

        if show_snap:
            snap_element = toolsettings.snap_element
            row = layout.row(align=True)
            row.prop(toolsettings, "use_snap", text="")
            row.prop(toolsettings, "snap_element", icon_only=True)
            if snap_element == 'INCREMENT':
                row.prop(toolsettings, "use_snap_grid_absolute", text="")
            else:
                row.prop(toolsettings, "snap_target", text="")
                if obj:
                    if mode == 'EDIT':
                        row.prop(toolsettings, "use_snap_self", text="")
                    if mode in {'OBJECT', 'POSE', 'EDIT'
                                } and snap_element != 'VOLUME':
                        row.prop(toolsettings,
                                 "use_snap_align_rotation",
                                 text="")

            if snap_element == 'VOLUME':
                row.prop(toolsettings, "use_snap_peel_object", text="")
            elif snap_element == 'FACE':
                row.prop(toolsettings, "use_snap_project", text="")

        # AutoMerge editing
        if obj:
            if (mode == 'EDIT' and obj.type == 'MESH'):
                layout.prop(toolsettings,
                            "use_mesh_automerge",
                            text="",
                            icon='AUTOMERGE_ON')

        # Pose
        if obj and mode == 'POSE':
            row = layout.row(align=True)
            row.operator("pose.copy", text="", icon='COPYDOWN')
            row.operator("pose.paste", text="",
                         icon='PASTEDOWN').flipped = False
            row.operator("pose.paste", text="",
                         icon='PASTEFLIPDOWN').flipped = True

        # GPencil
        if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
            row = layout.row(align=True)
            row.operator("gpencil.copy", text="", icon='COPYDOWN')
            row.operator("gpencil.paste", text="", icon='PASTEDOWN')

            # XXX: icon
            layout.prop(context.gpencil_data,
                        "use_onion_skinning",
                        text="Onion Skins",
                        icon='PARTICLE_PATH')

            row = layout.row(align=True)
            row.prop(context.tool_settings.gpencil_sculpt, "use_select_mask")
            row.prop(context.tool_settings.gpencil_sculpt,
                     "selection_alpha",
                     slider=True)