diff options
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r-- | source/blender/editors/screen/area.c | 209 |
1 files changed, 190 insertions, 19 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 1d4a24d3e4e..1bbf6e3b0dc 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -147,17 +147,12 @@ static void area_draw_azone(short x1, short y1, short x2, short y2) glEnd(); } -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(); @@ -186,6 +181,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) @@ -207,7 +275,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; @@ -479,6 +559,96 @@ static void region_azone_edge(AZone *az, ARegion *ar) BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); } +#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) { if(!(ar->flag & RGN_FLAG_HIDDEN)) { @@ -686,15 +856,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; @@ -710,12 +871,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' */ @@ -729,7 +900,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; |