diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-05-10 06:43:07 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-05-10 06:48:25 +0300 |
commit | 6b082278d19599100cc0b50cc96e4fa00865d093 (patch) | |
tree | d5f7341c5f53d1282d71383218f2a9f8d46c1caa /source/blender/editors/screen | |
parent | a287153ee49741e23dbee273a6ad7425dab94de4 (diff) |
UI: expose tool settings in the 3D view side-bar
Internally tool settings have been moved to the 3D view.
Added the ability for to draw panels from another space/region
so they can be mirrored in the properties editor.
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/area.c | 86 |
1 files changed, 49 insertions, 37 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index b359a4c4440..d74d4a0d798 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -2300,14 +2300,48 @@ static void ed_panel_draw(const bContext *C, * Matching against any of these strings will draw the panel. * Can be NULL to skip context checks. */ -void ED_region_panels_layout_ex( - const bContext *C, ARegion *ar, const char *contexts[], int contextnr, const bool vertical) +void ED_region_panels_layout_ex(const bContext *C, + ARegion *ar, + ListBase *paneltypes, + const char *contexts[], + int contextnr, + const bool vertical, + const char *category_override) { + /* collect panels to draw */ + LinkNode *panel_types_stack = NULL; + for (PanelType *pt = paneltypes->last; pt; pt = pt->prev) { + WorkSpace *workspace = CTX_wm_workspace(C); + /* Only draw top level panels. */ + if (pt->parent) { + continue; + } + + if (category_override) { + if (!STREQ(pt->category, category_override)) { + continue; + } + } + + /* verify context */ + if (contexts && pt->context[0] && !streq_array_any(pt->context, contexts)) { + continue; + } + + /* If we're tagged, only use compatible. */ + if (pt->owner_id[0] && BKE_workspace_owner_id_check(workspace, pt->owner_id) == false) { + continue; + } + + /* draw panel */ + if (pt->draw && (!pt->poll || pt->poll(C, pt))) { + BLI_linklist_prepend_alloca(&panel_types_stack, pt); + } + } + ar->runtime.category = NULL; - const WorkSpace *workspace = CTX_wm_workspace(C); ScrArea *sa = CTX_wm_area(C); - PanelType *pt; View2D *v2d = &ar->v2d; int x, y, w, em; bool is_context_new = 0; @@ -2315,16 +2349,15 @@ void ED_region_panels_layout_ex( /* XXX, should use some better check? */ /* For now also has hardcoded check for clip editor until it supports actual toolbar. */ - bool use_category_tabs = ((1 << ar->regiontype) & RGN_TYPE_HAS_CATEGORY_MASK) || - (ar->regiontype == RGN_TYPE_TOOLS && sa->spacetype == SPACE_CLIP); + bool use_category_tabs = (category_override == NULL) && + ((((1 << ar->regiontype) & RGN_TYPE_HAS_CATEGORY_MASK) || + (ar->regiontype == RGN_TYPE_TOOLS && sa->spacetype == SPACE_CLIP))); /* offset panels for small vertical tab area */ const char *category = NULL; const int category_tabs_width = UI_PANEL_CATEGORY_MARGIN_WIDTH; int margin_x = 0; const bool region_layout_based = ar->flag & RGN_FLAG_DYNAMIC_SIZE; - BLI_SMALLSTACK_DECLARE(pt_stack, PanelType *); - if (contextnr != -1) { is_context_new = UI_view2d_tab_set(v2d, contextnr); } @@ -2348,42 +2381,19 @@ void ED_region_panels_layout_ex( scroll = v2d->scroll; - /* collect panels to draw */ - for (pt = ar->type->paneltypes.last; pt; pt = pt->prev) { - /* Only draw top level panels. */ - if (pt->parent) { - continue; - } - - /* verify context */ - if (contexts && pt->context[0] && !streq_array_any(pt->context, contexts)) { - continue; - } - - /* If we're tagged, only use compatible. */ - if (pt->owner_id[0] && BKE_workspace_owner_id_check(workspace, pt->owner_id) == false) { - continue; - } - - /* draw panel */ - if (pt->draw && (!pt->poll || pt->poll(C, pt))) { - BLI_SMALLSTACK_PUSH(pt_stack, pt); - } - } - /* collect categories */ if (use_category_tabs) { UI_panel_category_clear_all(ar); /* gather unique categories */ - BLI_SMALLSTACK_ITER_BEGIN (pt_stack, pt) { + for (LinkNode *pt_link = panel_types_stack; pt_link; pt_link = pt_link->next) { + PanelType *pt = pt_link->link; if (pt->category[0]) { if (!UI_panel_category_find(ar, pt->category)) { UI_panel_category_add(ar, pt->category); } } } - BLI_SMALLSTACK_ITER_END; if (!UI_panel_category_is_visible(ar)) { use_category_tabs = false; @@ -2411,7 +2421,8 @@ void ED_region_panels_layout_ex( /* set view2d view matrix - UI_block_begin() stores it */ UI_view2d_view_ortho(v2d); - BLI_SMALLSTACK_ITER_BEGIN (pt_stack, pt) { + for (LinkNode *pt_link = panel_types_stack; pt_link; pt_link = pt_link->next) { + PanelType *pt = pt_link->link; Panel *panel = UI_panel_find_by_type(&ar->panels, pt); if (use_category_tabs && pt->category[0] && !STREQ(category, pt->category)) { @@ -2422,7 +2433,6 @@ void ED_region_panels_layout_ex( ed_panel_draw(C, sa, ar, &ar->panels, pt, panel, w, em, vertical); } - BLI_SMALLSTACK_ITER_END; /* align panels and return size */ UI_panels_end(C, ar, &x, &y); @@ -2493,9 +2503,11 @@ void ED_region_panels_layout_ex( ar->runtime.category = category; } } + void ED_region_panels_layout(const bContext *C, ARegion *ar) { - ED_region_panels_layout_ex(C, ar, NULL, -1, true); + bool vertical = true; + ED_region_panels_layout_ex(C, ar, &ar->type->paneltypes, NULL, -1, vertical, NULL); } void ED_region_panels_draw(const bContext *C, ARegion *ar) @@ -2544,7 +2556,7 @@ void ED_region_panels_ex( const bContext *C, ARegion *ar, const char *contexts[], int contextnr, const bool vertical) { /* TODO: remove? */ - ED_region_panels_layout_ex(C, ar, contexts, contextnr, vertical); + ED_region_panels_layout_ex(C, ar, &ar->type->paneltypes, contexts, contextnr, vertical, NULL); ED_region_panels_draw(C, ar); } |