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
|
|
|
|
|
2019-06-11 16:08:32 +10:00
|
|
|
from bl_ui.space_toolsystem_common import (
|
2017-10-21 16:19:48 +11:00
|
|
|
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
|
|
|
|
2019-03-31 18:43:14 +02:00
|
|
|
from bpy.app.translations import pgettext_tip as tip_
|
|
|
|
|
|
|
|
|
2019-01-09 12:27:58 +11:00
|
|
|
def kmi_to_string_or_none(kmi):
|
|
|
|
return kmi.to_string() if kmi else "<none>"
|
|
|
|
|
|
|
|
|
2018-08-02 17:41:11 +10:00
|
|
|
def generate_from_enum_ex(
|
2019-04-19 07:32:24 +02:00
|
|
|
_context, *,
|
2019-03-15 14:18:21 +11:00
|
|
|
idname_prefix,
|
2018-08-02 17:41:11 +10:00
|
|
|
icon_prefix,
|
2018-11-05 13:54:43 +11:00
|
|
|
type,
|
2018-08-02 17:41:11 +10:00
|
|
|
attr,
|
2019-09-30 13:33:54 +02:00
|
|
|
cursor='DEFAULT',
|
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
|
2019-03-15 12:45:41 +11:00
|
|
|
idname = enum.identifier
|
2018-08-02 17:41:11 +10:00
|
|
|
tool_defs.append(
|
|
|
|
ToolDef.from_dict(
|
|
|
|
dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname=idname_prefix + name,
|
2019-03-15 12:45:41 +11:00
|
|
|
label=name,
|
|
|
|
icon=icon_prefix + idname.lower(),
|
2019-09-30 13:33:54 +02:00
|
|
|
cursor=cursor,
|
2019-03-15 12:45:41 +11:00
|
|
|
data_block=idname,
|
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
|
2019-04-19 07:32:24 +02:00
|
|
|
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)
|
|
|
|
|
2019-04-13 20:36:53 +02:00
|
|
|
class VIEW3D_GGT_xform_gizmo:
|
2018-12-19 20:51:04 +11:00
|
|
|
@staticmethod
|
|
|
|
def draw_settings_with_index(context, layout, index):
|
|
|
|
scene = context.scene
|
2018-12-19 22:36:33 +11:00
|
|
|
orient_slot = scene.transform_orientation_slots[index]
|
2018-12-20 07:43:50 +11:00
|
|
|
layout.prop(orient_slot, "type")
|
2018-12-19 20:51:04 +11:00
|
|
|
|
2018-11-21 09:09:34 +11:00
|
|
|
|
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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-06-22 15:07:11 +02:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.cursor",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="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-12-14 12:17:00 +11:00
|
|
|
keymap="3D View Tool: Cursor",
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.none",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def description(_context, _item, km):
|
2019-01-09 12:27:58 +11:00
|
|
|
if km is not None:
|
2019-02-20 16:38:21 +11:00
|
|
|
kmi_add = km.keymap_items.find_from_operator("view3d.ruler_add")
|
|
|
|
kmi_remove = km.keymap_items.find_from_operator("view3d.ruler_remove")
|
2019-01-09 12:27:58 +11:00
|
|
|
else:
|
2019-02-20 16:38:21 +11:00
|
|
|
kmi_add = None
|
|
|
|
kmi_remove = None
|
2019-04-09 23:16:11 +10:00
|
|
|
return tip_(
|
2018-09-07 11:48:03 +10:00
|
|
|
"Measure distance and angles.\n"
|
2018-11-28 23:52:05 +11:00
|
|
|
"\u2022 {} anywhere for new measurement.\n"
|
2018-09-07 11:48:03 +10:00
|
|
|
"\u2022 Drag ruler segment to measure an angle.\n"
|
2019-02-20 16:38:21 +11:00
|
|
|
"\u2022 {} to remove the active ruler.\n"
|
2019-02-04 10:32:17 +11:00
|
|
|
"\u2022 Ctrl while dragging to snap.\n"
|
|
|
|
"\u2022 Shift while dragging to measure surface thickness."
|
2018-11-28 23:52:05 +11:00
|
|
|
).format(
|
2019-02-20 16:38:21 +11:00
|
|
|
kmi_to_string_or_none(kmi_add),
|
|
|
|
kmi_to_string_or_none(kmi_remove),
|
2018-11-28 23:52:05 +11:00
|
|
|
)
|
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.measure",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Measure",
|
2018-11-28 23:52:05 +11:00
|
|
|
description=description,
|
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-12-14 12:17:00 +11:00
|
|
|
keymap="3D View Tool: Measure",
|
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 = ""
|
|
|
|
|
|
|
|
gpl = context.active_gpencil_layer
|
|
|
|
if gpl is not None:
|
2019-03-12 19:49:46 +01:00
|
|
|
layout.label(text="Annotation:")
|
2018-11-27 17:33:52 +11:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.annotate",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Annotate",
|
2018-11-27 17:33:52 +11:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.annotate_line",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Annotate Line",
|
2018-11-27 17:33:52 +11:00
|
|
|
icon="ops.gpencil.draw.line",
|
2019-09-26 14:31:52 +02:00
|
|
|
cursor='PAINT_BRUSH',
|
2018-11-27 17:33:52 +11:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.annotate_polygon",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Annotate Polygon",
|
2018-11-27 17:33:52 +11:00
|
|
|
icon="ops.gpencil.draw.poly",
|
2019-09-26 14:31:52 +02:00
|
|
|
cursor='PAINT_BRUSH',
|
2018-11-27 17:33:52 +11:00
|
|
|
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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(context, layout, _tool):
|
2018-11-27 17:33:52 +11:00
|
|
|
# TODO: Move this setting to tool_settings
|
2018-12-21 12:47:44 +11:00
|
|
|
prefs = context.preferences
|
|
|
|
layout.prop(prefs.edit, "grease_pencil_eraser_radius", text="Radius")
|
2018-11-27 17:33:52 +11:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.annotate_eraser",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Annotate Eraser",
|
2018-11-27 17:33:52 +11:00
|
|
|
icon="ops.gpencil.draw.eraser",
|
2019-09-26 14:31:52 +02:00
|
|
|
cursor='ERASER',
|
2018-11-27 17:33:52 +11:00
|
|
|
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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(context, layout, _tool):
|
2019-04-13 20:36:53 +02:00
|
|
|
_template_widget.VIEW3D_GGT_xform_gizmo.draw_settings_with_index(context, layout, 1)
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.move",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Move",
|
2018-06-28 10:34:41 +02:00
|
|
|
# cursor='SCROLL_XY',
|
2018-05-07 21:38:43 +02:00
|
|
|
icon="ops.transform.translate",
|
2019-04-13 20:36:53 +02:00
|
|
|
widget="VIEW3D_GGT_xform_gizmo",
|
2018-07-03 18:33:52 +02:00
|
|
|
operator="transform.translate",
|
2018-12-14 12:17:00 +11:00
|
|
|
keymap="3D View Tool: Move",
|
2018-12-19 20:51:04 +11:00
|
|
|
draw_settings=draw_settings,
|
2018-05-07 21:38:43 +02:00
|
|
|
)
|
2018-04-30 12:14:46 +02:00
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def rotate():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(context, layout, _tool):
|
2019-04-13 20:36:53 +02:00
|
|
|
_template_widget.VIEW3D_GGT_xform_gizmo.draw_settings_with_index(context, layout, 2)
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.rotate",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Rotate",
|
2018-06-28 10:34:41 +02:00
|
|
|
# cursor='SCROLL_XY',
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.transform.rotate",
|
2019-04-13 20:36:53 +02:00
|
|
|
widget="VIEW3D_GGT_xform_gizmo",
|
2018-07-03 18:33:52 +02:00
|
|
|
operator="transform.rotate",
|
2018-12-14 12:17:00 +11:00
|
|
|
keymap="3D View Tool: Rotate",
|
2018-12-19 20:51:04 +11:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def scale():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(context, layout, _tool):
|
2019-04-13 20:36:53 +02:00
|
|
|
_template_widget.VIEW3D_GGT_xform_gizmo.draw_settings_with_index(context, layout, 3)
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.scale",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Scale",
|
2018-06-28 10:34:41 +02:00
|
|
|
# cursor='SCROLL_XY',
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.transform.resize",
|
2019-04-13 20:36:53 +02:00
|
|
|
widget="VIEW3D_GGT_xform_gizmo",
|
2018-07-03 18:33:52 +02:00
|
|
|
operator="transform.resize",
|
2018-12-14 12:17:00 +11:00
|
|
|
keymap="3D View Tool: Scale",
|
2018-12-19 20:51:04 +11:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def scale_cage():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(context, layout, _tool):
|
2019-04-13 20:36:53 +02:00
|
|
|
_template_widget.VIEW3D_GGT_xform_gizmo.draw_settings_with_index(context, layout, 3)
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.scale_cage",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Scale Cage",
|
2018-04-30 12:14:46 +02:00
|
|
|
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",
|
2019-02-21 16:42:59 +11:00
|
|
|
keymap="3D View Tool: Scale",
|
2018-12-19 20:51:04 +11:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
2019-05-24 01:35:48 +10:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def transform():
|
|
|
|
def draw_settings(context, layout, tool):
|
2019-07-01 13:11:55 +10:00
|
|
|
if layout.use_property_split:
|
2019-05-24 01:35:48 +10:00
|
|
|
layout.label(text="Gizmos:")
|
|
|
|
|
2019-12-07 03:45:50 +11:00
|
|
|
show_drag = True
|
|
|
|
if context.preferences.experimental.use_tool_fallback:
|
|
|
|
tool_settings = context.tool_settings
|
|
|
|
if tool_settings.workspace_tool_type == 'FALLBACK':
|
|
|
|
show_drag = False
|
|
|
|
|
|
|
|
if show_drag:
|
|
|
|
props = tool.gizmo_group_properties("VIEW3D_GGT_xform_gizmo")
|
|
|
|
layout.prop(props, "drag_action")
|
2019-05-24 01:35:48 +10:00
|
|
|
|
|
|
|
_template_widget.VIEW3D_GGT_xform_gizmo.draw_settings_with_index(context, layout, 1)
|
|
|
|
|
|
|
|
return dict(
|
|
|
|
idname="builtin.transform",
|
|
|
|
label="Transform",
|
|
|
|
description=(
|
|
|
|
"Supports any combination of grab, rotate & scale at once"
|
|
|
|
),
|
|
|
|
icon="ops.transform.transform",
|
|
|
|
widget="VIEW3D_GGT_xform_gizmo",
|
|
|
|
keymap="3D View Tool: Transform",
|
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
|
|
|
|
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():
|
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.select",
|
2019-09-04 11:55:36 +02:00
|
|
|
label="Tweak",
|
2018-11-22 16:05:28 +01:00
|
|
|
icon="ops.generic.select",
|
|
|
|
widget=None,
|
2019-09-04 11:55:36 +02:00
|
|
|
keymap="3D View Tool: Tweak",
|
2018-11-22 16:05:28 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def box():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-10-05 10:27:04 +10:00
|
|
|
props = tool.operator_properties("view3d.select_box")
|
2019-05-06 15:59:34 +02:00
|
|
|
row = layout.row()
|
|
|
|
row.use_property_split = False
|
|
|
|
row.prop(props, "mode", text="", expand=True, icon_only=True)
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.select_box",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Select Box",
|
2018-10-05 10:27:04 +10:00
|
|
|
icon="ops.generic.select_box",
|
2018-04-30 12:14:46 +02:00
|
|
|
widget=None,
|
2018-12-14 12:17:00 +11:00
|
|
|
keymap="3D View Tool: Select Box",
|
2018-11-13 14:05:20 +11:00
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def lasso():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-11-13 14:05:20 +11:00
|
|
|
props = tool.operator_properties("view3d.select_lasso")
|
2019-05-06 15:59:34 +02:00
|
|
|
row = layout.row()
|
|
|
|
row.use_property_split = False
|
|
|
|
row.prop(props, "mode", text="", expand=True, icon_only=True)
|
2018-11-13 14:05:20 +11:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.select_lasso",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Select Lasso",
|
2018-11-13 14:05:20 +11:00
|
|
|
icon="ops.generic.select_lasso",
|
|
|
|
widget=None,
|
2018-12-14 13:21:13 +11:00
|
|
|
keymap="3D View Tool: Select Lasso",
|
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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-08-29 15:03:50 +10:00
|
|
|
props = tool.operator_properties("view3d.select_circle")
|
2019-05-06 15:59:34 +02:00
|
|
|
row = layout.row()
|
|
|
|
row.use_property_split = False
|
|
|
|
row.prop(props, "mode", text="", expand=True, icon_only=True)
|
2018-08-29 15:03:50 +10:00
|
|
|
layout.prop(props, "radius")
|
2018-10-25 21:05:29 +11:00
|
|
|
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_cursor(_context, tool, xy):
|
2018-10-25 21:05:29 +11:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.select_circle",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Select Circle",
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.generic.select_circle",
|
|
|
|
widget=None,
|
2018-12-14 12:17:00 +11:00
|
|
|
keymap="3D View Tool: Select Circle",
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.roll",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Roll",
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.armature.bone.roll",
|
2019-12-12 18:38:41 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_free",
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.bone_envelope",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Bone Envelope",
|
2018-05-15 13:49:44 +02:00
|
|
|
icon="ops.transform.bone_envelope",
|
2019-12-12 18:38:41 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_free",
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.bone_size",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Bone Size",
|
2018-05-15 13:49:44 +02:00
|
|
|
icon="ops.transform.bone_size",
|
2019-12-12 18:38:41 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_free",
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.extrude",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Extrude",
|
2018-04-30 12:14:46 +02:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.extrude_to_cursor",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Extrude to Cursor",
|
2018-04-30 12:14:46 +02:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.add_cube",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Add Cube",
|
2018-08-29 18:40:32 +10:00
|
|
|
icon="ops.mesh.primitive_cube_add_gizmo",
|
2019-01-08 12:24:45 +01:00
|
|
|
description=(
|
|
|
|
"Add cube to mesh interactively"
|
|
|
|
),
|
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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-05-22 14:00:44 +02:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.rip_region",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Rip Region",
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.mesh.rip",
|
2019-12-07 03:45:50 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_free",
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.rip_edge",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Rip Edge",
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.mesh.rip_edge",
|
2019-12-12 18:38:41 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_free",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def poly_build():
|
2019-09-15 05:26:15 +10:00
|
|
|
def draw_settings(_context, layout, tool):
|
2019-08-27 16:19:25 +02:00
|
|
|
props = tool.operator_properties("mesh.polybuild_face_at_cursor_move")
|
|
|
|
props_macro = props.MESH_OT_polybuild_face_at_cursor
|
|
|
|
layout.prop(props_macro, "create_quads")
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.poly_build",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Poly Build",
|
2018-04-30 12:14:46 +02:00
|
|
|
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=(),
|
2019-08-27 16:19:25 +02:00
|
|
|
draw_settings=draw_settings,
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def edge_slide():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-08-22 17:53:03 +10:00
|
|
|
props = tool.operator_properties("transform.edge_slide")
|
|
|
|
layout.prop(props, "correct_uv")
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.edge_slide",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Edge Slide",
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.transform.edge_slide",
|
2019-12-07 03:45:50 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_normal",
|
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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-08-22 17:53:03 +10:00
|
|
|
props = tool.operator_properties("transform.vert_slide")
|
|
|
|
layout.prop(props, "correct_uv")
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.vertex_slide",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Vertex Slide",
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.transform.vert_slide",
|
2019-12-07 03:45:50 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_free",
|
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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-09-17 14:52:54 +10:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.spin",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Spin",
|
2018-04-30 12:14:46 +02:00
|
|
|
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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-09-17 14:52:54 +10:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.spin_duplicates",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Spin Duplicates",
|
2018-04-30 12:14:46 +02:00
|
|
|
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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-05-22 14:00:44 +02:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.inset_faces",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Inset Faces",
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.mesh.inset",
|
2019-12-07 03:45:50 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_normal",
|
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():
|
2019-12-12 11:56:20 -05:00
|
|
|
def draw_settings(context, layout, tool, *, extra=False):
|
2018-08-22 17:37:07 +10:00
|
|
|
props = tool.operator_properties("mesh.bevel")
|
2019-12-12 11:56:20 -05:00
|
|
|
region_type = context.region.type
|
|
|
|
|
|
|
|
if extra == False:
|
|
|
|
if props.offset_type == 'PERCENT':
|
|
|
|
layout.prop(props, "offset_pct")
|
|
|
|
else:
|
|
|
|
offset_text = "Width"
|
|
|
|
if props.offset_type == 'DEPTH':
|
|
|
|
offset_text = "Depth"
|
|
|
|
elif props.offset_type == 'OFFSET':
|
|
|
|
offset_text = "Offset"
|
|
|
|
layout.prop(props, "offset", text=offset_text)
|
|
|
|
if region_type == 'TOOL_HEADER':
|
|
|
|
layout.prop(props, "offset_type", text="")
|
|
|
|
else:
|
|
|
|
layout.prop(props, "offset_type")
|
|
|
|
|
|
|
|
layout.prop(props, "segments")
|
|
|
|
layout.prop(props, "profile", slider=True)
|
|
|
|
|
|
|
|
if region_type == 'TOOL_HEADER':
|
|
|
|
layout.popover("TOPBAR_PT_tool_settings_extra", text="...")
|
|
|
|
else:
|
|
|
|
extra = True
|
|
|
|
|
|
|
|
if extra or region_type != 'TOOL_HEADER':
|
|
|
|
layout.prop(props, "vertex_only")
|
|
|
|
layout.prop(props, "clamp_overlap")
|
|
|
|
layout.prop(props, "loop_slide")
|
|
|
|
layout.prop(props, "mark_seam")
|
|
|
|
layout.prop(props, "mark_sharp")
|
|
|
|
layout.prop(props, "harden_normals")
|
|
|
|
|
|
|
|
layout.prop(props, "material")
|
|
|
|
|
|
|
|
layout.prop(props, "miter_outer", text="Outer Miter")
|
|
|
|
layout.prop(props, "miter_inner", text="Inner Miter")
|
|
|
|
if props.miter_inner == 'ARC':
|
|
|
|
layout.prop(props, "spread")
|
|
|
|
|
|
|
|
layout.prop(props, "use_custom_profile")
|
|
|
|
if props.use_custom_profile:
|
|
|
|
tool_settings = context.tool_settings
|
|
|
|
layout.template_curveprofile(tool_settings, "custom_bevel_profile_preset")
|
2018-08-22 17:37:07 +10:00
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.bevel",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Bevel",
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.mesh.bevel",
|
2019-12-07 03:45:50 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_normal",
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.extrude_region",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-08-29 22:59:49 +10:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.extrude_along_normals",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Extrude Along Normals",
|
2018-08-29 22:59:49 +10:00
|
|
|
icon="ops.mesh.extrude_region_shrink_fatten",
|
2019-12-07 03:45:50 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_normal",
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.extrude_individual",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Extrude Individual",
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.mesh.extrude_faces_move",
|
2019-12-07 03:45:50 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_normal",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def extrude_cursor():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-09-27 12:23:01 +10:00
|
|
|
props = tool.operator_properties("mesh.dupli_extrude_cursor")
|
|
|
|
layout.prop(props, "rotate_source")
|
|
|
|
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.extrude_to_cursor",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Extrude to Cursor",
|
2018-04-30 12:14:46 +02:00
|
|
|
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
|
|
|
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-08-22 14:04:37 +10:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.loop_cut",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Loop Cut",
|
2018-04-30 12:14:46 +02:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.offset_edge_loop_cut",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Offset Edge Loop Cut",
|
2018-04-30 12:14:46 +02:00
|
|
|
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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-09-13 09:23:24 +10:00
|
|
|
props = tool.operator_properties("mesh.vertices_smooth")
|
|
|
|
layout.prop(props, "repeat")
|
2018-04-30 12:14:46 +02:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.smooth",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Smooth",
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.mesh.vertices_smooth",
|
2019-12-07 03:45:50 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_normal",
|
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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-09-13 09:23:24 +10:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.randomize",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Randomize",
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.transform.vertex_random",
|
2019-12-07 03:45:50 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_normal",
|
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():
|
2019-10-23 02:34:30 +11:00
|
|
|
def draw_settings(context, layout, _tool):
|
|
|
|
# props = tool.operator_properties("transform.shear")
|
2019-04-13 20:36:53 +02:00
|
|
|
_template_widget.VIEW3D_GGT_xform_gizmo.draw_settings_with_index(context, layout, 2)
|
2018-08-28 20:41:48 +10:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.shear",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Shear",
|
2018-08-28 20:41:48 +10:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.to_sphere",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="To Sphere",
|
2018-08-28 20:41:48 +10:00
|
|
|
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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-05-22 14:00:44 +02:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.shrink_fatten",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Shrink/Fatten",
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.transform.shrink_fatten",
|
2019-12-07 03:45:50 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_normal",
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.push_pull",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Push/Pull",
|
2018-04-30 12:14:46 +02:00
|
|
|
icon="ops.transform.push_pull",
|
2019-12-07 03:45:50 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_normal",
|
2018-11-15 12:22:36 +11:00
|
|
|
keymap=(),
|
2018-04-30 12:14:46 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def knife():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-05-22 14:00:44 +02:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.knife",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Knife",
|
2019-07-05 17:44:47 +10:00
|
|
|
cursor='KNIFE',
|
2018-04-30 12:14:46 +02:00
|
|
|
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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-09-12 06:24:15 +10:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.bisect",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Bisect",
|
2018-04-30 12:14:46 +02:00
|
|
|
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():
|
2019-04-19 07:32:24 +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
|
|
|
|
|
2019-05-27 16:55:43 +02:00
|
|
|
col = layout.column()
|
2018-05-11 20:25:01 +02:00
|
|
|
|
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.draw",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.extrude",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.extrude_cursor",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.tilt",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Tilt",
|
2018-11-15 22:27:02 +11:00
|
|
|
icon="ops.transform.tilt",
|
2019-12-12 18:38:41 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_free",
|
2018-11-15 22:27:02 +11:00
|
|
|
keymap=(),
|
|
|
|
)
|
|
|
|
|
2019-03-03 12:37:18 +01:00
|
|
|
@ToolDef.from_fn
|
2019-03-04 09:50:59 +01:00
|
|
|
def curve_radius():
|
2019-03-03 12:37:18 +01:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.radius",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Radius",
|
2019-03-04 10:26:27 +01:00
|
|
|
description=(
|
|
|
|
"Expand or contract the radius of the selected curve points"
|
|
|
|
),
|
2019-03-04 09:50:59 +01:00
|
|
|
icon="ops.curve.radius",
|
2019-12-12 18:38:41 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_free",
|
2019-03-03 12:37:18 +01:00
|
|
|
keymap=(),
|
|
|
|
)
|
2018-05-07 21:38:43 +02:00
|
|
|
|
2019-03-03 20:37:47 +01:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def curve_vertex_randomize():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2019-03-03 20:37:47 +01:00
|
|
|
props = tool.operator_properties("transform.vertex_random")
|
|
|
|
layout.prop(props, "uniform")
|
|
|
|
layout.prop(props, "normal")
|
|
|
|
layout.prop(props, "seed")
|
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.randomize",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Randomize",
|
2019-03-03 20:37:47 +01:00
|
|
|
icon="ops.curve.vertex_random",
|
2019-12-07 03:45:50 +11:00
|
|
|
widget="VIEW3D_GGT_tool_generic_handle_normal",
|
2019-03-03 20:37:47 +01:00
|
|
|
keymap=(),
|
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-05-15 12:40:50 +02:00
|
|
|
class _defs_pose:
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def breakdown():
|
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.breakdowner",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.push",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.relax",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="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,
|
2019-03-15 14:18:21 +11:00
|
|
|
idname_prefix="builtin_brush.",
|
2018-08-02 17:41:11 +10:00
|
|
|
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,
|
2019-03-15 14:18:21 +11:00
|
|
|
idname_prefix="builtin_brush.",
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.box_hide",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.box_mask",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="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
|
|
|
|
2019-06-07 16:04:12 +10:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def mask_lasso():
|
|
|
|
return dict(
|
|
|
|
idname="builtin.lasso_mask",
|
|
|
|
label="Lasso Mask",
|
2019-06-07 10:24:19 +02:00
|
|
|
icon="ops.sculpt.lasso_mask",
|
2019-06-07 16:04:12 +10:00
|
|
|
widget=None,
|
|
|
|
keymap=(),
|
|
|
|
)
|
|
|
|
|
2019-09-09 15:42:51 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def mesh_filter():
|
2019-09-15 05:26:15 +10:00
|
|
|
def draw_settings(_context, layout, tool):
|
2019-09-09 15:42:51 +02:00
|
|
|
props = tool.operator_properties("sculpt.mesh_filter")
|
|
|
|
layout.prop(props, "type", expand=False)
|
|
|
|
layout.prop(props, "strength")
|
|
|
|
layout.prop(props, "deform_axis")
|
|
|
|
|
|
|
|
return dict(
|
|
|
|
idname="builtin.mesh_filter",
|
|
|
|
label="Mesh Filter",
|
|
|
|
icon="ops.sculpt.mesh_filter",
|
|
|
|
widget=None,
|
2019-09-10 06:11:52 +10:00
|
|
|
keymap=(),
|
2019-09-09 15:42:51 +02:00
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
2018-08-28 21:00:25 +10:00
|
|
|
|
2019-09-10 06:11:52 +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):
|
2019-03-31 18:43:14 +02:00
|
|
|
if context is None:
|
|
|
|
return True
|
2018-09-21 19:24:29 +02:00
|
|
|
ob = context.active_object
|
2019-04-16 12:18:28 +02:00
|
|
|
return (ob and ob.type == 'MESH' and
|
2019-01-08 15:15:35 +11:00
|
|
|
(ob.data.use_paint_mask or
|
|
|
|
ob.data.use_paint_mask_vertex))
|
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,
|
2019-03-15 14:18:21 +11:00
|
|
|
idname_prefix="builtin_brush.",
|
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-12-20 13:01:40 +11:00
|
|
|
|
2018-04-30 16:43:13 +02:00
|
|
|
class _defs_texture_paint:
|
|
|
|
|
2019-03-11 13:45:15 +01:00
|
|
|
@staticmethod
|
|
|
|
def poll_select_mask(context):
|
2019-03-31 18:43:14 +02:00
|
|
|
if context is None:
|
|
|
|
return True
|
2019-03-11 13:45:15 +01:00
|
|
|
ob = context.active_object
|
2019-04-16 12:18:28 +02:00
|
|
|
return (ob and ob.type == 'MESH' and
|
2019-03-11 13:45:15 +01:00
|
|
|
(ob.data.use_paint_mask))
|
|
|
|
|
2018-04-30 16:43:13 +02:00
|
|
|
@staticmethod
|
|
|
|
def generate_from_brushes(context):
|
2018-11-06 12:08:39 +11:00
|
|
|
return generate_from_enum_ex(
|
|
|
|
context,
|
2019-03-15 14:18:21 +11:00
|
|
|
idname_prefix="builtin_brush.",
|
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):
|
2019-03-31 18:43:14 +02:00
|
|
|
if context is None:
|
|
|
|
return True
|
2018-09-21 19:24:29 +02:00
|
|
|
ob = context.active_object
|
2019-04-16 12:18:28 +02:00
|
|
|
return (ob and ob.type == 'MESH' and
|
2018-09-21 19:24:29 +02:00
|
|
|
(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,
|
2019-03-15 14:18:21 +11:00
|
|
|
idname_prefix="builtin_brush.",
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.sample_weight",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Sample Weight",
|
2018-05-01 12:20:53 +02:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.sample_vertex_group",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Sample Vertex Group",
|
2018-05-01 12:20:53 +02:00
|
|
|
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:
|
2019-06-11 16:08:32 +10:00
|
|
|
from bl_ui.properties_paint_common import UnifiedPaintPanel
|
2019-03-12 16:19:37 +11:00
|
|
|
UnifiedPaintPanel.prop_unified_weight(layout, context, brush, "weight", slider=True)
|
|
|
|
UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True)
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.gradient",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Gradient",
|
2018-05-01 12:46:25 +02:00
|
|
|
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):
|
2019-03-31 18:43:14 +02:00
|
|
|
if context is None:
|
|
|
|
return True
|
2018-10-05 13:07:01 +10:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.cursor",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Cursor",
|
2018-10-04 12:04:36 +10:00
|
|
|
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
|
|
|
)
|
|
|
|
|
2019-03-07 14:03:59 +11:00
|
|
|
# Currently a place holder so we can switch away from the annotation tool.
|
|
|
|
# Falls back to default image editor action.
|
|
|
|
@ToolDef.from_fn
|
2019-03-07 18:02:52 +11:00
|
|
|
def sample():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2019-03-07 18:02:52 +11:00
|
|
|
props = tool.operator_properties("image.sample")
|
2019-03-08 00:36:48 +11:00
|
|
|
layout.prop(props, "size")
|
2019-03-07 14:03:59 +11:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.sample",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Sample",
|
2019-03-07 14:03:59 +11:00
|
|
|
description=(
|
2019-03-07 18:02:52 +11:00
|
|
|
"Sample pixel values under the cursor"
|
2019-03-07 14:03:59 +11:00
|
|
|
),
|
2019-03-07 18:02:52 +11:00
|
|
|
icon="ops.paint.weight_sample", # XXX, needs own icon.
|
|
|
|
keymap="Image Editor Tool: Sample",
|
|
|
|
draw_settings=draw_settings,
|
2019-03-07 14:03:59 +11:00
|
|
|
)
|
|
|
|
|
2018-10-04 12:04:36 +10:00
|
|
|
|
|
|
|
class _defs_image_uv_transform:
|
|
|
|
|
2019-06-26 01:39:58 +10:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def translate():
|
|
|
|
return dict(
|
|
|
|
idname="builtin.move",
|
|
|
|
label="Move",
|
|
|
|
icon="ops.transform.translate",
|
|
|
|
# widget="VIEW3D_GGT_xform_gizmo",
|
|
|
|
operator="transform.translate",
|
|
|
|
keymap="Image Editor Tool: Uv, Move",
|
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def rotate():
|
|
|
|
return dict(
|
|
|
|
idname="builtin.rotate",
|
|
|
|
label="Rotate",
|
|
|
|
icon="ops.transform.rotate",
|
|
|
|
# widget="VIEW3D_GGT_xform_gizmo",
|
|
|
|
operator="transform.rotate",
|
|
|
|
keymap="Image Editor Tool: Uv, Rotate",
|
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def scale():
|
|
|
|
return dict(
|
|
|
|
idname="builtin.scale",
|
|
|
|
label="Scale",
|
|
|
|
icon="ops.transform.resize",
|
|
|
|
# widget="VIEW3D_GGT_xform_gizmo",
|
|
|
|
operator="transform.resize",
|
|
|
|
keymap="Image Editor Tool: Uv, Scale",
|
|
|
|
)
|
|
|
|
|
2018-10-04 12:04:36 +10:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def transform():
|
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.transform",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Transform",
|
2018-10-04 12:04:36 +10:00
|
|
|
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():
|
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.select",
|
2019-09-04 11:55:36 +02:00
|
|
|
label="Tweak",
|
2018-11-22 16:05:28 +01:00
|
|
|
icon="ops.generic.select",
|
|
|
|
widget=None,
|
|
|
|
keymap=(),
|
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def box():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-10-05 10:27:04 +10:00
|
|
|
props = tool.operator_properties("uv.select_box")
|
2019-05-06 15:59:34 +02:00
|
|
|
row = layout.row()
|
|
|
|
row.use_property_split = False
|
|
|
|
row.prop(props, "mode", text="", expand=True, icon_only=True)
|
2018-05-16 18:41:11 +02:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.select_box",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Select Box",
|
2018-10-05 10:27:04 +10:00
|
|
|
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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-11-23 17:52:28 +11:00
|
|
|
props = tool.operator_properties("uv.select_lasso")
|
2019-05-06 15:59:34 +02:00
|
|
|
row = layout.row()
|
|
|
|
row.use_property_split = False
|
|
|
|
row.prop(props, "mode", text="", expand=True, icon_only=True)
|
2018-11-13 14:05:20 +11:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.select_lasso",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Select Lasso",
|
2018-11-13 14:05:20 +11:00
|
|
|
icon="ops.generic.select_lasso",
|
|
|
|
widget=None,
|
2018-12-14 13:21:13 +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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-10-04 15:12:28 +10:00
|
|
|
props = tool.operator_properties("uv.select_circle")
|
2019-05-06 15:59:34 +02:00
|
|
|
row = layout.row()
|
|
|
|
row.use_property_split = False
|
|
|
|
row.prop(props, "mode", text="", expand=True, icon_only=True)
|
2018-10-04 15:12:28 +10:00
|
|
|
layout.prop(props, "radius")
|
2019-05-30 21:28:04 +10:00
|
|
|
|
|
|
|
def draw_cursor(_context, tool, xy):
|
|
|
|
from gpu_extras.presets import draw_circle_2d
|
|
|
|
props = tool.operator_properties("uv.select_circle")
|
|
|
|
radius = props.radius
|
|
|
|
draw_circle_2d(xy, (1.0,) * 4, radius, 32)
|
|
|
|
|
2018-05-16 18:41:11 +02:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.select_circle",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Select Circle",
|
2018-05-16 18:41:11 +02:00
|
|
|
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,
|
2019-05-30 21:28:04 +10:00
|
|
|
draw_cursor=draw_cursor,
|
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):
|
2019-05-01 18:10:34 +10:00
|
|
|
def draw_cursor(context, _tool, xy):
|
|
|
|
from gpu_extras.presets import draw_circle_2d
|
|
|
|
tool_settings = context.tool_settings
|
|
|
|
uv_sculpt = tool_settings.uv_sculpt
|
|
|
|
if not uv_sculpt.show_brush:
|
|
|
|
return
|
|
|
|
ups = tool_settings.unified_paint_settings
|
|
|
|
if ups.use_unified_size:
|
|
|
|
radius = ups.size
|
|
|
|
else:
|
|
|
|
brush = tool_settings.uv_sculpt.brush
|
|
|
|
if brush is None:
|
|
|
|
return
|
|
|
|
radius = brush.size
|
|
|
|
draw_circle_2d(xy, (1.0,) * 4, radius, 32)
|
|
|
|
|
2018-10-05 13:07:01 +10:00
|
|
|
return generate_from_enum_ex(
|
|
|
|
context,
|
2019-03-15 14:18:21 +11:00
|
|
|
idname_prefix="builtin_brush.",
|
2018-10-05 13:07:01 +10:00
|
|
|
icon_prefix="brush.uv_sculpt.",
|
2019-05-01 18:10:34 +10:00
|
|
|
type=bpy.types.Brush,
|
2018-10-05 13:07:01 +10:00
|
|
|
attr="uv_sculpt_tool",
|
2019-05-01 18:10:34 +10:00
|
|
|
tooldef_keywords=dict(
|
|
|
|
operator="sculpt.uv_sculpt_stroke",
|
|
|
|
keymap="Image Editor Tool: Uv, Sculpt Stroke",
|
|
|
|
draw_cursor=draw_cursor,
|
|
|
|
),
|
2018-10-05 13:07:01 +10:00
|
|
|
)
|
|
|
|
|
|
|
|
|
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,
|
2019-03-15 14:18:21 +11:00
|
|
|
idname_prefix="builtin_brush.",
|
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",
|
2019-10-10 20:04:10 +02:00
|
|
|
cursor='DOT',
|
2018-11-02 09:10:23 +11:00
|
|
|
tooldef_keywords=dict(
|
|
|
|
operator="gpencil.draw",
|
|
|
|
),
|
2018-07-31 10:22:19 +02:00
|
|
|
)
|
|
|
|
|
2019-01-11 19:15:23 +01:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def cutter():
|
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.cutter",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Cutter",
|
2019-01-11 19:15:23 +01:00
|
|
|
icon="ops.gpencil.stroke_cutter",
|
|
|
|
cursor='KNIFE',
|
|
|
|
widget=None,
|
|
|
|
keymap=(),
|
|
|
|
)
|
|
|
|
|
2018-11-14 19:19:04 +11:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def line():
|
2018-11-09 17:05:32 +11:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.line",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Line",
|
2018-11-09 17:05:32 +11:00
|
|
|
icon="ops.gpencil.primitive_line",
|
2019-06-16 20:16:28 +02: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
|
|
|
)
|
|
|
|
|
2019-10-18 22:02:45 +01:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def polyline():
|
|
|
|
return dict(
|
|
|
|
idname="builtin.polyline",
|
|
|
|
label="Polyline",
|
|
|
|
icon="ops.gpencil.primitive_polyline",
|
|
|
|
cursor='CROSSHAIR',
|
|
|
|
widget=None,
|
|
|
|
keymap=(),
|
2019-10-23 01:03:31 +11:00
|
|
|
)
|
2019-10-18 22:02:45 +01:00
|
|
|
|
2018-11-14 19:19:04 +11:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def box():
|
2018-11-09 17:05:32 +11:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.box",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Box",
|
2018-11-09 17:05:32 +11:00
|
|
|
icon="ops.gpencil.primitive_box",
|
2019-06-16 20:16:28 +02: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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.circle",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Circle",
|
2018-11-09 17:05:32 +11:00
|
|
|
icon="ops.gpencil.primitive_circle",
|
2019-06-16 20:16:28 +02: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-12-03 14:55:57 +00:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def arc():
|
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.arc",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Arc",
|
2018-12-03 14:55:57 +00:00
|
|
|
icon="ops.gpencil.primitive_arc",
|
2019-06-16 20:16:28 +02:00
|
|
|
cursor='CROSSHAIR',
|
2018-12-03 14:55:57 +00:00
|
|
|
widget=None,
|
|
|
|
keymap=(),
|
|
|
|
)
|
2018-12-15 17:21:47 +01:00
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def curve():
|
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.curve",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Curve",
|
2018-12-15 17:21:47 +01:00
|
|
|
icon="ops.gpencil.primitive_curve",
|
2019-06-16 20:16:28 +02:00
|
|
|
cursor='CROSSHAIR',
|
2018-12-15 17:21:47 +01:00
|
|
|
widget=None,
|
|
|
|
keymap=(),
|
2019-10-23 01:03:31 +11:00
|
|
|
)
|
2018-07-31 10:22:19 +02:00
|
|
|
|
2019-10-11 13:28:22 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def eyedropper():
|
|
|
|
return dict(
|
|
|
|
idname="builtin.eyedropper",
|
|
|
|
label="Eyedropper",
|
2019-10-30 11:11:26 +01:00
|
|
|
icon="ops.paint.eyedropper_add",
|
2019-10-11 13:28:22 +02:00
|
|
|
cursor='EYEDROPPER',
|
|
|
|
widget=None,
|
|
|
|
keymap=(),
|
|
|
|
)
|
|
|
|
|
2019-10-12 10:22:09 +11:00
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
class _defs_gpencil_edit:
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def bend():
|
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.bend",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Bend",
|
2018-07-31 10:22:19 +02:00
|
|
|
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():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(context, layout, _tool):
|
2019-01-11 19:15:23 +01:00
|
|
|
layout.prop(context.tool_settings.gpencil_sculpt, "intersection_threshold")
|
2018-11-22 16:05:28 +01:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.select",
|
2019-09-04 11:55:36 +02:00
|
|
|
label="Tweak",
|
2018-11-22 16:05:28 +01:00
|
|
|
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")
|
2019-05-06 15:59:34 +02:00
|
|
|
row = layout.row()
|
|
|
|
row.use_property_split = False
|
|
|
|
row.prop(props, "mode", text="", expand=True, icon_only=True)
|
2019-01-11 19:15:23 +01:00
|
|
|
layout.prop(context.tool_settings.gpencil_sculpt, "intersection_threshold")
|
2018-09-21 10:28:51 +02:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.select_box",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Select Box",
|
2018-10-05 10:27:04 +10:00
|
|
|
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")
|
2019-05-06 15:59:34 +02:00
|
|
|
row = layout.row()
|
|
|
|
row.use_property_split = False
|
|
|
|
row.prop(props, "mode", text="", expand=True, icon_only=True)
|
2019-01-11 19:15:23 +01:00
|
|
|
layout.prop(context.tool_settings.gpencil_sculpt, "intersection_threshold")
|
2018-09-21 10:28:51 +02:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.select_lasso",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Select Lasso",
|
2018-11-13 14:05:20 +11:00
|
|
|
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():
|
2019-01-11 19:15:23 +01:00
|
|
|
def draw_settings(context, layout, tool):
|
2019-03-05 22:26:45 +11:00
|
|
|
props = tool.operator_properties("gpencil.select_circle")
|
2019-05-06 15:59:34 +02:00
|
|
|
row = layout.row()
|
|
|
|
row.use_property_split = False
|
|
|
|
row.prop(props, "mode", text="", expand=True, icon_only=True)
|
2019-03-05 22:26:45 +11:00
|
|
|
layout.prop(props, "radius")
|
2019-01-11 19:15:23 +01:00
|
|
|
layout.prop(context.tool_settings.gpencil_sculpt, "intersection_threshold")
|
2019-05-30 21:28:04 +10:00
|
|
|
|
|
|
|
def draw_cursor(_context, tool, xy):
|
|
|
|
from gpu_extras.presets import draw_circle_2d
|
|
|
|
props = tool.operator_properties("gpencil.select_circle")
|
|
|
|
radius = props.radius
|
|
|
|
draw_circle_2d(xy, (1.0,) * 4, radius, 32)
|
|
|
|
|
2018-09-21 10:28:51 +02:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.select_circle",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Select Circle",
|
2018-11-13 14:05:20 +11:00
|
|
|
icon="ops.generic.select_circle",
|
2018-09-21 10:28:51 +02:00
|
|
|
widget=None,
|
2018-11-15 13:34:47 +11:00
|
|
|
keymap=(),
|
2019-01-11 19:15:23 +01:00
|
|
|
draw_settings=draw_settings,
|
2019-05-30 21:28:04 +10:00
|
|
|
draw_cursor=draw_cursor,
|
2018-09-21 10:28:51 +02:00
|
|
|
)
|
|
|
|
|
2019-03-07 11:12:30 +01:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def radius():
|
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.radius",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Radius",
|
2019-03-07 11:12:30 +01:00
|
|
|
description=(
|
|
|
|
"Expand or contract the radius of the selected points"
|
|
|
|
),
|
|
|
|
icon="ops.gpencil.radius",
|
|
|
|
|
|
|
|
widget=None,
|
|
|
|
keymap=(),
|
|
|
|
)
|
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def shear():
|
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.shear",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Shear",
|
2018-07-31 10:22:19 +02:00
|
|
|
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(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.to_sphere",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="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
|
|
|
)
|
|
|
|
|
2019-03-04 19:31:36 +01:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def extrude():
|
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.extrude",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Extrude",
|
2019-03-04 19:31:36 +01:00
|
|
|
icon="ops.gpencil.extrude_move",
|
|
|
|
widget="VIEW3D_GGT_xform_extrude",
|
|
|
|
keymap=(),
|
|
|
|
draw_settings=_template_widget.VIEW3D_GGT_xform_extrude.draw_settings,
|
|
|
|
)
|
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
|
|
|
|
class _defs_gpencil_sculpt:
|
2018-11-05 06:57:01 +11:00
|
|
|
|
2019-08-10 17:19:54 +02:00
|
|
|
@staticmethod
|
|
|
|
def poll_select_mask(context):
|
|
|
|
if context is None:
|
|
|
|
return True
|
|
|
|
ob = context.active_object
|
|
|
|
ts = context.scene.tool_settings
|
2019-08-17 16:18:09 +02:00
|
|
|
return ob and ob.type == 'GPENCIL' and (ts.use_gpencil_select_mask_point or
|
|
|
|
ts.use_gpencil_select_mask_stroke or
|
|
|
|
ts.use_gpencil_select_mask_segment)
|
2019-08-10 17:19:54 +02:00
|
|
|
|
2018-11-13 16:52:39 +11:00
|
|
|
@staticmethod
|
|
|
|
def generate_from_brushes(context):
|
|
|
|
return generate_from_enum_ex(
|
|
|
|
context,
|
2019-03-15 14:18:21 +11:00
|
|
|
idname_prefix="builtin_brush.",
|
2018-11-13 16:52:39 +11:00
|
|
|
icon_prefix="ops.gpencil.sculpt_",
|
|
|
|
type=bpy.types.GPencilSculptSettings,
|
|
|
|
attr="sculpt_tool",
|
2019-06-06 15:53:11 +10:00
|
|
|
tooldef_keywords=dict(
|
|
|
|
operator="gpencil.sculpt_paint",
|
|
|
|
keymap="3D View Tool: Sculpt Gpencil, Paint",
|
|
|
|
),
|
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,
|
2019-03-15 14:18:21 +11:00
|
|
|
idname_prefix="builtin_brush.",
|
2018-11-13 16:52:39 +11:00
|
|
|
icon_prefix="ops.gpencil.sculpt_",
|
|
|
|
type=bpy.types.GPencilSculptSettings,
|
|
|
|
attr="weight_tool",
|
2019-06-11 09:20:33 +10:00
|
|
|
tooldef_keywords=dict(
|
|
|
|
operator="gpencil.sculpt_paint",
|
|
|
|
keymap="3D View Tool: Sculpt Gpencil, Paint",
|
|
|
|
),
|
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():
|
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.select",
|
2019-09-04 11:55:36 +02:00
|
|
|
label="Tweak",
|
2018-11-27 18:39:29 +11:00
|
|
|
icon="ops.generic.select",
|
|
|
|
widget=None,
|
2019-09-04 11:55:36 +02:00
|
|
|
keymap="Node Tool: Tweak",
|
2018-11-27 18:39:29 +11:00
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def box():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-11-27 18:39:29 +11:00
|
|
|
props = tool.operator_properties("node.select_box")
|
2019-05-06 15:59:34 +02:00
|
|
|
row = layout.row()
|
|
|
|
row.use_property_split = False
|
|
|
|
row.prop(props, "mode", text="", expand=True, icon_only=True)
|
2018-11-27 18:39:29 +11:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.select_box",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Select Box",
|
2018-11-27 18:39:29 +11:00
|
|
|
icon="ops.generic.select_box",
|
|
|
|
widget=None,
|
|
|
|
keymap="Node Tool: Select Box",
|
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def lasso():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2018-11-27 18:39:29 +11:00
|
|
|
props = tool.operator_properties("node.select_lasso")
|
2019-05-06 15:59:34 +02:00
|
|
|
row = layout.row()
|
|
|
|
row.use_property_split = False
|
|
|
|
row.prop(props, "mode", text="", expand=True, icon_only=True)
|
2018-11-27 18:39:29 +11:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.select_lasso",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Select Lasso",
|
2018-11-27 18:39:29 +11:00
|
|
|
icon="ops.generic.select_lasso",
|
|
|
|
widget=None,
|
|
|
|
keymap="Node Tool: Select Lasso",
|
|
|
|
draw_settings=draw_settings,
|
|
|
|
)
|
|
|
|
|
2019-03-05 23:29:49 +11:00
|
|
|
@ToolDef.from_fn
|
|
|
|
def circle():
|
2019-04-19 07:32:24 +02:00
|
|
|
def draw_settings(_context, layout, tool):
|
2019-03-05 23:29:49 +11:00
|
|
|
props = tool.operator_properties("node.select_circle")
|
2019-05-06 15:59:34 +02:00
|
|
|
row = layout.row()
|
|
|
|
row.use_property_split = False
|
|
|
|
row.prop(props, "mode", text="", expand=True, icon_only=True)
|
2019-03-05 23:29:49 +11:00
|
|
|
layout.prop(props, "radius")
|
2019-05-30 21:28:04 +10:00
|
|
|
|
|
|
|
def draw_cursor(_context, tool, xy):
|
|
|
|
from gpu_extras.presets import draw_circle_2d
|
|
|
|
props = tool.operator_properties("node.select_circle")
|
|
|
|
radius = props.radius
|
|
|
|
draw_circle_2d(xy, (1.0,) * 4, radius, 32)
|
|
|
|
|
2019-03-05 23:29:49 +11:00
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.select_circle",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Select Circle",
|
2019-03-05 23:29:49 +11:00
|
|
|
icon="ops.generic.select_circle",
|
|
|
|
widget=None,
|
|
|
|
keymap="Node Tool: Select Circle",
|
|
|
|
draw_settings=draw_settings,
|
2019-05-30 21:28:04 +10:00
|
|
|
draw_cursor=draw_cursor,
|
2019-03-05 23:29:49 +11:00
|
|
|
)
|
|
|
|
|
2018-11-27 18:39:29 +11:00
|
|
|
|
2018-11-28 17:37:40 +11:00
|
|
|
class _defs_node_edit:
|
|
|
|
|
|
|
|
@ToolDef.from_fn
|
|
|
|
def links_cut():
|
|
|
|
return dict(
|
2019-03-15 14:18:21 +11:00
|
|
|
idname="builtin.links_cut",
|
2019-03-15 12:45:41 +11:00
|
|
|
label="Links Cut",
|
2019-03-11 23:22:41 +01:00
|
|
|
icon="ops.node.links_cut",
|
2018-11-28 17:37:40 +11:00
|
|
|
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
|
|
|
|
2019-12-07 03:45:50 +11:00
|
|
|
# Default group to use as a fallback.
|
|
|
|
tool_fallback_id = "builtin.select"
|
|
|
|
|
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 = (
|
2019-06-26 01:39:58 +10:00
|
|
|
_defs_image_uv_transform.translate,
|
|
|
|
_defs_image_uv_transform.rotate,
|
|
|
|
_defs_image_uv_transform.scale,
|
2018-10-04 12:04:36 +10:00
|
|
|
_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': [
|
2019-03-07 18:02:52 +11:00
|
|
|
_defs_image_generic.sample,
|
2019-03-07 14:03:59 +11:00
|
|
|
*_tools_annotate,
|
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:"
|
|
|
|
|
2019-12-07 03:45:50 +11:00
|
|
|
# Default group to use as a fallback.
|
|
|
|
tool_fallback_id = "builtin.select"
|
|
|
|
|
2018-11-27 18:39:29 +11:00
|
|
|
@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,
|
2019-03-05 23:29:49 +11:00
|
|
|
_defs_node_select.circle,
|
2018-11-27 18:39:29 +11:00
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
_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
|
|
|
|
2019-12-07 03:45:50 +11:00
|
|
|
# Default group to use as a fallback.
|
|
|
|
tool_fallback_id = "builtin.select"
|
|
|
|
|
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.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
|
|
|
),
|
2019-05-23 18:12:14 +02:00
|
|
|
_defs_transform.transform,
|
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
|
|
|
),
|
|
|
|
)
|
|
|
|
|
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,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
2018-11-30 09:06:36 +11:00
|
|
|
_tools_default = (
|
|
|
|
*_tools_select,
|
|
|
|
_defs_view3d_generic.cursor,
|
|
|
|
None,
|
|
|
|
*_tools_transform,
|
|
|
|
None,
|
|
|
|
*_tools_annotate,
|
2019-05-03 09:41:34 +02:00
|
|
|
_defs_view3d_generic.ruler,
|
2018-11-30 09:06:36 +11:00
|
|
|
)
|
|
|
|
|
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-11-30 09:06:36 +11:00
|
|
|
*_tools_default,
|
2017-10-21 16:19:48 +11:00
|
|
|
],
|
|
|
|
'POSE': [
|
2018-11-30 09:06:36 +11:00
|
|
|
*_tools_default,
|
2018-07-31 10:22:19 +02:00
|
|
|
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-11-30 09:06:36 +11:00
|
|
|
*_tools_default,
|
2018-04-29 16:36:31 +02:00
|
|
|
None,
|
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-11-30 09:06:36 +11:00
|
|
|
*_tools_default,
|
2018-07-31 10:22:19 +02:00
|
|
|
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-11-30 09:06:36 +11:00
|
|
|
*_tools_default,
|
2018-07-31 10:22:19 +02:00
|
|
|
None,
|
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
|
|
|
),
|
2019-03-07 09:58:56 +01:00
|
|
|
None,
|
|
|
|
_defs_edit_curve.curve_radius,
|
|
|
|
_defs_edit_curve.tilt,
|
|
|
|
None,
|
|
|
|
_defs_edit_curve.curve_vertex_randomize,
|
2017-10-21 16:19:48 +11:00
|
|
|
],
|
2018-11-30 09:02:11 +11:00
|
|
|
'EDIT_SURFACE': [
|
2018-11-30 09:06:36 +11:00
|
|
|
*_tools_default,
|
2018-11-30 09:02:11 +11:00
|
|
|
],
|
2018-11-20 18:52:27 +11:00
|
|
|
'EDIT_METABALL': [
|
2018-11-30 09:06:36 +11:00
|
|
|
*_tools_default,
|
2018-11-20 18:52:27 +11:00
|
|
|
],
|
2018-11-20 21:41:39 +11:00
|
|
|
'EDIT_LATTICE': [
|
2018-11-30 09:06:36 +11:00
|
|
|
*_tools_default,
|
2018-11-20 21:41:39 +11:00
|
|
|
],
|
2019-01-14 14:16:08 +11:00
|
|
|
'EDIT_TEXT': [
|
|
|
|
_defs_view3d_generic.cursor,
|
|
|
|
None,
|
|
|
|
*_tools_annotate,
|
2019-05-03 09:41:34 +02:00
|
|
|
_defs_view3d_generic.ruler,
|
2019-01-14 14:16:08 +11:00
|
|
|
],
|
2018-05-28 18:05:21 +02:00
|
|
|
'PARTICLE': [
|
2019-03-06 00:28:06 +11:00
|
|
|
*_tools_select,
|
2018-08-23 12:12:11 +10:00
|
|
|
_defs_view3d_generic.cursor,
|
2019-03-06 00:28:06 +11:00
|
|
|
None,
|
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,
|
2019-06-07 10:35:07 +02:00
|
|
|
(
|
|
|
|
_defs_sculpt.mask_border,
|
|
|
|
_defs_sculpt.mask_lasso,
|
|
|
|
),
|
2018-08-23 12:56:02 +10:00
|
|
|
_defs_sculpt.hide_border,
|
2019-05-03 09:41:34 +02:00
|
|
|
None,
|
2019-09-09 15:42:51 +02:00
|
|
|
_defs_sculpt.mesh_filter,
|
|
|
|
None,
|
2019-09-10 19:55:15 +02:00
|
|
|
_defs_transform.translate,
|
|
|
|
_defs_transform.rotate,
|
|
|
|
_defs_transform.scale,
|
|
|
|
_defs_transform.transform,
|
|
|
|
None,
|
2019-05-03 09:41:34 +02:00
|
|
|
*_tools_annotate,
|
2018-04-29 14:31:00 +02:00
|
|
|
],
|
2018-04-30 16:43:13 +02:00
|
|
|
'PAINT_TEXTURE': [
|
|
|
|
_defs_texture_paint.generate_from_brushes,
|
2019-03-11 13:45:15 +01:00
|
|
|
None,
|
|
|
|
lambda context: (
|
|
|
|
VIEW3D_PT_tools_active._tools_select
|
|
|
|
if _defs_texture_paint.poll_select_mask(context)
|
|
|
|
else ()
|
|
|
|
),
|
2019-05-03 09:41:34 +02:00
|
|
|
*_tools_annotate,
|
2018-04-30 16:43:13 +02:00
|
|
|
],
|
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 ()
|
|
|
|
),
|
2019-05-03 09:41:34 +02:00
|
|
|
*_tools_annotate,
|
2018-04-30 16:06:51 +02:00
|
|
|
],
|
|
|
|
'PAINT_WEIGHT': [
|
2018-04-30 16:59:16 +02:00
|
|
|
_defs_weight_paint.generate_from_brushes,
|
2019-03-08 15:07:18 +01:00
|
|
|
_defs_weight_paint.gradient,
|
2018-05-01 12:20:53 +02:00
|
|
|
None,
|
2019-03-08 15:07:18 +01:00
|
|
|
(
|
2019-03-20 10:44:13 +11:00
|
|
|
_defs_weight_paint.sample_weight,
|
|
|
|
_defs_weight_paint.sample_weight_group,
|
2019-03-08 15:07:18 +01:00
|
|
|
),
|
|
|
|
None,
|
2019-03-12 10:51:04 +11:00
|
|
|
lambda context: (
|
|
|
|
(_defs_view3d_generic.cursor,)
|
2019-03-31 18:43:14 +02:00
|
|
|
if context is None or context.pose_object
|
2019-03-12 10:51:04 +11:00
|
|
|
else ()
|
|
|
|
),
|
2018-05-01 12:20:53 +02:00
|
|
|
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 ()
|
|
|
|
),
|
2019-05-03 09:41:34 +02:00
|
|
|
*_tools_annotate,
|
2018-04-30 15:21:04 +02:00
|
|
|
],
|
2018-12-14 16:45:57 +01:00
|
|
|
'PAINT_GPENCIL': [
|
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,
|
2019-01-11 19:15:23 +01:00
|
|
|
_defs_gpencil_paint.cutter,
|
2018-11-09 17:05:32 +11:00
|
|
|
None,
|
2019-10-11 13:28:22 +02:00
|
|
|
_defs_gpencil_paint.eyedropper,
|
|
|
|
None,
|
2018-11-09 17:05:32 +11:00
|
|
|
_defs_gpencil_paint.line,
|
2019-10-18 22:02:45 +01:00
|
|
|
_defs_gpencil_paint.polyline,
|
2018-12-03 14:55:57 +00:00
|
|
|
_defs_gpencil_paint.arc,
|
2018-12-15 17:21:47 +01:00
|
|
|
_defs_gpencil_paint.curve,
|
2018-12-17 19:03:46 +01:00
|
|
|
_defs_gpencil_paint.box,
|
|
|
|
_defs_gpencil_paint.circle,
|
2018-07-31 10:22:19 +02:00
|
|
|
],
|
2018-12-14 16:45:57 +01:00
|
|
|
'EDIT_GPENCIL': [
|
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,
|
2019-03-04 19:31:36 +01:00
|
|
|
_defs_gpencil_edit.extrude,
|
2019-03-07 11:12:30 +01:00
|
|
|
_defs_gpencil_edit.radius,
|
2018-07-31 10:22:19 +02:00
|
|
|
_defs_gpencil_edit.bend,
|
2019-03-07 11:12:30 +01:00
|
|
|
(
|
|
|
|
_defs_gpencil_edit.shear,
|
|
|
|
_defs_gpencil_edit.tosphere,
|
|
|
|
),
|
2019-03-04 19:31:36 +01:00
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
],
|
2018-12-14 16:45:57 +01:00
|
|
|
'SCULPT_GPENCIL': [
|
2018-11-13 16:52:39 +11:00
|
|
|
_defs_gpencil_sculpt.generate_from_brushes,
|
2019-08-10 17:19:54 +02:00
|
|
|
None,
|
|
|
|
lambda context: (
|
|
|
|
VIEW3D_PT_tools_active._tools_gpencil_select
|
|
|
|
if _defs_gpencil_sculpt.poll_select_mask(context)
|
|
|
|
else ()
|
|
|
|
),
|
2018-07-31 10:22:19 +02:00
|
|
|
],
|
2018-12-14 16:45:57 +01:00
|
|
|
'WEIGHT_GPENCIL': [
|
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)
|