Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/area.c
| Context not available. | |||||
| View2D *v2d = &ar->v2d; | View2D *v2d = &ar->v2d; | ||||
| View2DScrollers *scrollers; | View2DScrollers *scrollers; | ||||
| int x, y, xco, yco, w, em, triangle, open; | int x, y, xco, yco, w, em, triangle, open; | ||||
| int x_ofs = 0; | |||||
| bool is_context_new = 0; | bool is_context_new = 0; | ||||
| int redo; | int redo; | ||||
| int scroll; | int scroll; | ||||
| bool use_category_tabs = (ar->regiontype == RGN_TYPE_TOOLS); /* XXX, should use some better check? */ | |||||
brecht: Is there any reason to restrict this to the tools region instead of setting this to true and… | |||||
Not Done Inline ActionsThere isn't any important reason, since tabs wont display if none are define, we could remove this var, however it might get annoying if a single addon defines a category in an area where none of the others do (like properties), so I was thinking to make a conscious decision to only enable this for some kinds of regions. Later on we could enable more. campbellbarton: There isn't any important reason, since tabs wont display if none are define, we could remove… | |||||
| /* offset panels for small vertical tab area */ | |||||
| const char *category = NULL; | |||||
| /* XXX | |||||
| * Not totally happy to have do do this, ideally defining a small margin could be done in a cleaner way. | |||||
| * (perhaps follow something similar to what scrollbars do). - Campbell */ | |||||
| int category_tabs_width = 0; | |||||
| BLI_SMALLSTACK_DECLARE(pt_stack, PanelType *); | BLI_SMALLSTACK_DECLARE(pt_stack, PanelType *); | ||||
| if (contextnr >= 0) | if (contextnr >= 0) | ||||
| Context not available. | |||||
| } | } | ||||
| /* collect categories */ | |||||
| if (use_category_tabs) { | |||||
| UI_panel_category_clear_all(ar); | |||||
| /* gather unique categories */ | |||||
| BLI_SMALLSTACK_ITER_BEGIN(pt_stack, pt) | |||||
| { | |||||
| if (pt->category[0]) { | |||||
| if (!UI_panel_category_find(ar, pt->category)) { | |||||
| UI_panel_category_add(ar, pt->category); | |||||
| } | |||||
| } | |||||
| } | |||||
| BLI_SMALLSTACK_ITER_END; | |||||
| if (!ar->panels_category.first) { | |||||
| use_category_tabs = false; | |||||
| } | |||||
| else { | |||||
| category = UI_panel_category_active_get(ar, true); | |||||
| category_tabs_width = U.widget_unit * 0.8; | |||||
| x_ofs = category_tabs_width; | |||||
| } | |||||
| } | |||||
| /* sortof hack - but we cannot predict the height of panels, until it's being generated */ | /* sortof hack - but we cannot predict the height of panels, until it's being generated */ | ||||
| /* the layout engine works with fixed width (from v2d->cur), which is being set at end of the loop */ | /* the layout engine works with fixed width (from v2d->cur), which is being set at end of the loop */ | ||||
| /* in case scroller settings (hide flags) differ from previous, the whole loop gets done again */ | /* in case scroller settings (hide flags) differ from previous, the whole loop gets done again */ | ||||
| for (redo = 2; redo > 0; redo--) { | for (redo = 2; redo > 0; redo--) { | ||||
| if (vertical) { | if (vertical) { | ||||
| w = BLI_rctf_size_x(&v2d->cur); | w = BLI_rctf_size_x(&v2d->cur); | ||||
| em = (ar->type->prefsizex) ? UI_UNIT_Y / 2 : UI_UNIT_Y; | em = (ar->type->prefsizex) ? UI_UNIT_Y / 2 : UI_UNIT_Y; | ||||
| Context not available. | |||||
| BLI_SMALLSTACK_ITER_BEGIN(pt_stack, pt) | BLI_SMALLSTACK_ITER_BEGIN(pt_stack, pt) | ||||
| { | { | ||||
| int w_ofs, x_ofs_scale; | |||||
| if (pt->category[0] && !STREQ(category, pt->category)) | |||||
| continue; | |||||
| /* draw panel */ | |||||
Not Done Inline ActionsI'm not totally happy to have do do this, ideally defining a small margin could be done in a cleaner way. (perhaps follow something similar to what scrollbars do). campbellbarton: I'm not totally happy to have do do this, ideally defining a small margin could be done in a… | |||||
| block = uiBeginBlock(C, ar, pt->idname, UI_EMBOSS); | block = uiBeginBlock(C, ar, pt->idname, UI_EMBOSS); | ||||
| panel = uiBeginPanel(sa, ar, block, pt, &open); | panel = uiBeginPanel(sa, ar, block, pt, &open); | ||||
| /* bad fixed values */ | /* bad fixed values */ | ||||
| triangle = (int)(UI_UNIT_Y * 1.1f); | triangle = (int)(UI_UNIT_Y * 1.1f); | ||||
| x_ofs_scale = x_ofs * uiBlockGetAspect(block); | |||||
| w_ofs = w - x_ofs_scale; | |||||
| if (pt->draw_header && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) { | if (pt->draw_header && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) { | ||||
| /* for enabled buttons */ | /* for enabled buttons */ | ||||
| panel->layout = uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, | panel->layout = uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, | ||||
| triangle, (UI_UNIT_Y * 1.1f) + style->panelspace, UI_UNIT_Y, 1, style); | triangle, (UI_UNIT_Y * 1.1f) + style->panelspace, | ||||
| UI_UNIT_Y, 1, style); | |||||
| pt->draw_header(C, panel); | pt->draw_header(C, panel); | ||||
| Context not available. | |||||
| panel->labelofs = 0; | panel->labelofs = 0; | ||||
| } | } | ||||
| if (use_category_tabs) { | |||||
| panel->labelofs += x_ofs_scale; | |||||
| } | |||||
| if (open) { | if (open) { | ||||
| short panelContext; | short panelContext; | ||||
| Context not available. | |||||
| panelContext = UI_LAYOUT_PANEL; | panelContext = UI_LAYOUT_PANEL; | ||||
| panel->layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, panelContext, | panel->layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, panelContext, | ||||
| style->panelspace, 0, w - 2 * style->panelspace, em, style); | style->panelspace + x_ofs_scale, 0, | ||||
| w_ofs - 2 * style->panelspace, em, style); | |||||
| pt->draw(C, panel); | pt->draw(C, panel); | ||||
| Context not available. | |||||
| UI_ThemeClearColor((ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK); | UI_ThemeClearColor((ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK); | ||||
| glClear(GL_COLOR_BUFFER_BIT); | glClear(GL_COLOR_BUFFER_BIT); | ||||
| } | } | ||||
| /* set the view */ | /* set the view */ | ||||
| UI_view2d_view_ortho(v2d); | UI_view2d_view_ortho(v2d); | ||||
| Context not available. | |||||
| /* restore view matrix */ | /* restore view matrix */ | ||||
| UI_view2d_view_restore(C); | UI_view2d_view_restore(C); | ||||
| if (use_category_tabs) { | |||||
| UI_panel_category_draw_all(ar, category, category_tabs_width); | |||||
| } | |||||
| /* scrollers */ | /* scrollers */ | ||||
| scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); | scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); | ||||
| UI_view2d_scrollers_draw(C, v2d, scrollers); | UI_view2d_scrollers_draw(C, v2d, scrollers); | ||||
| Context not available. | |||||
Is there any reason to restrict this to the tools region instead of setting this to true and detecting if there are any panels that have categories?
I guess it could get out of hand with addons adding categories everywhere.