Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2008-12-14 14:50:28 +0300
committerJoshua Leung <aligorith@gmail.com>2008-12-14 14:50:28 +0300
commitfd1c8aa62ee7abb7a405d2de23b7907cab4a30c3 (patch)
treed7a34d2888635301162d878cf0a7a33e0a0efe26 /source/blender/editors
parentf436bc83275599e44ab9c068805ca70d5d199891 (diff)
View2D: More scroller related things
* Scrollers now keep corners free for drawing widgets if there are horizontal and vertical ones in use. They draw a rect which covers up all of the excess over-flowing drawing that was previously masked by the vertical scrollers. * Tweaked the behaviour of the scroller zoom-handles again as they still weren't behaving correctly on vertical scrollers. This was partly caused by a typo, but also wrong checks...
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/interface/view2d.c29
-rw-r--r--source/blender/editors/interface/view2d_ops.c28
2 files changed, 43 insertions, 14 deletions
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 28ff61d5f11..7177d62ef4e 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -125,9 +125,8 @@ void UI_view2d_size_update(View2D *v2d, int winx, int winy)
v2d->mask.ymax= v2d->hor.ymin - 1;
}
-#if 0 // FIXME: we currently have overlap bugs there...
/* adjust vertical scroller if there's a horizontal scroller, to leave corner free */
- if (v2d->scroll & /*V2D_SCROLL_VERTICAL*/) {
+ if (v2d->scroll & V2D_SCROLL_VERTICAL) {
/* just set y min/max for vertical scroller to y min/max of mask as appropriate */
if (v2d->scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) {
/* on bottom edge of region (V2D_SCROLL_BOTTOM_O is outliner, the other is for standard) */
@@ -138,7 +137,6 @@ void UI_view2d_size_update(View2D *v2d, int winx, int winy)
v2d->vert.ymax= v2d->mask.ymax;
}
}
-#endif
}
/* cope with unitialized veriables for simple cases, like header or outliner */
@@ -1081,7 +1079,7 @@ static void scroll_printstr(View2DScrollers *scrollers, float x, float y, float
void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *vs)
{
const short darker= -50, dark= -10, light= 20, lighter= 50;
- rcti vert, hor;
+ rcti vert, hor, corner;
/* make copies of rects for less typing */
vert= v2d->vert;
@@ -1325,6 +1323,29 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
else if (v2d->scroll & V2D_SCROLL_LEFT)
sdrawline(vert.xmax, vert.ymin, vert.xmax, vert.ymax);
}
+
+ /* draw a 'sunken square' to cover up any overlapping corners resulting from intersection of overflowing scroller data */
+ if ((v2d->scroll & V2D_SCROLL_VERTICAL) && (v2d->scroll & V2D_SCROLL_HORIZONTAL)) {
+ /* set bounds (these should be right) */
+ corner.xmin= vert.xmin;
+ corner.xmax= vert.xmax;
+ corner.ymin= hor.ymin;
+ corner.ymax= hor.ymax;
+
+ /* firstly, draw using background color to cover up any overlapping junk */
+ UI_ThemeColor(TH_SHADE1);
+ glRecti(corner.xmin, corner.ymin, corner.xmax, corner.ymax);
+
+ /* now, draw suggestive highlighting... */
+ /* first, dark lines on top to suggest scrollers overlap box */
+ UI_ThemeColorShade(TH_SHADE1, darker);
+ sdrawline(corner.xmin, corner.ymin, corner.xmin, corner.ymax);
+ sdrawline(corner.xmin, corner.ymax, corner.xmax, corner.ymax);
+ /* now, light lines on bottom to show box is sunken in */
+ UI_ThemeColorShade(TH_SHADE1, lighter);
+ sdrawline(corner.xmax, corner.ymin, corner.xmax, corner.ymax);
+ sdrawline(corner.xmin, corner.ymin, corner.xmax, corner.ymin);
+ }
}
/* free temporary memory used for drawing scrollers */
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 0564e6436a7..f1dde562c9d 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -868,16 +868,24 @@ enum {
*/
static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_min, int sh_max)
{
- short in_min, in_max;
+ short in_min, in_max, in_view=1;
/* firstly, check if
* - 'bubble' fills entire scroller
* - 'bubble' completely out of view on either side
*/
- if ( ((sh_min <= sc_min) && (sh_max >= sc_max)) ||
- ((sh_min <= sc_min) && (sh_max <= sc_max)) ||
- ((sh_min >= sc_max) && (sh_max >= sc_max)) )
- {
+ if ((sh_min <= sc_min) && (sh_max >= sc_max)) in_view= 0;
+ if (sh_min == sh_max) {
+ if (sh_min <= sc_min) in_view= 0;
+ if (sh_max >= sc_max) in_view= 0;
+ }
+ else {
+ if (sh_max <= sc_min) in_view= 0;
+ if (sh_min >= sc_max) in_view= 0;
+ }
+
+
+ if (in_view == 0) {
/* handles are only activated if the mouse is within the relative quater lengths of the scroller */
int qLen = (sc_max + sc_min) / 4;
@@ -890,15 +898,15 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
}
/* check if mouse is in or past either handle */
- in_max= (mouse >= (sh_max - V2D_SCROLLER_HANDLE_SIZE));
- in_min= (mouse <= (sh_min + V2D_SCROLLER_HANDLE_SIZE));
+ in_max= ( (mouse >= (sh_max - V2D_SCROLLER_HANDLE_SIZE)) && (mouse <= (sh_max + V2D_SCROLLER_HANDLE_SIZE)) );
+ in_min= ( (mouse <= (sh_min + V2D_SCROLLER_HANDLE_SIZE)) && (mouse >= (sh_min - V2D_SCROLLER_HANDLE_SIZE)) );
/* check if overlap --> which means user clicked on bar, as bar is within handles region */
if (in_max && in_min)
return SCROLLHANDLE_BAR;
- if (in_max)
+ else if (in_max)
return SCROLLHANDLE_MAX;
- if (in_min)
+ else if (in_min)
return SCROLLHANDLE_MIN;
/* unlikely to happen, though we just cover it in case */
@@ -960,7 +968,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
}
else {
/* check which handle we're in */
- vsm->zone= mouse_in_scroller_handle(y, v2d->vert.xmin, v2d->vert.xmax, scrollers->vert_min, scrollers->vert_max);
+ vsm->zone= mouse_in_scroller_handle(y, v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max);
}
}
UI_view2d_scrollers_free(scrollers);