2017-10-21 16:19:48 +11:00
|
|
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
#
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
|
|
|
|
|
|
|
# <pep8 compliant>
|
|
|
|
|
|
|
|
# For now group all tools together
|
|
|
|
# we may want to move these into per space-type files.
|
|
|
|
#
|
|
|
|
# For now keep this in a single file since it's an area that may change,
|
|
|
|
# so avoid making changes all over the place.
|
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
import bpy
|
2017-10-21 16:19:48 +11:00
|
|
|
from bpy.types import Panel
|
|
|
|
|
|
|
|
from .space_toolsystem_common import (
|
|
|
|
ToolSelectPanelHelper,
|
2018-04-27 13:23:29 +02:00
|
|
|
ToolDef,
|
2017-10-21 16:19:48 +11:00
|
|
|
)
|
2018-11-02 09:10:23 +11:00
|
|
|
|
2018-08-02 17:41:11 +10:00
|
|
|
def generate_from_enum_ex(
|
|
|
|
context, *,
|
|
|
|
icon_prefix,
|
2018-11-05 13:54:43 +11:00
|
|
|
type,
|
2018-08-02 17:41:11 +10:00
|
|
|
attr,
|
2018-11-06 12:08:39 +11:00
|
|
|
tooldef_keywords={},
|
2018-08-02 17:41:11 +10:00
|
|
|
):
|
|
|
|
tool_defs = []
|
2018-11-05 13:54:43 +11:00
|
|
|
for enum in type.bl_rna.properties[attr].enum_items_static:
|
2018-08-02 17:41:11 +10:00
|
|
|
name = enum.name
|
|
|
|
identifier = enum.identifier
|
|
|
|
tool_defs.append(
|
|
|
|
ToolDef.from_dict(
|
|
|
|
dict(
|
|
|
|
text=name,
|
|
|
|
icon=icon_prefix + identifier.lower(),
|
|
|
|
data_block=identifier,
|
2018-11-06 12:08:39 +11:00
|
|
|
**tooldef_keywords,
|
2018-08-02 17:41:11 +10:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
return tuple(tool_defs)
|
|
|
|
|
|
|
|
|
2018-11-21 09:09:34 +11:00
|
|
|
# Use for shared widget data.
|
|
|
|
class _template_widget:
|
2018-11-21 09:25:55 +11:00
|
|
|
class VIEW3D_GGT_xform_extrude:
|
2018-11-21 09:09:34 +11:00
|
|
|
@staticmethod
|
|
|
|
def draw_settings(context, layout, tool):
|
2018-11-21 09:25:55 +11:00
|
|
|
props = tool.gizmo_group_properties("VIEW3D_GGT_xform_extrude")
|
2018-11-21 09:09:34 +11:00
|
|
|
layout.prop(props, "axis_type", expand=True)
|
|
|
|
|
|
|
|
|
2018-04-27 13:23:29 +02:00
|
|
|
class _defs_view3d_generic:
|
2018-04-30 12:14:46 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def cursor():
|
2018-06-22 15:07:11 +02:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("view3d.cursor3d")
|
|
|
|
layout.prop(props, "use_depth")
|
|
|
|
layout.prop(props, "orientation")
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
2018-05-07 21:38:43 +02:00
|
|
|
text="Cursor",
|
2018-08-31 14:37:10 +10:00
|
|
|
description=(
|
2018-10-04 12:04:36 +10:00
|
|
|
"Set the cursor location, drag to transform"
|
2018-08-31 14:37:10 +10:00
|
|
|
),
|
2018-05-07 21:38:43 +02:00
|
|
|
icon="ops.generic.cursor",
|
2018-11-16 09:44:19 +11:00
|
|
|
keymap=(),
|
2018-06-22 15:07:11 +02:00
|
|
|
draw_settings=draw_settings,
|
2018-05-07 21:38:43 +02:00
|
|
|
)
|
2018-04-30 12:14:46 +02:00
|
|
|
|
2018-05-28 18:05:21 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def cursor_click():
|
|
|
|
return dict(
|
2018-06-15 12:28:19 +02:00
|
|
|
text="None",
|
2018-05-28 18:05:21 +02:00
|
|
|
icon="ops.generic.cursor",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-05-28 18:05:21 +02:00
|
|
|
)
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def ruler():
|
|
|
|
return dict(
|
2018-08-23 16:50:43 +10:00
|
|
|
text="Measure",
|
2018-09-07 11:48:03 +10:00
|
|
|
description=(
|
|
|
|
"Measure distance and angles.\n"
|
|
|
|
"\u2022 Drag anywhere for new measurement.\n"
|
|
|
|
"\u2022 Drag ruler segment to measure an angle.\n"
|
|
|
|
"\u2022 Drag ruler outside the view to remove.\n"
|
|
|
|
"\u2022 Ctrl to snap.\n"
|
|
|
|
"\u2022 Shift to measure surface thickness"
|
|
|
|
),
|
2018-05-07 21:38:43 +02:00
|
|
|
icon="ops.view3d.ruler",
|
2018-07-15 14:24:10 +02:00
|
|
|
widget="VIEW3D_GGT_ruler",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-05-07 21:38:43 +02:00
|
|
|
)
|
|
|
|
|
2018-08-28 21:00:25 +10:00
|
|
|
|
2018-11-27 17:33:52 +11:00
|
|
|
class _defs_annotate:
|
|
|
|
|
|
|
|
def draw_settings_common(context, layout, tool):
|
|
|
|
if type(context.gpencil_data_owner) is bpy.types.Object:
|
|
|
|
gpd = context.scene.grease_pencil
|
|
|
|
else:
|
|
|
|
gpd = context.gpencil_data
|
|
|
|
|
|
|
|
if gpd is not None:
|
|
|
|
if gpd.layers.active_note is not None:
|
|
|
|
text = gpd.layers.active_note
|
|
|
|
maxw = 25
|
|
|
|
if len(text) > maxw:
|
|
|
|
text = text[:maxw - 5] + '..' + text[-3:]
|
2018-10-10 11:10:13 +11:00
|
|
|
else:
|
2018-11-27 17:33:52 +11:00
|
|
|
text = ""
|
|
|
|
|
|
|
|
layout.label(text="Annotation:")
|
|
|
|
gpl = context.active_gpencil_layer
|
|
|
|
if gpl is not None:
|
|
|
|
sub = layout.row(align=True)
|
|
|
|
sub.ui_units_x = 8
|
|
|
|
|
|
|
|
sub.prop(gpl, "color", text="")
|
|
|
|
sub.popover(
|
|
|
|
panel="TOPBAR_PT_annotation_layers",
|
|
|
|
text=text,
|
|
|
|
)
|
2018-07-31 10:22:19 +02:00
|
|
|
|
2018-11-27 17:33:52 +11:00
|
|
|
tool_settings = context.tool_settings
|
|
|
|
space_type = tool.space_type
|
|
|
|
if space_type == 'VIEW_3D':
|
|
|
|
layout.separator()
|
2018-07-31 10:22:19 +02:00
|
|
|
|
2018-11-27 17:33:52 +11:00
|
|
|
row = layout.row(align=True)
|
|
|
|
row.prop(tool_settings, "annotation_stroke_placement_view3d", text="Placement")
|
|
|
|
if tool_settings.gpencil_stroke_placement_view3d == 'CURSOR':
|
|
|
|
row.prop(tool_settings.gpencil_sculpt, "lockaxis")
|
|
|
|
elif tool_settings.gpencil_stroke_placement_view3d in {'SURFACE', 'STROKE'}:
|
|
|
|
row.prop(tool_settings, "use_gpencil_stroke_endpoints")
|
2018-07-31 10:22:19 +02:00
|
|
|
|
2018-11-27 17:33:52 +11:00
|
|
|
@ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
|
|
|
|
def scribble(*, draw_settings):
|
|
|
|
return dict(
|
|
|
|
text="Annotate",
|
|
|
|
icon="ops.gpencil.draw",
|
|
|
|
cursor='PAINT_BRUSH',
|
|
|
|
keymap="Generic Tool: Annotate",
|
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
2018-11-05 06:57:01 +11:00
|
|
|
|
2018-11-27 17:33:52 +11:00
|
|
|
@ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
|
|
|
|
def line(*, draw_settings):
|
|
|
|
return dict(
|
|
|
|
text="Annotate Line",
|
|
|
|
icon="ops.gpencil.draw.line",
|
|
|
|
cursor='CROSSHAIR',
|
|
|
|
keymap="Generic Tool: Annotate Line",
|
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
2018-07-31 10:22:19 +02:00
|
|
|
|
2018-11-27 17:33:52 +11:00
|
|
|
@ToolDef.from_fn.with_args(draw_settings=draw_settings_common)
|
|
|
|
def poly(*, draw_settings):
|
|
|
|
return dict(
|
|
|
|
text="Annotate Polygon",
|
|
|
|
icon="ops.gpencil.draw.poly",
|
|
|
|
cursor='CROSSHAIR',
|
|
|
|
keymap="Generic Tool: Annotate Polygon",
|
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
2018-08-28 21:00:25 +10:00
|
|
|
|
2018-11-27 17:33:52 +11:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def eraser():
|
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
# TODO: Move this setting to tool_settings
|
|
|
|
user_prefs = context.user_preferences
|
|
|
|
layout.prop(user_prefs.edit, "grease_pencil_eraser_radius", text="Radius")
|
|
|
|
return dict(
|
|
|
|
text="Annotate Eraser",
|
|
|
|
icon="ops.gpencil.draw.eraser",
|
|
|
|
cursor='CROSSHAIR', # XXX: Always show brush circle when enabled
|
|
|
|
keymap="Generic Tool: Annotate Eraser",
|
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
2018-07-31 10:22:19 +02:00
|
|
|
|
|
|
|
|
2018-04-27 13:23:29 +02:00
|
|
|
class _defs_transform:
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def translate():
|
|
|
|
return dict(
|
2018-09-06 12:13:01 +02:00
|
|
|
text="Move",
|
2018-06-28 10:34:41 +02:00
|
|
|
# cursor='SCROLL_XY',
|
2018-05-07 21:38:43 +02:00
|
|
|
icon="ops.transform.translate",
|
2018-07-15 14:24:10 +02:00
|
|
|
widget="TRANSFORM_GGT_gizmo",
|
2018-07-03 18:33:52 +02:00
|
|
|
operator="transform.translate",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-05-07 21:38:43 +02:00
|
|
|
)
|
2018-04-30 12:14:46 +02:00
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def rotate():
|
|
|
|
return dict(
|
|
|
|
text="Rotate",
|
2018-06-28 10:34:41 +02:00
|
|
|
# cursor='SCROLL_XY',
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.transform.rotate",
|
2018-07-15 14:24:10 +02:00
|
|
|
widget="TRANSFORM_GGT_gizmo",
|
2018-07-03 18:33:52 +02:00
|
|
|
operator="transform.rotate",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def scale():
|
|
|
|
return dict(
|
|
|
|
text="Scale",
|
2018-06-28 10:34:41 +02:00
|
|
|
# cursor='SCROLL_XY',
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.transform.resize",
|
2018-07-15 14:24:10 +02:00
|
|
|
widget="TRANSFORM_GGT_gizmo",
|
2018-07-03 18:33:52 +02:00
|
|
|
operator="transform.resize",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def scale_cage():
|
|
|
|
return dict(
|
|
|
|
text="Scale Cage",
|
|
|
|
icon="ops.transform.resize.cage",
|
2018-07-15 14:24:10 +02:00
|
|
|
widget="VIEW3D_GGT_xform_cage",
|
2018-07-03 18:33:52 +02:00
|
|
|
operator="transform.resize",
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def transform():
|
2018-06-22 19:22:49 +02:00
|
|
|
def draw_settings(context, layout, tool):
|
2018-10-19 11:54:26 +11:00
|
|
|
layout.label(text="Gizmos:")
|
2018-06-22 19:22:49 +02:00
|
|
|
tool_settings = context.tool_settings
|
2018-07-29 11:54:12 +10:00
|
|
|
layout.prop(tool_settings, "use_gizmo_mode")
|
2018-10-19 11:54:26 +11:00
|
|
|
|
|
|
|
props = tool.gizmo_group_properties("TRANSFORM_GGT_gizmo")
|
|
|
|
layout.prop(props, "drag_action")
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Transform",
|
2018-08-31 14:37:10 +10:00
|
|
|
description=(
|
|
|
|
"Supports any combination of grab, rotate & scale at once"
|
|
|
|
),
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.transform.transform",
|
2018-07-15 14:24:10 +02:00
|
|
|
widget="TRANSFORM_GGT_gizmo",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-06-22 19:22:49 +02:00
|
|
|
draw_settings=draw_settings,
|
2018-05-07 21:38:43 +02:00
|
|
|
)
|
|
|
|
|
2018-04-27 13:23:29 +02:00
|
|
|
|
|
|
|
class _defs_view3d_select:
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
@ToolDef.from_fn
|
2018-11-22 16:05:28 +01:00
|
|
|
def select():
|
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
pass
|
|
|
|
return dict(
|
|
|
|
text="Select",
|
|
|
|
icon="ops.generic.select",
|
|
|
|
widget=None,
|
|
|
|
keymap=(),
|
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def box():
|
2018-08-14 10:28:41 +10:00
|
|
|
def draw_settings(context, layout, tool):
|
2018-10-05 10:27:04 +10:00
|
|
|
props = tool.operator_properties("view3d.select_box")
|
2018-08-14 10:28:41 +10:00
|
|
|
layout.prop(props, "mode", expand=True)
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
2018-10-05 10:27:04 +10:00
|
|
|
text="Select Box",
|
|
|
|
icon="ops.generic.select_box",
|
2018-04-30 12:14:46 +02:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-11-13 14:05:20 +11:00
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def lasso():
|
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("view3d.select_lasso")
|
|
|
|
layout.prop(props, "mode", expand=True)
|
|
|
|
return dict(
|
|
|
|
text="Select Lasso",
|
|
|
|
icon="ops.generic.select_lasso",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-08-14 10:28:41 +10:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def circle():
|
2018-08-29 15:03:50 +10:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("view3d.select_circle")
|
|
|
|
layout.prop(props, "radius")
|
2018-10-25 21:05:29 +11:00
|
|
|
|
|
|
|
def draw_cursor(context, tool, xy):
|
|
|
|
from gpu_extras.presets import draw_circle_2d
|
|
|
|
props = tool.operator_properties("view3d.select_circle")
|
|
|
|
radius = props.radius
|
|
|
|
draw_circle_2d(xy, (1.0,) * 4, radius, 32)
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Select Circle",
|
|
|
|
icon="ops.generic.select_circle",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-08-29 15:03:50 +10:00
|
|
|
draw_settings=draw_settings,
|
2018-10-25 21:05:29 +11:00
|
|
|
draw_cursor=draw_cursor,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
2018-11-13 14:05:20 +11:00
|
|
|
|
2018-04-27 13:23:29 +02:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Object Modes (named based on context.mode)
|
|
|
|
|
2018-05-07 21:38:43 +02:00
|
|
|
|
2018-04-27 13:23:29 +02:00
|
|
|
class _defs_edit_armature:
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def roll():
|
|
|
|
return dict(
|
|
|
|
text="Roll",
|
|
|
|
icon="ops.armature.bone.roll",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
2018-05-15 10:24:26 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def bone_envelope():
|
|
|
|
return dict(
|
|
|
|
text="Bone Envelope",
|
2018-05-15 13:49:44 +02:00
|
|
|
icon="ops.transform.bone_envelope",
|
2018-05-15 10:24:26 +02:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-05-15 10:24:26 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def bone_size():
|
|
|
|
return dict(
|
|
|
|
text="Bone Size",
|
2018-05-15 13:49:44 +02:00
|
|
|
icon="ops.transform.bone_size",
|
2018-05-15 10:24:26 +02:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-05-15 10:24:26 +02:00
|
|
|
)
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def extrude():
|
|
|
|
return dict(
|
|
|
|
text="Extrude",
|
|
|
|
icon="ops.armature.extrude_move",
|
2018-11-21 09:25:55 +11:00
|
|
|
widget="VIEW3D_GGT_xform_extrude",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-11-21 09:25:55 +11:00
|
|
|
draw_settings=_template_widget.VIEW3D_GGT_xform_extrude.draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def extrude_cursor():
|
|
|
|
return dict(
|
|
|
|
text="Extrude to Cursor",
|
|
|
|
icon="ops.armature.extrude_cursor",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-04-27 13:23:29 +02:00
|
|
|
)
|
2018-05-07 21:38:43 +02:00
|
|
|
|
|
|
|
|
2018-04-27 13:23:29 +02:00
|
|
|
class _defs_edit_mesh:
|
|
|
|
|
2018-05-10 20:16:22 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def cube_add():
|
|
|
|
return dict(
|
|
|
|
text="Add Cube",
|
2018-08-29 18:40:32 +10:00
|
|
|
icon="ops.mesh.primitive_cube_add_gizmo",
|
2018-05-10 20:16:22 +02:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-05-10 20:16:22 +02:00
|
|
|
)
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def rip_region():
|
2018-05-22 14:00:44 +02:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("mesh.rip_move")
|
2018-05-11 20:22:04 +02:00
|
|
|
props_macro = props.MESH_OT_rip
|
|
|
|
layout.prop(props_macro, "use_fill")
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Rip Region",
|
|
|
|
icon="ops.mesh.rip",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-05-11 20:22:04 +02:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def rip_edge():
|
|
|
|
return dict(
|
|
|
|
text="Rip Edge",
|
|
|
|
icon="ops.mesh.rip_edge",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def poly_build():
|
|
|
|
return dict(
|
|
|
|
text="Poly Build",
|
|
|
|
icon="ops.mesh.polybuild_hover",
|
2018-09-09 16:11:02 +10:00
|
|
|
widget="VIEW3D_GGT_mesh_preselect_elem",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def edge_slide():
|
2018-08-22 17:53:03 +10:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("transform.edge_slide")
|
|
|
|
layout.prop(props, "correct_uv")
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Edge Slide",
|
|
|
|
icon="ops.transform.edge_slide",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-08-22 17:53:03 +10:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def vert_slide():
|
2018-08-22 17:53:03 +10:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("transform.vert_slide")
|
|
|
|
layout.prop(props, "correct_uv")
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Vertex Slide",
|
|
|
|
icon="ops.transform.vert_slide",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-08-22 17:53:03 +10:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def spin():
|
2018-09-17 14:52:54 +10:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("mesh.spin")
|
|
|
|
layout.prop(props, "steps")
|
2018-10-02 17:05:13 +10:00
|
|
|
props = tool.gizmo_group_properties("MESH_GGT_spin")
|
|
|
|
layout.prop(props, "axis")
|
2018-09-17 14:52:54 +10:00
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Spin",
|
|
|
|
icon="ops.mesh.spin",
|
2018-09-18 13:24:35 +10:00
|
|
|
widget="MESH_GGT_spin",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-09-17 14:52:54 +10:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def spin_duplicate():
|
2018-09-17 14:52:54 +10:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("mesh.spin")
|
|
|
|
layout.prop(props, "steps")
|
2018-10-02 17:05:13 +10:00
|
|
|
props = tool.gizmo_group_properties("MESH_GGT_spin")
|
|
|
|
layout.prop(props, "axis")
|
2018-09-17 14:52:54 +10:00
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Spin (Duplicate)",
|
|
|
|
icon="ops.mesh.spin.duplicate",
|
2018-09-18 13:24:35 +10:00
|
|
|
widget="MESH_GGT_spin",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-09-17 14:52:54 +10:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def inset():
|
2018-05-22 14:00:44 +02:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("mesh.inset")
|
2018-05-11 20:23:29 +02:00
|
|
|
layout.prop(props, "use_outset")
|
|
|
|
layout.prop(props, "use_individual")
|
|
|
|
layout.prop(props, "use_even_offset")
|
|
|
|
layout.prop(props, "use_relative_offset")
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Inset Faces",
|
|
|
|
icon="ops.mesh.inset",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-05-11 20:23:29 +02:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def bevel():
|
2018-08-22 17:37:07 +10:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("mesh.bevel")
|
|
|
|
layout.prop(props, "offset_type")
|
|
|
|
layout.prop(props, "segments")
|
|
|
|
layout.prop(props, "profile", slider=True)
|
|
|
|
layout.prop(props, "vertex_only")
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Bevel",
|
|
|
|
icon="ops.mesh.bevel",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-08-22 17:37:07 +10:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def extrude():
|
|
|
|
return dict(
|
|
|
|
text="Extrude Region",
|
2018-10-02 18:48:28 +10:00
|
|
|
# The operator description isn't useful in this case, give our own.
|
|
|
|
description=(
|
|
|
|
"Extrude freely or along an axis"
|
|
|
|
),
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.mesh.extrude_region_move",
|
2018-11-21 09:25:55 +11:00
|
|
|
widget="VIEW3D_GGT_xform_extrude",
|
2018-10-02 18:48:28 +10:00
|
|
|
# Important to use same operator as 'E' key.
|
|
|
|
operator="view3d.edit_mesh_extrude_move_normal",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-11-21 09:25:55 +11:00
|
|
|
draw_settings=_template_widget.VIEW3D_GGT_xform_extrude.draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
2018-08-29 22:59:49 +10:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def extrude_normals():
|
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("mesh.extrude_region_shrink_fatten")
|
|
|
|
props_macro = props.TRANSFORM_OT_shrink_fatten
|
|
|
|
layout.prop(props_macro, "use_even_offset")
|
|
|
|
return dict(
|
|
|
|
text="Extrude Along Normals",
|
|
|
|
icon="ops.mesh.extrude_region_shrink_fatten",
|
|
|
|
widget=None,
|
2018-10-02 15:17:00 +10:00
|
|
|
operator="mesh.extrude_region_shrink_fatten",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-08-29 22:59:49 +10:00
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def extrude_individual():
|
|
|
|
return dict(
|
|
|
|
text="Extrude Individual",
|
|
|
|
icon="ops.mesh.extrude_faces_move",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def extrude_cursor():
|
2018-09-27 12:23:01 +10:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("mesh.dupli_extrude_cursor")
|
|
|
|
layout.prop(props, "rotate_source")
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Extrude to Cursor",
|
|
|
|
icon="ops.mesh.dupli_extrude_cursor",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-09-27 12:23:01 +10:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def loopcut_slide():
|
2018-08-22 14:04:37 +10:00
|
|
|
|
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("mesh.loopcut_slide")
|
|
|
|
props_macro = props.MESH_OT_loopcut
|
|
|
|
layout.prop(props_macro, "number_cuts")
|
|
|
|
props_macro = props.TRANSFORM_OT_edge_slide
|
|
|
|
layout.prop(props_macro, "correct_uv")
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Loop Cut",
|
|
|
|
icon="ops.mesh.loopcut_slide",
|
2018-08-21 19:02:28 +10:00
|
|
|
widget="VIEW3D_GGT_mesh_preselect_edgering",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-08-22 14:04:37 +10:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def offset_edge_loops_slide():
|
|
|
|
return dict(
|
|
|
|
text="Offset Edge Loop Cut",
|
|
|
|
icon="ops.mesh.offset_edge_loops_slide",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def vertex_smooth():
|
2018-09-13 09:23:24 +10:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("mesh.vertices_smooth")
|
|
|
|
layout.prop(props, "repeat")
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Smooth",
|
|
|
|
icon="ops.mesh.vertices_smooth",
|
2018-09-13 09:19:30 +10:00
|
|
|
widget="WM_GGT_value_operator_redo",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-09-13 09:23:24 +10:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def vertex_randomize():
|
2018-09-13 09:23:24 +10:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("transform.vertex_random")
|
|
|
|
layout.prop(props, "uniform")
|
|
|
|
layout.prop(props, "normal")
|
|
|
|
layout.prop(props, "seed")
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Randomize",
|
|
|
|
icon="ops.transform.vertex_random",
|
2018-09-13 09:19:30 +10:00
|
|
|
widget="WM_GGT_value_operator_redo",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-09-13 09:23:24 +10:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
2018-08-28 20:41:48 +10:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def shear():
|
2018-10-18 13:55:01 +11:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("transform.shear")
|
|
|
|
layout.label(text="View Axis:")
|
|
|
|
layout.prop(props, "shear_axis", expand=True)
|
2018-08-28 20:41:48 +10:00
|
|
|
return dict(
|
|
|
|
text="Shear",
|
|
|
|
icon="ops.transform.shear",
|
2018-10-16 21:55:39 +11:00
|
|
|
widget="VIEW3D_GGT_xform_shear",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-10-18 13:55:01 +11:00
|
|
|
draw_settings=draw_settings,
|
2018-08-28 20:41:48 +10:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def tosphere():
|
|
|
|
return dict(
|
|
|
|
text="To Sphere",
|
|
|
|
icon="ops.transform.tosphere",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-08-28 20:41:48 +10:00
|
|
|
)
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def shrink_fatten():
|
2018-05-22 14:00:44 +02:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("transform.shrink_fatten")
|
2018-05-11 20:23:29 +02:00
|
|
|
layout.prop(props, "use_even_offset")
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Shrink/Fatten",
|
|
|
|
icon="ops.transform.shrink_fatten",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-05-11 20:23:29 +02:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def push_pull():
|
|
|
|
return dict(
|
|
|
|
text="Push/Pull",
|
|
|
|
icon="ops.transform.push_pull",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def knife():
|
2018-05-22 14:00:44 +02:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("mesh.knife_tool")
|
2018-04-27 14:13:16 +02:00
|
|
|
layout.prop(props, "use_occlude_geometry")
|
|
|
|
layout.prop(props, "only_selected")
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Knife",
|
|
|
|
icon="ops.mesh.knife_tool",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-04-30 12:14:46 +02:00
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def bisect():
|
2018-09-12 06:24:15 +10:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("mesh.bisect")
|
|
|
|
layout.prop(props, "use_fill")
|
|
|
|
layout.prop(props, "clear_inner")
|
|
|
|
layout.prop(props, "clear_outer")
|
|
|
|
layout.prop(props, "threshold")
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Bisect",
|
|
|
|
icon="ops.mesh.bisect",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-09-12 06:24:15 +10:00
|
|
|
draw_settings=draw_settings,
|
2018-04-27 13:23:29 +02:00
|
|
|
)
|
|
|
|
|
2018-05-07 21:38:43 +02:00
|
|
|
|
2018-04-27 13:23:29 +02:00
|
|
|
class _defs_edit_curve:
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def draw():
|
2018-05-22 14:00:44 +02:00
|
|
|
def draw_settings(context, layout, tool):
|
2018-05-11 20:25:01 +02:00
|
|
|
# Tool settings initialize operator options.
|
|
|
|
tool_settings = context.tool_settings
|
|
|
|
cps = tool_settings.curve_paint_settings
|
|
|
|
|
|
|
|
col = layout.row()
|
|
|
|
|
|
|
|
col.prop(cps, "curve_type")
|
|
|
|
|
|
|
|
if cps.curve_type == 'BEZIER':
|
|
|
|
col.prop(cps, "error_threshold")
|
|
|
|
col.prop(cps, "fit_method")
|
|
|
|
col.prop(cps, "use_corners_detect")
|
|
|
|
|
|
|
|
col = layout.row()
|
|
|
|
col.active = cps.use_corners_detect
|
|
|
|
col.prop(cps, "corner_angle")
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
|
|
|
text="Draw",
|
2018-05-18 11:57:40 +02:00
|
|
|
cursor='PAINT_BRUSH',
|
2018-10-21 16:04:58 +11:00
|
|
|
icon="ops.curve.draw",
|
2018-04-30 12:14:46 +02:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-05-11 20:25:01 +02:00
|
|
|
draw_settings=draw_settings,
|
2018-04-27 13:23:29 +02:00
|
|
|
)
|
|
|
|
|
2018-08-29 15:14:41 +10:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def extrude():
|
|
|
|
return dict(
|
|
|
|
text="Extrude",
|
2018-10-21 16:04:58 +11:00
|
|
|
icon="ops.curve.extrude_move",
|
2018-11-21 09:25:55 +11:00
|
|
|
widget="VIEW3D_GGT_xform_extrude",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-11-21 09:25:55 +11:00
|
|
|
draw_settings=_template_widget.VIEW3D_GGT_xform_extrude.draw_settings,
|
2018-08-29 15:14:41 +10:00
|
|
|
)
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def extrude_cursor():
|
|
|
|
return dict(
|
|
|
|
text="Extrude Cursor",
|
2018-10-21 16:04:58 +11:00
|
|
|
icon="ops.curve.extrude_cursor",
|
2018-04-30 12:14:46 +02:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-04-27 13:23:29 +02:00
|
|
|
)
|
|
|
|
|
2018-11-15 22:27:02 +11:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def tilt():
|
|
|
|
return dict(
|
|
|
|
text="Tilt",
|
|
|
|
icon="ops.transform.tilt",
|
|
|
|
widget=None,
|
|
|
|
keymap=(),
|
|
|
|
)
|
|
|
|
|
2018-05-07 21:38:43 +02:00
|
|
|
|
2018-05-15 12:40:50 +02:00
|
|
|
class _defs_pose:
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def breakdown():
|
|
|
|
return dict(
|
|
|
|
text="Breakdowner",
|
2018-05-15 13:49:44 +02:00
|
|
|
icon="ops.pose.breakdowner",
|
2018-05-15 12:40:50 +02:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-05-15 12:40:50 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def push():
|
|
|
|
return dict(
|
|
|
|
text="Push",
|
2018-05-15 13:49:44 +02:00
|
|
|
icon="ops.pose.push",
|
2018-05-15 12:40:50 +02:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-05-15 12:40:50 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def relax():
|
|
|
|
return dict(
|
|
|
|
text="Relax",
|
2018-05-15 13:49:44 +02:00
|
|
|
icon="ops.pose.relax",
|
2018-05-15 12:40:50 +02:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-05-15 12:40:50 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-08-02 17:41:11 +10:00
|
|
|
class _defs_particle:
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def generate_from_brushes(context):
|
|
|
|
return generate_from_enum_ex(
|
|
|
|
context,
|
|
|
|
icon_prefix="brush.particle.",
|
2018-11-05 13:54:43 +11:00
|
|
|
type=bpy.types.ParticleEdit,
|
2018-08-02 17:41:11 +10:00
|
|
|
attr="tool",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-04-29 14:31:00 +02:00
|
|
|
class _defs_sculpt:
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def generate_from_brushes(context):
|
2018-11-06 12:08:39 +11:00
|
|
|
return generate_from_enum_ex(
|
|
|
|
context,
|
2018-04-30 15:21:04 +02:00
|
|
|
icon_prefix="brush.sculpt.",
|
2018-11-06 12:08:39 +11:00
|
|
|
type=bpy.types.Brush,
|
|
|
|
attr="sculpt_tool",
|
2018-04-30 15:21:04 +02:00
|
|
|
)
|
2018-04-29 16:36:31 +02:00
|
|
|
|
2018-08-23 12:56:02 +10:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def hide_border():
|
|
|
|
return dict(
|
2018-10-05 10:27:04 +10:00
|
|
|
text="Box Hide",
|
2018-08-23 22:46:04 +10:00
|
|
|
icon="ops.sculpt.border_hide",
|
2018-08-23 12:56:02 +10:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-08-23 12:56:02 +10:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def mask_border():
|
|
|
|
return dict(
|
2018-10-05 10:27:04 +10:00
|
|
|
text="Box Mask",
|
2018-08-23 22:46:04 +10:00
|
|
|
icon="ops.sculpt.border_mask",
|
2018-08-23 12:56:02 +10:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-08-23 12:56:02 +10:00
|
|
|
)
|
2018-04-30 16:06:51 +02:00
|
|
|
|
2018-08-28 21:00:25 +10:00
|
|
|
|
2018-04-30 16:06:51 +02:00
|
|
|
class _defs_vertex_paint:
|
2018-04-30 15:21:04 +02:00
|
|
|
|
2018-08-29 16:21:48 +10:00
|
|
|
@staticmethod
|
|
|
|
def poll_select_mask(context):
|
2018-09-21 19:24:29 +02:00
|
|
|
ob = context.active_object
|
|
|
|
return ob.type == 'MESH' and ob.data.use_paint_mask
|
2018-08-29 16:21:48 +10:00
|
|
|
|
2018-04-30 15:21:04 +02:00
|
|
|
@staticmethod
|
|
|
|
def generate_from_brushes(context):
|
2018-11-06 12:08:39 +11:00
|
|
|
return generate_from_enum_ex(
|
|
|
|
context,
|
2018-04-30 16:06:51 +02:00
|
|
|
icon_prefix="brush.paint_vertex.",
|
2018-11-06 12:08:39 +11:00
|
|
|
type=bpy.types.Brush,
|
|
|
|
attr="vertex_tool",
|
2018-04-30 15:21:04 +02:00
|
|
|
)
|
2018-04-29 14:31:00 +02:00
|
|
|
|
2018-04-30 16:43:13 +02:00
|
|
|
class _defs_texture_paint:
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def generate_from_brushes(context):
|
2018-11-06 12:08:39 +11:00
|
|
|
return generate_from_enum_ex(
|
|
|
|
context,
|
2018-04-30 16:43:13 +02:00
|
|
|
icon_prefix="brush.paint_texture.",
|
2018-11-06 12:08:39 +11:00
|
|
|
type=bpy.types.Brush,
|
|
|
|
attr="image_tool",
|
2018-04-30 16:43:13 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-04-30 16:06:51 +02:00
|
|
|
class _defs_weight_paint:
|
|
|
|
|
2018-08-29 16:21:48 +10:00
|
|
|
@staticmethod
|
|
|
|
def poll_select_mask(context):
|
2018-09-21 19:24:29 +02:00
|
|
|
ob = context.active_object
|
|
|
|
return (ob.type == 'MESH' and
|
|
|
|
(ob.data.use_paint_mask or
|
|
|
|
ob.data.use_paint_mask_vertex))
|
2018-08-29 16:21:48 +10:00
|
|
|
|
2018-04-30 16:06:51 +02:00
|
|
|
@staticmethod
|
|
|
|
def generate_from_brushes(context):
|
2018-11-06 12:08:39 +11:00
|
|
|
return generate_from_enum_ex(
|
|
|
|
context,
|
2018-04-30 16:06:51 +02:00
|
|
|
icon_prefix="brush.paint_weight.",
|
2018-11-06 12:08:39 +11:00
|
|
|
type=bpy.types.Brush,
|
2018-11-06 18:06:33 +11:00
|
|
|
attr="weight_tool",
|
2018-04-30 16:06:51 +02:00
|
|
|
)
|
|
|
|
|
2018-05-01 12:20:53 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def sample_weight():
|
|
|
|
return dict(
|
|
|
|
text="Sample Weight",
|
|
|
|
icon="ops.paint.weight_sample",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-05-01 12:20:53 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def sample_weight_group():
|
|
|
|
return dict(
|
|
|
|
text="Sample Vertex Group",
|
|
|
|
icon="ops.paint.weight_sample_group",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-05-01 12:20:53 +02:00
|
|
|
)
|
|
|
|
|
2018-04-30 16:06:51 +02:00
|
|
|
@ToolDef.from_fn
|
2018-05-01 12:46:25 +02:00
|
|
|
def gradient():
|
2018-05-22 14:00:44 +02:00
|
|
|
def draw_settings(context, layout, tool):
|
2018-09-05 16:01:53 +10:00
|
|
|
brush = context.tool_settings.weight_paint.brush
|
|
|
|
if brush is not None:
|
|
|
|
from .properties_paint_common import UnifiedPaintPanel
|
|
|
|
UnifiedPaintPanel.prop_unified_weight(layout, context, brush, "weight", slider=True, text="Weight")
|
2018-09-05 16:05:00 +10:00
|
|
|
props = tool.operator_properties("paint.weight_gradient")
|
|
|
|
layout.prop(props, "type")
|
2018-04-30 16:06:51 +02:00
|
|
|
|
|
|
|
return dict(
|
2018-05-01 12:46:25 +02:00
|
|
|
text="Gradient",
|
|
|
|
icon="ops.paint.weight_gradient",
|
2018-04-30 16:06:51 +02:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-05-01 12:46:25 +02:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 16:06:51 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-10-04 12:04:36 +10:00
|
|
|
class _defs_image_generic:
|
|
|
|
|
2018-10-05 13:07:01 +10:00
|
|
|
@staticmethod
|
|
|
|
def poll_uvedit(context):
|
|
|
|
ob = context.edit_object
|
|
|
|
if ob is not None:
|
|
|
|
data = ob.data
|
|
|
|
if data is not None:
|
|
|
|
return bool(getattr(data, "uv_layers", False))
|
|
|
|
return False
|
|
|
|
|
2018-10-04 12:04:36 +10:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def cursor():
|
|
|
|
return dict(
|
|
|
|
text="Cursor",
|
|
|
|
description=(
|
|
|
|
"Set the cursor location, drag to transform"
|
|
|
|
),
|
|
|
|
icon="ops.generic.cursor",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-10-04 12:04:36 +10:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class _defs_image_uv_transform:
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def transform():
|
|
|
|
return dict(
|
|
|
|
text="Transform",
|
|
|
|
description=(
|
|
|
|
"Supports any combination of grab, rotate & scale at once"
|
|
|
|
),
|
|
|
|
icon="ops.transform.transform",
|
|
|
|
widget="IMAGE_GGT_gizmo2d",
|
|
|
|
# No keymap default action, only for gizmo!
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class _defs_image_uv_select:
|
2018-05-16 18:41:11 +02:00
|
|
|
|
|
|
|
@ToolDef.from_fn
|
2018-11-22 16:05:28 +01:00
|
|
|
def select():
|
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
pass
|
|
|
|
return dict(
|
|
|
|
text="Select",
|
|
|
|
icon="ops.generic.select",
|
|
|
|
widget=None,
|
|
|
|
keymap=(),
|
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def box():
|
2018-10-04 15:12:28 +10:00
|
|
|
def draw_settings(context, layout, tool):
|
2018-10-05 10:27:04 +10:00
|
|
|
props = tool.operator_properties("uv.select_box")
|
2018-11-23 17:52:28 +11:00
|
|
|
layout.prop(props, "mode", expand=True)
|
2018-05-16 18:41:11 +02:00
|
|
|
return dict(
|
2018-10-05 10:27:04 +10:00
|
|
|
text="Select Box",
|
|
|
|
icon="ops.generic.select_box",
|
2018-05-16 18:41:11 +02:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-10-04 15:12:28 +10:00
|
|
|
draw_settings=draw_settings,
|
2018-05-16 18:41:11 +02:00
|
|
|
)
|
|
|
|
|
2018-11-13 14:05:20 +11:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def lasso():
|
2018-11-23 17:52:28 +11:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("uv.select_lasso")
|
|
|
|
layout.prop(props, "mode", expand=True)
|
2018-11-13 14:05:20 +11:00
|
|
|
return dict(
|
|
|
|
text="Select Lasso",
|
|
|
|
icon="ops.generic.select_lasso",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-11-23 17:52:28 +11:00
|
|
|
draw_settings=draw_settings,
|
2018-11-13 14:05:20 +11:00
|
|
|
)
|
|
|
|
|
2018-05-16 18:41:11 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def circle():
|
2018-10-04 15:12:28 +10:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("uv.select_circle")
|
|
|
|
layout.prop(props, "radius")
|
2018-05-16 18:41:11 +02:00
|
|
|
return dict(
|
|
|
|
text="Select Circle",
|
|
|
|
icon="ops.generic.select_circle",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-10-04 15:12:28 +10:00
|
|
|
draw_settings=draw_settings,
|
2018-05-16 18:41:11 +02:00
|
|
|
)
|
|
|
|
|
2018-07-31 21:06:08 +10:00
|
|
|
|
2018-10-05 13:07:01 +10:00
|
|
|
class _defs_image_uv_sculpt:
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def generate_from_brushes(context):
|
|
|
|
return generate_from_enum_ex(
|
|
|
|
context,
|
|
|
|
icon_prefix="brush.uv_sculpt.",
|
2018-11-21 17:56:10 +11:00
|
|
|
type=bpy.types.ToolSettings,
|
2018-10-05 13:07:01 +10:00
|
|
|
attr="uv_sculpt_tool",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
class _defs_gpencil_paint:
|
2018-08-24 23:59:56 +02:00
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
@staticmethod
|
|
|
|
def generate_from_brushes(context):
|
2018-11-06 12:08:39 +11:00
|
|
|
return generate_from_enum_ex(
|
|
|
|
context,
|
2018-11-03 20:33:59 +11:00
|
|
|
icon_prefix="brush.gpencil_draw.",
|
2018-11-06 12:08:39 +11:00
|
|
|
type=bpy.types.Brush,
|
|
|
|
attr="gpencil_tool",
|
2018-11-02 09:10:23 +11:00
|
|
|
tooldef_keywords=dict(
|
|
|
|
operator="gpencil.draw",
|
|
|
|
),
|
2018-07-31 10:22:19 +02:00
|
|
|
)
|
|
|
|
|
2018-11-14 19:19:04 +11:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def line():
|
2018-11-09 17:05:32 +11:00
|
|
|
return dict(
|
|
|
|
text="Line",
|
|
|
|
icon="ops.gpencil.primitive_line",
|
2018-11-21 10:52:46 +01:00
|
|
|
cursor='CROSSHAIR',
|
2018-11-09 17:05:32 +11:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-11-09 17:05:32 +11:00
|
|
|
)
|
|
|
|
|
2018-11-14 19:19:04 +11:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def box():
|
2018-11-09 17:05:32 +11:00
|
|
|
return dict(
|
|
|
|
text="Box",
|
|
|
|
icon="ops.gpencil.primitive_box",
|
2018-11-21 10:52:46 +01:00
|
|
|
cursor='CROSSHAIR',
|
2018-11-09 17:05:32 +11:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-11-09 17:05:32 +11:00
|
|
|
)
|
|
|
|
|
2018-11-14 19:19:04 +11:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def circle():
|
2018-11-09 17:05:32 +11:00
|
|
|
return dict(
|
|
|
|
text="Circle",
|
|
|
|
icon="ops.gpencil.primitive_circle",
|
2018-11-21 10:52:46 +01:00
|
|
|
cursor='CROSSHAIR',
|
2018-11-09 17:05:32 +11:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-11-09 17:05:32 +11:00
|
|
|
)
|
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
|
|
|
|
class _defs_gpencil_edit:
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def bend():
|
|
|
|
return dict(
|
|
|
|
text="Bend",
|
|
|
|
icon="ops.gpencil.edit_bend",
|
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-07-31 10:22:19 +02:00
|
|
|
)
|
|
|
|
|
2018-11-22 16:05:28 +01:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def select():
|
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
pass
|
|
|
|
return dict(
|
|
|
|
text="Select",
|
|
|
|
icon="ops.generic.select",
|
|
|
|
widget=None,
|
|
|
|
keymap=(),
|
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
|
|
|
|
2018-09-21 10:28:51 +02:00
|
|
|
@ToolDef.from_fn
|
2018-10-05 10:27:04 +10:00
|
|
|
def box_select():
|
2018-11-13 14:05:20 +11:00
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("gpencil.select_box")
|
|
|
|
layout.prop(props, "mode", expand=True)
|
2018-09-21 10:28:51 +02:00
|
|
|
return dict(
|
2018-10-05 10:27:04 +10:00
|
|
|
text="Select Box",
|
|
|
|
icon="ops.generic.select_box",
|
2018-09-21 10:28:51 +02:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-11-13 14:05:20 +11:00
|
|
|
draw_settings=draw_settings,
|
2018-09-21 10:28:51 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
2018-11-13 14:05:20 +11:00
|
|
|
def lasso_select():
|
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("gpencil.select_lasso")
|
|
|
|
layout.prop(props, "mode", expand=True)
|
2018-09-21 10:28:51 +02:00
|
|
|
return dict(
|
2018-11-13 14:05:20 +11:00
|
|
|
text="Select Lasso",
|
|
|
|
icon="ops.generic.select_lasso",
|
2018-09-21 10:28:51 +02:00
|
|
|
widget=None,
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-11-13 14:05:20 +11:00
|
|
|
draw_settings=draw_settings,
|
2018-09-21 10:28:51 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
2018-11-13 14:05:20 +11:00
|
|
|
def circle_select():
|
2018-09-21 10:28:51 +02:00
|
|
|
return dict(
|
2018-11-13 14:05:20 +11:00
|
|
|
text="Select Circle",
|
|
|
|
icon="ops.generic.select_circle",
|
2018-09-21 10:28:51 +02:00
|
|
|
widget=None,
|
2018-11-15 13:34:47 +11:00
|
|
|
keymap=(),
|
2018-09-21 10:28:51 +02:00
|
|
|
)
|
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def shear():
|
|
|
|
return dict(
|
|
|
|
text="Shear",
|
|
|
|
icon="ops.gpencil.edit_shear",
|
|
|
|
widget=None,
|
2018-11-15 13:34:47 +11:00
|
|
|
keymap=(),
|
2018-07-31 10:22:19 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def tosphere():
|
|
|
|
return dict(
|
|
|
|
text="To Sphere",
|
2018-10-21 16:04:58 +11:00
|
|
|
icon="ops.transform.tosphere",
|
2018-07-31 10:22:19 +02:00
|
|
|
widget=None,
|
2018-11-15 13:34:47 +11:00
|
|
|
keymap=(),
|
2018-07-31 10:22:19 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class _defs_gpencil_sculpt:
|
2018-11-05 06:57:01 +11:00
|
|
|
|
2018-11-13 16:52:39 +11:00
|
|
|
@staticmethod
|
|
|
|
def generate_from_brushes(context):
|
|
|
|
return generate_from_enum_ex(
|
|
|
|
context,
|
|
|
|
icon_prefix="ops.gpencil.sculpt_",
|
|
|
|
type=bpy.types.GPencilSculptSettings,
|
|
|
|
attr="sculpt_tool",
|
2018-07-31 10:22:19 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class _defs_gpencil_weight:
|
2018-11-05 06:57:01 +11:00
|
|
|
|
2018-11-13 16:52:39 +11:00
|
|
|
@staticmethod
|
|
|
|
def generate_from_brushes(context):
|
|
|
|
return generate_from_enum_ex(
|
|
|
|
context,
|
|
|
|
icon_prefix="ops.gpencil.sculpt_",
|
|
|
|
type=bpy.types.GPencilSculptSettings,
|
|
|
|
attr="weight_tool",
|
2018-07-31 10:22:19 +02:00
|
|
|
)
|
|
|
|
|
2018-05-16 18:41:11 +02:00
|
|
|
|
2018-11-27 18:39:29 +11:00
|
|
|
class _defs_node_select:
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def select():
|
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
pass
|
|
|
|
return dict(
|
|
|
|
text="Select",
|
|
|
|
icon="ops.generic.select",
|
|
|
|
widget=None,
|
|
|
|
keymap="Node Tool: Select",
|
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def box():
|
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("node.select_box")
|
|
|
|
layout.prop(props, "deselect")
|
|
|
|
pass
|
|
|
|
return dict(
|
|
|
|
text="Select Box",
|
|
|
|
icon="ops.generic.select_box",
|
|
|
|
widget=None,
|
|
|
|
keymap="Node Tool: Select Box",
|
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def lasso():
|
|
|
|
def draw_settings(context, layout, tool):
|
|
|
|
props = tool.operator_properties("node.select_lasso")
|
|
|
|
layout.prop(props, "deselect")
|
|
|
|
pass
|
|
|
|
return dict(
|
|
|
|
text="Select Lasso",
|
|
|
|
icon="ops.generic.select_lasso",
|
|
|
|
widget=None,
|
|
|
|
keymap="Node Tool: Select Lasso",
|
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-11-28 17:37:40 +11:00
|
|
|
class _defs_node_edit:
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def links_cut():
|
|
|
|
return dict(
|
|
|
|
text="Links Cut",
|
|
|
|
icon="ops.mesh.knife_tool",
|
|
|
|
widget=None,
|
|
|
|
keymap="Node Tool: Links Cut",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-05-16 18:41:11 +02:00
|
|
|
class IMAGE_PT_tools_active(ToolSelectPanelHelper, Panel):
|
|
|
|
bl_space_type = 'IMAGE_EDITOR'
|
|
|
|
bl_region_type = 'TOOLS'
|
|
|
|
bl_label = "Tools" # not visible
|
|
|
|
bl_options = {'HIDE_HEADER'}
|
|
|
|
|
|
|
|
# Satisfy the 'ToolSelectPanelHelper' API.
|
2018-07-14 09:02:36 +02:00
|
|
|
keymap_prefix = "Image Editor Tool:"
|
2018-05-16 18:41:11 +02:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tools_from_context(cls, context, mode=None):
|
|
|
|
if mode is None:
|
2018-08-17 12:59:24 +02:00
|
|
|
if context.space_data is None:
|
|
|
|
mode = 'VIEW'
|
2018-08-17 13:09:59 +02:00
|
|
|
else:
|
|
|
|
mode = context.space_data.mode
|
2018-05-16 18:41:11 +02:00
|
|
|
for tools in (cls._tools[None], cls._tools.get(mode, ())):
|
|
|
|
for item in tools:
|
|
|
|
if not (type(item) is ToolDef) and callable(item):
|
|
|
|
yield from item(context)
|
|
|
|
else:
|
|
|
|
yield item
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tools_all(cls):
|
|
|
|
yield from cls._tools.items()
|
|
|
|
|
|
|
|
# for reuse
|
2018-10-04 12:04:36 +10:00
|
|
|
_tools_transform = (
|
|
|
|
_defs_image_uv_transform.transform,
|
|
|
|
)
|
|
|
|
|
2018-05-16 18:41:11 +02:00
|
|
|
_tools_select = (
|
|
|
|
(
|
2018-11-22 16:05:28 +01:00
|
|
|
_defs_image_uv_select.select,
|
|
|
|
_defs_image_uv_select.box,
|
2018-10-04 12:04:36 +10:00
|
|
|
_defs_image_uv_select.circle,
|
|
|
|
_defs_image_uv_select.lasso,
|
2018-05-16 18:41:11 +02:00
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2018-08-21 01:17:15 +12:00
|
|
|
_tools_annotate = (
|
|
|
|
(
|
2018-11-27 17:33:52 +11:00
|
|
|
_defs_annotate.scribble,
|
|
|
|
_defs_annotate.line,
|
|
|
|
_defs_annotate.poly,
|
|
|
|
_defs_annotate.eraser,
|
2018-08-21 01:17:15 +12:00
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2018-05-16 18:41:11 +02:00
|
|
|
_tools = {
|
|
|
|
None: [
|
|
|
|
# for all modes
|
|
|
|
],
|
|
|
|
'VIEW': [
|
2018-10-19 20:10:14 +11:00
|
|
|
],
|
|
|
|
'UV': [
|
2018-05-16 18:41:11 +02:00
|
|
|
*_tools_select,
|
2018-11-16 09:27:53 +11:00
|
|
|
_defs_image_generic.cursor,
|
2018-10-04 12:04:36 +10:00
|
|
|
None,
|
|
|
|
*_tools_transform,
|
|
|
|
None,
|
2018-08-21 01:17:15 +12:00
|
|
|
*_tools_annotate,
|
2018-10-05 13:07:01 +10:00
|
|
|
None,
|
|
|
|
lambda context: (
|
|
|
|
_defs_image_uv_sculpt.generate_from_brushes(context)
|
|
|
|
if _defs_image_generic.poll_uvedit(context)
|
|
|
|
else ()
|
|
|
|
),
|
2018-05-16 18:41:11 +02:00
|
|
|
],
|
|
|
|
'MASK': [
|
|
|
|
None,
|
|
|
|
],
|
|
|
|
'PAINT': [
|
|
|
|
_defs_texture_paint.generate_from_brushes,
|
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-27 18:39:29 +11:00
|
|
|
class NODE_PT_tools_active(ToolSelectPanelHelper, Panel):
|
|
|
|
bl_space_type = 'NODE_EDITOR'
|
|
|
|
bl_region_type = 'TOOLS'
|
|
|
|
bl_label = "Tools" # not visible
|
|
|
|
bl_options = {'HIDE_HEADER'}
|
|
|
|
|
|
|
|
# Satisfy the 'ToolSelectPanelHelper' API.
|
|
|
|
keymap_prefix = "Node Editor Tool:"
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tools_from_context(cls, context, mode=None):
|
|
|
|
if mode is None:
|
|
|
|
if context.space_data is None:
|
|
|
|
mode = None
|
|
|
|
else:
|
|
|
|
mode = context.space_data.tree_type
|
|
|
|
for tools in (cls._tools[None], cls._tools.get(mode, ())):
|
|
|
|
for item in tools:
|
|
|
|
if not (type(item) is ToolDef) and callable(item):
|
|
|
|
yield from item(context)
|
|
|
|
else:
|
|
|
|
yield item
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tools_all(cls):
|
|
|
|
yield from cls._tools.items()
|
|
|
|
|
|
|
|
_tools_select = (
|
|
|
|
(
|
|
|
|
_defs_node_select.select,
|
|
|
|
_defs_node_select.box,
|
|
|
|
_defs_node_select.lasso,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
_tools_annotate = (
|
|
|
|
(
|
|
|
|
_defs_annotate.scribble,
|
|
|
|
_defs_annotate.line,
|
|
|
|
_defs_annotate.poly,
|
|
|
|
_defs_annotate.eraser,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
_tools = {
|
|
|
|
None: [
|
|
|
|
*_tools_select,
|
|
|
|
None,
|
|
|
|
*_tools_annotate,
|
2018-11-28 17:37:40 +11:00
|
|
|
None,
|
|
|
|
_defs_node_edit.links_cut,
|
2018-11-27 18:39:29 +11:00
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-21 16:19:48 +11:00
|
|
|
class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
|
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'TOOLS'
|
2018-04-24 16:04:07 +02:00
|
|
|
bl_label = "Tools" # not visible
|
|
|
|
bl_options = {'HIDE_HEADER'}
|
2017-10-21 16:19:48 +11:00
|
|
|
|
|
|
|
# Satisfy the 'ToolSelectPanelHelper' API.
|
2018-07-14 09:02:36 +02:00
|
|
|
keymap_prefix = "3D View Tool:"
|
2017-10-21 16:19:48 +11:00
|
|
|
|
|
|
|
@classmethod
|
2018-05-16 18:41:11 +02:00
|
|
|
def tools_from_context(cls, context, mode=None):
|
|
|
|
if mode is None:
|
|
|
|
mode = context.mode
|
|
|
|
for tools in (cls._tools[None], cls._tools.get(mode, ())):
|
2018-04-29 12:26:00 +02:00
|
|
|
for item in tools:
|
2018-04-30 13:46:01 +02:00
|
|
|
if not (type(item) is ToolDef) and callable(item):
|
2018-04-29 12:26:00 +02:00
|
|
|
yield from item(context)
|
|
|
|
else:
|
|
|
|
yield item
|
|
|
|
|
2017-10-21 16:19:48 +11:00
|
|
|
@classmethod
|
|
|
|
def tools_all(cls):
|
2018-04-26 14:43:32 +02:00
|
|
|
yield from cls._tools.items()
|
2017-10-21 16:19:48 +11:00
|
|
|
|
|
|
|
# for reuse
|
|
|
|
_tools_transform = (
|
2018-07-03 13:51:11 +02:00
|
|
|
_defs_transform.transform,
|
|
|
|
_defs_transform.translate,
|
2018-04-27 13:23:29 +02:00
|
|
|
_defs_transform.rotate,
|
2018-04-24 09:19:28 +02:00
|
|
|
(
|
2018-04-27 13:23:29 +02:00
|
|
|
_defs_transform.scale,
|
|
|
|
_defs_transform.scale_cage,
|
2018-04-24 09:19:28 +02:00
|
|
|
),
|
2017-10-21 16:19:48 +11:00
|
|
|
)
|
|
|
|
|
2018-04-29 16:36:31 +02:00
|
|
|
_tools_select = (
|
|
|
|
(
|
2018-11-22 16:05:28 +01:00
|
|
|
_defs_view3d_select.select,
|
|
|
|
_defs_view3d_select.box,
|
2018-04-29 16:36:31 +02:00
|
|
|
_defs_view3d_select.circle,
|
|
|
|
_defs_view3d_select.lasso,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
_tools_annotate = (
|
|
|
|
(
|
2018-11-27 17:33:52 +11:00
|
|
|
_defs_annotate.scribble,
|
|
|
|
_defs_annotate.line,
|
|
|
|
_defs_annotate.poly,
|
|
|
|
_defs_annotate.eraser,
|
2018-07-31 10:22:19 +02:00
|
|
|
),
|
|
|
|
_defs_view3d_generic.ruler,
|
|
|
|
)
|
|
|
|
|
2018-09-25 13:17:48 +02:00
|
|
|
_tools_gpencil_select = (
|
|
|
|
(
|
2018-11-22 16:05:28 +01:00
|
|
|
_defs_gpencil_edit.select,
|
2018-10-05 10:27:04 +10:00
|
|
|
_defs_gpencil_edit.box_select,
|
2018-09-25 13:17:48 +02:00
|
|
|
_defs_gpencil_edit.circle_select,
|
|
|
|
_defs_gpencil_edit.lasso_select,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2017-10-21 16:19:48 +11:00
|
|
|
_tools = {
|
|
|
|
None: [
|
2018-08-23 12:12:11 +10:00
|
|
|
# Don't use this! because of paint modes.
|
|
|
|
# _defs_view3d_generic.cursor,
|
2017-11-02 23:05:13 +11:00
|
|
|
# End group.
|
2017-10-21 16:19:48 +11:00
|
|
|
],
|
|
|
|
'OBJECT': [
|
2018-04-29 16:36:31 +02:00
|
|
|
*_tools_select,
|
2018-11-16 09:27:53 +11:00
|
|
|
_defs_view3d_generic.cursor,
|
2018-04-29 16:36:31 +02:00
|
|
|
None,
|
2017-10-21 16:19:48 +11:00
|
|
|
*_tools_transform,
|
2018-07-31 10:22:19 +02:00
|
|
|
None,
|
|
|
|
*_tools_annotate,
|
2017-10-21 16:19:48 +11:00
|
|
|
],
|
|
|
|
'POSE': [
|
2018-04-29 16:36:31 +02:00
|
|
|
*_tools_select,
|
2018-11-16 09:27:53 +11:00
|
|
|
_defs_view3d_generic.cursor,
|
2018-08-23 12:12:11 +10:00
|
|
|
None,
|
2017-10-21 16:19:48 +11:00
|
|
|
*_tools_transform,
|
2018-05-15 12:40:50 +02:00
|
|
|
None,
|
2018-07-31 10:22:19 +02:00
|
|
|
*_tools_annotate,
|
|
|
|
None,
|
2018-05-15 12:40:50 +02:00
|
|
|
(
|
|
|
|
_defs_pose.breakdown,
|
|
|
|
_defs_pose.push,
|
|
|
|
_defs_pose.relax,
|
2018-07-31 10:22:19 +02:00
|
|
|
),
|
2017-10-21 16:19:48 +11:00
|
|
|
],
|
|
|
|
'EDIT_ARMATURE': [
|
2018-04-29 16:36:31 +02:00
|
|
|
*_tools_select,
|
2018-11-16 09:27:53 +11:00
|
|
|
_defs_view3d_generic.cursor,
|
2018-04-29 16:36:31 +02:00
|
|
|
None,
|
2017-10-21 16:19:48 +11:00
|
|
|
*_tools_transform,
|
2018-07-31 10:22:19 +02:00
|
|
|
None,
|
|
|
|
*_tools_annotate,
|
2018-04-27 13:23:29 +02:00
|
|
|
_defs_edit_armature.roll,
|
2018-05-15 10:24:26 +02:00
|
|
|
(
|
|
|
|
_defs_edit_armature.bone_size,
|
|
|
|
_defs_edit_armature.bone_envelope,
|
|
|
|
),
|
2017-10-21 16:19:48 +11:00
|
|
|
None,
|
2018-04-27 19:16:00 +02:00
|
|
|
(
|
|
|
|
_defs_edit_armature.extrude,
|
|
|
|
_defs_edit_armature.extrude_cursor,
|
2018-07-31 10:22:19 +02:00
|
|
|
),
|
2017-10-21 16:19:48 +11:00
|
|
|
],
|
|
|
|
'EDIT_MESH': [
|
2018-04-29 16:36:31 +02:00
|
|
|
*_tools_select,
|
2018-11-16 09:27:53 +11:00
|
|
|
_defs_view3d_generic.cursor,
|
2018-04-29 16:36:31 +02:00
|
|
|
None,
|
2017-10-21 16:19:48 +11:00
|
|
|
*_tools_transform,
|
|
|
|
None,
|
2018-07-31 10:22:19 +02:00
|
|
|
*_tools_annotate,
|
|
|
|
None,
|
2018-05-10 20:16:22 +02:00
|
|
|
_defs_edit_mesh.cube_add,
|
|
|
|
None,
|
2018-04-24 15:32:11 +02:00
|
|
|
(
|
2018-04-30 20:40:36 +02:00
|
|
|
_defs_edit_mesh.extrude,
|
2018-08-29 22:59:49 +10:00
|
|
|
_defs_edit_mesh.extrude_normals,
|
2018-04-30 20:40:36 +02:00
|
|
|
_defs_edit_mesh.extrude_individual,
|
|
|
|
_defs_edit_mesh.extrude_cursor,
|
2018-04-24 15:32:11 +02:00
|
|
|
),
|
2018-04-27 13:23:29 +02:00
|
|
|
_defs_edit_mesh.inset,
|
2018-04-27 22:48:23 +02:00
|
|
|
_defs_edit_mesh.bevel,
|
2018-04-27 22:59:51 +02:00
|
|
|
(
|
|
|
|
_defs_edit_mesh.loopcut_slide,
|
|
|
|
_defs_edit_mesh.offset_edge_loops_slide,
|
|
|
|
),
|
2018-04-24 15:32:11 +02:00
|
|
|
(
|
2018-04-30 20:40:36 +02:00
|
|
|
_defs_edit_mesh.knife,
|
|
|
|
_defs_edit_mesh.bisect,
|
|
|
|
),
|
|
|
|
_defs_edit_mesh.poly_build,
|
|
|
|
(
|
|
|
|
_defs_edit_mesh.spin,
|
|
|
|
_defs_edit_mesh.spin_duplicate,
|
2018-04-24 15:32:11 +02:00
|
|
|
),
|
|
|
|
(
|
2018-04-27 13:23:29 +02:00
|
|
|
_defs_edit_mesh.vertex_smooth,
|
|
|
|
_defs_edit_mesh.vertex_randomize,
|
2018-04-24 15:32:11 +02:00
|
|
|
),
|
2018-04-30 20:40:36 +02:00
|
|
|
(
|
|
|
|
_defs_edit_mesh.edge_slide,
|
|
|
|
_defs_edit_mesh.vert_slide,
|
|
|
|
),
|
2018-04-24 15:32:11 +02:00
|
|
|
(
|
2018-04-27 13:23:29 +02:00
|
|
|
_defs_edit_mesh.shrink_fatten,
|
|
|
|
_defs_edit_mesh.push_pull,
|
2018-04-24 15:32:11 +02:00
|
|
|
),
|
2018-08-28 20:41:48 +10:00
|
|
|
(
|
|
|
|
_defs_edit_mesh.shear,
|
|
|
|
_defs_edit_mesh.tosphere,
|
|
|
|
),
|
2017-11-02 23:05:13 +11:00
|
|
|
(
|
2018-04-30 20:40:36 +02:00
|
|
|
_defs_edit_mesh.rip_region,
|
|
|
|
_defs_edit_mesh.rip_edge,
|
2018-04-26 07:31:39 +02:00
|
|
|
),
|
2017-10-21 16:19:48 +11:00
|
|
|
],
|
|
|
|
'EDIT_CURVE': [
|
2018-04-29 16:36:31 +02:00
|
|
|
*_tools_select,
|
2018-11-16 09:27:53 +11:00
|
|
|
_defs_view3d_generic.cursor,
|
2018-04-29 16:36:31 +02:00
|
|
|
None,
|
2017-10-21 16:19:48 +11:00
|
|
|
*_tools_transform,
|
|
|
|
None,
|
2018-07-31 10:22:19 +02:00
|
|
|
*_tools_annotate,
|
|
|
|
None,
|
2018-11-15 22:27:02 +11:00
|
|
|
_defs_edit_curve.tilt,
|
2018-04-27 13:23:29 +02:00
|
|
|
_defs_edit_curve.draw,
|
2018-08-29 15:14:41 +10:00
|
|
|
(
|
|
|
|
_defs_edit_curve.extrude,
|
|
|
|
_defs_edit_curve.extrude_cursor,
|
2018-11-15 22:27:02 +11:00
|
|
|
),
|
2017-10-21 16:19:48 +11:00
|
|
|
],
|
2018-11-20 18:52:27 +11:00
|
|
|
'EDIT_METABALL': [
|
|
|
|
*_tools_select,
|
|
|
|
_defs_view3d_generic.cursor,
|
|
|
|
None,
|
|
|
|
*_tools_transform,
|
|
|
|
None,
|
|
|
|
*_tools_annotate,
|
|
|
|
None,
|
|
|
|
],
|
2018-11-20 21:41:39 +11:00
|
|
|
'EDIT_LATTICE': [
|
|
|
|
*_tools_select,
|
|
|
|
_defs_view3d_generic.cursor,
|
|
|
|
None,
|
|
|
|
*_tools_transform,
|
|
|
|
None,
|
|
|
|
*_tools_annotate,
|
|
|
|
None,
|
|
|
|
],
|
2018-05-28 18:05:21 +02:00
|
|
|
'PARTICLE': [
|
2018-08-23 12:12:11 +10:00
|
|
|
_defs_view3d_generic.cursor,
|
2018-08-02 17:41:11 +10:00
|
|
|
_defs_particle.generate_from_brushes,
|
2018-05-28 18:05:21 +02:00
|
|
|
],
|
2018-04-29 14:31:00 +02:00
|
|
|
'SCULPT': [
|
|
|
|
_defs_sculpt.generate_from_brushes,
|
2018-08-23 12:56:02 +10:00
|
|
|
None,
|
|
|
|
_defs_sculpt.hide_border,
|
|
|
|
_defs_sculpt.mask_border,
|
2018-04-29 14:31:00 +02:00
|
|
|
],
|
2018-04-30 16:43:13 +02:00
|
|
|
'PAINT_TEXTURE': [
|
|
|
|
_defs_texture_paint.generate_from_brushes,
|
|
|
|
],
|
2018-04-30 15:21:04 +02:00
|
|
|
'PAINT_VERTEX': [
|
2018-04-30 16:06:51 +02:00
|
|
|
_defs_vertex_paint.generate_from_brushes,
|
2018-08-29 16:21:48 +10:00
|
|
|
None,
|
|
|
|
lambda context: (
|
|
|
|
VIEW3D_PT_tools_active._tools_select
|
|
|
|
if _defs_vertex_paint.poll_select_mask(context)
|
|
|
|
else ()
|
|
|
|
),
|
2018-04-30 16:06:51 +02:00
|
|
|
],
|
|
|
|
'PAINT_WEIGHT': [
|
2018-08-23 12:12:11 +10:00
|
|
|
# TODO, check for mixed pose mode
|
|
|
|
_defs_view3d_generic.cursor,
|
2018-04-30 16:59:16 +02:00
|
|
|
_defs_weight_paint.generate_from_brushes,
|
2018-05-01 12:20:53 +02:00
|
|
|
None,
|
|
|
|
_defs_weight_paint.sample_weight,
|
|
|
|
_defs_weight_paint.sample_weight_group,
|
|
|
|
None,
|
2018-08-29 16:21:48 +10:00
|
|
|
lambda context: (
|
|
|
|
VIEW3D_PT_tools_active._tools_select
|
|
|
|
if _defs_weight_paint.poll_select_mask(context)
|
|
|
|
else ()
|
|
|
|
),
|
2018-05-01 12:20:53 +02:00
|
|
|
None,
|
2018-05-01 12:46:25 +02:00
|
|
|
_defs_weight_paint.gradient,
|
2018-04-30 15:21:04 +02:00
|
|
|
],
|
2018-07-31 10:22:19 +02:00
|
|
|
'GPENCIL_PAINT': [
|
2018-11-09 17:05:32 +11:00
|
|
|
_defs_view3d_generic.cursor,
|
|
|
|
None,
|
2018-07-31 10:22:19 +02:00
|
|
|
_defs_gpencil_paint.generate_from_brushes,
|
2018-11-09 17:05:32 +11:00
|
|
|
None,
|
|
|
|
_defs_gpencil_paint.line,
|
|
|
|
_defs_gpencil_paint.box,
|
|
|
|
_defs_gpencil_paint.circle,
|
2018-07-31 10:22:19 +02:00
|
|
|
],
|
|
|
|
'GPENCIL_EDIT': [
|
2018-11-09 22:19:46 +01:00
|
|
|
*_tools_gpencil_select,
|
2018-11-16 09:27:53 +11:00
|
|
|
_defs_view3d_generic.cursor,
|
2018-07-31 10:22:19 +02:00
|
|
|
None,
|
2018-10-23 13:03:25 +02:00
|
|
|
*_tools_transform,
|
|
|
|
None,
|
2018-07-31 10:22:19 +02:00
|
|
|
_defs_gpencil_edit.bend,
|
|
|
|
_defs_gpencil_edit.shear,
|
|
|
|
_defs_gpencil_edit.tosphere,
|
|
|
|
],
|
|
|
|
'GPENCIL_SCULPT': [
|
2018-11-09 22:19:46 +01:00
|
|
|
*_tools_gpencil_select,
|
|
|
|
None,
|
2018-11-13 16:52:39 +11:00
|
|
|
_defs_gpencil_sculpt.generate_from_brushes,
|
2018-07-31 10:22:19 +02:00
|
|
|
],
|
|
|
|
'GPENCIL_WEIGHT': [
|
2018-11-13 16:52:39 +11:00
|
|
|
_defs_gpencil_weight.generate_from_brushes,
|
2018-07-31 10:22:19 +02:00
|
|
|
],
|
2017-10-21 16:19:48 +11:00
|
|
|
}
|
|
|
|
|
2018-11-04 10:25:27 +11:00
|
|
|
|
2017-10-21 16:19:48 +11:00
|
|
|
classes = (
|
2018-05-16 18:41:11 +02:00
|
|
|
IMAGE_PT_tools_active,
|
2018-11-27 18:39:29 +11:00
|
|
|
NODE_PT_tools_active,
|
2017-10-21 16:19:48 +11:00
|
|
|
VIEW3D_PT_tools_active,
|
|
|
|
)
|
|
|
|
|
|
|
|
if __name__ == "__main__": # only for live edit.
|
|
|
|
from bpy.utils import register_class
|
|
|
|
for cls in classes:
|
|
|
|
register_class(cls)
|