[Bf-blender-cvs] [ff377b9c163] topbar: Don't allow changing area into topbar editor, hide its menu item

Julian Eisel noreply at git.blender.org
Thu Apr 19 11:55:38 CEST 2018


Commit: ff377b9c1638bae9a4bff9c70233e80fb0749f8a
Author: Julian Eisel
Date:   Thu Apr 19 11:52:27 2018 +0200
Branches: topbar
https://developer.blender.org/rBff377b9c1638bae9a4bff9c70233e80fb0749f8a

Don't allow changing area into topbar editor, hide its menu item

We probably want to allow Python scripts to check if an area is the
topbar or later the status bar. Not sure if that'll work right now, I
can't test since global areas are not iterable through BPY at all.
Maybe that's fine too ;)

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

M	source/blender/makesrna/intern/rna_screen.c
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index 593f5aa669d..61ec6339ce8 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -136,10 +136,22 @@ static int rna_Screen_fullscreen_get(PointerRNA *ptr)
 /* UI compatible list: should not be needed, but for now we need to keep EMPTY
  * at least in the static version of this enum for python scripts. */
 static const EnumPropertyItem *rna_Area_type_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr),
-                                             PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
+                                             PropertyRNA *UNUSED(prop), bool *r_free)
 {
+	EnumPropertyItem *item = NULL;
+	int totitem = 0;
+
 	/* +1 to skip SPACE_EMPTY */
-	return rna_enum_space_type_items + 1;
+	for (const EnumPropertyItem *item_from = rna_enum_space_type_items + 1; item_from->identifier; item_from++) {
+		if (ELEM(item_from->value, SPACE_TOPBAR)) {
+			continue;
+		}
+		RNA_enum_item_add(&item, &totitem, item_from);
+	}
+	RNA_enum_item_end(&item, &totitem);
+	*r_free = true;
+
+	return item;
 }
 
 static int rna_Area_type_get(PointerRNA *ptr)
@@ -151,6 +163,13 @@ static int rna_Area_type_get(PointerRNA *ptr)
 
 static void rna_Area_type_set(PointerRNA *ptr, int value)
 {
+	if (ELEM(value, SPACE_TOPBAR)) {
+		/* Special case: An area can not be set to show the top-bar editor (or
+		 * other global areas). However it should still be possible to identify
+		 * its type from Python. */
+		return;
+	}
+
 	ScrArea *sa = (ScrArea *)ptr->data;
 	sa->butspacetype = value;
 }
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 898b7811c92..304b2ae53d0 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -87,7 +87,7 @@ const EnumPropertyItem rna_enum_space_type_items[] = {
 	                "advanced editing and script development"},
 	{SPACE_INFO, "INFO", ICON_INFO, "Info", "Main menu bar and list of error messages "
 	             "(drag down to expand and display)"},
-	/* TODO: topbar shouldn't be selectable through menu. */
+	/* Special case: Top-bar isn't supposed to be a regular editor for the user. */
 	{SPACE_TOPBAR, "TOPBAR", ICON_NONE, "Top Bar", "Global bar at the top of the screen for global per-window settings"},
 
 	/* Data */
@@ -1869,6 +1869,7 @@ static void rna_def_space(BlenderRNA *brna)
 	prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "spacetype");
 	RNA_def_property_enum_items(prop, rna_enum_space_type_items);
+	/* When making this editable, take care for the special case of global areas (see rna_Area_type_set). */
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 	RNA_def_property_ui_text(prop, "Type", "Space data type");



More information about the Bf-blender-cvs mailing list