Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- commit 6ae1b00e347bb0becf7e3e8c419d4a80de16788a
- Author: Kenneth Rohde Christiansen <kenneth.christiansen@gmail.com>
- Date: Wed Feb 23 16:14:10 2011 +0100
- Rename the bounded scale methods. Make the methods equal when no scaling is allowed
- Reviewed by Zalan Bujtas.
- diff --git a/src/WebViewState.cpp b/src/WebViewState.cpp
- index b675830..7e93da1 100644
- --- a/src/WebViewState.cpp
- +++ b/src/WebViewState.cpp
- @@ -63,17 +63,19 @@ bool WebViewState::isUserScalable() const
- return m_isUserScalable || m_minimumScale != m_maximumScale;
- }
- -qreal WebViewState::softlyBoundedScale(qreal value) const
- +qreal WebViewState::innerBoundedScale(qreal value) const
- {
- return qBound(m_minimumScale, value, m_maximumScale);
- }
- -qreal WebViewState::boundedScale(qreal value) const
- +qreal WebViewState::outerBoundedScale(qreal value) const
- {
- - qreal hardMin = qreal(0.5) * m_minimumScale;
- - qreal hardMax = qreal(2.0) * m_maximumScale;
- -
- - return bindToScaleLimits(qBound(hardMin, value, hardMax));
- + if (isUserScalable()) {
- + qreal hardMin = qreal(0.5) * m_minimumScale;
- + qreal hardMax = qreal(2.0) * m_maximumScale;
- + return bindToScaleLimits(qBound(hardMin, value, hardMax));
- + }
- + return innerBoundedScale(value);
- }
- void WebViewState::setInitialScale(qreal value)
- diff --git a/src/WebViewState.h b/src/WebViewState.h
- index bc92f9c..3d0d960 100644
- --- a/src/WebViewState.h
- +++ b/src/WebViewState.h
- @@ -27,8 +27,8 @@ public:
- qreal pixelRatio() const { return m_pixelRatio; }
- bool isUserScalable() const;
- - qreal softlyBoundedScale(qreal scale) const;
- - qreal boundedScale(qreal value) const;
- + qreal innerBoundedScale(qreal scale) const;
- + qreal outerBoundedScale(qreal value) const;
- private:
- qreal m_initialScale;
- @@ -41,6 +41,4 @@ private:
- };
- Q_DECLARE_METATYPE(WebViewState);
- -
- -
- #endif
- diff --git a/src/WebViewport.cpp b/src/WebViewport.cpp
- index fbbbb61..27bd75e 100644
- --- a/src/WebViewport.cpp
- +++ b/src/WebViewport.cpp
- @@ -286,11 +286,9 @@ void WebViewport::zoomAndFocusWidthChange(qreal dw)
- // We need to recalc the viewport before using boundedScale.
- updateItemStateFromViewportMeta();
- - qreal newScale = dw * scale;
- - if (viewportItem()->state().isUserScalable())
- - newScale = viewportItem()->state().boundedScale(newScale);
- - else
- - newScale = viewportItem()->state().softlyBoundedScale(newScale);
- +
- + // FIXME: Why isn't inner used?
- + qreal newScale = viewportItem()->state().outerBoundedScale(dw * scale);
- QPointF newPosition = position() * (newScale / scale);
- @@ -313,7 +311,7 @@ void WebViewport::zoomAndFocusInputField()
- // current MeeGo Touch API's it is impossible to know before the
- // VKB has animated fully in. This does it for now.
- QPointF viewportCenter = QPointF(25, geometry().height() / 5);
- - qreal targetScale = viewportItem()->state().softlyBoundedScale(2.0);
- + qreal targetScale = viewportItem()->state().innerBoundedScale(2.0);
- QPointF position = positionAtTarget(hotspot, viewportCenter, targetScale);
- startZoomAnimation(position, targetScale);
- @@ -334,7 +332,7 @@ void WebViewport::zoomToArea(const QPointF& requestedZoomPoint, const QRectF& ta
- int margin = 8;
- QRectF contentsArea = targetZoomableArea.adjusted(-margin, -margin, margin, margin);
- - qreal targetScale = viewportItem()->state().softlyBoundedScale(size().width() / (contentsArea.size().width()));
- + qreal targetScale = viewportItem()->state().innerBoundedScale(size().width() / (contentsArea.size().width()));
- // We want to end up with the targetArea filling the whole width of the viewport,
- // and centralized vertically where the user requested zoom. Thus our hotspot
- // is the center of the targetArea x-wise and the requested zoom position, y-wise.
- @@ -345,7 +343,7 @@ void WebViewport::zoomToArea(const QPointF& requestedZoomPoint, const QRectF& ta
- if (isSameZoomScale(targetScale)) {
- // If we are requested to zoom to a similar scale.
- targetScale = size().width() / viewportItem()->size().width();
- - targetScale = viewportItem()->state().softlyBoundedScale(targetScale);
- + targetScale = viewportItem()->state().innerBoundedScale(targetScale);
- hotspot.setX(viewportItem()->size().width() / 2);
- hotspot.setY(requestedZoomPoint.y());
- }
- @@ -472,7 +470,7 @@ void WebViewport::endZoomScaleChange()
- bool WebViewport::bounceBackToViewIfNeeded()
- {
- qreal currentScale = viewportItem()->appliedZoomScale();
- - qreal boundedCurrentScale = viewportItem()->state().softlyBoundedScale(currentScale);
- + qreal boundedCurrentScale = viewportItem()->state().innerBoundedScale(currentScale);
- // Bounce back and center contents point in viewport center.
- if (boundedCurrentScale != currentScale) {
- @@ -545,10 +543,7 @@ void WebViewport::updatePinchZoom(qreal scaleFactor, const QPointF& newCenterPoi
- qreal scale = m_pinchStartScale * scaleFactor;
- // Allow zooming out beyond mimimum scale on pages that do not explicit disallow it.
- - if (!viewportItem()->state().isUserScalable())
- - scale = viewportItem()->state().softlyBoundedScale(scale);
- - else
- - scale = viewportItem()->state().boundedScale(scale);
- + scale = viewportItem()->state().outerBoundedScale(scale);
- QPointF targetPosition = positionAtTarget(m_pinchUnscaledHotspot, m_pinchViewportHotspot, scale, /* keepContentsInView */ false) + (m_pinchViewportHotspot - newCenterPoint);
- @@ -592,7 +587,7 @@ bool WebViewport::processZoomKeys(QKeyEvent* event)
- else
- scale /= 1.0 + s_zoomScaleWheelStep;
- - scale = viewportItem()->state().softlyBoundedScale(scale);
- + scale = viewportItem()->state().innerBoundedScale(scale);
- // Zoom to the center.
- QPointF viewportHotspot = visibleCenter();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement