WM: split panel drawing into layout and draw

This matches changes made to the header.
This commit is contained in:
Campbell Barton 2018-06-11 18:23:36 +02:00
parent 1f1ca74476
commit 3e1f83a1dc
3 changed files with 52 additions and 14 deletions

View File

@ -76,15 +76,22 @@ void ED_region_tag_redraw_partial(struct ARegion *ar, const struct rcti *rct)
void ED_region_tag_redraw_overlay(struct ARegion *ar);
void ED_region_tag_redraw_no_rebuild(struct ARegion *ar);
void ED_region_tag_refresh_ui(struct ARegion *ar);
void ED_region_panels_init(struct wmWindowManager *wm, struct ARegion *ar);
void ED_region_panels(
const struct bContext *C, struct ARegion *ar,
const char *contexts[], int contextnr,
const bool vertical);
void ED_region_header_init(struct ARegion *ar);
void ED_region_header(const struct bContext *C, struct ARegion *ar);
void ED_region_header_layout(const struct bContext *C, struct ARegion *ar);
void ED_region_header_draw(const struct bContext *C, struct ARegion *ar);
void ED_region_panels_init(struct wmWindowManager *wm, struct ARegion *ar);
void ED_region_panels(
const struct bContext *C, struct ARegion *ar,
const char *contexts[], int contextnr, const bool vertical);
void ED_region_panels_layout(
const struct bContext *C, struct ARegion *ar,
const char *contexts[], int contextnr, const bool vertical);
void ED_region_panels_draw(
const struct bContext *C, struct ARegion *ar);
void ED_region_header_init(struct ARegion *ar);
void ED_region_header(const struct bContext *C, struct ARegion *ar);
void ED_region_header_layout(const struct bContext *C, struct ARegion *ar);
void ED_region_header_draw(const struct bContext *C, struct ARegion *ar);
void ED_region_cursor_set(struct wmWindow *win, struct ScrArea *sa, struct ARegion *ar);
void ED_region_toggle_hidden(struct bContext *C, struct ARegion *ar);
void ED_region_visibility_change_update(struct bContext *C, struct ARegion *ar);

View File

@ -1891,13 +1891,16 @@ 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(const bContext *C, ARegion *ar, const char *contexts[], int contextnr, const bool vertical)
void ED_region_panels_layout(
const bContext *C, ARegion *ar,
const char *contexts[], int contextnr, const bool vertical)
{
ar->runtime.category = NULL;
const WorkSpace *workspace = CTX_wm_workspace(C);
ScrArea *sa = CTX_wm_area(C);
PanelType *pt;
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
int x, y, w, em;
bool is_context_new = 0;
int scroll;
@ -2059,6 +2062,15 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *contexts[], in
#endif
}
if (use_category_tabs) {
ar->runtime.category = category;
}
}
void ED_region_panels_draw(const bContext *C, ARegion *ar)
{
View2D *v2d = &ar->v2d;
region_clear_color(C, ar, (ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK);
/* reset line width for drawing tabs */
@ -2073,16 +2085,27 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *contexts[], in
/* restore view matrix */
UI_view2d_view_restore(C);
if (use_category_tabs) {
UI_panel_category_draw_all(ar, category);
/* Set in layout. */
if (ar->runtime.category) {
UI_panel_category_draw_all(ar, ar->runtime.category);
}
/* scrollers */
scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
View2DScrollers *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_free(scrollers);
}
void ED_region_panels(
const bContext *C, ARegion *ar,
const char *contexts[], int contextnr, const bool vertical)
{
/* TODO: remove? */
ED_region_panels_layout(C, ar, contexts, contextnr, vertical);
ED_region_panels_draw(C, ar);
}
void ED_region_panels_init(wmWindowManager *wm, ARegion *ar)
{
wmKeyMap *keymap;

View File

@ -309,6 +309,12 @@ typedef struct ScrArea {
ScrArea_Runtime runtime;
} ScrArea;
typedef struct ARegion_Runtime {
/* Panel category to use between 'layout' and 'draw'. */
const char *category;
} ARegion_Runtime;
typedef struct ARegion {
struct ARegion *next, *prev;
@ -347,6 +353,8 @@ typedef struct ARegion {
char *headerstr; /* use this string to draw info */
void *regiondata; /* XXX 2.50, need spacedata equivalent? */
ARegion_Runtime runtime;
} ARegion;
/* area->flag */