[Bf-blender-cvs] [5c8f1053b5f] blender2.8: UI: split UV editor out of the image space

Campbell Barton noreply at git.blender.org
Wed Dec 5 04:39:23 CET 2018


Commit: 5c8f1053b5f0f65168497fe5989cbc1b5cbba1ea
Author: Campbell Barton
Date:   Wed Dec 5 14:35:45 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB5c8f1053b5f0f65168497fe5989cbc1b5cbba1ea

UI: split UV editor out of the image space

===================================================================

M	release/scripts/startup/bl_ui/space_image.py
M	source/blender/editors/space_image/space_image.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index 836e15ef07b..d2bd2e11842 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -523,7 +523,8 @@ class IMAGE_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
-        layout.prop(sima, "mode", text="")
+        if sima.mode != 'UV':
+            layout.prop(sima, "ui_mode", text="")
 
         # UV editing.
         if show_uvedit:
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 01d2fc28c6b..b5c7657d890 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -53,6 +53,10 @@
 #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"
@@ -69,8 +73,6 @@
 
 #include "BIF_gl.h"
 
-#include "RNA_access.h"
-
 #include "WM_api.h"
 #include "WM_types.h"
 #include "WM_message.h"
@@ -954,6 +956,37 @@ static void image_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID
 	}
 }
 
+/**
+ * \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 */
@@ -977,6 +1010,9 @@ void ED_spacetype_image(void)
 	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");
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 43781c47828..9c1b999cbd6 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -909,8 +909,11 @@ typedef struct SpaceImage {
 	float centx, centy;             /* storage for offset while render drawing */
 
 	char  mode;                     /* view/paint/mask */
+	/* Storage for sub-space types. */
+	char mode_prev;
+
 	char  pin;
-	short pad;
+	char _pad;
 	short curtile; /* the currently active tile of the image when tile is enabled, is kept in sync with the active faces tile */
 	short lock;
 	char dt_uv; /* UV draw type */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index e8cda30a511..c2065548836 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -167,14 +167,42 @@ const EnumPropertyItem rna_enum_space_action_mode_items[] = {
 #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", ""},
@@ -3539,10 +3567,16 @@ 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");
 
-	/* 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");



More information about the Bf-blender-cvs mailing list