diff options
author | Sebastian Geerken <devnull@localhost> | 2012-12-26 10:45:09 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2012-12-26 10:45:09 +0100 |
commit | f559233bbed07f250efcd22a91eeaeebef4b27c1 (patch) | |
tree | 87bc1c6f40e7e1e6f83509fe7ca3f07416f0fcda /dw/layout.cc | |
parent | ac2476d602f5b08827d7b76b37cd05992789eb4a (diff) | |
parent | b3fe28cd46ffe481e455c23795a311112de57b1a (diff) |
Merge with main repo.
Diffstat (limited to 'dw/layout.cc')
-rw-r--r-- | dw/layout.cc | 43 |
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) |