WM: use layout/draw callbacks for buttons space

This commit is contained in:
Campbell Barton 2018-06-11 18:36:00 +02:00
parent 3e1f83a1dc
commit 3df809958b
1 changed files with 8 additions and 13 deletions

View File

@ -144,7 +144,7 @@ static void buttons_main_region_init(wmWindowManager *wm, ARegion *ar)
WM_event_add_keymap_handler(&ar->handlers, keymap);
}
static void buttons_main_region_draw_properties(const bContext *C, SpaceButs *sbuts, ARegion *ar)
static void buttons_main_region_layout_properties(const bContext *C, SpaceButs *sbuts, ARegion *ar)
{
const bool vertical = (sbuts->align == BUT_VERTICAL);
@ -208,7 +208,7 @@ static void buttons_main_region_draw_properties(const bContext *C, SpaceButs *sb
}
}
static void buttons_main_region_draw_tool(const bContext *C, SpaceButs *sbuts, ARegion *ar)
static void buttons_main_region_layout_tool(const bContext *C, SpaceButs *sbuts, ARegion *ar)
{
const bool vertical = (sbuts->align == BUT_VERTICAL);
const char *contexts[3] = {NULL};
@ -260,30 +260,24 @@ static void buttons_main_region_draw_tool(const bContext *C, SpaceButs *sbuts, A
ARRAY_SET_ITEMS(contexts, ".todo");
break;
}
if (contexts[0]) {
ED_region_panels(C, ar, contexts, -1, vertical);
}
}
else if (workspace->tools_space_type == SPACE_IMAGE) {
/* TODO */
}
if (contexts[0] == NULL) {
UI_ThemeClearColor(TH_BACK);
glClear(GL_COLOR_BUFFER_BIT);
}
ED_region_panels_layout(C, ar, contexts, -1, vertical);
}
static void buttons_main_region_draw(const bContext *C, ARegion *ar)
static void buttons_main_region_layout(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
SpaceButs *sbuts = CTX_wm_space_buts(C);
if (sbuts->mainb == BCONTEXT_TOOL) {
buttons_main_region_draw_tool(C, sbuts, ar);
buttons_main_region_layout_tool(C, sbuts, ar);
}
else {
buttons_main_region_draw_properties(C, sbuts, ar);
buttons_main_region_layout_properties(C, sbuts, ar);
}
sbuts->re_align = 0;
@ -619,7 +613,8 @@ void ED_spacetype_buttons(void)
art = MEM_callocN(sizeof(ARegionType), "spacetype buttons region");
art->regionid = RGN_TYPE_WINDOW;
art->init = buttons_main_region_init;
art->draw = buttons_main_region_draw;
art->layout = buttons_main_region_layout;
art->draw = ED_region_panels_draw;
art->listener = buttons_main_region_listener;
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
BLI_addhead(&st->regiontypes, art);