[Bf-blender-cvs] [6991b477d7a] blender2.8: UI: expose Driver as a space type

Campbell Barton noreply at git.blender.org
Wed Jun 20 18:47:08 CEST 2018


Commit: 6991b477d7adcea2426110c9e53482db6b7d3f90
Author: Campbell Barton
Date:   Wed Jun 20 18:45:56 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB6991b477d7adcea2426110c9e53482db6b7d3f90

UI: expose Driver as a space type

See: T54744

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

M	release/scripts/startup/bl_ui/space_graph.py
M	source/blender/editors/space_graph/space_graph.c
M	source/blender/editors/space_node/space_node.c
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_graph.py b/release/scripts/startup/bl_ui/space_graph.py
index e655f9d5d15..6aeef4d7240 100644
--- a/release/scripts/startup/bl_ui/space_graph.py
+++ b/release/scripts/startup/bl_ui/space_graph.py
@@ -36,7 +36,8 @@ class GRAPH_HT_header(Header):
         row = layout.row(align=True)
         row.template_header()
 
-        layout.prop(st, "mode", text="")
+        # Now a exposed as a sub-space type
+        # layout.prop(st, "mode", text="")
 
         GRAPH_MT_editor_menus.draw_collapsible(context, layout)
 
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index d208ead317b..7c3105843c5 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -60,6 +60,8 @@
 #include "WM_message.h"
 
 #include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
 
 #include "UI_resources.h"
 #include "UI_view2d.h"
@@ -799,6 +801,24 @@ static void graph_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID
 	}
 }
 
+static int graph_space_subtype_get(ScrArea *sa)
+{
+	SpaceIpo *sgraph = sa->spacedata.first;
+	return sgraph->mode;
+}
+
+static void graph_space_subtype_set(ScrArea *sa, int value)
+{
+	SpaceIpo *sgraph = sa->spacedata.first;
+	sgraph->mode = value;
+}
+
+static void graph_space_subtype_item_extend(
+        bContext *UNUSED(C), EnumPropertyItem **item, int *totitem)
+{
+	RNA_enum_items_add(item, totitem, rna_enum_space_graph_mode_items);
+}
+
 /* only called once, from space/spacetypes.c */
 void ED_spacetype_ipo(void)
 {
@@ -817,6 +837,9 @@ void ED_spacetype_ipo(void)
 	st->listener = graph_listener;
 	st->refresh = graph_refresh;
 	st->id_remap = graph_id_remap;
+	st->space_subtype_item_extend = graph_space_subtype_item_extend;
+	st->space_subtype_get = graph_space_subtype_get;
+	st->space_subtype_set = graph_space_subtype_set;
 
 	/* regions: main window */
 	art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
@@ -867,4 +890,3 @@ void ED_spacetype_ipo(void)
 
 	BKE_spacetype_register(st);
 }
-
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 441ab03cb28..14ba9280a75 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -1045,4 +1045,3 @@ void ED_spacetype_node(void)
 
 	BKE_spacetype_register(st);
 }
-
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index da2705d4660..cb82ab8a88f 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -55,6 +55,7 @@ extern const EnumPropertyItem rna_enum_snap_node_element_items[];
 extern const EnumPropertyItem rna_enum_curve_fit_method_items[];
 extern const EnumPropertyItem rna_enum_mesh_select_mode_items[];
 extern const EnumPropertyItem rna_enum_mesh_delimit_mode_items[];
+extern const EnumPropertyItem rna_enum_space_graph_mode_items[];
 extern const EnumPropertyItem rna_enum_space_type_items[];
 extern const EnumPropertyItem rna_enum_space_image_mode_items[];
 extern const EnumPropertyItem rna_enum_region_type_items[];
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 34d393c7b62..5b1800e808c 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -106,6 +106,12 @@ const EnumPropertyItem rna_enum_space_type_items[] = {
 	{0, NULL, 0, NULL, NULL}
 };
 
+const EnumPropertyItem rna_enum_space_graph_mode_items[] = {
+	{SIPO_MODE_ANIMATION, "FCURVES", ICON_IPO, "Graph Editor",
+	 "Edit animation/keyframes displayed as 2D curves"},
+	{SIPO_MODE_DRIVERS, "DRIVERS", ICON_DRIVER, "Drivers", "Edit drivers"},
+	{0, NULL, 0, NULL, NULL}
+};
 
 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"},
@@ -3672,13 +3678,6 @@ static void rna_def_space_graph(BlenderRNA *brna)
 	StructRNA *srna;
 	PropertyRNA *prop;
 
-	static const EnumPropertyItem mode_items[] = {
-		{SIPO_MODE_ANIMATION, "FCURVES", ICON_IPO, "F-Curve",
-		 "Edit animation/keyframes displayed as 2D curves"},
-		{SIPO_MODE_DRIVERS, "DRIVERS", ICON_DRIVER, "Drivers", "Edit drivers"},
-		{0, NULL, 0, NULL, NULL}
-	};
-
 	/* this is basically the same as the one for the 3D-View, but with some entries omitted */
 	static const EnumPropertyItem gpivot_items[] = {
 		{V3D_AROUND_CENTER_BOUNDS, "BOUNDING_BOX_CENTER", ICON_ROTATE, "Bounding Box Center", ""},
@@ -3697,7 +3696,7 @@ static void rna_def_space_graph(BlenderRNA *brna)
 	/* 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, mode_items);
+	RNA_def_property_enum_items(prop, rna_enum_space_graph_mode_items);
 	RNA_def_property_ui_text(prop, "Mode", "Editing context being displayed");
 	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, "rna_SpaceGraphEditor_display_mode_update");



More information about the Bf-blender-cvs mailing list