aboutsummaryrefslogtreecommitdiff
path: root/dw/layout.cc
diff options
context:
space:
mode:
Diffstat (limited to 'dw/layout.cc')
-rw-r--r--dw/layout.cc43
1 files changed, 23 insertions, 20 deletions
diff --git a/dw/layout.cc b/dw/layout.cc
index 89cdf9a6..35279243 100644
--- a/dw/layout.cc
+++ b/dw/layout.cc
@@ -415,16 +415,16 @@ void Layout::scrollIdle ()
case HPOS_CENTER:
scrollX =
scrollTargetX
- - (viewportWidth - vScrollbarThickness - scrollTargetWidth) / 2;
+ - (viewportWidth - currVScrollbarThickness() - scrollTargetWidth) / 2;
break;
case HPOS_RIGHT:
scrollX =
scrollTargetX
- - (viewportWidth - vScrollbarThickness - scrollTargetWidth);
+ - (viewportWidth - currVScrollbarThickness() - scrollTargetWidth);
break;
case HPOS_INTO_VIEW:
xChanged = calcScrollInto (scrollTargetX, scrollTargetWidth, &scrollX,
- viewportWidth - vScrollbarThickness);
+ viewportWidth - currVScrollbarThickness());
break;
case HPOS_NO_CHANGE:
xChanged = false;
@@ -439,16 +439,16 @@ void Layout::scrollIdle ()
case VPOS_CENTER:
scrollY =
scrollTargetY
- - (viewportHeight - hScrollbarThickness - scrollTargetHeight) / 2;
+ - (viewportHeight - currHScrollbarThickness() - scrollTargetHeight)/2;
break;
case VPOS_BOTTOM:
scrollY =
scrollTargetY
- - (viewportHeight - hScrollbarThickness - scrollTargetHeight);
+ - (viewportHeight - currHScrollbarThickness() - scrollTargetHeight);
break;
case VPOS_INTO_VIEW:
yChanged = calcScrollInto (scrollTargetY, scrollTargetHeight, &scrollY,
- viewportHeight - hScrollbarThickness);
+ viewportHeight - currHScrollbarThickness());
break;
case VPOS_NO_CHANGE:
yChanged = false;
@@ -536,6 +536,17 @@ void Layout::draw (View *view, Rectangle *area)
}
}
+int Layout::currHScrollbarThickness()
+{
+ return (canvasWidth > viewportWidth) ? hScrollbarThickness : 0;
+}
+
+int Layout::currVScrollbarThickness()
+{
+ return (canvasAscent + canvasDescent > viewportHeight) ?
+ vScrollbarThickness : 0;
+}
+
/**
* Sets the anchor to scroll to.
*/
@@ -674,15 +685,12 @@ void Layout::resizeIdle ()
// view->queueDrawTotal (false);
if (usesViewport) {
- int actualHScrollbarThickness =
- (canvasWidth > viewportWidth) ? hScrollbarThickness : 0;
- int actualVScrollbarThickness =
- (canvasAscent + canvasDescent > viewportHeight) ?
- vScrollbarThickness : 0;
+ int currHThickness = currHScrollbarThickness();
+ int currVThickness = currVScrollbarThickness();
if (!canvasHeightGreater &&
canvasAscent + canvasDescent
- > viewportHeight - actualHScrollbarThickness) {
+ > viewportHeight - currHThickness) {
canvasHeightGreater = true;
setSizeHints ();
/* May queue a new resize. */
@@ -690,8 +698,7 @@ void Layout::resizeIdle ()
// Set viewport sizes.
view->setViewportSize (viewportWidth, viewportHeight,
- actualHScrollbarThickness,
- actualVScrollbarThickness);
+ currHThickness, currVThickness);
}
}
@@ -958,9 +965,7 @@ bool Layout::processMouseEvent (MousePositionEvent *event,
if (event->xCanvas < scrollX)
event->xCanvas = scrollX;
else {
- int actualVScrollbarThickness =
- canvasAscent + canvasDescent > viewportHeight ? vScrollbarThickness:0;
- int maxX = scrollX + viewportWidth - actualVScrollbarThickness - 1;
+ int maxX = scrollX + viewportWidth - currVScrollbarThickness() - 1;
if (event->xCanvas > maxX)
event->xCanvas = maxX;
@@ -968,9 +973,7 @@ bool Layout::processMouseEvent (MousePositionEvent *event,
if (event->yCanvas < scrollY)
event->yCanvas = scrollY;
else {
- int actualHScrollbarThickness =
- (canvasWidth > viewportWidth) ? hScrollbarThickness : 0;
- int maxY = misc::min(scrollY + viewportHeight -actualHScrollbarThickness,
+ int maxY = misc::min(scrollY + viewportHeight -currHScrollbarThickness(),
canvasAscent + canvasDescent) - 1;
if (event->yCanvas > maxY)