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.
|
|
|
|
|
|
|
|
from bpy.types import Panel
|
|
|
|
|
|
|
|
from .space_toolsystem_common import (
|
|
|
|
ToolSelectPanelHelper,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
|
|
|
|
bl_space_type = 'VIEW_3D'
|
|
|
|
bl_region_type = 'TOOLS'
|
|
|
|
bl_category = "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.
|
|
|
|
keymap_prefix = "3D View Tool: "
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tools_from_context(cls, context):
|
|
|
|
return (cls._tools[None], cls._tools.get(context.mode, ()))
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tools_all(cls):
|
2017-11-03 16:30:51 +11:00
|
|
|
return [t for t_list in cls._tools.values() for t in t_list]
|
2017-10-21 16:19:48 +11:00
|
|
|
|
|
|
|
# Internal Data
|
|
|
|
|
|
|
|
# for reuse
|
|
|
|
_tools_transform = (
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Translate",
|
|
|
|
icon="ops.transform.translate",
|
|
|
|
widget="TRANSFORM_WGT_manipulator",
|
|
|
|
keymap=(
|
|
|
|
("transform.translate", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
dict(
|
|
|
|
text="Rotate",
|
|
|
|
icon="ops.transform.rotate",
|
|
|
|
widget="TRANSFORM_WGT_manipulator",
|
|
|
|
keymap=(
|
|
|
|
("transform.rotate", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')),
|
|
|
|
),
|
|
|
|
),
|
2018-04-24 09:19:28 +02:00
|
|
|
(
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Scale",
|
|
|
|
icon="ops.transform.resize",
|
|
|
|
widget="TRANSFORM_WGT_manipulator",
|
|
|
|
keymap=(
|
|
|
|
("transform.resize", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
dict(
|
|
|
|
text="Scale Cage",
|
|
|
|
icon="ops.transform.resize.cage",
|
|
|
|
widget="VIEW3D_WGT_xform_cage",
|
|
|
|
keymap=None,
|
|
|
|
),
|
2018-04-24 09:19:28 +02:00
|
|
|
),
|
2017-11-11 02:43:04 +11:00
|
|
|
None,
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Ruler/Protractor",
|
|
|
|
icon="ops.view3d.ruler",
|
|
|
|
widget="VIEW3D_WGT_ruler",
|
|
|
|
keymap=(
|
|
|
|
("view3d.ruler_add", dict(), dict(type='EVT_TWEAK_A', value='ANY')),
|
|
|
|
),
|
|
|
|
),
|
2018-04-24 15:32:11 +02:00
|
|
|
|
|
|
|
# DEBUGGING ONLY
|
|
|
|
# ("Pixel Test", "tool_icon.pixeltest", None, (("wm.splash", dict(), dict(type='ACTIONMOUSE', value='PRESS')),)),
|
2017-10-21 16:19:48 +11:00
|
|
|
)
|
|
|
|
|
|
|
|
_tools = {
|
|
|
|
None: [
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Cursor",
|
|
|
|
icon="ops.generic.cursor",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("view3d.cursor3d", dict(), dict(type='ACTIONMOUSE', value='CLICK')),
|
|
|
|
),
|
|
|
|
),
|
2017-11-02 23:05:13 +11:00
|
|
|
|
|
|
|
# 'Select' Group
|
|
|
|
(
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Select Border",
|
|
|
|
icon="ops.generic.select_border",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("view3d.select_border",
|
|
|
|
dict(deselect=False),
|
|
|
|
dict(type='EVT_TWEAK_A', value='ANY')),
|
|
|
|
("view3d.select_border",
|
|
|
|
dict(deselect=True),
|
|
|
|
dict(type='EVT_TWEAK_A', value='ANY', ctrl=True)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
dict(
|
|
|
|
text="Select Circle",
|
|
|
|
icon="ops.generic.select_circle",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("view3d.select_circle",
|
|
|
|
dict(deselect=False),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
("view3d.select_circle",
|
|
|
|
dict(deselect=True),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS', ctrl=True)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
dict(
|
|
|
|
text="Select Lasso",
|
|
|
|
icon="ops.generic.select_lasso",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("view3d.select_lasso",
|
|
|
|
dict(deselect=False),
|
|
|
|
dict(type='EVT_TWEAK_A', value='ANY')),
|
|
|
|
("view3d.select_lasso",
|
|
|
|
dict(deselect=True),
|
|
|
|
dict(type='EVT_TWEAK_A', value='ANY', ctrl=True)),
|
|
|
|
),
|
|
|
|
),
|
2017-11-02 23:05:13 +11:00
|
|
|
),
|
|
|
|
# End group.
|
2017-10-21 16:19:48 +11:00
|
|
|
],
|
|
|
|
'OBJECT': [
|
|
|
|
*_tools_transform,
|
|
|
|
],
|
|
|
|
'POSE': [
|
|
|
|
*_tools_transform,
|
|
|
|
],
|
2018-04-24 16:54:38 +02:00
|
|
|
'PAINT_WEIGHT': [
|
|
|
|
# TODO, override brush events
|
|
|
|
(
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Linear Gradient",
|
|
|
|
icon=None,
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("paint.weight_gradient", dict(type='LINEAR'),
|
|
|
|
dict(type='EVT_TWEAK_A', value='ANY')),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
dict(
|
|
|
|
text="Radial Gradient",
|
|
|
|
icon=None,
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("paint.weight_gradient",
|
|
|
|
dict(type='RADIAL'),
|
|
|
|
dict(type='EVT_TWEAK_A', value='ANY')),
|
|
|
|
),
|
|
|
|
),
|
2018-04-24 16:54:38 +02:00
|
|
|
),
|
|
|
|
],
|
2017-10-21 16:19:48 +11:00
|
|
|
'EDIT_ARMATURE': [
|
|
|
|
*_tools_transform,
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Roll",
|
|
|
|
icon=None,
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("transform.transform",
|
|
|
|
dict(release_confirm=True, mode='BONE_ROLL'),
|
|
|
|
dict(type='EVT_TWEAK_A', value='ANY'),),
|
|
|
|
),
|
|
|
|
),
|
2017-10-21 16:19:48 +11:00
|
|
|
None,
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Extrude Cursor",
|
|
|
|
icon="ops.armature.extrude",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("armature.click_extrude", dict(), dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
),
|
|
|
|
),
|
2017-10-21 16:19:48 +11:00
|
|
|
],
|
|
|
|
'EDIT_MESH': [
|
|
|
|
*_tools_transform,
|
|
|
|
None,
|
2018-04-24 15:32:11 +02:00
|
|
|
(
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Rip Region",
|
|
|
|
icon="ops.mesh.rip",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("mesh.rip_move", dict(),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
dict(
|
|
|
|
text="Rip Edge",
|
|
|
|
icon="ops.mesh.rip_edge",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("mesh.rip_edge_edge_move", dict(),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
),
|
|
|
|
),
|
2018-04-24 15:32:11 +02:00
|
|
|
),
|
2017-10-25 15:42:08 +11:00
|
|
|
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Poly Build",
|
|
|
|
icon="ops.mesh.polybuild_hover",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("mesh.polybuild_face_at_cursor_move",
|
|
|
|
dict(TRANSFORM_OT_translate=dict(release_confirm=True)),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
("mesh.polybuild_split_at_cursor_move",
|
|
|
|
dict(TRANSFORM_OT_translate=dict(release_confirm=True)),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS', ctrl=True)),
|
|
|
|
("mesh.polybuild_dissolve_at_cursor", dict(), dict(type='ACTIONMOUSE', value='CLICK', alt=True)),
|
|
|
|
("mesh.polybuild_hover", dict(use_boundary=False), dict(type='MOUSEMOVE', value='ANY', alt=True)),
|
|
|
|
("mesh.polybuild_hover", dict(use_boundary=True), dict(type='MOUSEMOVE', value='ANY', any=True)),
|
|
|
|
),
|
|
|
|
),
|
2017-10-25 15:42:08 +11:00
|
|
|
|
2018-04-24 15:32:11 +02:00
|
|
|
|
|
|
|
# 'Slide' Group
|
|
|
|
(
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Edge Slide",
|
|
|
|
icon="ops.transform.edge_slide",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("transform.edge_slide", dict(release_confirm=True),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
dict(
|
|
|
|
text="Vertex Slide",
|
|
|
|
icon="ops.transform.edge_slide",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("transform.vert_slide", dict(release_confirm=True),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
),
|
|
|
|
),
|
2018-04-24 15:32:11 +02:00
|
|
|
),
|
|
|
|
# End group.
|
|
|
|
|
|
|
|
(
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Spin",
|
|
|
|
icon="ops.mesh.spin",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
2018-04-24 15:32:11 +02:00
|
|
|
("mesh.spin", dict(),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS')),
|
2018-04-26 07:31:39 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
dict(
|
|
|
|
text="Spin (Duplicate)",
|
|
|
|
icon="ops.mesh.spin.duplicate",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("mesh.spin", dict(dupli=True),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
),
|
|
|
|
),
|
2018-04-24 15:32:11 +02:00
|
|
|
),
|
|
|
|
|
|
|
|
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Inset Faces",
|
|
|
|
icon="ops.mesh.inset",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("mesh.inset", dict(),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
),
|
|
|
|
),
|
2018-04-24 15:32:11 +02:00
|
|
|
|
|
|
|
(
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Extrude Region",
|
|
|
|
icon="ops.view3d.edit_mesh_extrude",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("view3d.edit_mesh_extrude", dict(),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
dict(
|
|
|
|
text="Extrude Individual",
|
|
|
|
icon="ops.view3d.edit_mesh_extrude_individual",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("mesh.extrude_faces_move", dict(),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
),
|
|
|
|
),
|
2018-04-24 15:32:11 +02:00
|
|
|
),
|
|
|
|
|
|
|
|
(
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Randomize",
|
|
|
|
icon="ops.transform.vertex_random",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("transform.vertex_random", dict(),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
dict(
|
|
|
|
text="Smooth",
|
|
|
|
icon="ops.mesh.vertices_smooth",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("mesh.vertices_smooth", dict(),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
),
|
|
|
|
),
|
2018-04-24 15:32:11 +02:00
|
|
|
),
|
|
|
|
|
|
|
|
(
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Shrink/Fatten",
|
|
|
|
icon="ops.transform.shrink_fatten",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("transform.shrink_fatten", dict(release_confirm=True),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
dict(
|
|
|
|
text="Push/Pull",
|
|
|
|
icon="ops.transform.push_pull",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("transform.push_pull", dict(release_confirm=True),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
),
|
|
|
|
),
|
2018-04-24 15:32:11 +02:00
|
|
|
),
|
|
|
|
|
2017-11-02 23:05:13 +11:00
|
|
|
# Knife Group
|
|
|
|
(
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Knife",
|
|
|
|
icon="ops.mesh.knife_tool",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("mesh.knife_tool",
|
|
|
|
dict(wait_for_input=False, use_occlude_geometry=True, only_selected=False),
|
|
|
|
dict(type='ACTIONMOUSE', value='PRESS')),),
|
|
|
|
),
|
2017-11-03 16:30:51 +11:00
|
|
|
None,
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Bisect",
|
|
|
|
icon="ops.mesh.bisect",
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("mesh.bisect",
|
|
|
|
dict(),
|
|
|
|
dict(type='EVT_TWEAK_A', value='ANY')),),
|
|
|
|
),
|
2017-11-02 23:05:13 +11:00
|
|
|
),
|
|
|
|
# End group.
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Extrude Cursor",
|
|
|
|
icon=None,
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("mesh.dupli_extrude_cursor", dict(), dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
),
|
|
|
|
),
|
2017-10-21 16:19:48 +11:00
|
|
|
],
|
|
|
|
'EDIT_CURVE': [
|
|
|
|
*_tools_transform,
|
|
|
|
None,
|
2018-04-26 07:31:39 +02:00
|
|
|
dict(
|
|
|
|
text="Draw",
|
|
|
|
icon=None,
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("curve.draw", dict(wait_for_input=False), dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
dict(
|
|
|
|
text="Extrude Cursor",
|
|
|
|
icon=None,
|
|
|
|
widget=None,
|
|
|
|
keymap=(
|
|
|
|
("curve.vertex_add", dict(), dict(type='ACTIONMOUSE', value='PRESS')),
|
|
|
|
),
|
|
|
|
),
|
2017-10-21 16:19:48 +11:00
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
classes = (
|
|
|
|
VIEW3D_PT_tools_active,
|
|
|
|
)
|
|
|
|
|
|
|
|
if __name__ == "__main__": # only for live edit.
|
|
|
|
from bpy.utils import register_class
|
|
|
|
for cls in classes:
|
|
|
|
register_class(cls)
|