image space now has a mode for view/paint/mask editing.
authorCampbell Barton <ideasman42@gmail.com>
Wed, 25 Jul 2012 11:25:10 +0000 (11:25 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 25 Jul 2012 11:25:10 +0000 (11:25 +0000)
release/scripts/startup/bl_ui/space_image.py
source/blender/editors/interface/interface_icons.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/space_image/image_draw.c
source/blender/editors/space_image/image_edit.c
source/blender/editors/util/undo.c
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/intern/rna_space.c

index cfe5d66740cdb1c83bf158a788c433ef32825185..855e738f7761a3bb9ab8bf9c2c9fd3f8875bba04 100644 (file)
@@ -153,10 +153,6 @@ class IMAGE_MT_image(Menu):
                     if ima.source in {'FILE', 'GENERATED'} and ima.type != 'OPEN_EXR_MULTILAYER':
                         layout.operator("image.pack", text="Pack As PNG").as_png = True
 
-            if not context.tool_settings.use_uv_sculpt:
-                layout.separator()
-                layout.prop(sima, "use_image_paint")
-
             layout.separator()
 
 
@@ -411,7 +407,7 @@ class IMAGE_HT_header(Header):
             layout.template_image_layers(ima, iuser)
 
             # painting
-            layout.prop(sima, "use_image_paint", text="")
+            layout.prop(sima, "mode", text="")
 
             # draw options
             row = layout.row(align=True)
@@ -423,7 +419,7 @@ class IMAGE_HT_header(Header):
             if ima.type == 'COMPOSITE' and ima.source in {'MOVIE', 'SEQUENCE'}:
                 row.operator("image.play_composite", icon='PLAY')
 
-        if show_uvedit or sima.use_image_paint:
+        if show_uvedit or sima.mode == 'PAINT':
             layout.prop(sima, "use_realtime_update", text="", icon_only=True, icon='LOCKED')
 
 
index 002c3d48a0150a6ca34e0651ab784159e45e1cb2..2bfead708beeb0b9756d04299761d06c8e769ce0 100644 (file)
@@ -1091,7 +1091,7 @@ static int ui_id_brush_get_icon(bContext *C, ID *id)
                                mode = OB_MODE_TEXTURE_PAINT;
                }
                else if ((sima = CTX_wm_space_image(C)) &&
-                        (sima->flag & SI_DRAWTOOL))
+                        (sima->mode == SI_MODE_PAINT))
                {
                        mode = OB_MODE_TEXTURE_PAINT;
                }
index 073e60ca87cc4a81a0bafd60ce7bcad78bf46b8e..aa239af43f7dc3528db1085f1c7852ba830cd291 100644 (file)
@@ -4667,8 +4667,9 @@ static int image_paint_poll(bContext *C)
                if (sima) {
                        ARegion *ar = CTX_wm_region(C);
 
-                       if ((sima->flag & SI_DRAWTOOL) && ar->regiontype == RGN_TYPE_WINDOW)
+                       if ((sima->mode == SI_MODE_PAINT) && ar->regiontype == RGN_TYPE_WINDOW) {
                                return 1;
+                       }
                }
        }
 
index cf78eaabd88f9eb785c88680afaf282abb621244..aaa2676c4c2f9f06b1326375607e92ada8d9d3bb 100644 (file)
@@ -754,7 +754,7 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene)
                draw_image_buffer(sima, ar, scene, ima, ibuf, 0.0f, 0.0f, zoomx, zoomy);
 
        /* paint helpers */
-       if (sima->flag & SI_DRAWTOOL)
+       if (sima->mode == SI_MODE_PAINT)
                draw_image_paint_helpers(ar, scene, zoomx, zoomy);
 
 
index 1c488fe4ac7f569c19bf5143c3a0968207496a3d..ae6fe704c6f5b44315dcfd084dc8f1c188c21ef2 100644 (file)
@@ -66,8 +66,11 @@ void ED_space_image_set(SpaceImage *sima, Scene *scene, Object *obedit, Image *i
         * to check if the face is displayed in UV-localview */
        sima->image = ima;
 
-       if (ima == NULL || ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE)
-               sima->flag &= ~SI_DRAWTOOL;
+       if (ima == NULL || ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE) {
+               if (sima->mode == SI_MODE_PAINT) {
+                       sima->mode = SI_MODE_VIEW;
+               }
+       }
 
        if (sima->image)
                BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE);
@@ -257,7 +260,7 @@ int ED_space_image_show_paint(SpaceImage *sima)
        if (ED_space_image_show_render(sima))
                return 0;
 
-       return (sima->flag & SI_DRAWTOOL);
+       return (sima->mode == SI_MODE_PAINT);
 }
 
 int ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit)
index 0c2bfff3b57a19251a05bbddea43c875fdf8019a..65b921688423da6d51bc7713182b7c0cfdfb301f 100644 (file)
@@ -141,7 +141,7 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
        if (sa && (sa->spacetype == SPACE_IMAGE)) {
                SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
                
-               if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->flag & SI_DRAWTOOL)) {
+               if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) {
                        if (!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname) && undoname)
                                if (U.uiflag & USER_GLOBALUNDO)
                                        BKE_undo_name(C, undoname);
@@ -238,7 +238,7 @@ int ED_undo_valid(const bContext *C, const char *undoname)
        if (sa && sa->spacetype == SPACE_IMAGE) {
                SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
                
-               if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->flag & SI_DRAWTOOL)) {
+               if ((obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) || (sima->mode == SI_MODE_PAINT)) {
                        return 1;
                }
        }
index a33b7ef12d0c827d4da91434bf7a4e736b64a3bf..6299c46171e86c4341d3ce4e27810dabb129ea04 100644 (file)
@@ -718,6 +718,13 @@ typedef enum eSpaceImage_UVDT_Stretch {
        SI_UVDT_STRETCH_AREA = 1,
 } eSpaceImage_UVDT_Stretch;
 
+/* SpaceImage->mode */
+typedef enum eSpaceImage_Mode {
+       SI_MODE_VIEW  = 0,
+       SI_MODE_PAINT = 1,
+       SI_MODE_MASK  = 2
+} eSpaceImage_Mode;
+
 /* SpaceImage->sticky
  * Note DISABLE should be 0, however would also need to re-arrange icon order,
  * also, sticky loc is the default mode so this means we don't need to 'do_versons' */
@@ -732,7 +739,7 @@ typedef enum eSpaceImage_Flag {
 /*     SI_BE_SQUARE          = (1 << 0), */  /* deprecated */
        SI_EDITTILE           = (1 << 1),     /* XXX - not used but should be? */
        SI_CLIP_UV            = (1 << 2),
-       SI_DRAWTOOL           = (1 << 3),
+/*     SI_DRAWTOOL           = (1 << 3), */  /* deprecated */
        SI_NO_DRAWFACES       = (1 << 4),
        SI_DRAWSHADOW         = (1 << 5),
 /*     SI_SELACTFACE         = (1 << 6), */  /* deprecated */
index 9f8fbea6a15130477bff9a11df851c3a294ff4e2..78811492cd4701fddce3aa68eaa1b012aa4e8c98 100644 (file)
@@ -1956,6 +1956,13 @@ static void rna_def_space_buttons(BlenderRNA *brna)
 
 static void rna_def_space_image(BlenderRNA *brna)
 {
+       static EnumPropertyItem image_space_mode_items[] = {
+               {SI_MODE_VIEW, "VIEW", ICON_FILE_IMAGE, "View", "View the image and UV edit in mesh editmode"},
+               {SI_MODE_PAINT, "PAINT", ICON_TPAINT_HLT, "Paint", "2D image painting mode"},
+               {SI_MODE_MASK, "MASK", ICON_MOD_MASK, "Mask", "Mask editing"},
+               {0, NULL, 0, NULL, NULL}
+       };
+
        StructRNA *srna;
        PropertyRNA *prop;
 
@@ -2025,12 +2032,12 @@ static void rna_def_space_image(BlenderRNA *brna)
        RNA_def_property_pointer_funcs(prop, "rna_SpaceImageEditor_uvedit_get", NULL, NULL, NULL);
        RNA_def_property_ui_text(prop, "UV Editor", "UV editor settings");
        
-       /* paint */
-       prop = RNA_def_property(srna, "use_image_paint", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAWTOOL);
-       RNA_def_property_ui_text(prop, "Image Painting", "Enable image painting mode");
-       RNA_def_property_ui_icon(prop, ICON_TPAINT_HLT, 0);
-       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_paint_update");
+       /* mode */
+       prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "mode");
+       RNA_def_property_enum_items(prop, image_space_mode_items);
+       RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed");
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
 
        /* grease pencil */
        prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);