Popover for Pivot Point in top bar
authorPablo Vazquez <venomgfx@gmail.com>
Wed, 16 May 2018 10:03:22 +0000 (12:03 +0200)
committerPablo Vazquez <venomgfx@gmail.com>
Wed, 16 May 2018 10:03:53 +0000 (12:03 +0200)
From T55038

release/scripts/startup/bl_ui/space_topbar.py

index 719396ccdd1fe42278151d22e538289e08531e24..ad3ff075a5227006eb70957fe5c2c6299e8a08b1 100644 (file)
@@ -197,11 +197,18 @@ class TOPBAR_HT_lower_bar(Header):
 
         object_mode = 'OBJECT' if obj is None else obj.mode
 
-        # Pivit & Orientation
+        # Pivot & Orientation
+        pivot_point = context.tool_settings.transform_pivot_point
+        act_pivot_point = bpy.types.ToolSettings.bl_rna.properties['transform_pivot_point'].enum_items[pivot_point]
+
         row = layout.row(align=True)
-        row.prop(toolsettings, "transform_pivot_point", text="", icon_only=True)
-        if (obj is None) or (mode in {'OBJECT', 'POSE', 'WEIGHT_PAINT'}):
-            row.prop(toolsettings, "use_transform_pivot_point_align", text="")
+        row.popover(
+            space_type='TOPBAR',
+            region_type='HEADER',
+            panel_type="TOPBAR_PT_pivot_point",
+            icon=act_pivot_point.icon,
+            text=""
+        )
 
         layout.prop(scene, "transform_orientation", text="")
 
@@ -331,6 +338,30 @@ class _draw_left_context_mode:
         UnifiedPaintPanel.prop_unified_strength(layout, context, brush, "strength", slider=True, text="Strength")
 
 
+class TOPBAR_PT_pivot_point(Panel):
+    bl_space_type = 'TOPBAR'
+    bl_region_type = 'HEADER'
+    bl_label = "Pivot Point"
+
+    def draw(self, context):
+        toolsettings = context.tool_settings
+        obj = context.active_object
+        mode = context.mode
+
+        layout = self.layout
+        col = layout.column()
+        col.label(text="Pivot Point")
+        col.prop(toolsettings, "transform_pivot_point", expand=True)
+
+        layout.separator()
+
+        if (obj is None) or (mode in {'OBJECT', 'POSE', 'WEIGHT_PAINT'}):
+            layout.prop(
+                    toolsettings,
+                    "use_transform_pivot_point_align",
+                    text="Center Points Only")
+
+
 class INFO_MT_editor_menus(Menu):
     bl_idname = "INFO_MT_editor_menus"
     bl_label = ""
@@ -597,6 +628,7 @@ class INFO_MT_help(Menu):
 classes = (
     TOPBAR_HT_upper_bar,
     TOPBAR_HT_lower_bar,
+    TOPBAR_PT_pivot_point,
     INFO_MT_editor_menus,
     INFO_MT_file,
     INFO_MT_file_import,