diff options
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r-- | source/blender/editors/screen/area.c | 97 |
1 files changed, 72 insertions, 25 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 69af4fbb45d..79ba11a5c55 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -274,6 +274,28 @@ static void region_scissor_winrct(ARegion *ar, rcti *winrct) } /* only exported for WM */ +/* makes region ready for drawing, sets pixelspace */ +void ED_region_set(const bContext *C, ARegion *ar) +{ + wmWindow *win= CTX_wm_window(C); + ScrArea *sa= CTX_wm_area(C); + rcti winrct; + + /* checks other overlapping regions */ + region_scissor_winrct(ar, &winrct); + + ar->drawrct= winrct; + + /* note; this sets state, so we can use wmOrtho and friends */ + wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct); + + UI_SetTheme(sa?sa->spacetype:0, ar->type?ar->type->regionid:0); + + ED_region_pixelspace(ar); +} + + +/* only exported for WM */ void ED_region_do_draw(bContext *C, ARegion *ar) { wmWindow *win= CTX_wm_window(C); @@ -308,7 +330,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) glClear(GL_COLOR_BUFFER_BIT); UI_ThemeColor(TH_TEXT); - BLF_draw_default(20, 6, 0.0f, ar->headerstr); + BLF_draw_default(20, 8, 0.0f, ar->headerstr); } else if(at->draw) { at->draw(C, ar); @@ -888,13 +910,6 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) ARegion *newar= BKE_area_region_copy(st, ar); BLI_addtail(&sa1->regionbase, newar); } - -#ifndef DISABLE_PYTHON - /* scripts */ - BPY_free_scriptlink(&sa1->scriptlink); - sa1->scriptlink= sa2->scriptlink; - BPY_copy_scriptlink(&sa1->scriptlink); /* copies internal pointers */ -#endif } /* *********** Space switching code *********** */ @@ -1041,7 +1056,7 @@ static char *windowtype_pup(void) "|Video Sequence Editor %x8" //143 "|Timeline %x15" //163 - "|Audio Window %x11" //163 + // "|Audio Window %x11" //163 "|Text Editor %x9" //179 "|%l" //192 @@ -1058,7 +1073,8 @@ static char *windowtype_pup(void) "|%l" //293 - "|Scripts Window %x14"//313 + // "|Scripts Window %x14"//313 + "|Console %x18" ); } @@ -1069,7 +1085,7 @@ static void spacefunc(struct bContext *C, void *arg1, void *arg2) } /* returns offset for next button in header */ -int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) +int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco) { ScrArea *sa= CTX_wm_area(C); uiBut *but; @@ -1082,9 +1098,18 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) "Click for menu of available types."); uiButSetFunc(but, spacefunc, NULL, NULL); - xco += XIC + 14; + return xco + XIC + 14; +} + +int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) +{ + ScrArea *sa= CTX_wm_area(C); + int xco= 8; + xco= ED_area_header_switchbutton(C, block, yco); + uiBlockSetEmboss(block, UI_EMBOSSN); + if (sa->flag & HEADER_NO_PULLDOWN) { uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, ICON_DISCLOSURE_TRI_RIGHT, @@ -1099,16 +1124,15 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) &(sa->flag), 0, 0, 0, 0, "Hide pulldown menus"); } - xco+=XIC; - + uiBlockSetEmboss(block, UI_EMBOSS); - return xco; + return xco + XIC; } /************************ standard UI regions ************************/ -void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *context) +void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *context, int contextnr) { ScrArea *sa= CTX_wm_area(C); uiStyle *style= U.uistyles.first; @@ -1116,8 +1140,12 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex PanelType *pt; Panel *panel; View2D *v2d= &ar->v2d; + View2DScrollers *scrollers; float col[3]; - int xco, yco, x, y, miny=0, w, em, header, triangle, open; + int xco, yco, x, y, miny=0, w, em, header, triangle, open, newcontext= 0; + + if(contextnr >= 0) + newcontext= UI_view2d_tab_set(v2d, contextnr); if(vertical) { w= v2d->cur.xmax - v2d->cur.xmin; @@ -1217,22 +1245,27 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex /* before setting the view */ if(vertical) { - v2d->keepofs |= V2D_LOCKOFS_X; - v2d->keepofs &= ~V2D_LOCKOFS_Y; + v2d->keepofs |= V2D_LOCKOFS_X|V2D_KEEPOFS_Y; + v2d->keepofs &= ~(V2D_LOCKOFS_Y|V2D_KEEPOFS_X); // don't jump back when panels close or hide - y= MAX2(-y, -v2d->cur.ymin); + if(!newcontext) + y= MAX2(-y, -v2d->cur.ymin); + else + y= -y; } else { - v2d->keepofs &= ~V2D_LOCKOFS_X; - v2d->keepofs |= V2D_LOCKOFS_Y; - + v2d->keepofs |= V2D_LOCKOFS_Y|V2D_KEEPOFS_X; + v2d->keepofs &= ~(V2D_LOCKOFS_X|V2D_KEEPOFS_Y); + // don't jump back when panels close or hide - x= MAX2(x, v2d->cur.xmax); + if(!newcontext) + x= MAX2(x, v2d->cur.xmax); y= -y; } - UI_view2d_totRect_set(v2d, x, y); + // +V2D_SCROLL_HEIGHT is workaround to set the actual height + UI_view2d_totRect_set(v2d, x+V2D_SCROLL_WIDTH, y+V2D_SCROLL_HEIGHT); /* set the view */ UI_view2d_view_ortho(C, v2d); @@ -1242,12 +1275,26 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex /* restore view matrix */ UI_view2d_view_restore(C); + + /* scrollers */ + scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + UI_view2d_scrollers_draw(C, v2d, scrollers); + UI_view2d_scrollers_free(scrollers); } void ED_region_panels_init(wmWindowManager *wm, ARegion *ar) { ListBase *keymap; + + // XXX quick hacks for files saved with 2.5 already (i.e. the builtin defaults file) + // scrollbars for button regions + ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); + ar->v2d.keepzoom |= V2D_KEEPZOOM; + // correctly initialised User-Prefs? + if(!(ar->v2d.align & V2D_ALIGN_NO_POS_Y)) + ar->v2d.flag &= ~V2D_IS_INITIALISED; + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx, ar->winy); keymap= WM_keymap_listbase(wm, "View2D Buttons List", 0, 0); |