diff options
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r-- | source/blender/editors/screen/area.c | 64 |
1 files changed, 44 insertions, 20 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index a1a4f33d008..a1ba861f477 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -43,6 +43,8 @@ #include "BLI_rand.h" #include "BLI_utildefines.h" +#include "BLF_api.h" + #include "BKE_context.h" #include "BKE_global.h" #include "BKE_screen.h" @@ -650,8 +652,12 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int if(ar->next==NULL && alignment!=RGN_ALIGN_QSPLIT) alignment= RGN_ALIGN_NONE; + /* prefsize, for header we stick to exception */ prefsizex= ar->sizex?ar->sizex:ar->type->prefsizex; - prefsizey= ar->sizey?ar->sizey:ar->type->prefsizey; + if(ar->regiontype==RGN_TYPE_HEADER) + prefsizey= ar->type->prefsizey; + else + prefsizey= ar->sizey?ar->sizey:ar->type->prefsizey; /* hidden is user flag */ if(ar->flag & RGN_FLAG_HIDDEN); @@ -811,8 +817,18 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int ar->winrct.xmax= ar->winrct.xmin; } /* in end, add azones, where appropriate */ - region_azone_add(sa, ar, alignment); - + if(ar->regiontype == RGN_TYPE_HEADER && ar->winy + 6 > sa->winy) { + /* The logic for this is: when the header takes up the full area, + * disallow hiding it to view the main window. + * + * Without this, uou can drag down the file selectors header and hide it + * by accident very easily (highly annoying!), the value 6 is arbitrary + * but accounts for small common rounding problems when scaling the UI, + * must be minimum '4' */ + } + else { + region_azone_add(sa, ar, alignment); + } region_rect_recursive(sa, ar->next, remainder, quad); } @@ -953,6 +969,9 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) uiFreeBlocks(NULL, &ar->uiblocks); } + /* rechecks 2d matrix for header on dpi changing, do not do for other regions, it resets view && blocks view2d operator polls (ton) */ + if(ar->regiontype==RGN_TYPE_HEADER) + ar->v2d.flag &= ~V2D_IS_INITIALISED; } } @@ -1121,7 +1140,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) /* tell WM to refresh, cursor types etc */ WM_event_add_mousemove(C); - /*send space change notifyer*/ + /*send space change notifier*/ WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, sa); ED_area_tag_refresh(sa); @@ -1148,7 +1167,7 @@ void ED_area_prevspace(bContext *C, ScrArea *sa) } ED_area_tag_redraw(sa); - /*send space change notifyer*/ + /*send space change notifier*/ WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, sa); } @@ -1196,7 +1215,7 @@ static void spacefunc(struct bContext *C, void *UNUSED(arg1), void *UNUSED(arg2) ED_area_newspace(C, CTX_wm_area(C), CTX_wm_area(C)->butspacetype); ED_area_tag_redraw(CTX_wm_area(C)); - /*send space change notifyer*/ + /*send space change notifier*/ WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, CTX_wm_area(C)); } @@ -1208,13 +1227,12 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco) int xco= 8; but= uiDefIconTextButC(block, ICONTEXTROW, 0, ICON_VIEW3D, - editortype_pup(), xco, yco, XIC+10, YIC, + editortype_pup(), xco, yco, UI_UNIT_X+10, UI_UNIT_Y, &(sa->butspacetype), 1.0, SPACEICONMAX, 0, 0, - "Displays current editor type. " - "Click for menu of available types"); + _("Displays current editor type. Click for menu of available types")); uiButSetFunc(but, spacefunc, NULL, NULL); - return xco + XIC + 14; + return xco + UI_UNIT_X + 14; } int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) @@ -1230,21 +1248,21 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) if (sa->flag & HEADER_NO_PULLDOWN) { uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, ICON_DISCLOSURE_TRI_RIGHT, - xco,yco,XIC,YIC-2, + xco,yco,UI_UNIT_X,UI_UNIT_Y-2, &(sa->flag), 0, 0, 0, 0, "Show pulldown menus"); } else { uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, ICON_DISCLOSURE_TRI_DOWN, - xco,yco,XIC,YIC-2, + xco,yco,UI_UNIT_X,UI_UNIT_Y-2, &(sa->flag), 0, 0, 0, 0, "Hide pulldown menus"); } uiBlockSetEmboss(block, UI_EMBOSS); - return xco + XIC; + return xco + UI_UNIT_X; } /************************ standard UI regions ************************/ @@ -1265,11 +1283,11 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * if(vertical) { w= v2d->cur.xmax - v2d->cur.xmin; - em= (ar->type->prefsizex)? 10: 20; + em= (ar->type->prefsizex)? UI_UNIT_Y/2: UI_UNIT_Y; } else { w= UI_PANEL_WIDTH; - em= (ar->type->prefsizex)? 10: 20; + em= (ar->type->prefsizex)? UI_UNIT_Y/2: UI_UNIT_Y; } x= 0; @@ -1293,8 +1311,8 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * panel= uiBeginPanel(sa, ar, block, pt, &open); /* bad fixed values */ - header= (pt->flag & PNL_NO_HEADER)? 0: 20; - triangle= 22; + header= (pt->flag & PNL_NO_HEADER)? 0: UI_UNIT_Y; + triangle= (int)(UI_UNIT_Y * 1.1f); if(vertical) y -= header; @@ -1446,6 +1464,7 @@ void ED_region_header(const bContext *C, ARegion *ar) HeaderType *ht; Header header = {NULL}; int maxco, xco, yco; + int headery= ED_area_headersize(); /* clear */ UI_ThemeClearColor((ED_screen_area_active(C))?TH_HEADER:TH_HEADERDESEL); @@ -1455,12 +1474,12 @@ void ED_region_header(const bContext *C, ARegion *ar) UI_view2d_view_ortho(&ar->v2d); xco= maxco= 8; - yco= HEADERY-4; + yco= headery-4; /* 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, HEADERY-6, 1, style); + layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, UI_UNIT_Y, 1, style); if(ht->draw) { header.type= ht; @@ -1484,7 +1503,7 @@ void ED_region_header(const bContext *C, ARegion *ar) } /* always as last */ - UI_view2d_totRect_set(&ar->v2d, maxco+XIC+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin); + UI_view2d_totRect_set(&ar->v2d, maxco+UI_UNIT_X+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin); /* restore view matrix? */ UI_view2d_view_restore(C); @@ -1495,3 +1514,8 @@ void ED_region_header_init(ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); } +/* UI_UNIT_Y is defined as U variable now, depending dpi */ +int ED_area_headersize(void) +{ + return UI_UNIT_Y+6; +} |