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-10-26 07:05:07 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-10-26 07:05:07 +0300
commit6be7a98906b769c1496127552b524124a0e70c5a (patch)
tree9b20ec2147c656e815adb4688045acbb5af3e074 /source/blender
parent4c75cc488a49ff9dedf9b0aa520f8688d753b987 (diff)
PyAPI: raise error when toolbar panels use tabs
Add-ons that register panels in the toolbar can no longer use 'bl_categories' (tabs).
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/screen/area.c2
-rw-r--r--source/blender/makesdna/DNA_screen_types.h3
-rw-r--r--source/blender/makesrna/intern/rna_ui.c19
-rw-r--r--source/blender/windowmanager/WM_toolsystem.h3
4 files changed, 22 insertions, 5 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 5faa35729c4..b914dd5ecae 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2076,7 +2076,7 @@ void ED_region_panels_layout_ex(
int scroll;
/* XXX, should use some better check? */
- bool use_category_tabs = (ELEM(ar->regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI));
+ bool use_category_tabs = (1 << ar->regiontype) & RGN_TYPE_HAS_CATEGORY_MASK;
/* offset panels for small vertical tab area */
const char *category = NULL;
const int category_tabs_width = UI_PANEL_CATEGORY_MARGIN_WIDTH;
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index 9a57f1ae37b..50bf24e0b55 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -477,6 +477,9 @@ enum {
/* use for function args */
#define RGN_TYPE_ANY -1
+/* Region supports panel tabs (categories). */
+#define RGN_TYPE_HAS_CATEGORY_MASK (1 << RGN_TYPE_UI)
+
/* region alignment */
#define RGN_ALIGN_NONE 0
#define RGN_ALIGN_TOP 1
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index 0756d5e39ee..9d395f3ec9b 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
#include "BLT_translation.h"
@@ -41,6 +42,7 @@
#include "UI_interface.h"
#include "WM_types.h"
+#include "WM_toolsystem.h"
/* see WM_types.h */
const EnumPropertyItem rna_enum_operator_context_items[] = {
@@ -243,9 +245,20 @@ static StructRNA *rna_Panel_register(
return NULL;
}
- if ((dummypt.category[0] == '\0') && (dummypt.region_type == RGN_TYPE_TOOLS)) {
- /* Use a fallback, otherwise an empty value will draw the panel in every category. */
- strcpy(dummypt.category, PNL_CATEGORY_FALLBACK);
+ if ((1 << dummypt.region_type) & RGN_TYPE_HAS_CATEGORY_MASK) {
+ if (dummypt.category[0] == '\0') {
+ /* Use a fallback, otherwise an empty value will draw the panel in every category. */
+ strcpy(dummypt.category, PNL_CATEGORY_FALLBACK);
+ }
+ }
+ else {
+ if (dummypt.category[0] != '\0') {
+ if ((1 << dummypt.space_type) & WM_TOOLSYSTEM_SPACE_MASK) {
+ BKE_reportf(reports, RPT_ERROR, "Registering panel class: '%s' has category '%s' ",
+ dummypt.idname, dummypt.category);
+ return NULL;
+ }
+ }
}
if (!(art = region_type_find(reports, dummypt.space_type, dummypt.region_type)))
diff --git a/source/blender/windowmanager/WM_toolsystem.h b/source/blender/windowmanager/WM_toolsystem.h
index 21408896877..fd61e5c9699 100644
--- a/source/blender/windowmanager/WM_toolsystem.h
+++ b/source/blender/windowmanager/WM_toolsystem.h
@@ -41,6 +41,7 @@ struct PointerRNA;
struct ScrArea;
struct Main;
struct StructRNA;
+struct WorkSpace;
/* wm_toolsystem.c */
@@ -58,7 +59,7 @@ bool WM_toolsystem_ref_ensure(
struct WorkSpace *workspace, const bToolKey *tkey,
struct bToolRef **r_tref);
struct bToolRef *WM_toolsystem_ref_set_by_name(
- bContext *C, struct WorkSpace *workspace, const bToolKey *tkey,
+ struct bContext *C, struct WorkSpace *workspace, const bToolKey *tkey,
const char *name, bool cycle);
struct bToolRef_Runtime *WM_toolsystem_runtime_from_context(struct bContext *C);