Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-02-28 17:26:02 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-02-28 17:31:07 +0300
commitd937d06c02f62c11385c1c1f58d963fec03365d9 (patch)
treec9a7052205b4cbcc4c9219ed2e9838cc5414c56c /source/blender/makesrna
parent80d1d9629e1d4dd12aca580e3844a24f5d160356 (diff)
WorkSpace: UI filtering for add-ons
Allows for each workspace to have it's own add-ons on display. Filtering for: Panels, Menus, Keymaps & Manipulators. Automatically applies to add-ons at the moment. Access from workspace, toggled off by default once enabled, add-ons can be white-listed. See D3076
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/RNA_access.h5
-rw-r--r--source/blender/makesrna/RNA_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_access.c19
-rw-r--r--source/blender/makesrna/intern/rna_ui.c22
-rw-r--r--source/blender/makesrna/intern/rna_wm.c4
-rw-r--r--source/blender/makesrna/intern/rna_wm_manipulator.c11
-rw-r--r--source/blender/makesrna/intern/rna_workspace.c103
7 files changed, 164 insertions, 1 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 816a472559f..5e3cbeaa057 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -719,6 +719,7 @@ extern StructRNA RNA_WipeSequence;
extern StructRNA RNA_WireframeModifier;
extern StructRNA RNA_WoodTexture;
extern StructRNA RNA_WorkSpace;
+extern StructRNA RNA_wmOwnerIDs;
extern StructRNA RNA_World;
extern StructRNA RNA_WorldAmbientOcclusion;
extern StructRNA RNA_WorldLighting;
@@ -1303,6 +1304,10 @@ void RNA_property_override_status(
PointerRNA *ptr, PropertyRNA *prop, const int index,
bool *r_overridable, bool *r_overridden, bool *r_mandatory, bool *r_locked);
+void RNA_struct_state_owner_set(const char *name);
+const char *RNA_struct_state_owner_get(void);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 2a9b9ebe376..57eeb9e11e0 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -505,7 +505,6 @@ typedef struct ExtensionRNA {
StructRNA *srna;
StructCallbackFunc call;
StructFreeFunc free;
-
} ExtensionRNA;
#ifdef __cplusplus
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 1750c50b9da..0f47a461cda 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -7723,3 +7723,22 @@ bool RNA_path_resolved_create(
return false;
}
}
+
+static char rna_struct_state_owner[64];
+void RNA_struct_state_owner_set(const char *name)
+{
+ if (name) {
+ BLI_strncpy(rna_struct_state_owner, name, sizeof(rna_struct_state_owner));
+ }
+ else {
+ rna_struct_state_owner[0] = '\0';
+ }
+}
+
+const char *RNA_struct_state_owner_get(void)
+{
+ if (rna_struct_state_owner[0]) {
+ return rna_struct_state_owner;
+ }
+ return NULL;
+}
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index f2527a8a5e9..40657b3a225 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -267,6 +267,13 @@ static StructRNA *rna_Panel_register(
else
BLI_addtail(&art->paneltypes, pt);
+ {
+ const char *owner_id = RNA_struct_state_owner_get();
+ if (owner_id) {
+ BLI_strncpy(pt->owner_id, owner_id, sizeof(pt->owner_id));
+ }
+ }
+
/* update while blender is running */
WM_main_add_notifier(NC_WINDOW, NULL);
@@ -773,6 +780,13 @@ static StructRNA *rna_Menu_register(
mt->poll = (have_function[0]) ? menu_poll : NULL;
mt->draw = (have_function[1]) ? menu_draw : NULL;
+ {
+ const char *owner_id = RNA_struct_state_owner_get();
+ if (owner_id) {
+ BLI_strncpy(mt->owner_id, owner_id, sizeof(mt->owner_id));
+ }
+ }
+
WM_menutype_add(mt);
/* update while blender is running */
@@ -1023,6 +1037,10 @@ static void rna_def_panel(BlenderRNA *brna)
RNA_def_property_string_sdna(prop, NULL, "type->category");
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+ prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "type->owner_id");
+ RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+
prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "type->space_type");
RNA_def_property_enum_items(prop, rna_enum_space_type_items);
@@ -1290,6 +1308,10 @@ static void rna_def_menu(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
+ prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "type->owner_id");
+ RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+
RNA_define_verify_sdna(1);
}
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index e827a099f5b..5110f4cc27a 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -2253,6 +2253,10 @@ static void rna_def_keyconfig(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Name", "Name of the key map");
RNA_def_struct_name_property(srna, prop);
+ prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "owner_id");
+ RNA_def_property_ui_text(prop, "Owner", "Internal owner");
+
prop = RNA_def_property(srna, "space_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "spaceid");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c
index d6de12407b0..bb40a12f5d5 100644
--- a/source/blender/makesrna/intern/rna_wm_manipulator.c
+++ b/source/blender/makesrna/intern/rna_wm_manipulator.c
@@ -806,6 +806,13 @@ static StructRNA *rna_ManipulatorGroup_register(
wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_append_ptr(
BPY_RNA_manipulatorgroup_wrapper, (void *)&dummywgt);
+ {
+ const char *owner_id = RNA_struct_state_owner_get();
+ if (owner_id) {
+ BLI_strncpy(wgt->owner_id, owner_id, sizeof(wgt->owner_id));
+ }
+ }
+
if (wgt->flag & WM_MANIPULATORGROUPTYPE_PERSISTENT) {
WM_manipulator_group_type_add_ptr_ex(wgt, mmap_type);
@@ -1204,6 +1211,10 @@ static void rna_def_manipulatorgroup(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_REGISTER);
RNA_def_property_ui_text(prop, "Region Type", "The region where the panel is going to be used in");
+ prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "type->owner_id");
+ RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
+
/* bl_options */
static EnumPropertyItem manipulatorgroup_flag_items[] = {
{WM_MANIPULATORGROUPTYPE_3D, "3D", 0, "3D",
diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c
index 5e0a4b97981..7ac4134f02b 100644
--- a/source/blender/makesrna/intern/rna_workspace.c
+++ b/source/blender/makesrna/intern/rna_workspace.c
@@ -52,6 +52,10 @@
#include "RNA_access.h"
+static void rna_window_update_all(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+{
+ WM_main_add_notifier(NC_WINDOW, NULL);
+}
void rna_workspace_screens_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
@@ -79,8 +83,94 @@ static PointerRNA rna_workspace_transform_orientations_item_get(CollectionProper
return rna_pointer_inherit_refine(&iter->parent, &RNA_TransformOrientation, transform_orientation);
}
+/* workspace.owner_ids */
+
+static wmOwnerID *rna_WorkSpace_owner_ids_new(
+ WorkSpace *workspace, const char *name)
+{
+ wmOwnerID *owner_id = MEM_callocN(sizeof(*owner_id), __func__);
+ BLI_addtail(&workspace->owner_ids, owner_id);
+ BLI_strncpy(owner_id->name, name, sizeof(owner_id->name));
+ WM_main_add_notifier(NC_WINDOW, NULL);
+ return owner_id;
+}
+
+static void rna_WorkSpace_owner_ids_remove(
+ WorkSpace *workspace, ReportList *reports, PointerRNA *wstag_ptr)
+{
+ wmOwnerID *owner_id = wstag_ptr->data;
+ if (BLI_remlink_safe(&workspace->owner_ids, owner_id) == false) {
+ BKE_reportf(reports, RPT_ERROR,
+ "wmOwnerID '%s' not in workspace '%s'",
+ owner_id->name, workspace->id.name + 2);
+ return;
+ }
+
+ MEM_freeN(owner_id);
+ RNA_POINTER_INVALIDATE(wstag_ptr);
+
+ WM_main_add_notifier(NC_WINDOW, NULL);
+}
+
+static void rna_WorkSpace_owner_ids_clear(
+ WorkSpace *workspace)
+{
+ BLI_freelistN(&workspace->owner_ids);
+ WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, workspace);
+}
+
#else /* RNA_RUNTIME */
+static void rna_def_workspace_owner(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "wmOwnerID", NULL);
+ RNA_def_struct_sdna(srna, "wmOwnerID");
+ RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
+ RNA_def_struct_ui_text(srna, "Work Space UI Tag", "");
+
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Name", "");
+ RNA_def_struct_name_property(srna, prop);
+}
+
+static void rna_def_workspace_owner_ids(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "wmOwnerIDs");
+ srna = RNA_def_struct(brna, "wmOwnerIDs", NULL);
+ RNA_def_struct_sdna(srna, "WorkSpace");
+ RNA_def_struct_ui_text(srna, "WorkSpace UI Tags", "");
+
+ /* add owner_id */
+ func = RNA_def_function(srna, "new", "rna_WorkSpace_owner_ids_new");
+ RNA_def_function_ui_description(func, "Add ui tag");
+ parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the tag");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ /* return type */
+ parm = RNA_def_pointer(func, "owner_id", "wmOwnerID", "", "");
+ RNA_def_function_return(func, parm);
+
+ /* remove owner_id */
+ func = RNA_def_function(srna, "remove", "rna_WorkSpace_owner_ids_remove");
+ RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ RNA_def_function_ui_description(func, "Remove ui tag");
+ /* owner_id to remove */
+ parm = RNA_def_pointer(func, "owner_id", "wmOwnerID", "", "Tag to remove");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
+ RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
+
+ /* clear all modifiers */
+ func = RNA_def_function(srna, "clear", "rna_WorkSpace_owner_ids_clear");
+ RNA_def_function_ui_description(func, "Remove all tags");
+}
+
static void rna_def_workspace(BlenderRNA *brna)
{
StructRNA *srna;
@@ -121,6 +211,11 @@ static void rna_def_workspace(BlenderRNA *brna)
"rna_workspace_transform_orientations_item_get", NULL, NULL, NULL, NULL);
RNA_def_property_ui_text(prop, "Transform Orientations", "");
+ prop = RNA_def_property(srna, "owner_ids", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_struct_type(prop, "wmOwnerID");
+ RNA_def_property_ui_text(prop, "UI Tags", "");
+ rna_def_workspace_owner_ids(brna, prop);
+
prop = RNA_def_property(srna, "object_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_object_mode_items);
RNA_def_property_ui_text(prop, "Mode", "Object interaction mode used in this window");
@@ -138,6 +233,13 @@ static void rna_def_workspace(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Scene Settings",
"Use scene settings instead of workspace settings");
RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, NULL);
+
+ prop = RNA_def_property(srna, "use_filter_by_owner", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flags", WORKSPACE_USE_FILTER_BY_ORIGIN);
+ RNA_def_property_ui_text(prop, "Use UI Tags",
+ "Filter the UI by tags");
+ RNA_def_property_update(prop, 0, "rna_window_update_all");
}
static void rna_def_transform_orientation(BlenderRNA *brna)
@@ -160,6 +262,7 @@ static void rna_def_transform_orientation(BlenderRNA *brna)
void RNA_def_workspace(BlenderRNA *brna)
{
+ rna_def_workspace_owner(brna);
rna_def_workspace(brna);
rna_def_transform_orientation(brna);
}