diff options
author | Ton Roosendaal <ton@blender.org> | 2011-06-04 21:03:46 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2011-06-04 21:03:46 +0400 |
commit | 88676349a473020937ba5f2637535bf5960059c9 (patch) | |
tree | cb02be5fea2f127b284430508fcab3de959c37d7 /source/blender/editors/screen | |
parent | 4a59928484b93a6c3876c0c8b065f6d313640804 (diff) |
Code holiday commit:
- fix: user pref, window title was reset to 'Blender' on tab usage
- Undo history menu back:
- name "Undo History"
- hotkey alt+ctrl+z (alt+apple+z for mac)
- works like 2.4x, only for global undo, editmode and particle edit.
- Menu scroll
- for small windows or screens, popup menus now allow to display
all items, using internal scrolling
- works with a timer, scrolling 10 items per second when mouse
is over the top or bottom arrow
- if menu is too big to display, it now draws to top or bottom,
based on largest available space.
- also works for hotkey driven pop up menus.
- User pref "DPI" follows widget/layout size
- widgets & headers now become bigger and smaller, to match
'dpi' font sizes. Works well to match UI to monitor size.
- note that icons can get fuzzy, we need better mipmaps for it
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/area.c | 30 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_edit.c | 19 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 14 |
3 files changed, 48 insertions, 15 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index a1a4f33d008..fb535f2fee5 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -650,8 +650,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); @@ -953,6 +957,8 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) uiFreeBlocks(NULL, &ar->uiblocks); } + /* rechecks all 2d matrices */ + ar->v2d.flag &= ~V2D_IS_INITIALISED; } } @@ -1208,13 +1214,13 @@ 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"); 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 +1236,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 ************************/ @@ -1446,6 +1452,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 +1462,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 +1491,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 +1502,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; +} diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 9bc2b1a402c..eb41dcd147b 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -671,9 +671,9 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) /* test for collapsed areas. This could happen in some blender version... */ /* ton: removed option now, it needs Context... */ - /* make each window at least HEADERY high */ + /* make each window at least ED_area_headersize() high */ for(sa= sc->areabase.first; sa; sa= sa->next) { - int headery= HEADERY+1; + int headery= ED_area_headersize()+1; if(sa->v1->vec.y+headery > sa->v2->vec.y) { /* lower edge */ @@ -1055,6 +1055,18 @@ void ED_screen_draw(wmWindow *win) win->screen->do_draw= 0; } +/* helper call for below, dpi changes headers */ +static void screen_refresh_headersizes(void) +{ + const ListBase *lb= BKE_spacetypes_list(); + SpaceType *st; + + for(st= lb->first; st; st= st->next) { + ARegionType *art= BKE_regiontype_from_id(st, RGN_TYPE_HEADER); + if(art) art->prefsizey= ED_area_headersize(); + } +} + /* make this screen usable */ /* for file read and first use, for scaling window, area moves */ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) @@ -1076,6 +1088,9 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) else wm_subwindow_position(win, win->screen->mainwin, &winrct); + /* header size depends on DPI, let's verify */ + screen_refresh_headersizes(); + for(sa= win->screen->areabase.first; sa; sa= sa->next) { /* set spacetype and region callbacks, calls init() */ /* sets subwindows for regions, adds handlers */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index f454dd9ce02..d1d59457fd9 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -868,13 +868,14 @@ typedef struct sAreaMoveData { static void area_move_set_limits(bScreen *sc, int dir, int *bigger, int *smaller) { ScrArea *sa; + int areaminy= ED_area_headersize()+1; /* we check all areas and test for free space with MINSIZE */ *bigger= *smaller= 100000; for(sa= sc->areabase.first; sa; sa= sa->next) { if(dir=='h') { - int y1= sa->v2->vec.y - sa->v1->vec.y-AREAMINY; + int y1= sa->v2->vec.y - sa->v1->vec.y-areaminy; /* if top or down edge selected, test height */ if(sa->v1->flag && sa->v4->flag) @@ -933,6 +934,7 @@ static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int bScreen *sc= CTX_wm_screen(C); ScrVert *v1; ScrArea *sa; + int areaminy= ED_area_headersize()+1; delta= CLAMPIS(delta, -smaller, bigger); @@ -950,8 +952,8 @@ static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int v1->vec.y-= (v1->vec.y % AREAGRID); /* prevent too small top header */ - if(v1->vec.y > win->sizey-AREAMINY) - v1->vec.y= win->sizey-AREAMINY; + if(v1->vec.y > win->sizey-areaminy) + v1->vec.y= win->sizey-areaminy; } } } @@ -1165,6 +1167,7 @@ static int area_split_init(bContext *C, wmOperator *op) { ScrArea *sa= CTX_wm_area(C); sAreaSplitData *sd; + int areaminy= ED_area_headersize()+1; int dir; /* required context */ @@ -1175,7 +1178,7 @@ static int area_split_init(bContext *C, wmOperator *op) /* minimal size */ if(dir=='v' && sa->winx < 2*AREAMINX) return 0; - if(dir=='h' && sa->winy < 2*AREAMINY) return 0; + if(dir=='h' && sa->winy < 2*areaminy) return 0; /* custom data */ sd= (sAreaSplitData*)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); @@ -3314,6 +3317,7 @@ void ED_operatortypes_screen(void) WM_operatortype_append(ED_OT_undo); WM_operatortype_append(ED_OT_undo_push); WM_operatortype_append(ED_OT_redo); + WM_operatortype_append(ED_OT_undo_history); } @@ -3422,9 +3426,11 @@ void ED_keymap_screen(wmKeyConfig *keyconf) #ifdef __APPLE__ WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0); + WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT|KM_OSKEY, 0); #endif WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); /* render */ |