#include "BKE_screen.h"
#include "BKE_workspace.h"
+#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+
#include "DEG_depsgraph.h"
#include "IMB_imbuf_types.h"
#include "BIF_gl.h"
-#include "RNA_access.h"
-
#include "WM_api.h"
#include "WM_types.h"
#include "WM_message.h"
}
}
+/**
+ * \note Used for splitting out a subset of modes is more involved,
+ * The previous non-uv-edit mode is stored so switching back to the
+ * image doesn't always reset the sub-mode.
+ */
+static int image_space_subtype_get(ScrArea *sa)
+{
+ SpaceImage *sima = sa->spacedata.first;
+ return sima->mode == SI_MODE_UV ? SI_MODE_UV : SI_MODE_VIEW;
+}
+
+static void image_space_subtype_set(ScrArea *sa, int value)
+{
+ SpaceImage *sima = sa->spacedata.first;
+ if (value == SI_MODE_UV) {
+ if (sima->mode != SI_MODE_UV) {
+ sima->mode_prev = sima->mode;
+ }
+ sima->mode = value;
+ }
+ else {
+ sima->mode = sima->mode_prev;
+ }
+}
+
+static void image_space_subtype_item_extend(
+ bContext *UNUSED(C), EnumPropertyItem **item, int *totitem)
+{
+ RNA_enum_items_add(item, totitem, rna_enum_space_image_mode_items);
+}
+
/**************************** spacetype *****************************/
/* only called once, from space/spacetypes.c */
st->context = image_context;
st->gizmos = image_widgets;
st->id_remap = image_id_remap;
+ st->space_subtype_item_extend = image_space_subtype_item_extend;
+ st->space_subtype_get = image_space_subtype_get;
+ st->space_subtype_set = image_space_subtype_set;
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype image region");
#undef SACT_ITEM_MASK
#undef SACT_ITEM_CACHEFILE
+
+#define SI_ITEM_VIEW(name, icon) \
+ {SI_MODE_VIEW, "VIEW", icon, name, "View the image"}
+#define SI_ITEM_UV \
+ {SI_MODE_UV, "UV", ICON_GROUP_UVS, "UV Edit", "UV edit in mesh editmode"}
+#define SI_ITEM_PAINT \
+ {SI_MODE_PAINT, "PAINT", ICON_TPAINT_HLT, "Paint", "2D image painting mode"}
+#define SI_ITEM_MASK \
+ {SI_MODE_MASK, "MASK", ICON_MOD_MASK, "Mask", "Mask editing"}
+
+static const EnumPropertyItem rna_enum_space_image_mode_all_items[] = {
+ SI_ITEM_VIEW("View", ICON_FILE_IMAGE),
+ SI_ITEM_UV,
+ SI_ITEM_PAINT,
+ SI_ITEM_MASK,
+ {0, NULL, 0, NULL, NULL}
+};
+
+static const EnumPropertyItem rna_enum_space_image_mode_ui_items[] = {
+ SI_ITEM_VIEW("View", ICON_FILE_IMAGE),
+ SI_ITEM_PAINT,
+ SI_ITEM_MASK,
+ {0, NULL, 0, NULL, NULL}
+};
+
const EnumPropertyItem rna_enum_space_image_mode_items[] = {
- {SI_MODE_VIEW, "VIEW", ICON_FILE_IMAGE, "View", "View the image"},
- {SI_MODE_UV, "UV", ICON_GROUP_UVS, "UV Edit", "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"},
+ SI_ITEM_VIEW("Image Editor", ICON_IMAGE),
+ SI_ITEM_UV,
{0, NULL, 0, NULL, NULL}
};
+#undef SI_ITEM_VIEW
+#undef SI_ITEM_UV
+#undef SI_ITEM_PAINT
+#undef SI_ITEM_MASK
+
#define V3D_S3D_CAMERA_LEFT {STEREO_LEFT_ID, "LEFT", ICON_RESTRICT_RENDER_OFF, "Left", ""},
#define V3D_S3D_CAMERA_RIGHT {STEREO_RIGHT_ID, "RIGHT", ICON_RESTRICT_RENDER_OFF, "Right", ""},
#define V3D_S3D_CAMERA_S3D {STEREO_3D_ID, "S3D", ICON_CAMERA_STEREO, "3D", ""},
RNA_def_property_pointer_funcs(prop, "rna_SpaceImageEditor_uvedit_get", NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "UV Editor", "UV editor settings");
- /* mode */
+ /* mode (hidden in the UI, see 'ui_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, rna_enum_space_image_mode_items);
+ RNA_def_property_enum_items(prop, rna_enum_space_image_mode_all_items);
+ RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_mode_update");
+
+ prop = RNA_def_property(srna, "ui_mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "mode");
+ RNA_def_property_enum_items(prop, rna_enum_space_image_mode_ui_items);
RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_mode_update");