move mask and draw settings into its own struct to be shared between spaces.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 24 Jul 2012 20:33:55 +0000 (20:33 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 24 Jul 2012 20:33:55 +0000 (20:33 +0000)
source/blender/blenkernel/intern/mask.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_clip/clip_draw.c
source/blender/editors/space_clip/clip_editor.c
source/blender/editors/space_clip/space_clip.c
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/intern/rna_space.c

index 6fe838666c5f2285e5f1c3b8133805922a4ef8de..6d49137d892b16a127155f33bbf9685e2cf69475 100644 (file)
@@ -1484,8 +1484,8 @@ void BKE_mask_unlink(Main *bmain, Mask *mask)
                                if (sl->spacetype == SPACE_CLIP) {
                                        SpaceClip *sc = (SpaceClip *) sl;
 
-                                       if (sc->mask == mask)
-                                               sc->mask = NULL;
+                                       if (sc->mask_info.mask == mask)
+                                               sc->mask_info.mask = NULL;
                                }
                        }
                }
index ffc62135607ee1cc0d2f75e72a4f6c68c6e4e44a..68252fd7e25021f6c39d3d3b7e7c00098d7654f4 100644 (file)
@@ -5297,7 +5297,8 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                SpaceImage *sima = (SpaceImage *)sl;
                                                
                                                sima->image = newlibadr_us(fd, sc->id.lib, sima->image);
-                                               
+                                               sima->mask_info.mask = newlibadr_us(fd, sc->id.lib, sima->mask_info.mask);
+
                                                /* NOTE: pre-2.5, this was local data not lib data, but now we need this as lib data
                                                 * so fingers crossed this works fine!
                                                 */
@@ -5383,7 +5384,7 @@ static void lib_link_screen(FileData *fd, Main *main)
                                                SpaceClip *sclip = (SpaceClip *)sl;
                                                
                                                sclip->clip = newlibadr_us(fd, sc->id.lib, sclip->clip);
-                                               sclip->mask = newlibadr_us(fd, sc->id.lib, sclip->mask);
+                                               sclip->mask_info.mask = newlibadr_us(fd, sc->id.lib, sclip->mask_info.mask);
                                                
                                                sclip->scopes.track_search = NULL;
                                                sclip->scopes.track_preview = NULL;
@@ -5672,7 +5673,7 @@ void lib_link_screen_restore(Main *newmain, bScreen *curscreen, Scene *curscene)
                                        SpaceClip *sclip = (SpaceClip *)sl;
                                        
                                        sclip->clip = restore_pointer_by_name(newmain, (ID *)sclip->clip, 1);
-                                       sclip->mask = restore_pointer_by_name(newmain, (ID *)sclip->mask, 1);
+                                       sclip->mask_info.mask = restore_pointer_by_name(newmain, (ID *)sclip->mask_info.mask, 1);
                                        
                                        sclip->scopes.ok = 0;
                                }
index 2391d6c909eb3a07407a6b4ec77909b0d4755e0d..b63703a728d5d41f1962703f9d1ab7684b604974 100644 (file)
@@ -1951,8 +1951,8 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op)
        {
                SpaceClip *sc = CTX_wm_space_clip(C);
                if (sc) {
-                       if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask) {
-                               MaskLayer *masklay = BKE_mask_layer_active(sc->mask);
+                       if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask_info.mask) {
+                               MaskLayer *masklay = BKE_mask_layer_active(sc->mask_info.mask);
                                mask_to_keylist(&ads, masklay, &keys);
                        }
                }
index 37da40e11b392d6900ca8d45449e06aef5245092..7734661aa96068ebbb6ed2c33edbd55028e64e58 100644 (file)
@@ -198,8 +198,8 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc
        clip_draw_curfra_label(sc, x, 8.0f);
 
        /* movie clip animation */
-       if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask) {
-               MaskLayer *masklay = BKE_mask_layer_active(sc->mask);
+       if ((sc->mode == SC_MODE_MASKEDIT) && sc->mask_info.mask) {
+               MaskLayer *masklay = BKE_mask_layer_active(sc->mask_info.mask);
                if (masklay) {
                        MaskLayerShape *masklay_shape;
 
index 224a250fe4c9db925af5d2df35912154d7ba786a..9bde3a3d4d5e52aeaebfa661cea9551c5912523b 100644 (file)
@@ -115,7 +115,7 @@ int ED_space_clip_maskedit_mask_poll(bContext *C)
                if (clip) {
                        SpaceClip *sc = CTX_wm_space_clip(C);
 
-                       return sc->mask != NULL;
+                       return sc->mask_info.mask != NULL;
                }
        }
 
@@ -509,14 +509,14 @@ void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieCl
 
 Mask *ED_space_clip_get_mask(SpaceClip *sc)
 {
-       return sc->mask;
+       return sc->mask_info.mask;
 }
 
 void ED_space_clip_set_mask(bContext *C, SpaceClip *sc, Mask *mask)
 {
-       sc->mask = mask;
+       sc->mask_info.mask = mask;
 
-       if (sc->mask && sc->mask->id.us == 0) {
+       if (sc->mask_info.mask && sc->mask_info.mask->id.us == 0) {
                sc->clip->id.us = 1;
        }
 
index bdbfa2506741390b2661144898e826a445a31830..9b1ffcf31b1fe17266569261a58d770a435de75e 100644 (file)
@@ -766,8 +766,8 @@ static int clip_context(const bContext *C, const char *member, bContextDataResul
                return TRUE;
        }
        else if (CTX_data_equals(member, "edit_mask")) {
-               if (sc->mask)
-                       CTX_data_id_pointer_set(result, &sc->mask->id);
+               if (sc->mask_info.mask)
+                       CTX_data_id_pointer_set(result, &sc->mask_info.mask->id);
                return TRUE;
        }
 
@@ -1120,7 +1120,7 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar)
                        int width, height;
                        ED_mask_size(C, &width, &height);
                        ED_mask_draw_region(mask, ar,
-                                           sc->mask_draw_flag, sc->mask_draw_type,
+                                           sc->mask_info.draw_flag, sc->mask_info.draw_type,
                                            width, height,
                                            TRUE, TRUE,
                                            sc->stabmat, C);
index 7e1094ef93b04e653f0186573cba7d7bbb47b407..0ab3b74f2e08d0e900476af4e0521c43badc345c 100644 (file)
@@ -513,6 +513,15 @@ typedef enum eSpaceSeq_Proxy_RenderSize {
        SEQ_PROXY_RENDER_SIZE_FULL      = 100
 } eSpaceSeq_Proxy_RenderSize;
 
+typedef struct MaskSpaceInfo
+{
+       /* **** mask editing **** */
+       struct Mask *mask;
+       /* draw options */
+       char draw_flag;
+       char draw_type;
+       char pad3[6];
+} MaskSpaceInfo;
 
 /* File Selector ========================================== */
 
@@ -689,6 +698,8 @@ typedef struct SpaceImage {
        char sticky; /* sticky selection type */
        char dt_uvstretch;
        char around;
+
+       MaskSpaceInfo mask_info;
 } SpaceImage;
 
 
@@ -1012,12 +1023,7 @@ typedef struct SpaceClip {
 
        int around, pad4;             /* pivot point for transforms */
 
-       /* **** mask editing **** */
-       struct Mask *mask;
-       /* draw options */
-       char mask_draw_flag;
-       char mask_draw_type;
-       char pad3[6];
+       MaskSpaceInfo mask_info;
 } SpaceClip;
 
 /* SpaceClip->flag */
index 4473a9ef0f6f46a98d43ad7d1e5c46028b09d076..9f8fbea6a15130477bff9a11df851c3a294ff4e2 100644 (file)
@@ -1103,6 +1103,31 @@ static void rna_def_space(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Type", "Space data type");
 }
 
+/* for all spaces that use a mask */
+void mask_space_info(StructRNA *srna, int noteflag, const char *mask_set_func)
+{
+       PropertyRNA *prop;
+
+       prop = RNA_def_property(srna, "mask", PROP_POINTER, PROP_NONE);
+       RNA_def_property_pointer_sdna(prop, NULL, "mask_info.mask");
+       RNA_def_property_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Mask", "Mask displayed and edited in this space");
+       RNA_def_property_pointer_funcs(prop, NULL, mask_set_func, NULL, NULL);
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
+
+       /* mask drawing */
+       prop = RNA_def_property(srna, "mask_draw_type", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "mask_info.draw_type");
+       RNA_def_property_enum_items(prop, dt_uv_items);
+       RNA_def_property_ui_text(prop, "Edge Draw Type", "Draw type for mask splines");
+       RNA_def_property_update(prop, noteflag, NULL);
+
+       prop = RNA_def_property(srna, "show_mask_smooth", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "mask_info.draw_flag", MASK_DRAWFLAG_SMOOTH);
+       RNA_def_property_ui_text(prop, "Draw Smooth Splines", "");
+       RNA_def_property_update(prop, noteflag, NULL);
+}
+
 static void rna_def_space_image_uv(BlenderRNA *brna)
 {
        StructRNA *srna;
@@ -1220,6 +1245,9 @@ 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);
+
+       /* mask */
+       mask_space_info(srna, NC_SPACE | ND_SPACE_IMAGE, NULL);
 }
 
 static void rna_def_space_outliner(BlenderRNA *brna)
@@ -3064,24 +3092,7 @@ static void rna_def_space_clip(BlenderRNA *brna)
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
 
        /* mask */
-       prop = RNA_def_property(srna, "mask", PROP_POINTER, PROP_NONE);
-       RNA_def_property_flag(prop, PROP_EDITABLE);
-       RNA_def_property_ui_text(prop, "Mask", "Mask displayed and edited in this space");
-       RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceClipEditor_mask_set", NULL, NULL);
-       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
-
-       /* mask drawing */
-       prop = RNA_def_property(srna, "mask_draw_type", PROP_ENUM, PROP_NONE);
-       RNA_def_property_enum_sdna(prop, NULL, "mask_draw_type");
-       RNA_def_property_enum_items(prop, dt_uv_items);
-       RNA_def_property_ui_text(prop, "Edge Draw Type", "Draw type for mask splines");
-       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
-
-       prop = RNA_def_property(srna, "show_mask_smooth", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "mask_draw_flag", MASK_DRAWFLAG_SMOOTH);
-       RNA_def_property_ui_text(prop, "Draw Smooth Splines", "");
-       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
-
+       mask_space_info(srna, NC_SPACE | ND_SPACE_CLIP, "rna_SpaceClipEditor_mask_set");
 
        /* mode */
        prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);