diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-12-26 01:31:19 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-12-26 01:31:19 +0400 |
commit | 2cd5436a81da5c15ac70bd2b80c2f062cce5d02e (patch) | |
tree | 2cc12476fb3fa653042eef99fa6b5d4d8cb290ec /source/blender/editors/screen | |
parent | 4ced91da47ec1e95d71beef07b218fd0290ff68a (diff) | |
parent | 02d72b5c076f4ae1b47da74fe7a60a916edad9f2 (diff) |
svn merge ^/trunk/blender -r42839:42871
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 71 |
1 files changed, 56 insertions, 15 deletions
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 2f80c58a836..de67a702598 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1664,6 +1664,47 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_FINISHED; } +static int region_scale_get_maxsize(RegionMoveData *rmd) +{ + int maxsize= 0; + + if(rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { + return rmd->sa->winx - UI_UNIT_X; + } + + if(rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) { + /* this calculation seems overly verbose + * can someone explain why this method is necessary? - campbell */ + maxsize = rmd->maxsize - ((rmd->sa->headertype==HEADERTOP)?UI_UNIT_Y*2:UI_UNIT_Y) - (UI_UNIT_Y/4); + } + + return maxsize; +} + +static void region_scale_validate_size(RegionMoveData *rmd) +{ + if((rmd->ar->flag & RGN_FLAG_HIDDEN)==0) { + short *size, maxsize= -1; + + + if(rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) + size= &rmd->ar->sizex; + else + size= &rmd->ar->sizey; + + maxsize= region_scale_get_maxsize(rmd); + + if(*size > maxsize && maxsize > 0) + *size= maxsize; + } +} + +static void region_scale_toggle_hidden(bContext *C, RegionMoveData *rmd) +{ + ED_region_toggle_hidden(C, rmd->ar); + region_scale_validate_size(rmd); +} + static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) { RegionMoveData *rmd= op->customdata; @@ -1683,35 +1724,31 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) if(rmd->ar->sizex < UI_UNIT_X) { rmd->ar->sizex= rmd->origval; if(!(rmd->ar->flag & RGN_FLAG_HIDDEN)) - ED_region_toggle_hidden(C, rmd->ar); + region_scale_toggle_hidden(C, rmd); } else if(rmd->ar->flag & RGN_FLAG_HIDDEN) - ED_region_toggle_hidden(C, rmd->ar); + region_scale_toggle_hidden(C, rmd); } else { - int maxsize=0; + int maxsize= region_scale_get_maxsize(rmd); delta= event->y - rmd->origy; if(rmd->edge==AE_BOTTOM_TO_TOPLEFT) delta= -delta; rmd->ar->sizey= rmd->origval + delta; CLAMP(rmd->ar->sizey, 0, rmd->maxsize); - if(rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) { - /* this calculation seems overly verbose - * can someone explain why this method is necessary? - campbell */ - maxsize = rmd->maxsize - ((rmd->sa->headertype==HEADERTOP)?UI_UNIT_Y*2:UI_UNIT_Y) - (UI_UNIT_Y/4); - } - /* note, 'UI_UNIT_Y/4' means you need to drag the header almost * all the way down for it to become hidden, this is done * otherwise its too easy to do this by accident */ - if(rmd->ar->sizey < UI_UNIT_Y/4 || (maxsize > 0 && (rmd->ar->sizey > maxsize)) ) { + if(rmd->ar->sizey < UI_UNIT_Y/4) { rmd->ar->sizey= rmd->origval; if(!(rmd->ar->flag & RGN_FLAG_HIDDEN)) - ED_region_toggle_hidden(C, rmd->ar); + region_scale_toggle_hidden(C, rmd); } + else if(maxsize > 0 && (rmd->ar->sizey > maxsize)) + rmd->ar->sizey= maxsize; else if(rmd->ar->flag & RGN_FLAG_HIDDEN) - ED_region_toggle_hidden(C, rmd->ar); + region_scale_toggle_hidden(C, rmd); } ED_area_tag_redraw(rmd->sa); WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); @@ -1723,10 +1760,14 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) if(ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) { if(rmd->ar->flag & RGN_FLAG_HIDDEN) { - ED_region_toggle_hidden(C, rmd->ar); - ED_area_tag_redraw(rmd->sa); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + region_scale_toggle_hidden(C, rmd); + } + else if(rmd->ar->flag & RGN_FLAG_TOO_SMALL) { + region_scale_validate_size(rmd); } + + ED_area_tag_redraw(rmd->sa); + WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } MEM_freeN(op->customdata); op->customdata = NULL; |