[Bf-extensions-cvs] [c22bc472] master: space_view3d_pie_menus: use gizmos for pie menu switching
Campbell Barton
noreply at git.blender.org
Fri Apr 26 10:13:12 CEST 2019
Commit: c22bc472b870c8f5a486a674275a5026f7a9a32b
Author: Campbell Barton
Date: Fri Apr 26 18:11:51 2019 +1000
Branches: master
https://developer.blender.org/rBAc22bc472b870c8f5a486a674275a5026f7a9a32b
space_view3d_pie_menus: use gizmos for pie menu switching
Animators in the studio prefer this over tools.
===================================================================
M space_view3d_pie_menus/pie_manipulator_menu.py
===================================================================
diff --git a/space_view3d_pie_menus/pie_manipulator_menu.py b/space_view3d_pie_menus/pie_manipulator_menu.py
index d06e4bf7..2c0af6a5 100644
--- a/space_view3d_pie_menus/pie_manipulator_menu.py
+++ b/space_view3d_pie_menus/pie_manipulator_menu.py
@@ -32,21 +32,56 @@ bl_info = {
import bpy
from bpy.types import (
- Menu,
- Operator,
- )
+ Menu,
+ Operator,
+)
+from bpy.props import (
+ BoolProperty,
+ EnumProperty,
+)
class WManupulators(Operator):
- bl_idname = "w.manupulators"
+ bl_idname = "w.manipulators"
bl_label = "W Manupulators"
bl_options = {'REGISTER', 'UNDO'}
bl_description = " Show/Hide Manipulator"
+ extend: BoolProperty(
+ default=False,
+ )
+ type: EnumProperty(
+ items=(
+ ('TRANSLATE', "Move", ""),
+ ('ROTATE', "Rotate", ""),
+ ('SCALE', "Scale", ""),
+ )
+ )
+
def execute(self, context):
- context.space_data.show_gizmo_tool = not context.space_data.show_gizmo_tool
+ space_data = context.space_data
+ space_data.show_gizmo_context = True
+
+ attrs = (
+ "show_gizmo_object_translate",
+ "show_gizmo_object_rotate",
+ "show_gizmo_object_scale",
+ )
+ attr_t, attr_r, attr_s = attrs
+ attr_index = ('TRANSLATE', 'ROTATE', 'SCALE').index(self.type)
+ attr_active = attrs[attr_index]
+
+ if self.extend:
+ setattr(space_data, attr_active, not getattr(space_data, attr_active))
+ else:
+ for attr in attrs:
+ setattr(space_data, attr, attr == attr_active)
return {'FINISHED'}
+ def invoke(self, context, event):
+ self.extend = event.shift
+ return self.execute(context)
+
# Pie Manipulators - Ctrl + Space
class PieManipulator(Menu):
@@ -57,13 +92,14 @@ class PieManipulator(Menu):
layout = self.layout
pie = layout.menu_pie()
# 4 - LEFT
- pie.operator("wm.tool_set_by_id", text="Translate", icon='NONE').name = "builtin.move"
+ pie.operator("w.manipulators", text="Translate", icon='NONE').type = 'TRANSLATE'
# 6 - RIGHT
- pie.operator("wm.tool_set_by_id", text="Rotate", icon='NONE').name = "builtin.rotate"
+ pie.operator("w.manipulators", text="Rotate", icon='NONE').type = 'ROTATE'
# 2 - BOTTOM
- pie.operator("wm.tool_set_by_id", text="Scale", icon='NONE').name = "builtin.scale"
+ pie.operator("w.manipulators", text="Scale", icon='NONE').type = 'SCALE'
# 8 - TOP
- pie.operator("w.manupulators", text="Show/Hide Toggle", icon='NONE')
+ props = pie.operator("wm.context_toggle", text="Show/Hide Toggle", icon='NONE')
+ props.data_path = "space_data.show_gizmo_context"
classes = (
More information about the Bf-extensions-cvs
mailing list