[Bf-blender-cvs] [36d5b6e9594] sculpt-dev: Sculpt: Brush settings panel editor
Joseph Eagar
noreply at git.blender.org
Thu Sep 23 03:28:52 CEST 2021
Commit: 36d5b6e9594223b78f4b7592b06865f9a195963b
Author: Joseph Eagar
Date: Wed Sep 22 18:26:25 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB36d5b6e9594223b78f4b7592b06865f9a195963b
Sculpt: Brush settings panel editor
* Moved brush settings (in sculpt mode) to
(for now) a new properties editor tab.
* Brush settings can now be individually configured
to show up in the workspace buttons.
* Brush settings can also be reordered.
* The new brush tab has a "preview" subpanel
to preview the workspace settings layout.
This is where settings are reordered.
===================================================================
M release/scripts/startup/bl_ui/__init__.py
M release/scripts/startup/bl_ui/properties_paint_common.py
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/blenkernel/BKE_brush_engine.h
M source/blender/blenkernel/intern/brush.c
M source/blender/blenkernel/intern/brush_channel_define.h
M source/blender/blenkernel/intern/brush_engine.c
M source/blender/blenkernel/intern/brush_engine_presets.c
M source/blender/editors/space_buttons/buttons_context.c
M source/blender/editors/space_buttons/space_buttons.c
M source/blender/editors/space_view3d/space_view3d.c
M source/blender/makesdna/DNA_sculpt_brush_types.h
M source/blender/makesdna/DNA_space_types.h
M source/blender/makesrna/intern/rna_brush_engine.c
M source/blender/makesrna/intern/rna_space.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index 25484e905c3..842750969b7 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -97,7 +97,7 @@ _modules = [
"space_view3d_toolbar",
# XXX, keep last so panels show after all other tool options.
- "properties_workspace",
+ "properties_workspace"
]
import bpy
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 3a7e9382046..d4b61f70437 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -29,6 +29,7 @@ channel_name_map = {
"autosmooth_fset_slide": "fset_slide",
"topology_rake_factor": "topology_rake"
};
+expand_channels = {"direction"}
class UnifiedPaintPanel:
# subclass must set
@@ -109,12 +110,15 @@ class UnifiedPaintPanel:
@staticmethod
def channel_unified(layout, context, brush, prop_name, icon='NONE', pressure=True, text=None,
- slider=False, header=False, expand=None, toolsettings_only=False):
+ slider=False, header=False, show_reorder=False, expand=None, toolsettings_only=False, ui_editing=True):
""" Generalized way of adding brush options to the UI,
along with their pen pressure setting and global toggle, if they exist. """
ch = brush.channels.channels[prop_name]
finalch = ch
+ if prop_name in expand_channels:
+ expand = True
+
l1 = layout
#if ch.ui_expanded:
@@ -161,6 +165,21 @@ class UnifiedPaintPanel:
path = "tool_settings.sculpt.channels.channels[\"%s\"]" % ch.idname
else:
path = "tool_settings.sculpt.brush.channels.channels[\"%s\"]" % ch.idname
+
+ if show_reorder:
+ props = row.operator("brush.change_channel_order", text="", icon="TRIA_UP")
+ props.channel = ch.idname
+ props.filterkey = "show_in_workspace"
+ props.direction = -1
+
+ props = row.operator("brush.change_channel_order", text="", icon="TRIA_DOWN")
+ props.filterkey = "show_in_workspace"
+ props.channel = ch.idname
+ props.direction = 1
+
+ if ui_editing:
+ row.prop(ch, "show_in_workspace", text="", icon="HIDE_OFF")
+ #row.prop(ch, "ui_order", text="")
if ch.type == "BITMASK":
row.label(text=text)
@@ -186,6 +205,8 @@ class UnifiedPaintPanel:
if pressure:
row.prop(finalch.mappings["PRESSURE"], "enabled", text="", icon="STYLUS_PRESSURE")
+
+
#if pressure_name:
# row.prop(brush, pressure_name, text="")
@@ -202,6 +223,9 @@ class UnifiedPaintPanel:
if ch.type == "BITMASK" or ch.type == "BOOL":
return
+ if not ui_editing and not show_reorder:
+ return
+
row.prop(ch, "ui_expanded", text="", icon="TRIA_DOWN" if ch.ui_expanded else "TRIA_RIGHT")
if ch.ui_expanded:
@@ -1075,9 +1099,6 @@ def brush_settings(layout, context, brush, popover=False):
layout.row().prop(brush, "mask_tool", expand=True)
- layout.template_curve_mapping(brush, "pressure_size_curve")
- layout.template_curve_mapping(brush, "pressure_strength_curve", brush=True)
-
# End sculpt_tool interface.
# 3D and 2D Texture Paint Mode.
@@ -1226,6 +1247,91 @@ def brush_shared_settings(layout, context, brush, popover=False):
"direction", expand=True)
#layout.row().prop(brush, "direction", expand=True)
+from bpy.types import Operator
+from bpy.props import IntProperty, StringProperty
+
+def get_ui_channels(channels, filterkeys=["show_in_workspace"]):
+ ret = []
+ for ch in channels:
+ ok = len(filterkeys) == 0
+ for key in filterkeys:
+ if getattr(ch, key):
+ ok = True
+ break
+ if ok:
+ ret.append(ch)
+
+ ret.sort(key = lambda x: x.ui_order)
+
+ return ret
+
+class ReorderBrushChannel(Operator):
+ """Tooltip"""
+ bl_idname = "brush.change_channel_order"
+ bl_label = "Change Channel Order"
+ bl_options = {"UNDO"}
+
+ direction : IntProperty()
+ channel : StringProperty()
+ filterkey : StringProperty()
+
+ @classmethod
+ def poll(cls, context):
+ return context.mode == "SCULPT" and context.tool_settings.sculpt.brush
+
+ def execute(self, context):
+ ts = context.tool_settings
+
+ brush = ts.sculpt.brush
+
+ channels = brush.channels.channels
+ if self.channel not in channels:
+ print("bad channel ", self.channel)
+ return {'CANCELLED'}
+
+ uinames = get_ui_channels(channels, [self.filterkey])
+ uinames = set(map(lambda x: x.idname, uinames))
+
+ channel = channels[self.channel]
+
+ channels = list(channels)
+ channels.sort(key = lambda x: x.ui_order)
+
+ i = channels.index(channel)
+ i2 = i + self.direction
+
+ print("ORDERING", i, i2, self.direction, i2 < 0 or i2 >= len(channels))
+
+ if i2 < 0 or i2 >= len(channels):
+ return {'CANCELLED'}
+
+ while i2 >= 0 and i2 < len(channels) and channels[i2].idname not in uinames:
+ i2 += self.direction
+
+ i2 = min(max(i2, 0), len(channels)-1)
+
+ tmp = channels[i2]
+ channels[i2] = channels[i]
+ channels[i] = tmp
+
+ #ensure ui_order is 1-to-1
+ for i, ch in enumerate(channels):
+ ch.ui_order = i
+ print(ch.idname, i)
+
+
+ return {'FINISHED'}
+
+def brush_settings_channels(layout, context, brush, ui_editing=False, popover=False, filterkey="show_in_workspace"):
+ channels = get_ui_channels(brush.channels.channels, [filterkey])
+
+ for ch in channels:
+ UnifiedPaintPanel.channel_unified(
+ layout.column(),
+ context,
+ brush,
+ ch.idname, show_reorder = ui_editing, expand=False, ui_editing=False)
+
def brush_settings_advanced(layout, context, brush, popover=False):
"""Draw advanced brush settings for Sculpt, Texture/Vertex/Weight Paint modes."""
@@ -1709,6 +1815,7 @@ def brush_basic_gpencil_vertex_settings(layout, _context, brush, *, compact=Fals
classes = (
VIEW3D_MT_tools_projectpaint_clone,
+ ReorderBrushChannel
)
if __name__ == "__main__": # only for live edit.
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 64170b8faa8..c4268bb100b 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -17,7 +17,7 @@
# ##### END GPL LICENSE BLOCK #####
# <pep8 compliant>
-from bpy.types import Menu, Panel, UIList, WindowManager
+from bpy.types import Menu, Panel, UIList, WindowManager, SpaceProperties
from bl_ui.properties_grease_pencil_common import (
GreasePencilSculptOptionsPanel,
GreasePencilDisplayPanel,
@@ -37,6 +37,7 @@ from bl_ui.properties_paint_common import (
brush_mask_texture_settings,
brush_settings,
brush_settings_advanced,
+ brush_settings_channels,
draw_color_settings,
)
from bl_ui.utils import PresetPanel
@@ -378,7 +379,9 @@ class VIEW3D_PT_tools_brush_select(Panel, View3DPaintBrushPanel, BrushSelectPane
bl_label = "Brushes"
-# TODO, move to space_view3d.py
+def is_brush_editor(context):
+ return type(context.space_data) == SpaceProperties and context.space_data.context == "BRUSH_EDITOR"
+
class VIEW3D_PT_tools_brush_settings(Panel, View3DPaintBrushPanel):
bl_context = ".paint_common"
bl_label = "Brush Settings"
@@ -386,7 +389,11 @@ class VIEW3D_PT_tools_brush_settings(Panel, View3DPaintBrushPanel):
@classmethod
def poll(cls, context):
settings = cls.paint_settings(context)
- return settings and settings.brush is not None
+
+ ok = settings and settings.brush is not None
+ ok = ok and not (context.mode == "SCULPT" and not is_brush_editor(context))
+
+ return ok
def draw(self, context):
layout = self.layout
@@ -399,6 +406,54 @@ class VIEW3D_PT_tools_brush_settings(Panel, View3DPaintBrushPanel):
brush_settings(layout.column(), context, brush, popover=self.is_popover)
+class VIEW3D_PT_tools_brush_settings_channels(Panel, View3DPaintBrushPanel):
+ bl_context = ".paint_common"
+ bl_label = "Brush Settings"
+
+ @classmethod
+ def poll(cls, context):
+ settings = cls.paint_settings(context)
+
+ ok = settings and settings.brush is not None
+ ok = ok and context.mode == "SCULPT" and not is_brush_editor(context)
+
+ return ok
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.use_property_split = True
+ layout.use_property_decorate = False # No animation.
+
+ settings = self.paint_settings(context)
+ brush = settings.brush
+
+ brush_settings_channels(layout.column(), context, brush, popover=self.is_popover)
+
+class VIEW3D_PT_tools_brush_settings_channels_preview(Panel, View3DPaintBrushPanel):
+ bl_context = ".paint_common"
+ bl_parent_id = "VIEW3D_PT_tools_brush_settings"
+ bl_label = "Settings Preview"
+
+ @classmethod
+ def poll(cls, context):
+ settings = cls.paint_settings(context)
+
+ ok = settings and settings.brush is not None
+ ok = ok and context.mode == "SCULPT" and is_brush_editor(context)
+
+ return ok
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.use_property_split = True
+ layout.use_property_decorate = False # No animation.
+
+ settings = self.paint_settings(context)
+ brush = settings.brush
+
+ brush_settings_channels(layout.column(), context, brush, ui_editing=True, popover=self.is_popover)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list