diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index cfe5d66740c..855e738f776 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -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') diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 002c3d48a01..2bfead708be 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -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; } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 073e60ca87c..aa239af43f7 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -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; + } } } diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index cf78eaabd88..aaa2676c4c2 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -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); diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 1c488fe4ac7..ae6fe704c6f 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -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) diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 0c2bfff3b57..65b92168842 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -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; } } diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index a33b7ef12d0..6299c46171e 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -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 */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 9f8fbea6a15..78811492cd4 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -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);