diff options
author | Joshua Leung <aligorith@gmail.com> | 2010-01-31 14:13:31 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2010-01-31 14:13:31 +0300 |
commit | 127754373216db89fc72cbfd564292dcd1437bdd (patch) | |
tree | 39dccb168f4ab60f913f621fa253046a112a4abe | |
parent | 6de25c937f41f180ef3aea4dcac50ce24d9510d7 (diff) |
Various tweaks to View2D code for handling of scrollbar interactions in relation to bug 19881:
* Clearly labelled the way that the scrollbar hiding works. Also see the report comments for an overview
* Added another pair of flags for another one of the cases in which scrollbars should also get ignored; when the entire contents of the view are visible, a pair of flags is now set in the view2d data (instead of for the scrollers tempdata only) for detecting this case too
* Fixed the potential for scrollbars without zoom handles shown to have those handles still considered. This still happened in the User Preferences window, but has now been disabled.
--
These changes still don't solve the bug though. Currently after the scrollbar operator passes through, the Outliner's activate-selection operators still fail to start.
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d.c | 23 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 24 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_view2d_types.h | 5 |
5 files changed, 46 insertions, 12 deletions
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 330209ef6f5..2ba7d8bb457 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -731,7 +731,7 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti * glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1)); for (rgb=0; rgb<3; rgb++) { - float *data; + float *data = NULL; if (rgb==0) data = hist->data_r; else if (rgb==1) data = hist->data_g; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 019aa10e902..bcee2b79080 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4234,13 +4234,13 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y) mask_rct.ymin= v2d->mask.ymin; mask_rct.ymax= v2d->mask.ymax; - if (v2d->scroll & V2D_SCROLL_VERTICAL_HIDE) { + if (v2d->scroll & (V2D_SCROLL_VERTICAL_HIDE|V2D_SCROLL_VERTICAL_FULLR)) { if (v2d->scroll & V2D_SCROLL_LEFT) mask_rct.xmin= v2d->vert.xmin; else if (v2d->scroll & V2D_SCROLL_RIGHT) mask_rct.xmax= v2d->vert.xmax; } - if (v2d->scroll & V2D_SCROLL_HORIZONTAL_HIDE) { + if (v2d->scroll & (V2D_SCROLL_HORIZONTAL_HIDE|V2D_SCROLL_HORIZONTAL_FULLR)) { if (v2d->scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) mask_rct.ymin= v2d->hor.ymin; else if (v2d->scroll & V2D_SCROLL_TOP) diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 7aabc147139..12265715415 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -62,7 +62,12 @@ /* *********************************************************************** */ -/* helper to allow scrollbars to dynamically hide */ +/* helper to allow scrollbars to dynamically hide + * - returns a copy of the scrollbar settings with the flags to display + * horizontal/vertical scrollbars removed + * - input scroll value is the v2d->scroll var + * - hide flags are set per region at drawtime + */ static int view2d_scroll_mapped(int scroll) { if(scroll & V2D_SCROLL_HORIZONTAL_HIDE) @@ -1411,10 +1416,14 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short CLAMP(scrollers->hor_min, hor.xmin, hor.xmax-V2D_SCROLLER_HANDLE_SIZE); } - /* check whether sliders can disappear */ + /* check whether sliders can disappear due to the full-range being used */ if(v2d->keeptot) { - if(fac1 <= 0.0f && fac2 >= 1.0f) + if ((fac1 <= 0.0f) && (fac2 >= 1.0f)) { + v2d->scroll |= V2D_SCROLL_HORIZONTAL_FULLR; scrollers->horfull= 1; + } + else + v2d->scroll &= ~V2D_SCROLL_HORIZONTAL_FULLR; } } @@ -1448,10 +1457,14 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short CLAMP(scrollers->vert_min, vert.ymin, vert.ymax-V2D_SCROLLER_HANDLE_SIZE); } - /* check whether sliders can disappear */ + /* check whether sliders can disappear due to the full-range being used */ if(v2d->keeptot) { - if(fac1 <= 0.0f && fac2 >= 1.0f) + if ((fac1 <= 0.0f) && (fac2 >= 1.0f)) { + v2d->scroll |= V2D_SCROLL_VERTICAL_FULLR; scrollers->vertfull= 1; + } + else + v2d->scroll &= ~V2D_SCROLL_VERTICAL_FULLR; } } diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index b25922cab5a..e84c9196e8b 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1414,6 +1414,18 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event) scroller_activate_init(C, op, event, in_scroller); vsm= (v2dScrollerMove *)op->customdata; + /* check if zoom zones are inappropriate (i.e. zoom widgets not shown), so cannot continue + * NOTE: see view2d.c for latest conditions, and keep this in sync with that + */ + if (ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) { + if ( ((vsm->scroller=='h') && (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL)==0) || + ((vsm->scroller=='v') && (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL)==0) ) + { + /* switch to bar (i.e. no scaling gets handled) */ + vsm->zone= SCROLLHANDLE_BAR; + } + } + /* check if zone is inappropriate (i.e. 'bar' but panning is banned), so cannot continue */ if (vsm->zone == SCROLLHANDLE_BAR) { if ( ((vsm->scroller=='h') && (v2d->keepofs & V2D_LOCKOFS_X)) || @@ -1426,15 +1438,21 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_PASS_THROUGH; } } + /* zone is also inappropriate if scroller is not visible... */ - if ( ((vsm->scroller=='h') && (v2d->scroll & V2D_SCROLL_HORIZONTAL_HIDE)) || - ((vsm->scroller=='v') && (v2d->scroll & V2D_SCROLL_VERTICAL_HIDE)) ) + if ( ((vsm->scroller=='h') && (v2d->scroll & (V2D_SCROLL_HORIZONTAL_HIDE|V2D_SCROLL_HORIZONTAL_FULLR))) || + ((vsm->scroller=='v') && (v2d->scroll & (V2D_SCROLL_VERTICAL_HIDE|V2D_SCROLL_VERTICAL_FULLR))) ) { + /* free customdata initialised */ + scroller_activate_exit(C, op); + /* can't catch this event for ourselves, so let it go to someone else? */ + // FIXME: still this doesn't fall through to the item_activate callback for the outliner... return OPERATOR_PASS_THROUGH; } - if(vsm->scroller=='h') + /* activate the scroller */ + if (vsm->scroller=='h') v2d->scroll_ui |= V2D_SCROLL_H_ACTIVE; else v2d->scroll_ui |= V2D_SCROLL_V_ACTIVE; diff --git a/source/blender/makesdna/DNA_view2d_types.h b/source/blender/makesdna/DNA_view2d_types.h index bc019ef8121..daffeb48447 100644 --- a/source/blender/makesdna/DNA_view2d_types.h +++ b/source/blender/makesdna/DNA_view2d_types.h @@ -124,9 +124,12 @@ typedef struct View2D { #define V2D_SCROLL_SCALE_VERTICAL (1<<5) /* scale markings - horizontal */ #define V2D_SCROLL_SCALE_HORIZONTAL (1<<6) - /* disable draw temporary */ + /* induce hiding of scrollbars - set by region drawing in response to size of region */ #define V2D_SCROLL_VERTICAL_HIDE (1<<7) #define V2D_SCROLL_HORIZONTAL_HIDE (1<<8) + /* scrollbar extends beyond its available window - set when calculating scrollbars for drawing */ +#define V2D_SCROLL_VERTICAL_FULLR (1<<9) +#define V2D_SCROLL_HORIZONTAL_FULLR (1<<10) /* scroll_ui, activate flag for drawing */ #define V2D_SCROLL_H_ACTIVE (1<<0) |