[Bf-blender-cvs] [1ce55693f51] blender2.8: UI: remove tools space type, use properties context

Campbell Barton noreply at git.blender.org
Fri Jun 8 16:36:14 CEST 2018


Commit: 1ce55693f511013ceed962e8614aa61dd2dff4d5
Author: Campbell Barton
Date:   Fri Jun 8 16:30:56 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB1ce55693f511013ceed962e8614aa61dd2dff4d5

UI: remove tools space type, use properties context

We've decieded to use tools context in properties editor.

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

M	release/scripts/startup/bl_ui/space_properties.py
M	source/blender/editors/space_buttons/buttons_context.c
M	source/blender/editors/space_buttons/space_buttons.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/RNA_enum_types.h
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_properties.py b/release/scripts/startup/bl_ui/space_properties.py
index cd7137e0254..2d1725b2087 100644
--- a/release/scripts/startup/bl_ui/space_properties.py
+++ b/release/scripts/startup/bl_ui/space_properties.py
@@ -32,8 +32,7 @@ class PROPERTIES_HT_header(Header):
         row = layout.row()
         row.template_header()
 
-        if view.mode == 'DATA_PROPERTIES':
-            row.prop(view, "context", expand=True, icon_only=True)
+        row.prop(view, "context", expand=True, icon_only=True)
 
 
 classes = (
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index 9caf381c93d..dd943e7988d 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -489,7 +489,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
 	}
 	/* No pinned root, use scene as initial root. */
 	else {
-		if (mainb == BCONTEXT_WORKSPACE) {
+		if (ELEM(mainb, BCONTEXT_WORKSPACE, BCONTEXT_TOOL)) {
 			RNA_id_pointer_create(&workspace->id, &path->ptr[0]);
 			path->len++;
 		}
@@ -525,6 +525,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
 		case BCONTEXT_WORLD:
 			found = buttons_context_path_world(path);
 			break;
+		case BCONTEXT_TOOL:
 		case BCONTEXT_WORKSPACE:
 			found = buttons_context_path_workspace(path);
 			break;
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 11857dd0b27..3787398c9e3 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -144,7 +144,6 @@ static void buttons_main_region_init(wmWindowManager *wm, ARegion *ar)
 
 static void buttons_main_region_draw_properties(const bContext *C, SpaceButs *sbuts, ARegion *ar)
 {
-	BLI_assert(sbuts->space_subtype == SB_SUBTYPE_DATA);
 	const bool vertical = (sbuts->align == BUT_VERTICAL);
 
 	buttons_context_compute(C, sbuts);
@@ -197,6 +196,9 @@ static void buttons_main_region_draw_properties(const bContext *C, SpaceButs *sb
 		case BCONTEXT_BONE_CONSTRAINT:
 			contexts[0] = "bone_constraint";
 			break;
+		case BCONTEXT_TOOL:
+			contexts[0] = "tool";
+			break;
 	}
 
 	if (contexts[0]) {
@@ -206,7 +208,6 @@ static void buttons_main_region_draw_properties(const bContext *C, SpaceButs *sb
 
 static void buttons_main_region_draw_tool(const bContext *C, SpaceButs *sbuts, ARegion *ar)
 {
-	BLI_assert(sbuts->space_subtype == SB_SUBTYPE_TOOL);
 	const bool vertical = (sbuts->align == BUT_VERTICAL);
 
 	const WorkSpace *workspace = CTX_wm_workspace(C);
@@ -271,12 +272,12 @@ static void buttons_main_region_draw(const bContext *C, ARegion *ar)
 	/* draw entirely, view changes should be handled here */
 	SpaceButs *sbuts = CTX_wm_space_buts(C);
 
-	if (sbuts->space_subtype == SB_SUBTYPE_DATA) {
-		buttons_main_region_draw_properties(C, sbuts, ar);
-	}
-	else if (sbuts->space_subtype == SB_SUBTYPE_TOOL) {
+	if (sbuts->mainb == BCONTEXT_TOOL) {
 		buttons_main_region_draw_tool(C, sbuts, ar);
 	}
+	else {
+		buttons_main_region_draw_properties(C, sbuts, ar);
+	}
 
 	sbuts->re_align = 0;
 	sbuts->mainbo = sbuts->mainb;
@@ -320,10 +321,8 @@ static void buttons_header_region_draw(const bContext *C, ARegion *ar)
 {
 	SpaceButs *sbuts = CTX_wm_space_buts(C);
 
-	if (sbuts->space_subtype == SB_SUBTYPE_DATA) {
-		/* Needed for RNA to get the good values! */
-		buttons_context_compute(C, sbuts);
-	}
+	/* Needed for RNA to get the good values! */
+	buttons_context_compute(C, sbuts);
 
 	ED_region_header(C, ar);
 }
@@ -590,24 +589,6 @@ static void buttons_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id,
 	}
 }
 
-static int buttons_space_subtype_get(ScrArea *sa)
-{
-	SpaceButs *sbuts = sa->spacedata.first;
-	return sbuts->space_subtype;
-}
-
-static void buttons_space_subtype_set(ScrArea *sa, int value)
-{
-	SpaceButs *sbuts = sa->spacedata.first;
-	sbuts->space_subtype = value;
-}
-
-static void buttons_space_subtype_item_extend(
-        bContext *UNUSED(C), EnumPropertyItem **item, int *totitem)
-{
-	RNA_enum_items_add(item, totitem, rna_enum_space_button_mode_items);
-}
-
 /* only called once, from space/spacetypes.c */
 void ED_spacetype_buttons(void)
 {
@@ -626,9 +607,6 @@ void ED_spacetype_buttons(void)
 	st->listener = buttons_area_listener;
 	st->context = buttons_context;
 	st->id_remap = buttons_id_remap;
-	st->space_subtype_item_extend = buttons_space_subtype_item_extend;
-	st->space_subtype_get = buttons_space_subtype_get;
-	st->space_subtype_set = buttons_space_subtype_set;
 
 	/* regions: main window */
 	art = MEM_callocN(sizeof(ARegionType), "spacetype buttons region");
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index d867e05f209..18fd17c006e 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -196,6 +196,7 @@ typedef enum eSpaceButtons_Context {
 	BCONTEXT_CONSTRAINT = 11,
 	BCONTEXT_BONE_CONSTRAINT = 12,
 	BCONTEXT_VIEW_LAYER = 13,
+	BCONTEXT_TOOL = 14,
 	BCONTEXT_WORKSPACE = 15,
 
 	/* always as last... */
@@ -220,12 +221,6 @@ typedef enum eSpaceButtons_Align {
 	BUT_AUTO = 3,
 } eSpaceButtons_Align;
 
-/* SpaceButs.flag */
-typedef enum eSpaceButtons_SubType {
-	SB_SUBTYPE_DATA = 0,
-	SB_SUBTYPE_TOOL = 1,
-} eSpaceButtons_SubType;
-
 /** \} */
 
 /* -------------------------------------------------------------------- */
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index 788b1372fc8..da2705d4660 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -57,7 +57,6 @@ extern const EnumPropertyItem rna_enum_mesh_select_mode_items[];
 extern const EnumPropertyItem rna_enum_mesh_delimit_mode_items[];
 extern const EnumPropertyItem rna_enum_space_type_items[];
 extern const EnumPropertyItem rna_enum_space_image_mode_items[];
-extern const EnumPropertyItem rna_enum_space_button_mode_items[];
 extern const EnumPropertyItem rna_enum_region_type_items[];
 extern const EnumPropertyItem rna_enum_object_modifier_type_items[];
 extern const EnumPropertyItem rna_enum_constraint_type_items[];
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 1db826bdb43..3daf4ca6fe0 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -114,13 +114,6 @@ const EnumPropertyItem rna_enum_space_image_mode_items[] = {
 	{0, NULL, 0, NULL, NULL}
 };
 
-/* Expanded into the Space.ui_type enum. */
-const EnumPropertyItem rna_enum_space_button_mode_items[] = {
-	{SB_SUBTYPE_DATA, "DATA_PROPERTIES", ICON_BUTS, "Data Properties", "Edit properties of active object and related data-blocks"},
-	{SB_SUBTYPE_TOOL, "TOOL_PROPERTIES", ICON_PREFERENCES, "Tool Properties", "Edit tool settings"},
-	{0, NULL, 0, NULL, NULL}
-};
-
 #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", ""},
@@ -218,6 +211,7 @@ const EnumPropertyItem rna_enum_clip_editor_mode_items[] = {
 
 /* Actually populated dynamically trough a function, but helps for context-less access (e.g. doc, i18n...). */
 static const EnumPropertyItem buttons_context_items[] = {
+	{BCONTEXT_TOOL, "TOOL", ICON_PREFERENCES, "Tool", "Tool settings"},
 	{BCONTEXT_SCENE, "SCENE", ICON_SCENE_DATA, "Scene", "Scene"},
 	{BCONTEXT_RENDER, "RENDER", ICON_SCENE, "Render", "Render"},
 	{BCONTEXT_VIEW_LAYER, "VIEW_LAYER", ICON_RENDER_RESULT, "View Layer", "View layer"},
@@ -1182,6 +1176,10 @@ static const EnumPropertyItem *rna_SpaceProperties_context_itemf(
 	EnumPropertyItem *item = NULL;
 	int totitem = 0;
 
+	if (sbuts->pathflag & (1 << BCONTEXT_TOOL)) {
+		RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_TOOL);
+	}
+
 	if (sbuts->pathflag & (1 << BCONTEXT_RENDER)) {
 		RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_RENDER);
 	}
@@ -3076,13 +3074,6 @@ static void rna_def_space_buttons(BlenderRNA *brna)
 	RNA_def_struct_sdna(srna, "SpaceButs");
 	RNA_def_struct_ui_text(srna, "Properties Space", "Properties space data");
 
-	/* Not exposed to the UI (access via space-type selector). */
-	prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
-	RNA_def_property_enum_sdna(prop, NULL, "space_subtype");
-	RNA_def_property_enum_items(prop, rna_enum_space_button_mode_items);
-	RNA_def_property_ui_text(prop, "Mode", "Arrangement of the panels");
-	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_PROPERTIES, NULL);
-
 	prop = RNA_def_property(srna, "context", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "mainb");
 	RNA_def_property_enum_items(prop, buttons_context_items);



More information about the Bf-blender-cvs mailing list