add mask buttons into the image space
authorCampbell Barton <ideasman42@gmail.com>
Wed, 25 Jul 2012 13:44:07 +0000 (13:44 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 25 Jul 2012 13:44:07 +0000 (13:44 +0000)
release/scripts/startup/bl_ui/properties_mask_common.py
release/scripts/startup/bl_ui/space_clip.py
release/scripts/startup/bl_ui/space_image.py

index bc82f3f1e2bd86972cef79b4975d17b4205991e6..a4a81b01980111d366ca22e839ada9b97cb0ec61 100644 (file)
@@ -25,13 +25,18 @@ import bpy
 from bpy.types import Menu
 
 
-class MASK_PT_mask():
+class MASK_PT_mask:
     # subclasses must define...
     #~ bl_space_type = 'CLIP_EDITOR'
     #~ bl_region_type = 'UI'
     bl_label = "Mask Settings"
     bl_options = {'DEFAULT_CLOSED'}
 
+    @classmethod
+    def poll(cls, context):
+        space_data = context.space_data
+        return space_data.mask and space_data.mode == 'MASK'
+
     def draw(self, context):
         layout = self.layout
 
@@ -43,7 +48,7 @@ class MASK_PT_mask():
         col.prop(mask, "frame_end")
 
 
-class MASK_PT_layers():
+class MASK_PT_layers:
     # subclasses must define...
     #~ bl_space_type = 'CLIP_EDITOR'
     #~ bl_region_type = 'UI'
@@ -51,9 +56,8 @@ class MASK_PT_layers():
 
     @classmethod
     def poll(cls, context):
-        sc = context.space_data
-
-        return sc.mask and sc.mode == 'MASKEDIT'
+        space_data = context.space_data
+        return space_data.mask and space_data.mode == 'MASK'
 
     def draw(self, context):
         layout = self.layout
@@ -104,7 +108,7 @@ class MASK_PT_spline():
         sc = context.space_data
         mask = sc.mask
 
-        if mask and sc.mode == 'MASKEDIT':
+        if mask and sc.mode == 'MASK':
             return mask.layers.active and mask.layers.active.splines.active
 
         return False
@@ -134,7 +138,7 @@ class MASK_PT_point():
         sc = context.space_data
         mask = sc.mask
 
-        if mask and sc.mode == 'MASKEDIT':
+        if mask and sc.mode == 'MASK':
             mask_layer_active = mask.layers.active
             return (mask_layer_active and
                     mask_layer_active.splines.active_point)
@@ -183,13 +187,18 @@ class MASK_PT_display():
     bl_label = "Mask Display"
     bl_options = {'DEFAULT_CLOSED'}
 
+    @classmethod
+    def poll(cls, context):
+        space_data = context.space_data
+        return space_data.mask and space_data.mode == 'MASK'
+
     def draw(self, context):
         layout = self.layout
 
-        sc = context.space_data
+        space_data = context.space_data
 
-        col.prop(layout, "mask_draw_type", text="")
-        col.prop(layout, "show_mask_smooth")
+        layout.prop(space_data, "mask_draw_type", text="")
+        layout.prop(space_data, "show_mask_smooth")
 
 
 class MASK_PT_tools():
@@ -198,6 +207,11 @@ class MASK_PT_tools():
     #~ bl_region_type = 'TOOLS'
     bl_label = "Mask Tools"
 
+    @classmethod
+    def poll(cls, context):
+        space_data = context.space_data
+        return space_data.mask and space_data.mode == 'MASK'
+
     def draw(self, context):
         layout = self.layout
 
index 4cf75f72dd0248d00b2e63683968cba190aa4b3d..1c86e93a067c3d115bb601b4b92e6dd9c95b65f8 100644 (file)
 
 import bpy
 from bpy.types import Panel, Header, Menu
-from bl_ui.properties_mask_common import (MASK_PT_mask,
-                                          MASK_PT_layers,
-                                          MASK_PT_spline,
-                                          MASK_PT_point,
-                                          MASK_PT_display,
-                                          MASK_PT_tools)
+
 
 class CLIP_HT_header(Header):
     bl_space_type = 'CLIP_EDITOR'
@@ -166,16 +161,6 @@ class CLIP_PT_clip_view_panel:
         return clip and sc.view == 'CLIP'
 
 
-class CLIP_PT_mask_view_panel:
-
-    @classmethod
-    def poll(cls, context):
-        sc = context.space_data
-        clip = sc.clip
-
-        return clip and sc.view == 'CLIP' and sc.mode == 'MASKEDIT'
-
-
 class CLIP_PT_tracking_panel:
 
     @classmethod
@@ -427,11 +412,6 @@ class CLIP_PT_tools_object(CLIP_PT_reconstruction_panel, Panel):
         col.prop(settings, "object_distance")
 
 
-class CLIP_PT_tools_mask(MASK_PT_tools, CLIP_PT_mask_view_panel, Panel):
-    bl_space_type = 'CLIP_EDITOR'
-    bl_region_type = 'TOOLS'
-
-
 class CLIP_PT_tools_grease_pencil(Panel):
     bl_space_type = 'CLIP_EDITOR'
     bl_region_type = 'TOOLS'
@@ -447,7 +427,7 @@ class CLIP_PT_tools_grease_pencil(Panel):
 
         if sc.mode == 'DISTORTION':
             return sc.view == 'CLIP'
-        elif sc.mode == 'MASKEDIT':
+        elif sc.mode == 'MASK':
             return True
 
         return False
@@ -643,21 +623,6 @@ class CLIP_PT_tracking_camera(Panel):
         col.prop(clip.tracking.camera, "k3")
 
 
-class CLIP_PT_mask_layers(MASK_PT_layers, Panel):
-    bl_space_type = 'CLIP_EDITOR'
-    bl_region_type = 'UI'
-
-
-class CLIP_PT_active_mask_spline(MASK_PT_spline, Panel):
-    bl_space_type = 'CLIP_EDITOR'
-    bl_region_type = 'UI'
-
-
-class CLIP_PT_active_mask_point(MASK_PT_point, Panel):
-    bl_space_type = 'CLIP_EDITOR'
-    bl_region_type = 'UI'
-
-
 class CLIP_PT_display(CLIP_PT_clip_view_panel, Panel):
     bl_space_type = 'CLIP_EDITOR'
     bl_region_type = 'UI'
@@ -703,16 +668,6 @@ class CLIP_PT_display(CLIP_PT_clip_view_panel, Panel):
             row.prop(clip, "display_aspect", text="")
 
 
-class CLIP_PT_mask(MASK_PT_mask, CLIP_PT_mask_view_panel, Panel):
-    bl_space_type = 'CLIP_EDITOR'
-    bl_region_type = 'UI'
-
-
-class CLIP_PT_mask_display(MASK_PT_display, CLIP_PT_mask_view_panel, Panel):
-    bl_space_type = 'CLIP_EDITOR'
-    bl_region_type = 'UI'
-
-
 class CLIP_PT_marker_display(CLIP_PT_clip_view_panel, Panel):
     bl_space_type = 'CLIP_EDITOR'
     bl_region_type = 'UI'
@@ -722,7 +677,7 @@ class CLIP_PT_marker_display(CLIP_PT_clip_view_panel, Panel):
     def poll(cls, context):
         sc = context.space_data
 
-        return sc.mode != 'MASKEDIT'
+        return sc.mode != 'MASK'
 
     def draw(self, context):
         layout = self.layout
@@ -1067,30 +1022,18 @@ class CLIP_MT_select(Menu):
 
     def draw(self, context):
         layout = self.layout
-        sc = context.space_data
 
-        if sc.mode == 'MASKEDIT':
-            layout.operator("mask.select_border")
-            layout.operator("mask.select_circle")
+        layout.operator("clip.select_border")
+        layout.operator("clip.select_circle")
 
-            layout.separator()
-
-            layout.operator("mask.select_all"
-                            ).action = 'TOGGLE'
-            layout.operator("mask.select_all",
-                            text="Inverse").action = 'INVERT'
-        else:
-            layout.operator("clip.select_border")
-            layout.operator("clip.select_circle")
-
-            layout.separator()
+        layout.separator()
 
-            layout.operator("clip.select_all"
-                            ).action = 'TOGGLE'
-            layout.operator("clip.select_all",
-                            text="Inverse").action = 'INVERT'
+        layout.operator("clip.select_all"
+                        ).action = 'TOGGLE'
+        layout.operator("clip.select_all",
+                        text="Inverse").action = 'INVERT'
 
-            layout.menu("CLIP_MT_select_grouped")
+        layout.menu("CLIP_MT_select_grouped")
 
 
 class CLIP_MT_select_grouped(Menu):
@@ -1186,5 +1129,48 @@ class CLIP_MT_stabilize_2d_specials(Menu):
 
         layout.operator("clip.stabilize_2d_select")
 
+
+# -----------------------------------------------------------------------------
+# Mask (similar code in space_image.py, keep in sync)
+
+
+from bl_ui.properties_mask_common import (MASK_PT_mask,
+                                          MASK_PT_layers,
+                                          MASK_PT_spline,
+                                          MASK_PT_point,
+                                          MASK_PT_display,
+                                          MASK_PT_tools)
+
+
+class CLIP_PT_mask(MASK_PT_mask, Panel):
+    bl_space_type = 'CLIP_EDITOR'
+    bl_region_type = 'UI'
+
+
+class CLIP_PT_mask_layers(MASK_PT_layers, Panel):
+    bl_space_type = 'CLIP_EDITOR'
+    bl_region_type = 'UI'
+
+
+class CLIP_PT_mask_display(MASK_PT_display, Panel):
+    bl_space_type = 'CLIP_EDITOR'
+    bl_region_type = 'UI'
+
+
+class CLIP_PT_active_mask_spline(MASK_PT_spline, Panel):
+    bl_space_type = 'CLIP_EDITOR'
+    bl_region_type = 'UI'
+
+
+class CLIP_PT_active_mask_point(MASK_PT_point, Panel):
+    bl_space_type = 'CLIP_EDITOR'
+    bl_region_type = 'UI'
+
+class CLIP_PT_tools_mask(MASK_PT_tools, Panel):
+    bl_space_type = 'CLIP_EDITOR'
+    bl_region_type = 'TOOLS'
+
+# --- end mask ---
+
 if __name__ == "__main__":  # only for live edit.
     bpy.utils.register_module(__name__)
index 05c2600407e5d35f84c4a8cbafa49c30591eca87..d8af9e2e5a4de44423c05cda0d13444996046217 100644 (file)
@@ -27,7 +27,7 @@ class ImagePaintPanel(UnifiedPaintPanel):
     bl_region_type = 'UI'
 
 
-class BrushButtonsPanel():
+class BrushButtonsPanel:
     bl_space_type = 'IMAGE_EDITOR'
     bl_region_type = 'UI'
 
@@ -849,5 +849,48 @@ class IMAGE_UV_sculpt(Panel, ImagePaintPanel):
             col.prop(toolsettings, "uv_relax_method")
 
 
+
+# -----------------------------------------------------------------------------
+# Mask (similar code in space_clip.py, keep in sync)
+# note! - panel placement does _not_ fit well with image panels... need to fix
+
+from bl_ui.properties_mask_common import (MASK_PT_mask,
+                                          MASK_PT_layers,
+                                          MASK_PT_spline,
+                                          MASK_PT_point,
+                                          MASK_PT_display,
+                                          MASK_PT_tools)
+
+
+class IMAGE_PT_mask(MASK_PT_mask, Panel):
+    bl_space_type = 'IMAGE_EDITOR'
+    bl_region_type = 'PREVIEW'
+
+
+class IMAGE_PT_mask_layers(MASK_PT_layers, Panel):
+    bl_space_type = 'IMAGE_EDITOR'
+    bl_region_type = 'PREVIEW'
+
+
+class IMAGE_PT_mask_display(MASK_PT_display, Panel):
+    bl_space_type = 'IMAGE_EDITOR'
+    bl_region_type = 'PREVIEW'
+
+
+class IMAGE_PT_active_mask_spline(MASK_PT_spline, Panel):
+    bl_space_type = 'IMAGE_EDITOR'
+    bl_region_type = 'PREVIEW'
+
+
+class IMAGE_PT_active_mask_point(MASK_PT_point, Panel):
+    bl_space_type = 'IMAGE_EDITOR'
+    bl_region_type = 'PREVIEW'
+
+class IMAGE_PT_tools_mask(MASK_PT_tools, Panel):
+    bl_space_type = 'IMAGE_EDITOR'
+    bl_region_type = 'UI'  # is 'TOOLS' in the clip editor
+
+# --- end mask ---
+
 if __name__ == "__main__":  # only for live edit.
     bpy.utils.register_module(__name__)