diff options
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r-- | source/blender/editors/screen/area.c | 226 |
1 files changed, 203 insertions, 23 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 4d531e78ec0..bc97cd9d3ff 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -188,17 +188,12 @@ static void area_draw_azone(short x1, short y1, short x2, short y2) } -static void region_draw_azone(AZone *az) +static void region_draw_azone_icon(AZone *az) { GLUquadricObj *qobj = NULL; short midx = az->x1 + (az->x2 - az->x1)/2; short midy = az->y1 + (az->y2 - az->y1)/2; - - if(az->ar==NULL) return; - - /* only display action zone icons when the region is hidden */ - if (!(az->ar->flag & RGN_FLAG_HIDDEN)) return; - + qobj = gluNewQuadric(); glPushMatrix(); @@ -227,6 +222,79 @@ static void region_draw_azone(AZone *az) sdrawline(midx-2, midy, midx+3, midy); } +static void region_draw_azone_tab(AZone *az) +{ + float col[3]; + + glEnable(GL_BLEND); + UI_GetThemeColor3fv(TH_HEADER, col); + glColor4f(col[0], col[1], col[2], 0.5f); + + /* add code to draw region hidden as 'too small' */ + switch(az->edge) { + case AE_TOP_TO_BOTTOMRIGHT: + uiSetRoundBox(3 + 16); + + uiDrawBoxShade(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); + uiRoundRect((float)az->x1, 0.3f+(float)az->y1, (float)az->x2, 0.3f+(float)az->y2, 4.0f); + break; + case AE_BOTTOM_TO_TOPLEFT: + uiSetRoundBox(12 + 16); + + uiDrawBoxShade(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); + uiRoundRect((float)az->x1, 0.3f+(float)az->y1, (float)az->x2, 0.3f+(float)az->y2, 4.0f); + break; + case AE_LEFT_TO_TOPRIGHT: + uiSetRoundBox(9 + 16); + + uiDrawBoxShade(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); + uiRoundRect((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f); + break; + case AE_RIGHT_TO_TOPLEFT: + uiSetRoundBox(6 + 16); + + uiDrawBoxShade(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); + uiRoundRect((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f); + break; + } + + glDisable(GL_BLEND); +} + +static void region_draw_azone_tria(AZone *az) +{ + extern void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); /* xxx temp */ + + glEnable(GL_BLEND); + //UI_GetThemeColor3fv(TH_HEADER, col); + glColor4f(0.0f, 0.0f, 0.0f, 0.35f); + + /* add code to draw region hidden as 'too small' */ + switch(az->edge) { + case AE_TOP_TO_BOTTOMRIGHT: + ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y1, (float)(az->x1+az->x2)/2, (float)az->y2); + break; + + case AE_BOTTOM_TO_TOPLEFT: + ui_draw_anti_tria((float)az->x1, (float)az->y2, (float)az->x2, (float)az->y2, (float)(az->x1+az->x2)/2, (float)az->y1); + break; + + case AE_LEFT_TO_TOPRIGHT: + ui_draw_anti_tria((float)az->x2, (float)az->y1, (float)az->x2, (float)az->y2, (float)az->x1, (float)(az->y1+az->y2)/2); + break; + + case AE_RIGHT_TO_TOPLEFT: + ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x1, (float)az->y2, (float)az->x2, (float)(az->y1+az->y2)/2); + break; + + } + + glDisable(GL_BLEND); +} /* only exported for WM */ void ED_area_overdraw(bContext *C) @@ -248,7 +316,19 @@ void ED_area_overdraw(bContext *C) if(az->type==AZONE_AREA) { area_draw_azone(az->x1, az->y1, az->x2, az->y2); } else if(az->type==AZONE_REGION) { - region_draw_azone(az); + + if(az->ar) { + /* only display tab or icons when the region is hidden */ + if (az->ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { + + if(G.rt==2) + region_draw_azone_tria(az); + else if(G.rt==1) + region_draw_azone_tab(az); + else + region_draw_azone_icon(az); + } + } } az->do_draw= 0; @@ -579,6 +659,96 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) } } +#define AZONEPAD_TABW 18 +#define AZONEPAD_TABH 7 + +/* region already made zero sized, in shape of edge */ +static void region_azone_tab(ScrArea *sa, AZone *az, ARegion *ar) +{ + AZone *azt; + int tot= 0, add; + + for(azt= sa->actionzones.first; azt; azt= azt->next) { + if(azt->edge == az->edge) tot++; + } + + switch(az->edge) { + case AE_TOP_TO_BOTTOMRIGHT: + if(ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; + az->x1= ar->winrct.xmax - 2*AZONEPAD_TABW; + az->y1= ar->winrct.ymax - add; + az->x2= ar->winrct.xmax - AZONEPAD_TABW; + az->y2= ar->winrct.ymax - add + AZONEPAD_TABH; + break; + case AE_BOTTOM_TO_TOPLEFT: + az->x1= ar->winrct.xmin + AZONEPAD_TABW; + az->y1= ar->winrct.ymin - AZONEPAD_TABH; + az->x2= ar->winrct.xmin + 2*AZONEPAD_TABW; + az->y2= ar->winrct.ymin; + break; + case AE_LEFT_TO_TOPRIGHT: + az->x1= ar->winrct.xmin + 1 - AZONEPAD_TABH; + az->y1= ar->winrct.ymax - 2*AZONEPAD_TABW; + az->x2= ar->winrct.xmin + 1; + az->y2= ar->winrct.ymax - AZONEPAD_TABW; + break; + case AE_RIGHT_TO_TOPLEFT: + az->x1= ar->winrct.xmax - 1; + az->y1= ar->winrct.ymax - 2*AZONEPAD_TABW; + az->x2= ar->winrct.xmax - 1 + AZONEPAD_TABH; + az->y2= ar->winrct.ymax - AZONEPAD_TABW; + break; + } + /* rect needed for mouse pointer test */ + BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); +} + +#define AZONEPAD_TRIAW 16 +#define AZONEPAD_TRIAH 9 + + +/* region already made zero sized, in shape of edge */ +static void region_azone_tria(ScrArea *sa, AZone *az, ARegion *ar) +{ + AZone *azt; + int tot= 0, add; + + for(azt= sa->actionzones.first; azt; azt= azt->next) { + if(azt->edge == az->edge) tot++; + } + + switch(az->edge) { + case AE_TOP_TO_BOTTOMRIGHT: + if(ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; + az->x1= ar->winrct.xmax - 2*AZONEPAD_TRIAW; + az->y1= ar->winrct.ymax - add; + az->x2= ar->winrct.xmax - AZONEPAD_TRIAW; + az->y2= ar->winrct.ymax - add + AZONEPAD_TRIAH; + break; + case AE_BOTTOM_TO_TOPLEFT: + az->x1= ar->winrct.xmin + AZONEPAD_TRIAW; + az->y1= ar->winrct.ymin - AZONEPAD_TRIAH; + az->x2= ar->winrct.xmin + 2*AZONEPAD_TRIAW; + az->y2= ar->winrct.ymin; + break; + case AE_LEFT_TO_TOPRIGHT: + az->x1= ar->winrct.xmin + 1 - AZONEPAD_TRIAH; + az->y1= ar->winrct.ymax - 2*AZONEPAD_TRIAW; + az->x2= ar->winrct.xmin + 1; + az->y2= ar->winrct.ymax - AZONEPAD_TRIAW; + break; + case AE_RIGHT_TO_TOPLEFT: + az->x1= ar->winrct.xmax - 1; + az->y1= ar->winrct.ymax - 2*AZONEPAD_TRIAW; + az->x2= ar->winrct.xmax - 1 + AZONEPAD_TRIAH; + az->y2= ar->winrct.ymax - AZONEPAD_TRIAW; + break; + } + /* rect needed for mouse pointer test */ + BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); +} + + static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge) { AZone *az; @@ -589,8 +759,13 @@ static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge) az->ar= ar; az->edge= edge; - if (ar->flag & RGN_FLAG_HIDDEN) { - region_azone_icon(sa, az, ar); + if (ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { + if(G.rt==2) + region_azone_tria(sa, az, ar); + else if(G.rt==1) + region_azone_tab(sa, az, ar); + else + region_azone_icon(sa, az, ar); } else { region_azone_edge(az, ar); } @@ -790,15 +965,6 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int ar->winx= ar->winrct.xmax - ar->winrct.xmin + 1; ar->winy= ar->winrct.ymax - ar->winrct.ymin + 1; - /* restore test exception */ - if(ar->alignment & RGN_SPLIT_PREV) { - if(ar->prev) { - remainder= remainder_prev; - ar->prev->winx= ar->prev->winrct.xmax - ar->prev->winrct.xmin + 1; - ar->prev->winy= ar->prev->winrct.ymax - ar->prev->winrct.ymin + 1; - } - } - /* set winrect for azones */ if(ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { ar->winrct= *remainder; @@ -814,12 +980,22 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int else /* prevent winrct to be valid */ ar->winrct.xmax= ar->winrct.xmin; } + + /* restore prev-split exception */ + if(ar->alignment & RGN_SPLIT_PREV) { + if(ar->prev) { + remainder= remainder_prev; + ar->prev->winx= ar->prev->winrct.xmax - ar->prev->winrct.xmin + 1; + ar->prev->winy= ar->prev->winrct.ymax - ar->prev->winrct.ymin + 1; + } + } + /* in end, add azones, where appropriate */ 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 + * Without this, you 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' */ @@ -833,7 +1009,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int static void area_calc_totrct(ScrArea *sa, int sizex, int sizey) { - short rt= CLAMPIS(G.rt, 0, 16); + short rt= 0; // CLAMPIS(G.rt, 0, 16); if(sa->v1->vec.x>0) sa->totrct.xmin= sa->v1->vec.x+1+rt; else sa->totrct.xmin= sa->v1->vec.x; @@ -1230,6 +1406,7 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco) "Displays current editor type. " "Click for menu of available types"); uiButSetFunc(but, spacefunc, NULL, NULL); + uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ return xco + UI_UNIT_X + 14; } @@ -1238,6 +1415,7 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) { ScrArea *sa= CTX_wm_area(C); int xco= 8; + uiBut *but; if (!sa->full) xco= ED_area_header_switchbutton(C, block, yco); @@ -1245,20 +1423,22 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) uiBlockSetEmboss(block, UI_EMBOSSN); if (sa->flag & HEADER_NO_PULLDOWN) { - uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, + but= uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, ICON_DISCLOSURE_TRI_RIGHT, 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, + but= uiDefIconButBitS(block, TOG, HEADER_NO_PULLDOWN, 0, ICON_DISCLOSURE_TRI_DOWN, xco,yco,UI_UNIT_X,UI_UNIT_Y-2, &(sa->flag), 0, 0, 0, 0, "Hide pulldown menus"); } + uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ + uiBlockSetEmboss(block, UI_EMBOSS); return xco + UI_UNIT_X; |