Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/area.c
| Show First 20 Lines • Show All 265 Lines • ▼ Show 20 Lines | |||||
| static void region_draw_azone_tab_plus(AZone *az) | static void region_draw_azone_tab_plus(AZone *az) | ||||
| { | { | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| /* add code to draw region hidden as 'too small' */ | /* add code to draw region hidden as 'too small' */ | ||||
| switch (az->edge) { | switch (az->edge) { | ||||
| case AE_TOP_TO_BOTTOMRIGHT: | 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; | break; | ||||
| case AE_BOTTOM_TO_TOPLEFT: | 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; | break; | ||||
| case AE_LEFT_TO_TOPRIGHT: | 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; | break; | ||||
| case AE_RIGHT_TO_TOPLEFT: | 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; | break; | ||||
| } | } | ||||
| glColor4f(0.05f, 0.05f, 0.05f, 0.4f); | 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); | glEnable(GL_BLEND); | ||||
| glColor4f(0.8f, 0.8f, 0.8f, 0.4f); | glColor4f(0.8f, 0.8f, 0.8f, 0.4f); | ||||
| draw_azone_plus((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2); | draw_azone_plus((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2); | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| } | } | ||||
| static void region_draw_azone_tab(AZone *az) | static void region_draw_azone_tab(AZone *az) | ||||
| { | { | ||||
| float col[3]; | float col[3]; | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| UI_GetThemeColor3fv(TH_HEADER, col); | UI_GetThemeColor3fv(TH_HEADER, col); | ||||
| glColor4f(col[0], col[1], col[2], 0.5f); | glColor4f(col[0], col[1], col[2], 0.5f); | ||||
| /* add code to draw region hidden as 'too small' */ | /* add code to draw region hidden as 'too small' */ | ||||
| switch (az->edge) { | switch (az->edge) { | ||||
| case AE_TOP_TO_BOTTOMRIGHT: | 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); | 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; | break; | ||||
| case AE_BOTTOM_TO_TOPLEFT: | 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); | 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; | break; | ||||
| case AE_LEFT_TO_TOPRIGHT: | 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); | 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; | break; | ||||
| case AE_RIGHT_TO_TOPLEFT: | 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); | 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; | break; | ||||
| } | } | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| } | } | ||||
| static void region_draw_azone_tria(AZone *az) | static void region_draw_azone_tria(AZone *az) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | #if 0 | ||||
| glRectf(ar->drawrct.xmin - ar->winrct.xmin, ar->drawrct.ymin - ar->winrct.ymin, | glRectf(ar->drawrct.xmin - ar->winrct.xmin, ar->drawrct.ymin - ar->winrct.ymin, | ||||
| ar->drawrct.xmax - ar->winrct.xmin, ar->drawrct.ymax - ar->winrct.ymin); | ar->drawrct.xmax - ar->winrct.xmin, ar->drawrct.ymax - ar->winrct.ymin); | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| #endif | #endif | ||||
| ar->do_draw = 0; | ar->do_draw = 0; | ||||
| memset(&ar->drawrct, 0, sizeof(ar->drawrct)); | memset(&ar->drawrct, 0, sizeof(ar->drawrct)); | ||||
| uiFreeInactiveBlocks(C, &ar->uiblocks); | UI_blocklist_free_inactive(C, &ar->uiblocks); | ||||
| if (sa && (win->screen->state != SCREENFULL)) { | if (sa && (win->screen->state != SCREENFULL)) { | ||||
| region_draw_emboss(ar, &ar->winrct); | region_draw_emboss(ar, &ar->winrct); | ||||
| } | } | ||||
| } | } | ||||
| /* ********************************** | /* ********************************** | ||||
| * maybe silly, but let's try for now | * maybe silly, but let's try for now | ||||
| ▲ Show 20 Lines • Show All 801 Lines • ▼ Show 20 Lines | |||||
| static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *handlers, int flag) | static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *handlers, int flag) | ||||
| { | { | ||||
| /* note, add-handler checks if it already exists */ | /* note, add-handler checks if it already exists */ | ||||
| /* XXX it would be good to have boundbox checks for some of these... */ | /* XXX it would be good to have boundbox checks for some of these... */ | ||||
| if (flag & ED_KEYMAP_UI) { | if (flag & ED_KEYMAP_UI) { | ||||
| /* user interface widgets */ | /* user interface widgets */ | ||||
| UI_add_region_handlers(handlers); | UI_region_handlers_add(handlers); | ||||
| } | } | ||||
| if (flag & ED_KEYMAP_VIEW2D) { | if (flag & ED_KEYMAP_VIEW2D) { | ||||
| /* 2d-viewport handling+manipulation */ | /* 2d-viewport handling+manipulation */ | ||||
| wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "View2D", 0, 0); | wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "View2D", 0, 0); | ||||
| WM_event_add_keymap_handler(handlers, keymap); | WM_event_add_keymap_handler(handlers, keymap); | ||||
| } | } | ||||
| if (flag & ED_KEYMAP_MARKERS) { | if (flag & ED_KEYMAP_MARKERS) { | ||||
| /* time-markers */ | /* time-markers */ | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | if (ar->swinid) { | ||||
| /* default region handlers */ | /* default region handlers */ | ||||
| ed_default_handlers(wm, sa, &ar->handlers, ar->type->keymapflag); | ed_default_handlers(wm, sa, &ar->handlers, ar->type->keymapflag); | ||||
| /* own handlers */ | /* own handlers */ | ||||
| if (ar->type->init) | if (ar->type->init) | ||||
| ar->type->init(wm, ar); | ar->type->init(wm, ar); | ||||
| } | } | ||||
| else { | else { | ||||
| /* prevent uiblocks to run */ | /* prevent uiblocks to run */ | ||||
| uiFreeBlocks(NULL, &ar->uiblocks); | UI_blocklist_free(NULL, &ar->uiblocks); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void region_update_rect(ARegion *ar) | static void region_update_rect(ARegion *ar) | ||||
| { | { | ||||
| ar->winx = BLI_rcti_size_x(&ar->winrct) + 1; | ar->winx = BLI_rcti_size_x(&ar->winrct) + 1; | ||||
| ar->winy = BLI_rcti_size_y(&ar->winrct) + 1; | ar->winy = BLI_rcti_size_y(&ar->winrct) + 1; | ||||
| ▲ Show 20 Lines • Show All 226 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| bScreen *scr = CTX_wm_screen(C); | bScreen *scr = CTX_wm_screen(C); | ||||
| PointerRNA areaptr; | PointerRNA areaptr; | ||||
| int xco = 0.4 * U.widget_unit; | int xco = 0.4 * U.widget_unit; | ||||
| RNA_pointer_create(&(scr->id), &RNA_Area, sa, &areaptr); | 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, ""); | &areaptr, "type", 0, 0.0f, 0.0f, 0.0f, 0.0f, ""); | ||||
| return xco + 1.7 * U.widget_unit; | return xco + 1.7 * U.widget_unit; | ||||
| } | } | ||||
| /************************ standard UI regions ************************/ | /************************ standard UI regions ************************/ | ||||
| void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *context, int contextnr) | void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *context, int contextnr) | ||||
| { | { | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| uiStyle *style = UI_GetStyleDraw(); | uiStyle *style = UI_style_get_dpi(); | ||||
| uiBlock *block; | uiBlock *block; | ||||
| PanelType *pt; | PanelType *pt; | ||||
| Panel *panel; | Panel *panel; | ||||
| View2D *v2d = &ar->v2d; | View2D *v2d = &ar->v2d; | ||||
| View2DScrollers *scrollers; | View2DScrollers *scrollers; | ||||
| int x, y, xco, yco, w, em, triangle; | int x, y, xco, yco, w, em, triangle; | ||||
| bool is_context_new = 0; | bool is_context_new = 0; | ||||
| int redo; | int redo; | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | for (redo = 2; redo > 0; redo--) { | ||||
| else { | else { | ||||
| w = UI_PANEL_WIDTH; | w = UI_PANEL_WIDTH; | ||||
| em = (ar->type->prefsizex) ? 10 : 20; | em = (ar->type->prefsizex) ? 10 : 20; | ||||
| } | } | ||||
| w -= margin_x; | w -= margin_x; | ||||
| /* create panels */ | /* 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); | UI_view2d_view_ortho(v2d); | ||||
| BLI_SMALLSTACK_ITER_BEGIN(pt_stack, pt) | BLI_SMALLSTACK_ITER_BEGIN(pt_stack, pt) | ||||
| { | { | ||||
| bool open; | 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 (use_category_tabs && pt->category[0] && !STREQ(category, pt->category)) { | ||||
| if ((panel == NULL) || ((panel->flag & PNL_PIN) == 0)) { | if ((panel == NULL) || ((panel->flag & PNL_PIN) == 0)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| } | } | ||||
| /* draw panel */ | /* draw panel */ | ||||
| block = uiBeginBlock(C, ar, pt->idname, UI_EMBOSS); | block = UI_block_begin(C, ar, pt->idname, UI_EMBOSS); | ||||
| panel = uiBeginPanel(sa, ar, block, pt, panel, &open); | panel = UI_panel_begin(sa, ar, block, pt, panel, &open); | ||||
| /* bad fixed values */ | /* bad fixed values */ | ||||
| triangle = (int)(UI_UNIT_Y * 1.1f); | triangle = (int)(UI_UNIT_Y * 1.1f); | ||||
| 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 = UI_block_layout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, | ||||
| triangle, (UI_UNIT_Y * 1.1f) + style->panelspace, UI_UNIT_Y, 1, 0, style); | triangle, (UI_UNIT_Y * 1.1f) + style->panelspace, UI_UNIT_Y, 1, 0, style); | ||||
| pt->draw_header(C, panel); | pt->draw_header(C, panel); | ||||
| uiBlockLayoutResolve(block, &xco, &yco); | UI_block_layout_resolve(block, &xco, &yco); | ||||
| panel->labelofs = xco - triangle; | panel->labelofs = xco - triangle; | ||||
| panel->layout = NULL; | panel->layout = NULL; | ||||
| } | } | ||||
| else { | else { | ||||
| panel->labelofs = 0; | panel->labelofs = 0; | ||||
| } | } | ||||
| if (open) { | if (open) { | ||||
| short panelContext; | short panelContext; | ||||
| /* panel context can either be toolbar region or normal panels region */ | /* panel context can either be toolbar region or normal panels region */ | ||||
| if (ar->regiontype == RGN_TYPE_TOOLS) | if (ar->regiontype == RGN_TYPE_TOOLS) | ||||
| panelContext = UI_LAYOUT_TOOLBAR; | panelContext = UI_LAYOUT_TOOLBAR; | ||||
| else | else | ||||
| panelContext = UI_LAYOUT_PANEL; | panelContext = UI_LAYOUT_PANEL; | ||||
| panel->layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, panelContext, | panel->layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, panelContext, | ||||
| style->panelspace, 0, w - 2 * style->panelspace, em, 0, style); | style->panelspace, 0, w - 2 * style->panelspace, em, 0, style); | ||||
| pt->draw(C, panel); | pt->draw(C, panel); | ||||
| uiBlockLayoutResolve(block, &xco, &yco); | UI_block_layout_resolve(block, &xco, &yco); | ||||
| panel->layout = NULL; | panel->layout = NULL; | ||||
| yco -= 2 * style->panelspace; | yco -= 2 * style->panelspace; | ||||
| uiEndPanel(block, w, -yco); | UI_panel_end(block, w, -yco); | ||||
| } | } | ||||
| else { | else { | ||||
| yco = 0; | yco = 0; | ||||
| uiEndPanel(block, w, 0); | UI_panel_end(block, w, 0); | ||||
| } | } | ||||
| uiEndBlock(C, block); | UI_block_end(C, block); | ||||
| } | } | ||||
| BLI_SMALLSTACK_ITER_END; | BLI_SMALLSTACK_ITER_END; | ||||
| /* align panels and return size */ | /* align panels and return size */ | ||||
| uiEndPanels(C, ar, &x, &y); | UI_panels_end(C, ar, &x, &y); | ||||
| /* before setting the view */ | /* before setting the view */ | ||||
| if (vertical) { | if (vertical) { | ||||
| /* we always keep the scroll offset - so the total view gets increased with the scrolled away part */ | /* we always keep the scroll offset - so the total view gets increased with the scrolled away part */ | ||||
| if (v2d->cur.ymax < - 0.001f) | if (v2d->cur.ymax < - 0.001f) | ||||
| y = min_ii(y, v2d->cur.ymin); | y = min_ii(y, v2d->cur.ymin); | ||||
| y = -y; | y = -y; | ||||
| } | } | ||||
| else { | else { | ||||
| /* don't jump back when panels close or hide */ | /* don't jump back when panels close or hide */ | ||||
| if (!is_context_new) | if (!is_context_new) | ||||
| x = max_ii(x, v2d->cur.xmax); | x = max_ii(x, v2d->cur.xmax); | ||||
| y = -y; | y = -y; | ||||
| } | } | ||||
| /* this also changes the 'cur' */ | /* this also changes the 'cur' */ | ||||
| UI_view2d_totRect_set(v2d, x, y); | UI_view2d_totRect_set(v2d, x, y); | ||||
| if (scroll != v2d->scroll) { | if (scroll != v2d->scroll) { | ||||
| /* Note: this code scales fine, but because of rounding differences, positions of elements | /* Note: this code scales fine, but because of rounding differences, positions of elements | ||||
| * flip +1 or -1 pixel compared to redoing the entire layout again. | * flip +1 or -1 pixel compared to redoing the entire layout again. | ||||
| * Leaving in commented code for future tests */ | * Leaving in commented code for future tests */ | ||||
| #if 0 | #if 0 | ||||
| uiScalePanels(ar, BLI_rctf_size_x(&v2d->cur)); | UI_panels_scale(ar, BLI_rctf_size_x(&v2d->cur)); | ||||
| break; | break; | ||||
| #endif | #endif | ||||
| } | } | ||||
| else { | else { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| Show All 11 Lines | else { | ||||
| 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); | ||||
| /* draw panels */ | /* draw panels */ | ||||
| uiDrawPanels(C, ar); | UI_panels_draw(C, ar); | ||||
| /* restore view matrix */ | /* restore view matrix */ | ||||
| UI_view2d_view_restore(C); | UI_view2d_view_restore(C); | ||||
| if (use_category_tabs) { | if (use_category_tabs) { | ||||
| UI_panel_category_draw_all(ar, category); | UI_panel_category_draw_all(ar, category); | ||||
| } | } | ||||
| Show All 10 Lines | void ED_region_panels_init(wmWindowManager *wm, ARegion *ar) | ||||
| UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx, ar->winy); | UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx, ar->winy); | ||||
| keymap = WM_keymap_find(wm->defaultconf, "View2D Buttons List", 0, 0); | keymap = WM_keymap_find(wm->defaultconf, "View2D Buttons List", 0, 0); | ||||
| WM_event_add_keymap_handler(&ar->handlers, keymap); | WM_event_add_keymap_handler(&ar->handlers, keymap); | ||||
| } | } | ||||
| void ED_region_header(const bContext *C, ARegion *ar) | void ED_region_header(const bContext *C, ARegion *ar) | ||||
| { | { | ||||
| uiStyle *style = UI_GetStyleDraw(); | uiStyle *style = UI_style_get_dpi(); | ||||
| uiBlock *block; | uiBlock *block; | ||||
| uiLayout *layout; | uiLayout *layout; | ||||
| HeaderType *ht; | HeaderType *ht; | ||||
| Header header = {NULL}; | Header header = {NULL}; | ||||
| int maxco, xco, yco; | int maxco, xco, yco; | ||||
| int headery = ED_area_headersize(); | int headery = ED_area_headersize(); | ||||
| /* clear */ | /* clear */ | ||||
| UI_ThemeClearColor((ED_screen_area_active(C)) ? TH_HEADER : TH_HEADERDESEL); | UI_ThemeClearColor((ED_screen_area_active(C)) ? TH_HEADER : TH_HEADERDESEL); | ||||
| glClear(GL_COLOR_BUFFER_BIT); | glClear(GL_COLOR_BUFFER_BIT); | ||||
| /* set view2d view matrix for scrolling (without scrollers) */ | /* set view2d view matrix for scrolling (without scrollers) */ | ||||
| UI_view2d_view_ortho(&ar->v2d); | UI_view2d_view_ortho(&ar->v2d); | ||||
| xco = maxco = 0.4f * UI_UNIT_X; | xco = maxco = 0.4f * UI_UNIT_X; | ||||
| yco = headery - floor(0.2f * UI_UNIT_Y); | yco = headery - floor(0.2f * UI_UNIT_Y); | ||||
| /* draw all headers types */ | /* draw all headers types */ | ||||
| for (ht = ar->type->headertypes.first; ht; ht = ht->next) { | for (ht = ar->type->headertypes.first; ht; ht = ht->next) { | ||||
| block = uiBeginBlock(C, ar, ht->idname, UI_EMBOSS); | block = UI_block_begin(C, ar, ht->idname, UI_EMBOSS); | ||||
| layout = uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, UI_UNIT_Y, 1, 0, style); | layout = UI_block_layout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, UI_UNIT_Y, 1, 0, style); | ||||
| if (ht->draw) { | if (ht->draw) { | ||||
| header.type = ht; | header.type = ht; | ||||
| header.layout = layout; | header.layout = layout; | ||||
| ht->draw(C, &header); | ht->draw(C, &header); | ||||
| /* for view2d */ | /* for view2d */ | ||||
| xco = uiLayoutGetWidth(layout); | xco = uiLayoutGetWidth(layout); | ||||
| if (xco > maxco) | if (xco > maxco) | ||||
| maxco = xco; | maxco = xco; | ||||
| } | } | ||||
| uiBlockLayoutResolve(block, &xco, &yco); | UI_block_layout_resolve(block, &xco, &yco); | ||||
| /* for view2d */ | /* for view2d */ | ||||
| if (xco > maxco) | if (xco > maxco) | ||||
| maxco = xco; | maxco = xco; | ||||
| uiEndBlock(C, block); | UI_block_end(C, block); | ||||
| uiDrawBlock(C, block); | UI_block_draw(C, block); | ||||
| } | } | ||||
| /* always as last */ | /* always as last */ | ||||
| UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, headery); | UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, headery); | ||||
| /* restore view matrix? */ | /* restore view matrix? */ | ||||
| UI_view2d_view_restore(C); | UI_view2d_view_restore(C); | ||||
| } | } | ||||
| void ED_region_header_init(ARegion *ar) | void ED_region_header_init(ARegion *ar) | ||||
| { | { | ||||
| UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); | UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); | ||||
| } | } | ||||
| /* UI_UNIT_Y is defined as U variable now, depending dpi */ | /* UI_UNIT_Y is defined as U variable now, depending dpi */ | ||||
| int ED_area_headersize(void) | int ED_area_headersize(void) | ||||
| { | { | ||||
| return (int)(HEADERY * UI_DPI_FAC); | return (int)(HEADERY * UI_DPI_FAC); | ||||
| } | } | ||||
| void ED_region_info_draw(ARegion *ar, const char *text, int block, float fill_color[4]) | void ED_region_info_draw(ARegion *ar, const char *text, int block, float fill_color[4]) | ||||
| { | { | ||||
| const int header_height = UI_UNIT_Y; | const int header_height = UI_UNIT_Y; | ||||
| uiStyle *style = UI_GetStyleDraw(); | uiStyle *style = UI_style_get_dpi(); | ||||
| int fontid = style->widget.uifont_id; | int fontid = style->widget.uifont_id; | ||||
| GLint scissor[4]; | GLint scissor[4]; | ||||
| rcti rect; | rcti rect; | ||||
| /* background box */ | /* background box */ | ||||
| ED_region_visible_rect(ar, &rect); | ED_region_visible_rect(ar, &rect); | ||||
| rect.ymin = BLI_rcti_size_y(&ar->winrct) - header_height; | rect.ymin = BLI_rcti_size_y(&ar->winrct) - header_height; | ||||
| ▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | |||||
| void ED_region_cache_draw_background(const ARegion *ar) | void ED_region_cache_draw_background(const ARegion *ar) | ||||
| { | { | ||||
| glColor4ub(128, 128, 255, 64); | glColor4ub(128, 128, 255, 64); | ||||
| glRecti(0, 0, ar->winx, 8 * UI_DPI_FAC); | glRecti(0, 0, ar->winx, 8 * UI_DPI_FAC); | ||||
| } | } | ||||
| void ED_region_cache_draw_curfra_label(const int framenr, const float x, const float y) | 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; | int fontid = style->widget.uifont_id; | ||||
| char numstr[32]; | char numstr[32]; | ||||
| float font_dims[2] = {0.0f, 0.0f}; | float font_dims[2] = {0.0f, 0.0f}; | ||||
| /* frame number */ | /* frame number */ | ||||
| BLF_size(fontid, 11.0f * U.pixelsize, U.dpi); | BLF_size(fontid, 11.0f * U.pixelsize, U.dpi); | ||||
| BLI_snprintf(numstr, sizeof(numstr), "%d", framenr); | BLI_snprintf(numstr, sizeof(numstr), "%d", framenr); | ||||
| Show All 27 Lines | |||||