diff options
author | corvid <corvid@lavabit.com> | 2012-12-24 05:40:05 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2012-12-24 05:40:05 +0000 |
commit | 965a474c4051d33e588553243d9614660fc33a5b (patch) | |
tree | f9e821e867711df94a337f0f3521506e0a888df0 | |
parent | 33e67fba5f78a33e0798a675028cfa7510f5d735 (diff) |
layout put scrollbar thickness calcs in separate fns
-rw-r--r-- | dw/layout.cc | 31 | ||||
-rw-r--r-- | dw/layout.hh | 2 |
2 files changed, 19 insertions, 14 deletions
diff --git a/dw/layout.cc b/dw/layout.cc index d91ff543..ad9d3ce1 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -535,6 +535,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. */ @@ -673,15 +684,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. */ @@ -689,8 +697,7 @@ void Layout::resizeIdle () // Set viewport sizes. view->setViewportSize (viewportWidth, viewportHeight, - actualHScrollbarThickness, - actualVScrollbarThickness); + currHThickness, currVThickness); } } @@ -957,9 +964,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; @@ -967,9 +972,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) diff --git a/dw/layout.hh b/dw/layout.hh index 7291b01d..7f33594b 100644 --- a/dw/layout.hh +++ b/dw/layout.hh @@ -191,6 +191,8 @@ private: void adjustScrollPos (); static bool calcScrollInto (int targetValue, int requestedSize, int *value, int viewportSize); + int currHScrollbarThickness(); + int currVScrollbarThickness(); void updateAnchor (); |