mask UI for space image
authorCampbell Barton <ideasman42@gmail.com>
Wed, 25 Jul 2012 12:15:22 +0000 (12:15 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 25 Jul 2012 12:15:22 +0000 (12:15 +0000)
release/scripts/startup/bl_ui/space_image.py
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_image/image_edit.c
source/blender/makesrna/intern/rna_space.c

index 855e738f7761a3bb9ab8bf9c2c9fd3f8875bba04..05c2600407e5d35f84c4a8cbafa49c30591eca87 100644 (file)
@@ -349,6 +349,7 @@ class IMAGE_HT_header(Header):
         ima = sima.image
         iuser = sima.image_user
         toolsettings = context.tool_settings
         ima = sima.image
         iuser = sima.image_user
         toolsettings = context.tool_settings
+        mode = sima.mode
 
         show_render = sima.show_render
         # show_paint = sima.show_paint
 
         show_render = sima.show_render
         # show_paint = sima.show_paint
@@ -402,13 +403,16 @@ class IMAGE_HT_header(Header):
             mesh = context.edit_object.data
             layout.prop_search(mesh.uv_textures, "active", mesh, "uv_textures", text="")
 
             mesh = context.edit_object.data
             layout.prop_search(mesh.uv_textures, "active", mesh, "uv_textures", text="")
 
+        layout.prop(sima, "mode", text="")
+
+        if mode == 'MASK':
+            row = layout.row()
+            row.template_ID(sima, "mask", new="mask.new")
+
         if ima:
             # layers
             layout.template_image_layers(ima, iuser)
 
         if ima:
             # layers
             layout.template_image_layers(ima, iuser)
 
-            # painting
-            layout.prop(sima, "mode", text="")
-
             # draw options
             row = layout.row(align=True)
             row.prop(sima, "draw_channels", text="", expand=True)
             # draw options
             row = layout.row(align=True)
             row.prop(sima, "draw_channels", text="", expand=True)
@@ -419,7 +423,7 @@ class IMAGE_HT_header(Header):
             if ima.type == 'COMPOSITE' and ima.source in {'MOVIE', 'SEQUENCE'}:
                 row.operator("image.play_composite", icon='PLAY')
 
             if ima.type == 'COMPOSITE' and ima.source in {'MOVIE', 'SEQUENCE'}:
                 row.operator("image.play_composite", icon='PLAY')
 
-        if show_uvedit or sima.mode == 'PAINT':
+        if show_uvedit or mode == 'PAINT':
             layout.prop(sima, "use_realtime_update", text="", icon_only=True, icon='LOCKED')
 
 
             layout.prop(sima, "use_realtime_update", text="", icon_only=True, icon='LOCKED')
 
 
index b63703a728d5d41f1962703f9d1ab7684b604974..74fa6158b734c1226cc3d9dd45b741d8b8142b01 100644 (file)
 #include "WM_api.h"
 #include "WM_types.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
 
-#include "ED_util.h"
+#include "ED_armature.h"
+#include "ED_clip.h"
 #include "ED_image.h"
 #include "ED_image.h"
-#include "ED_screen.h"
+#include "ED_keyframes_draw.h"
 #include "ED_object.h"
 #include "ED_object.h"
-#include "ED_armature.h"
+#include "ED_screen.h"
 #include "ED_screen_types.h"
 #include "ED_screen_types.h"
-#include "ED_keyframes_draw.h"
+#include "ED_sequencer.h"
+#include "ED_util.h"
 #include "ED_view3d.h"
 #include "ED_view3d.h"
-#include "ED_clip.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -458,9 +459,29 @@ int ED_operator_editmball(bContext *C)
 
 int ED_operator_mask(bContext *C)
 {
 
 int ED_operator_mask(bContext *C)
 {
-       SpaceClip *sc = CTX_wm_space_clip(C);
+       ScrArea *sa = CTX_wm_area(C);
+       if (sa && sa->spacedata.first) {
+               switch (sa->spacetype) {
+                       case SPACE_CLIP:
+                       {
+                               SpaceClip *sc = sa->spacedata.first;
+                               return ED_space_clip_check_show_maskedit(sc);
+                       }
+                       case SPACE_SEQ:
+                       {
+                               SpaceSeq *sseq = sa->spacedata.first;
+                               Scene *scene = CTX_data_scene(C);
+                               return ED_space_sequencer_check_show_maskedit(sseq, scene);
+                       }
+                       case SPACE_IMAGE:
+                       {
+                               SpaceImage *sima = sa->spacedata.first;
+                               return ED_space_image_check_show_maskedit(sima);
+                       }
+               }
+       }
 
 
-       return ED_space_clip_check_show_maskedit(sc);
+       return FALSE;
 }
 
 /* *************************** action zone operator ************************** */
 }
 
 /* *************************** action zone operator ************************** */
index ae6fe704c6f5b44315dcfd084dc8f1c188c21ef2..8b9c9d767558309c4ff7f433bbb78a8a268384c4 100644 (file)
@@ -301,9 +301,7 @@ int ED_space_image_show_uvshadow(SpaceImage *sima, Object *obedit)
 /* matches clip function */
 int ED_space_image_check_show_maskedit(SpaceImage *sima)
 {
 /* matches clip function */
 int ED_space_image_check_show_maskedit(SpaceImage *sima)
 {
-       /* MASKTODO - whem we have a mask edit option */
-       (void)sima;
-       return TRUE;
+       return (sima->mode == SI_MODE_MASK);
 }
 
 int ED_space_image_maskedit_poll(bContext *C)
 }
 
 int ED_space_image_maskedit_poll(bContext *C)
index 78811492cd4701fddce3aa68eaa1b012aa4e8c98..c710831d4213dac7519311df895cf83c47318f1d 100644 (file)
@@ -563,6 +563,13 @@ static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value)
        ED_space_image_set(sima, sc->scene, sc->scene->obedit, (Image *)value.data);
 }
 
        ED_space_image_set(sima, sc->scene, sc->scene->obedit, (Image *)value.data);
 }
 
+static void rna_SpaceImageEditor_mask_set(PointerRNA *ptr, PointerRNA value)
+{
+       SpaceImage *sima = (SpaceImage *)(ptr->data);
+
+       ED_space_image_set_mask(NULL, sima, (Mask *)value.data);
+}
+
 static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *UNUSED(C), PointerRNA *ptr,
                                                                   PropertyRNA *UNUSED(prop), int *free)
 {
 static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *UNUSED(C), PointerRNA *ptr,
                                                                   PropertyRNA *UNUSED(prop), int *free)
 {
@@ -1104,7 +1111,7 @@ static void rna_def_space(BlenderRNA *brna)
 }
 
 /* for all spaces that use a mask */
 }
 
 /* for all spaces that use a mask */
-void mask_space_info(StructRNA *srna, int noteflag, const char *mask_set_func)
+void rna_def_space_mask_info(StructRNA *srna, int noteflag, const char *mask_set_func)
 {
        PropertyRNA *prop;
 
 {
        PropertyRNA *prop;
 
@@ -1245,9 +1252,6 @@ static void rna_def_space_image_uv(BlenderRNA *brna)
        RNA_def_property_enum_items(prop, pivot_items);
        RNA_def_property_ui_text(prop, "Pivot", "Rotation/Scaling Pivot");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
        RNA_def_property_enum_items(prop, pivot_items);
        RNA_def_property_ui_text(prop, "Pivot", "Rotation/Scaling Pivot");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
-
-       /* mask */
-       mask_space_info(srna, NC_SPACE | ND_SPACE_IMAGE, NULL);
 }
 
 static void rna_def_space_outliner(BlenderRNA *brna)
 }
 
 static void rna_def_space_outliner(BlenderRNA *brna)
@@ -2071,6 +2075,9 @@ static void rna_def_space_image(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Show UV Editor", "Show UV editing related properties");
 
        rna_def_space_image_uv(brna);
        RNA_def_property_ui_text(prop, "Show UV Editor", "Show UV editing related properties");
 
        rna_def_space_image_uv(brna);
+
+       /* mask */
+       rna_def_space_mask_info(srna, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_mask_set");
 }
 
 static void rna_def_space_sequencer(BlenderRNA *brna)
 }
 
 static void rna_def_space_sequencer(BlenderRNA *brna)
@@ -3099,7 +3106,7 @@ static void rna_def_space_clip(BlenderRNA *brna)
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
 
        /* mask */
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
 
        /* mask */
-       mask_space_info(srna, NC_SPACE | ND_SPACE_CLIP, "rna_SpaceClipEditor_mask_set");
+       rna_def_space_mask_info(srna, NC_SPACE | ND_SPACE_CLIP, "rna_SpaceClipEditor_mask_set");
 
        /* mode */
        prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
 
        /* mode */
        prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);