[Bf-blender-cvs] [12603826eac] blender2.8: UI: Transform Orientations panel as popover

Vuk Gardašević noreply at git.blender.org
Mon Jul 2 18:44:07 CEST 2018


Commit: 12603826eac9bd7399e065987d3c583e2734b0a7
Author: Vuk Gardašević
Date:   Mon Jul 2 18:43:30 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB12603826eac9bd7399e065987d3c583e2734b0a7

UI: Transform Orientations panel as popover

Functionality fits in the Transform Orientations, no need for a dedicated
panel in the viewport sidebar.

See D3511

===================================================================

M	release/scripts/startup/bl_ui/space_topbar.py
M	release/scripts/startup/bl_ui/space_view3d.py

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 84fb386efd5..52d180c36b0 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -270,6 +270,34 @@ class TOPBAR_PT_snapping(Panel):
                 col.prop(toolsettings, "use_snap_peel_object")
 
 
+class TOPBAR_PT_transform_orientations(Panel):
+    bl_space_type = 'TOPBAR'
+    bl_region_type = 'HEADER'
+    bl_label = "Transform Orientations"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        view = context.space_data
+        return (view)
+
+    def draw(self, context):
+        layout = self.layout
+        layout.label("Tranform Orientations")
+
+        scene = context.scene
+        orientation = scene.current_orientation
+
+        col = layout.split(percentage=0.9)
+        col.prop(scene, "transform_orientation", expand=True)
+        col.operator("transform.create_orientation", text="", icon='ZOOMIN', emboss=False)
+
+        if orientation:
+            row = layout.row(align=False)
+            row.prop(orientation, "name", text="")
+            row.operator("transform.delete_orientation", text="", icon='X', emboss=False)
+
+
 class INFO_MT_editor_menus(Menu):
     bl_idname = "INFO_MT_editor_menus"
     bl_label = ""
@@ -629,6 +657,7 @@ classes = (
     TOPBAR_HT_lower_bar,
     TOPBAR_PT_pivot_point,
     TOPBAR_PT_snapping,
+    TOPBAR_PT_transform_orientations,
     TOPBAR_MT_file_specials,
     TOPBAR_MT_window_specials,
     INFO_MT_editor_menus,
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 432e5703805..e5e903f5338 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -119,7 +119,26 @@ class VIEW3D_HT_header(Header):
 
         # Orientation
         if object_mode in {'OBJECT', 'EDIT', 'POSE'}:
-            layout.prop(scene, "transform_orientation", text="")
+            orientation = scene.transform_orientation
+            current_orientation = scene.current_orientation
+
+            if not current_orientation:
+                trans_orientation = \
+                    bpy.types.Scene.bl_rna.properties["transform_orientation"].enum_items[orientation]
+                trans_icon = getattr(trans_orientation, "icon", "BLANK1")
+                trans_name = getattr(trans_orientation, "name", "Orientation")
+            else:
+                trans_icon = "VISIBLE_IPO_OFF"
+                trans_name = getattr(current_orientation, "name", "Orientation")
+
+            row = layout.row(align=True)
+            row.popover(
+                space_type='TOPBAR',
+                region_type='HEADER',
+                panel_type="TOPBAR_PT_transform_orientations",
+                text=trans_name,
+                icon=trans_icon,
+            )
 
         # Snap
         show_snap = False
@@ -191,7 +210,7 @@ class VIEW3D_HT_header(Header):
                 sub.active = tool_settings.proportional_edit != 'DISABLED'
                 sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True)
 
-        # Orientation & Pivot
+        # Pivot
         if object_mode in {'OBJECT', 'EDIT', 'POSE'}:
             pivot_point = tool_settings.transform_pivot_point
             act_pivot_point = bpy.types.ToolSettings.bl_rna.properties["transform_pivot_point"].enum_items[pivot_point]
@@ -4124,33 +4143,6 @@ class VIEW3D_PT_view3d_stereo(Panel):
         split.prop(view, "stereo_3d_volume_alpha", text="Alpha")
 
 
-class VIEW3D_PT_transform_orientations(Panel):
-    bl_space_type = 'VIEW_3D'
-    bl_region_type = 'UI'
-    bl_label = "Transform Orientations"
-    bl_options = {'DEFAULT_CLOSED'}
-
-    @classmethod
-    def poll(cls, context):
-        view = context.space_data
-        return (view)
-
-    def draw(self, context):
-        layout = self.layout
-
-        scene = context.scene
-        orientation = scene.current_orientation
-
-        row = layout.row(align=True)
-        row.prop(scene, "transform_orientation", text="")
-        row.operator("transform.create_orientation", text="", icon='ZOOMIN')
-
-        if orientation:
-            row = layout.row(align=True)
-            row.prop(orientation, "name", text="")
-            row.operator("transform.delete_orientation", text="", icon='X')
-
-
 class VIEW3D_PT_context_properties(Panel):
     bl_space_type = 'VIEW_3D'
     bl_region_type = 'UI'
@@ -4338,7 +4330,6 @@ classes = (
     VIEW3D_PT_overlay_pose,
     VIEW3D_PT_overlay_paint,
     VIEW3D_PT_overlay_sculpt,
-    VIEW3D_PT_transform_orientations,
     VIEW3D_PT_context_properties,
 )



More information about the Bf-blender-cvs mailing list