diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-31 22:39:48 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-31 22:42:02 +0300 |
commit | 14dee6d7a59f16761201798f85e60d09bd353750 (patch) | |
tree | b483eb20629057b1dd8ac5dff31734e418d88bb8 /source/blender/editors/screen | |
parent | e51cbce646c3bc94b8d5538d8b9bce53ee97a68d (diff) |
UI: support drawing panels from multiple contexts
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/area.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index f2ecf3d5ea2..b05496fc349 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1796,7 +1796,22 @@ static void region_clear_color(const bContext *C, const ARegion *ar, ThemeColorI } } -void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int contextnr, const bool vertical) +BLI_INLINE bool streq_array_any(const char *s, const char *arr[]) +{ + for (uint i = 0; arr[i]; i++) { + if (STREQ(arr[i], s)) { + return true; + } + } + return false; +} + +/** + * \param contexts: A NULL terminated array of context strings to match against. + * Matching against any of these strings will draw the panel. + * Can be NULL to skip context checks. + */ +void ED_region_panels(const bContext *C, ARegion *ar, const char *contexts[], int contextnr, const bool vertical) { const WorkSpace *workspace = CTX_wm_workspace(C); ScrArea *sa = CTX_wm_area(C); @@ -1844,7 +1859,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c /* collect panels to draw */ for (pt = ar->type->paneltypes.last; pt; pt = pt->prev) { /* verify context */ - if (context && pt->context[0] && !STREQ(context, pt->context)) { + if (contexts && pt->context[0] && !streq_array_any(pt->context, contexts)) { continue; } |