diff options
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r-- | source/blender/editors/screen/area.c | 240 |
1 files changed, 148 insertions, 92 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 296c38fa51a..81f06611c39 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -159,14 +159,8 @@ void ED_area_overdraw_flush(bContext *C, ScrArea *sa, ARegion *ar) for(az= sa->actionzones.first; az; az= az->next) { int xs, ys; - if(az->type==AZONE_AREA) { - xs= (az->x1+az->x2)/2; - ys= (az->y1+az->y2)/2; - } - else { - xs= az->x3; - ys= az->y3; - } + xs= (az->x1+az->x2)/2; + ys= (az->y1+az->y2)/2; /* test if inside */ if(BLI_in_rcti(&ar->winrct, xs, ys)) { @@ -196,25 +190,42 @@ static void area_draw_azone(short x1, short y1, short x2, short y2) fdrawline(xmin, ymax-2*dy+1, xmax-2*dx+1, ymin); } + static void region_draw_azone(ScrArea *sa, AZone *az) { - if(az->ar==NULL) return; + GLUquadricObj *qobj = gluNewQuadric(); + short midx = az->x1 + (az->x2 - az->x1)/2; + short midy = az->y1 + (az->y2 - az->y1)/2; - UI_SetTheme(sa->spacetype, az->ar->type->regionid); + if(az->ar==NULL) return; - UI_ThemeColor(TH_BACK); - glBegin(GL_TRIANGLES); - glVertex2s(az->x1, az->y1); - glVertex2s(az->x2, az->y2); - glVertex2s(az->x3, az->y3); - glEnd(); + /* only display action zone icons when the region is hidden */ + if (!(az->ar->flag & RGN_FLAG_HIDDEN)) return; - UI_ThemeColorShade(TH_BACK, 50); - sdrawline(az->x1, az->y1, az->x3, az->y3); + glPushMatrix(); + glTranslatef(midx, midy, 0.); - UI_ThemeColorShade(TH_BACK, -50); - sdrawline(az->x2, az->y2, az->x3, az->y3); + /* outlined circle */ + glEnable(GL_LINE_SMOOTH); + + glColor4f(1.f, 1.f, 1.f, 0.8f); + gluQuadricDrawStyle(qobj, GLU_FILL); + gluDisk( qobj, 0.0, 4.25f, 16, 1); + + glColor4f(0.2f, 0.2f, 0.2f, 0.9f); + + gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); + gluDisk( qobj, 0.0, 4.25f, 16, 1); + + glDisable(GL_LINE_SMOOTH); + + glPopMatrix(); + gluDeleteQuadric(qobj); + + /* + */ + sdrawline(midx, midy-2, midx, midy+3); + sdrawline(midx-2, midy, midx+3, midy); } @@ -235,10 +246,11 @@ void ED_area_overdraw(bContext *C) AZone *az; for(az= sa->actionzones.first; az; az= az->next) { if(az->do_draw) { - if(az->type==AZONE_AREA) + if(az->type==AZONE_AREA) { area_draw_azone(az->x1, az->y1, az->x2, az->y2); - else if(az->type==AZONE_REGION) + } else if(az->type==AZONE_REGION) { region_draw_azone(sa, az); + } az->do_draw= 0; } @@ -249,7 +261,7 @@ void ED_area_overdraw(bContext *C) } /* get scissor rect, checking overlapping regions */ -static void region_scissor_winrct(ARegion *ar, rcti *winrct) +void region_scissor_winrct(ARegion *ar, rcti *winrct) { *winrct= ar->winrct; @@ -449,72 +461,103 @@ static void area_azone_initialize(ScrArea *sa) BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); } -static void region_azone_initialize(ScrArea *sa, ARegion *ar, char edge) +#define AZONEPAD_EDGE 4 +#define AZONEPAD_ICON 8 +static void region_azone_edge(AZone *az, ARegion *ar) { - AZone *az, *azt; - - az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); - BLI_addtail(&(sa->actionzones), az); - az->type= AZONE_REGION; - az->ar= ar; - az->edge= edge; - - if(edge=='t') { - az->x1= ar->winrct.xmin+AZONESPOT; - az->y1= ar->winrct.ymax; - az->x2= ar->winrct.xmin+2*AZONESPOT; + if(az->edge=='t') { + az->x1= ar->winrct.xmin; + az->y1= ar->winrct.ymax - AZONEPAD_EDGE; + az->x2= ar->winrct.xmax; az->y2= ar->winrct.ymax; - az->x3= (az->x1+az->x2)/2; - az->y3= az->y2+AZONESPOT/2; - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y3); } - else if(edge=='b') { - az->x1= ar->winrct.xmin+AZONESPOT; - az->y1= ar->winrct.ymin; - az->x2= ar->winrct.xmin+2*AZONESPOT; + else if(az->edge=='b') { + az->x1= ar->winrct.xmin; + az->y1= ar->winrct.ymin + AZONEPAD_EDGE; + az->x2= ar->winrct.xmax; az->y2= ar->winrct.ymin; - az->x3= (az->x1+az->x2)/2; - az->y3= az->y2-AZONESPOT/2; - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y3, az->y1); } - else if(edge=='l') { + else if(az->edge=='l') { az->x1= ar->winrct.xmin; - az->y1= ar->winrct.ymax-AZONESPOT; - az->x2= ar->winrct.xmin; - az->y2= ar->winrct.ymax-2*AZONESPOT; - az->x3= az->x2-AZONESPOT/2; - az->y3= (az->y1+az->y2)/2; - BLI_init_rcti(&az->rect, az->x3, az->x1, az->y1, az->y2); + az->y1= ar->winrct.ymin; + az->x2= ar->winrct.xmin + AZONEPAD_EDGE; + az->y2= ar->winrct.ymax; } - else { // if(edge=='r') { + else { // if(az->edge=='r') { az->x1= ar->winrct.xmax; - az->y1= ar->winrct.ymax-AZONESPOT; - az->x2= ar->winrct.xmax; - az->y2= ar->winrct.ymax-2*AZONESPOT; - az->x3= az->x2+AZONESPOT/2; - az->y3= (az->y1+az->y2)/2; - BLI_init_rcti(&az->rect, az->x1, az->x3, az->y1, az->y2); + az->y1= ar->winrct.ymin; + az->x2= ar->winrct.xmax - AZONEPAD_EDGE; + az->y2= ar->winrct.ymax; + } + + BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); +} + +static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) +{ + AZone *azt; + + if(az->edge=='t') { + az->x1= ar->winrct.xmax - AZONEPAD_ICON; + az->y1= ar->winrct.ymax + AZONEPAD_ICON; + az->x2= ar->winrct.xmax - 2*AZONEPAD_ICON; + az->y2= ar->winrct.ymax + 2*AZONEPAD_ICON; } + else if(az->edge=='b') { + az->x1= ar->winrct.xmin + AZONEPAD_ICON; + az->y1= ar->winrct.ymin - AZONEPAD_ICON; + az->x2= ar->winrct.xmin + 2*AZONEPAD_ICON; + az->y2= ar->winrct.ymin - 2*AZONEPAD_ICON; + } + else if(az->edge=='l') { + az->x1= ar->winrct.xmin - 2*AZONEPAD_ICON; + az->y1= ar->winrct.ymax - 2*AZONEPAD_ICON; + az->x2= ar->winrct.xmin - AZONEPAD_ICON; + az->y2= ar->winrct.ymax - AZONEPAD_ICON; + } + else { // if(az->edge=='r') { + az->x1= ar->winrct.xmax + AZONEPAD_ICON; + az->y1= ar->winrct.ymax - 2*AZONEPAD_ICON; + az->x2= ar->winrct.xmax + 2*AZONEPAD_ICON; + az->y2= ar->winrct.ymax - AZONEPAD_ICON; + } + + BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); /* if more azones on 1 spot, set offset */ for(azt= sa->actionzones.first; azt; azt= azt->next) { if(az!=azt) { if( ABS(az->x1-azt->x1) < 2 && ABS(az->y1-azt->y1) < 2) { - if(edge=='t' || edge=='b') { + if(az->edge=='t' || az->edge=='b') { az->x1+= AZONESPOT; az->x2+= AZONESPOT; - az->x3+= AZONESPOT; - BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y3); + BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); } else { az->y1-= AZONESPOT; az->y2-= AZONESPOT; - az->y3-= AZONESPOT; - BLI_init_rcti(&az->rect, az->x1, az->x3, az->y1, az->y2); + BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); } } } } +} + +static void region_azone_initialize(ScrArea *sa, ARegion *ar, char edge) +{ + AZone *az; + + az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); + BLI_addtail(&(sa->actionzones), az); + az->type= AZONE_REGION; + az->ar= ar; + az->edge= edge; + + if (ar->flag & RGN_FLAG_HIDDEN) { + region_azone_icon(sa, az, ar); + } else { + region_azone_edge(az, ar); + } } @@ -797,6 +840,10 @@ static void ed_default_handlers(wmWindowManager *wm, ListBase *handlers, int fla ListBase *keymap= WM_keymap_listbase(wm, "Frames", 0, 0); WM_event_add_keymap_handler(handlers, keymap); } + if(flag & ED_KEYMAP_GPENCIL) { + ListBase *keymap= WM_keymap_listbase(wm, "Grease Pencil", 0, 0); + WM_event_add_keymap_handler(handlers, keymap); + } } @@ -1030,7 +1077,12 @@ void ED_area_prevspace(bContext *C) } #endif - ED_area_newspace(C, sa, sl->next->spacetype); + /* workaround for case of double prevspace, render window + with a file browser on top of it */ + if(sl->next->spacetype == SPACE_FILE && sl->next->next) + ED_area_newspace(C, sa, sl->next->next->spacetype); + else + ED_area_newspace(C, sa, sl->next->spacetype); } else { ED_area_newspace(C, sa, SPACE_INFO); @@ -1041,39 +1093,38 @@ void ED_area_prevspace(bContext *C) static char *windowtype_pup(void) { return( - "Window type:%t" //14 - "|3D View %x1" //30 - - "|%l" // 33 - - "|Graph Editor %x2" //54 - "|DopeSheet %x12" //73 - "|NLA Editor %x13" //94 - - "|%l" //97 - - "|UV/Image Editor %x6" //117 + "Window type:%t" + "|3D View %x1" + + "|%l" - "|Video Sequence Editor %x8" //143 - "|Timeline %x15" //163 - // "|Audio Window %x11" //163 - "|Text Editor %x9" //179 + "|Timeline %x15" + "|Graph Editor %x2" + "|DopeSheet %x12" + "|NLA Editor %x13" - "|%l" //192 + "|%l" + "|UV/Image Editor %x6" - "|User Preferences %x7" //213 - "|Outliner %x3" //232 - "|Buttons Window %x4" //251 + "|Video Sequence Editor %x8" + "|Text Editor %x9" "|Node Editor %x16" "|Logic Editor %x17" - "|%l" //254 - "|File Browser %x5" //290 + "|%l" + + "|Properties %x4" + "|Outliner %x3" + "|User Preferences %x19" + "|Info%x7" + + "|%l" + + "|File Browser %x5" - "|%l" //293 + "|%l" - // "|Scripts Window %x14"//313 "|Console %x18" ); } @@ -1245,6 +1296,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex /* before setting the view */ if(vertical) { + /* only allow scrolling in vertical direction */ v2d->keepofs |= V2D_LOCKOFS_X|V2D_KEEPOFS_Y; v2d->keepofs &= ~(V2D_LOCKOFS_Y|V2D_KEEPOFS_X); @@ -1255,8 +1307,12 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex y= -y; } else { - v2d->keepofs |= V2D_LOCKOFS_Y|V2D_KEEPOFS_X; - v2d->keepofs &= ~(V2D_LOCKOFS_X|V2D_KEEPOFS_Y); + /* for now, allow scrolling in both directions (since layouts are optimised for vertical, + * they often don't fit in horizontal layout) + */ + v2d->keepofs &= ~(V2D_LOCKOFS_X|V2D_LOCKOFS_Y|V2D_KEEPOFS_X|V2D_KEEPOFS_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 if(!newcontext) |