diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-11-09 23:20:40 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-11-11 01:06:54 +0300 |
commit | 5c6e3337801b493926210e96237be2b495fc5d1b (patch) | |
tree | 5ca4bd778c2d552a7eaf0645c3c1bc6be86d9e5d /source/blender/editors/screen | |
parent | 2b107beffd9b408ac1464288d07ee96214c09a30 (diff) |
UI Refactor T41640
Make the UI API more consistent and reduce confusion with some naming.
mainly:
- API function calls
- enum values
some internal static functions have been left for now
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/area.c | 96 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_context.c | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 4 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 18 |
4 files changed, 61 insertions, 59 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index ed224b2d5c2..630ff8fecf6 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -271,21 +271,21 @@ static void region_draw_azone_tab_plus(AZone *az) /* add code to draw region hidden as 'too small' */ switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); + UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); break; case AE_BOTTOM_TO_TOPLEFT: - uiSetRoundBox(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT); + UI_draw_roundbox_corner_set(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT); break; case AE_LEFT_TO_TOPRIGHT: - uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT); + UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT); break; case AE_RIGHT_TO_TOPLEFT: - uiSetRoundBox(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT); + UI_draw_roundbox_corner_set(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT); break; } glColor4f(0.05f, 0.05f, 0.05f, 0.4f); - uiRoundBox((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f); + UI_draw_roundbox((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f); glEnable(GL_BLEND); @@ -306,32 +306,32 @@ static void region_draw_azone_tab(AZone *az) /* add code to draw region hidden as 'too small' */ switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT | UI_RB_ALPHA); + UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT | UI_RB_ALPHA); - uiDrawBoxShade(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f); + UI_draw_roundbox_shade_x(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f); glColor4ub(0, 0, 0, 255); - uiRoundRect((float)az->x1, 0.3f + (float)az->y1, (float)az->x2, 0.3f + (float)az->y2, 4.0f); + UI_draw_roundbox_unfilled((float)az->x1, 0.3f + (float)az->y1, (float)az->x2, 0.3f + (float)az->y2, 4.0f); break; case AE_BOTTOM_TO_TOPLEFT: - uiSetRoundBox(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT | UI_RB_ALPHA); + UI_draw_roundbox_corner_set(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT | UI_RB_ALPHA); - uiDrawBoxShade(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f); + UI_draw_roundbox_shade_x(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f); glColor4ub(0, 0, 0, 255); - uiRoundRect((float)az->x1, 0.3f + (float)az->y1, (float)az->x2, 0.3f + (float)az->y2, 4.0f); + UI_draw_roundbox_unfilled((float)az->x1, 0.3f + (float)az->y1, (float)az->x2, 0.3f + (float)az->y2, 4.0f); break; case AE_LEFT_TO_TOPRIGHT: - uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT | UI_RB_ALPHA); + UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT | UI_RB_ALPHA); - uiDrawBoxShade(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f); + UI_draw_roundbox_shade_x(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f); glColor4ub(0, 0, 0, 255); - uiRoundRect((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f); + UI_draw_roundbox_unfilled((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f); break; case AE_RIGHT_TO_TOPLEFT: - uiSetRoundBox(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT | UI_RB_ALPHA); + UI_draw_roundbox_corner_set(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT | UI_RB_ALPHA); - uiDrawBoxShade(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f); + UI_draw_roundbox_shade_x(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f); glColor4ub(0, 0, 0, 255); - uiRoundRect((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f); + UI_draw_roundbox_unfilled((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f); break; } @@ -497,7 +497,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) ar->do_draw = 0; memset(&ar->drawrct, 0, sizeof(ar->drawrct)); - uiFreeInactiveBlocks(C, &ar->uiblocks); + UI_blocklist_free_inactive(C, &ar->uiblocks); if (sa && (win->screen->state != SCREENFULL)) { region_draw_emboss(ar, &ar->winrct); @@ -1315,7 +1315,7 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand /* XXX it would be good to have boundbox checks for some of these... */ if (flag & ED_KEYMAP_UI) { /* user interface widgets */ - UI_add_region_handlers(handlers); + UI_region_handlers_add(handlers); } if (flag & ED_KEYMAP_VIEW2D) { /* 2d-viewport handling+manipulation */ @@ -1409,7 +1409,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) } else { /* prevent uiblocks to run */ - uiFreeBlocks(NULL, &ar->uiblocks); + UI_blocklist_free(NULL, &ar->uiblocks); } } } @@ -1652,7 +1652,7 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco) RNA_pointer_create(&(scr->id), &RNA_Area, sa, &areaptr); - uiDefButR(block, MENU, 0, "", xco, yco, 1.5 * U.widget_unit, U.widget_unit, + uiDefButR(block, UI_BTYPE_MENU, 0, "", xco, yco, 1.5 * U.widget_unit, U.widget_unit, &areaptr, "type", 0, 0.0f, 0.0f, 0.0f, 0.0f, ""); return xco + 1.7 * U.widget_unit; @@ -1663,7 +1663,7 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco) void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *context, int contextnr) { ScrArea *sa = CTX_wm_area(C); - uiStyle *style = UI_GetStyleDraw(); + uiStyle *style = UI_style_get_dpi(); uiBlock *block; PanelType *pt; Panel *panel; @@ -1761,16 +1761,16 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * w -= margin_x; /* create panels */ - uiBeginPanels(C, ar); + UI_panels_begin(C, ar); - /* set view2d view matrix - uiBeginBlock() stores it */ + /* set view2d view matrix - UI_block_begin() stores it */ UI_view2d_view_ortho(v2d); BLI_SMALLSTACK_ITER_BEGIN(pt_stack, pt) { bool open; - panel = uiPanelFindByType(ar, pt); + panel = UI_panel_find_by_type(ar, pt); if (use_category_tabs && pt->category[0] && !STREQ(category, pt->category)) { if ((panel == NULL) || ((panel->flag & PNL_PIN) == 0)) { @@ -1779,20 +1779,21 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * } /* draw panel */ - block = uiBeginBlock(C, ar, pt->idname, UI_EMBOSS); - panel = uiBeginPanel(sa, ar, block, pt, panel, &open); + block = UI_block_begin(C, ar, pt->idname, UI_EMBOSS); + panel = UI_panel_begin(sa, ar, block, pt, panel, &open); /* bad fixed values */ triangle = (int)(UI_UNIT_Y * 1.1f); if (pt->draw_header && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) { /* for enabled buttons */ - panel->layout = uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, - triangle, (UI_UNIT_Y * 1.1f) + style->panelspace, UI_UNIT_Y, 1, 0, style); + panel->layout = UI_block_layout( + block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, + triangle, (UI_UNIT_Y * 1.1f) + style->panelspace, UI_UNIT_Y, 1, 0, style); pt->draw_header(C, panel); - uiBlockLayoutResolve(block, &xco, &yco); + UI_block_layout_resolve(block, &xco, &yco); panel->labelofs = xco - triangle; panel->layout = NULL; } @@ -1809,28 +1810,29 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * else panelContext = UI_LAYOUT_PANEL; - panel->layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, panelContext, - style->panelspace, 0, w - 2 * style->panelspace, em, 0, style); + panel->layout = UI_block_layout( + block, UI_LAYOUT_VERTICAL, panelContext, + style->panelspace, 0, w - 2 * style->panelspace, em, 0, style); pt->draw(C, panel); - uiBlockLayoutResolve(block, &xco, &yco); + UI_block_layout_resolve(block, &xco, &yco); panel->layout = NULL; yco -= 2 * style->panelspace; - uiEndPanel(block, w, -yco); + UI_panel_end(block, w, -yco); } else { yco = 0; - uiEndPanel(block, w, 0); + UI_panel_end(block, w, 0); } - uiEndBlock(C, block); + UI_block_end(C, block); } BLI_SMALLSTACK_ITER_END; /* align panels and return size */ - uiEndPanels(C, ar, &x, &y); + UI_panels_end(C, ar, &x, &y); /* before setting the view */ if (vertical) { @@ -1855,7 +1857,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * * flip +1 or -1 pixel compared to redoing the entire layout again. * Leaving in commented code for future tests */ #if 0 - uiScalePanels(ar, BLI_rctf_size_x(&v2d->cur)); + UI_panels_scale(ar, BLI_rctf_size_x(&v2d->cur)); break; #endif } @@ -1883,7 +1885,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * UI_view2d_view_ortho(v2d); /* draw panels */ - uiDrawPanels(C, ar); + UI_panels_draw(C, ar); /* restore view matrix */ UI_view2d_view_restore(C); @@ -1910,7 +1912,7 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *ar) void ED_region_header(const bContext *C, ARegion *ar) { - uiStyle *style = UI_GetStyleDraw(); + uiStyle *style = UI_style_get_dpi(); uiBlock *block; uiLayout *layout; HeaderType *ht; @@ -1930,8 +1932,8 @@ void ED_region_header(const bContext *C, ARegion *ar) /* draw all headers types */ for (ht = ar->type->headertypes.first; ht; ht = ht->next) { - block = uiBeginBlock(C, ar, ht->idname, UI_EMBOSS); - layout = uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, UI_UNIT_Y, 1, 0, style); + block = UI_block_begin(C, ar, ht->idname, UI_EMBOSS); + layout = UI_block_layout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, UI_UNIT_Y, 1, 0, style); if (ht->draw) { header.type = ht; @@ -1944,14 +1946,14 @@ void ED_region_header(const bContext *C, ARegion *ar) maxco = xco; } - uiBlockLayoutResolve(block, &xco, &yco); + UI_block_layout_resolve(block, &xco, &yco); /* for view2d */ if (xco > maxco) maxco = xco; - uiEndBlock(C, block); - uiDrawBlock(C, block); + UI_block_end(C, block); + UI_block_draw(C, block); } /* always as last */ @@ -1975,7 +1977,7 @@ int ED_area_headersize(void) void ED_region_info_draw(ARegion *ar, const char *text, int block, float fill_color[4]) { const int header_height = UI_UNIT_Y; - uiStyle *style = UI_GetStyleDraw(); + uiStyle *style = UI_style_get_dpi(); int fontid = style->widget.uifont_id; GLint scissor[4]; rcti rect; @@ -2115,7 +2117,7 @@ void ED_region_cache_draw_background(const ARegion *ar) void ED_region_cache_draw_curfra_label(const int framenr, const float x, const float y) { - uiStyle *style = UI_GetStyle(); + uiStyle *style = UI_style_get(); int fontid = style->widget.uifont_id; char numstr[32]; float font_dims[2] = {0.0f, 0.0f}; diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 7c8987ae778..18c9a94e46f 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -399,7 +399,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult if (sfile) { op = sfile->op; } - else if ((op = uiContextActiveOperator(C))) { + else if ((op = UI_context_active_operator_get(C))) { /* do nothign */ } else { diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 9463a702b76..c179cfc464c 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1439,7 +1439,7 @@ void ED_screen_set_subwinactive(bContext *C, wmEvent *event) /* this used to be a notifier, but needs to be done immediate * because it can undo setting the right button as active due * to delayed notifier handling */ - uiFreeActiveButtons(C, win->screen); + UI_screen_free_active_but(C, win->screen); } else region_cursor_set(win, scr->subwinactive, false); @@ -1813,7 +1813,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *sa, const s * switching screens with tooltip open because region and tooltip * are no longer in the same screen */ for (ar = sa->regionbase.first; ar; ar = ar->next) - uiFreeBlocks(C, &ar->uiblocks); + UI_blocklist_free(C, &ar->uiblocks); /* prevent hanging header prints */ ED_area_headerprint(sa, NULL); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index ac061752575..35d9b764043 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2737,8 +2737,8 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent if (actedge == NULL) return OPERATOR_CANCELLED; - pup = uiPupMenuBegin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); - layout = uiPupMenuLayout(pup); + pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); + layout = UI_popup_menu_layout(pup); WM_operator_properties_create(&ptr1, "SCREEN_OT_area_join"); @@ -2757,7 +2757,7 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent uiItemFullO(layout, "SCREEN_OT_area_split", NULL, ICON_NONE, ptr2.data, WM_OP_INVOKE_DEFAULT, 0); uiItemFullO(layout, "SCREEN_OT_area_join", NULL, ICON_NONE, ptr1.data, WM_OP_INVOKE_DEFAULT, 0); - uiPupMenuEnd(C, pup); + UI_popup_menu_end(C, pup); return OPERATOR_INTERFACE; } @@ -2857,14 +2857,14 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNU if (items == 0) return OPERATOR_CANCELLED; - pup = uiPupMenuBegin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); - layout = uiPupMenuLayout(pup); + pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); + layout = UI_popup_menu_layout(pup); for (i = items - 1, lastop = wm->operators.last; lastop; lastop = lastop->prev, i--) if (WM_operator_repeat_check(C, lastop)) uiItemIntO(layout, RNA_struct_ui_name(lastop->type->srna), ICON_NONE, op->type->idname, "index", i); - uiPupMenuEnd(C, pup); + UI_popup_menu_end(C, pup); return OPERATOR_INTERFACE; } @@ -3255,12 +3255,12 @@ static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv uiPopupMenu *pup; uiLayout *layout; - pup = uiPupMenuBegin(C, IFACE_("Header"), ICON_NONE); - layout = uiPupMenuLayout(pup); + pup = UI_popup_menu_begin(C, IFACE_("Header"), ICON_NONE); + layout = UI_popup_menu_layout(pup); ED_screens_header_tools_menu_create(C, layout, NULL); - uiPupMenuEnd(C, pup); + UI_popup_menu_end(C, pup); return OPERATOR_INTERFACE; } |