[Bf-blender-cvs] [16882ca5356] blender2.8: Image Space: make 'UV Edit' a separate mode

Campbell Barton noreply at git.blender.org
Fri Oct 19 11:16:03 CEST 2018


Commit: 16882ca5356d5861e3266b99e9b2434e5cf49073
Author: Campbell Barton
Date:   Fri Oct 19 20:10:14 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB16882ca5356d5861e3266b99e9b2434e5cf49073

Image Space: make 'UV Edit' a separate mode

This is needed for splitting UV into its own editor, see: T54744

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

M	release/scripts/startup/bl_ui/space_image.py
M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	source/blender/blenloader/intern/versioning_defaults.c
M	source/blender/editors/screen/screen_context.c
M	source/blender/editors/space_image/image_edit.c
M	source/blender/editors/uvedit/uvedit_buttons.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/makesrna/intern/rna_workspace_api.c
M	source/blender/windowmanager/intern/wm_toolsystem.c

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

diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index b77d2851574..1a9b8ab83b1 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -585,7 +585,8 @@ class IMAGE_HT_header(Header):
             sub.active = toolsettings.proportional_edit != 'DISABLED'
             sub.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
 
-        layout.prop(sima, "pivot_point", icon_only=True)
+        if show_uvedit or show_maskedit:
+            layout.prop(sima, "pivot_point", icon_only=True)
 
         row = layout.row()
         row.popover(
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 709636beb5f..b75a4fa09e2 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1810,6 +1810,8 @@ class IMAGE_PT_tools_active(ToolSelectPanelHelper, Panel):
             # for all modes
         ],
         'VIEW': [
+        ],
+        'UV': [
             _defs_image_generic.cursor,
             *_tools_select,
             None,
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index cbe1969f711..2a454a02f42 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -102,6 +102,21 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
 				BKE_workspace_tool_remove(workspace, workspace->tools.first);
 			}
 		}
+
+		{
+			/* 'UV Editing' should use UV mode. */
+			bScreen *screen = BLI_findstring(&bmain->screen, "Default.005", offsetof(ID, name) + 2);
+			for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+				for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+					if (sl->spacetype == SPACE_IMAGE) {
+						SpaceImage *sima = (SpaceImage *)sl;
+						if (sima->mode == SI_MODE_VIEW) {
+							sima->mode = SI_MODE_UV;
+						}
+					}
+				}
+			}
+		}
 	}
 
 	/* For 2D animation template. */
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index a87184120ca..021f5b9abd1 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -437,7 +437,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
 				if (ED_uvedit_test(obedit)) {
 					WorkSpace *workspace = CTX_wm_workspace(C);
 					if ((workspace->tools_space_type == SPACE_IMAGE) &&
-					    (workspace->tools_mode == SI_MODE_VIEW))
+					    (workspace->tools_mode == SI_MODE_UV))
 					{
 						CTX_data_id_pointer_set(result, &obact->id);
 					}
diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c
index 4388accc534..cde89230df8 100644
--- a/source/blender/editors/space_image/image_edit.c
+++ b/source/blender/editors/space_image/image_edit.c
@@ -361,8 +361,14 @@ bool ED_space_image_show_paint(SpaceImage *sima)
 
 bool ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit)
 {
-	if (sima && (ED_space_image_show_render(sima) || ED_space_image_show_paint(sima)))
-		return false;
+	if (sima) {
+		if (ED_space_image_show_render(sima)) {
+			return false;
+		}
+		if (sima->mode != SI_MODE_UV) {
+			return false;
+		}
+	}
 
 	if (obedit && obedit->type == OB_MESH) {
 		struct BMEditMesh *em = BKE_editmesh_from_object(obedit);
diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c
index 60500f0211a..317a07bcf96 100644
--- a/source/blender/editors/uvedit/uvedit_buttons.c
+++ b/source/blender/editors/uvedit/uvedit_buttons.c
@@ -210,6 +210,10 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event)
 
 static bool image_panel_uv_poll(const bContext *C, PanelType *UNUSED(pt))
 {
+	SpaceImage *sima = CTX_wm_space_image(C);
+	if (sima->mode != SI_MODE_UV) {
+		return false;
+	}
 	Object *obedit = CTX_data_edit_object(C);
 	return ED_uvedit_test(obedit);
 }
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 05ff65f0267..5f91c8a07cb 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -943,7 +943,8 @@ typedef enum eSpaceImage_UVDT_Stretch {
 typedef enum eSpaceImage_Mode {
 	SI_MODE_VIEW  = 0,
 	SI_MODE_PAINT = 1,
-	SI_MODE_MASK  = 2   /* note: mesh edit mode overrides mask */
+	SI_MODE_MASK  = 2,
+	SI_MODE_UV    = 3,
 } eSpaceImage_Mode;
 
 /* SpaceImage.sticky
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 80053095044..35bfc92370c 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -168,7 +168,8 @@ const EnumPropertyItem rna_enum_space_action_mode_items[] = {
 #undef SACT_ITEM_CACHEFILE
 
 const EnumPropertyItem rna_enum_space_image_mode_items[] = {
-	{SI_MODE_VIEW, "VIEW", ICON_FILE_IMAGE, "View", "View the image and UV edit in mesh editmode"},
+	{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"},
 	{0, NULL, 0, NULL, NULL}
diff --git a/source/blender/makesrna/intern/rna_workspace_api.c b/source/blender/makesrna/intern/rna_workspace_api.c
index fb237299dd0..3f9c419d7e3 100644
--- a/source/blender/makesrna/intern/rna_workspace_api.c
+++ b/source/blender/makesrna/intern/rna_workspace_api.c
@@ -103,8 +103,9 @@ static void rna_WorkspaceTool_refresh_from_context(
 				}
 			}
 			else if ((tref->space_type == SPACE_IMAGE) &&
-			         (tref->mode == SI_MODE_VIEW) &&
-			         (ob->mode & OB_MODE_EDIT))
+			         (tref->mode == SI_MODE_UV) &&
+			         (ob->mode &
+			          OB_MODE_EDIT))
 			{
 				const EnumPropertyItem *items = rna_enum_uv_sculpt_tool_items;
 				const int i = RNA_enum_from_value(items, ts->uv_sculpt_tool);
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c
index 5584fada329..e835ece0c6c 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -214,7 +214,7 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
 			}
 		}
 		if ((tref->space_type == SPACE_IMAGE) &&
-		    (tref->mode == SI_MODE_VIEW))
+		    (tref->mode == SI_MODE_UV))
 		{
 			/* Note that switching uv-sculpt boolean is a hack at the moment.
 			 * It would be best to make this either an operator or a higher level mode (like mesh-object sculpt mode). */
@@ -259,7 +259,7 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
 	else {
 		/* XXX, this part is weak, disables uv_sculpt when non uv-tool set. */
 		if ((tref->space_type == SPACE_IMAGE) &&
-		    (tref->mode == SI_MODE_VIEW))
+		    (tref->mode == SI_MODE_UV))
 		{
 			Main *bmain = CTX_data_main(C);
 			wmWindowManager *wm = bmain->wm.first;



More information about the Bf-blender-cvs mailing list