[Bf-blender-cvs] [a63e5d20583] blender2.8: UI: use display popover for image space

Campbell Barton noreply at git.blender.org
Wed Aug 22 01:19:03 CEST 2018


Commit: a63e5d20583bdd34254bfe289bbed94d8694371c
Author: Campbell Barton
Date:   Wed Aug 22 09:15:05 2018 +1000
Branches: blender2.8
https://developer.blender.org/rBa63e5d20583bdd34254bfe289bbed94d8694371c

UI: use display popover for image space

Also menu corrections and move scopes to sidebar.

D3625 by @lijenstina w/ minor edits

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

M	release/scripts/startup/bl_ui/space_image.py

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

diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index 7a1d4117451..06615ebb2c3 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -17,9 +17,15 @@
 # ##### END GPL LICENSE BLOCK #####
 
 # <pep8 compliant>
+
 import bpy
 import math
-from bpy.types import Header, Menu, Panel, UIList
+from bpy.types import (
+    Header,
+    Menu,
+    Panel,
+    UIList,
+)
 from .properties_paint_common import (
     UnifiedPaintPanel,
     brush_texture_settings,
@@ -85,6 +91,7 @@ class IMAGE_MT_view(Menu):
 
         layout.prop(uv, "show_other_objects")
         layout.prop(uv, "show_metadata")
+
         if paint.brush and (context.image_paint_object or sima.mode == 'PAINT'):
             layout.prop(uv, "show_texpaint")
             layout.prop(toolsettings, "show_uv_local_view", text="Show Same Material")
@@ -96,14 +103,7 @@ class IMAGE_MT_view(Menu):
 
         layout.separator()
 
-        ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
-
-        for a, b in ratios:
-            layout.operator(
-                "image.view_zoom_ratio",
-                text=iface_(f"Zoom {a:d}:{b:d}"),
-                translate=False,
-            ).ratio = a / b
+        layout.menu("IMAGE_MT_view_zoom")
 
         layout.separator()
 
@@ -128,6 +128,25 @@ class IMAGE_MT_view(Menu):
         layout.menu("INFO_MT_area")
 
 
+class IMAGE_MT_view_zoom(Menu):
+    bl_label = "Fractional Zoom"
+
+    def draw(self, context):
+        layout = self.layout
+
+        ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
+
+        for i, (a, b) in enumerate(ratios):
+            if i in {3, 4}:  # Draw separators around Zoom 1:1.
+                layout.separator()
+
+            layout.operator(
+                "image.view_zoom_ratio",
+                text=iface_(f"Zoom {a:d}:{b:d}"),
+                translate=False,
+            ).ratio = a / b
+
+
 class IMAGE_MT_select(Menu):
     bl_label = "Select"
 
@@ -174,7 +193,7 @@ class IMAGE_MT_brush(Menu):
         layout.prop(ups, "use_unified_color", text="Unified Color")
         layout.separator()
 
-        # brush tool
+        # Brush tool.
         layout.prop_menu_enum(brush, "image_tool")
 
 
@@ -194,6 +213,8 @@ class IMAGE_MT_image(Menu):
         layout.operator("image.read_viewlayers")
 
         if ima:
+            layout.separator()
+
             if not show_render:
                 layout.operator("image.replace", text="Replace...")
                 layout.operator("image.reload", text="Reload")
@@ -222,8 +243,8 @@ class IMAGE_MT_image(Menu):
                     layout.separator()
                     layout.operator("image.pack", text="Pack")
 
-                # only for dirty && specific image types, perhaps
-                # this could be done in operator poll too
+                # Only for dirty && specific image types, perhaps
+                # this could be done in operator poll too.
                 if ima.is_dirty:
                     if ima.source in {'FILE', 'GENERATED'} and ima.type != 'OPEN_EXR_MULTILAYER':
                         if ima.packed_file:
@@ -315,6 +336,10 @@ class IMAGE_MT_uvs_mirror(Menu):
     def draw(self, context):
         layout = self.layout
 
+        layout.operator("mesh.faces_mirror_uv")
+
+        layout.separator()
+
         layout.operator_context = 'EXEC_REGION_WIN'
 
         layout.operator("transform.mirror", text="X Axis").constraint_axis[0] = True
@@ -327,9 +352,9 @@ class IMAGE_MT_uvs_weldalign(Menu):
     def draw(self, context):
         layout = self.layout
 
-        layout.operator("uv.weld")  # W, 1
+        layout.operator("uv.weld")  # W, 1.
         layout.operator("uv.remove_doubles")
-        layout.operator_enum("uv.align", "axis")  # W, 2/3/4
+        layout.operator_enum("uv.align", "axis")  # W, 2/3/4.
 
 
 class IMAGE_MT_uvs(Menu):
@@ -362,10 +387,12 @@ class IMAGE_MT_uvs(Menu):
         layout.operator("uv.average_islands_scale")
         layout.operator("uv.minimize_stretch")
         layout.operator("uv.stitch")
+
+        layout.separator()
+
         layout.operator("uv.mark_seam").clear = False
         layout.operator("uv.mark_seam", text="Clear Seam").clear = True
         layout.operator("uv.seams_from_islands")
-        layout.operator("mesh.faces_mirror_uv")
 
         layout.separator()
 
@@ -392,7 +419,7 @@ class IMAGE_MT_uvs_select_mode(Menu):
         layout.operator_context = 'INVOKE_REGION_WIN'
         toolsettings = context.tool_settings
 
-        # do smart things depending on whether uv_select_sync is on
+        # Do smart things depending on whether uv_select_sync is on.
 
         if toolsettings.use_uv_select_sync:
             props = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
@@ -450,7 +477,7 @@ class IMAGE_MT_specials(Menu):
 
             layout.separator()
 
-            layout.operator_enum("uv.align", "axis")  # W, 2/3/4
+            layout.operator_enum("uv.align", "axis")  # W, 2/3/4.
 
             layout.separator()
 
@@ -483,7 +510,7 @@ class IMAGE_HT_header(Header):
 
         layout.prop(sima, "mode", text="")
 
-        # uv editing
+        # UV editing.
         if show_uvedit:
             uvedit = sima.uv_editor
 
@@ -519,7 +546,7 @@ class IMAGE_HT_header(Header):
             mesh = context.edit_object.data
             layout.prop_search(mesh.uv_layers, "active", mesh, "uv_layers", text="")
 
-            # Snap
+            # Snap.
             row = layout.row(align=True)
             row.prop(toolsettings, "use_snap", text="")
             row.prop(toolsettings, "snap_uv_element", icon_only=True)
@@ -535,17 +562,23 @@ class IMAGE_HT_header(Header):
 
         layout.prop(sima, "pivot_point", icon_only=True)
 
+        row = layout.row()
+        row.popover(
+            panel="IMAGE_PT_view_display",
+            text="Display"
+        )
+
         if ima:
             if ima.is_stereo_3d:
                 row = layout.row()
                 row.prop(sima, "show_stereo_3d", text="")
 
-            # layers
+            # layers.
             layout.template_image_layers(ima, iuser)
 
-            # draw options
-            row = layout.row(align=True)
-            row.prop(sima, "draw_channels", text="", expand=True)
+            # draw options.
+            row = layout.row()
+            row.prop(sima, "draw_channels", icon_only=True)
 
             row = layout.row(align=True)
             if ima.type == 'COMPOSITE':
@@ -592,7 +625,7 @@ class MASK_MT_editor_menus(Menu):
 
 # -----------------------------------------------------------------------------
 # Mask (similar code in space_clip.py, keep in sync)
-# note! - panel placement does _not_ fit well with image panels... need to fix
+# note! - panel placement does _not_ fit well with image panels... need to fix.
 
 from .properties_mask_common import (
     MASK_PT_mask,
@@ -664,9 +697,9 @@ class IMAGE_PT_image_properties(Panel):
         layout.template_image(sima, "image", iuser, multiview=True)
 
 
-class IMAGE_PT_view_properties(Panel):
+class IMAGE_PT_view_display(Panel):
     bl_space_type = 'IMAGE_EDITOR'
-    bl_region_type = 'UI'
+    bl_region_type = 'HEADER'
     bl_label = "Display"
 
     @classmethod
@@ -676,60 +709,94 @@ class IMAGE_PT_view_properties(Panel):
 
     def draw(self, context):
         layout = self.layout
+        layout.use_property_split = True
 
         sima = context.space_data
         ima = sima.image
 
-        show_render = sima.show_render
         show_uvedit = sima.show_uvedit
         show_maskedit = sima.show_maskedit
         uvedit = sima.uv_editor
 
-        split = layout.split()
+        col = layout.column()
 
-        col = split.column()
         if ima:
             col.prop(ima, "display_aspect", text="Aspect Ratio")
-
-            col = split.column()
-            col.label(text="Coordinates:")
-            col.prop(sima, "show_repeat", text="Repeat")
-            if show_uvedit:
-                col.prop(uvedit, "show_pixel_coords", text="Pixel")
-
-        elif show_uvedit:
-            col.label(text="Coordinates:")
-            col.prop(uvedit, "show_pixel_coords", text="Pixel")
+            col.prop(sima, "show_repeat", text="Repeat Image")
 
         if show_uvedit or show_maskedit:
+            col.separator()
+
             col = layout.column()
-            col.label("Cursor Location:")
-            col.row().prop(sima, "cursor_location", text="")
+            col.prop(sima, "cursor_location", text="Cursor Location")
 
         if show_uvedit:
-            col.separator()
+            col.prop(uvedit, "show_pixel_coords", text="Pixel Coordinates")
 
-            col.label(text="UVs:")
-            col.row().prop(uvedit, "edge_draw_type", expand=True)
 
-            split = layout.split()
+class IMAGE_PT_view_display_uv_edit_overlays(Panel):
+    bl_space_type = 'IMAGE_EDITOR'
+    bl_region_type = 'HEADER'
+    bl_label = "Overlays"
+    bl_parent_id = 'IMAGE_PT_view_display'
+    bl_options = {'DEFAULT_CLOSED'}
 
-            col = split.column()
-            col.prop(uvedit, "show_faces")
-            col.prop(uvedit, "show_smooth_edges", text="Smooth")
-            col.prop(uvedit, "show_modified_edges", text="Modified")
+    @classmethod
+    def poll(cls, context):
+        sima = context.space_data
+        return (sima and (sima.show_uvedit))
 
-            col = split.column()
-            col.prop(uvedit, "show_stretch", text="Stretch")
-            sub = col.column()
-            sub.active = uvedit.show_stretch
-            sub.row().prop(uvedit, "draw_stretch_type", expand=True)
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
 
-            col = layout.column()
-            col.prop(uvedit, "show_other_objects")
-            row = col.row()
-            row.active = uvedit.show_other_objects
-            row.prop(uvedit, "other_uv_filter", text="Filter")
+        sima = context.space_data
+        uvedit = sima.uv_editor
+
+        col = layout.column()
+
+        col.prop(uvedit, "edge_draw_type", text="Edges")
+        col.p

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list