From b45a05d4f633c546424ca854f6d2e0daf21daa74 Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 23 Oct 2014 16:46:49 +0100 Subject: [PATCH 1/2] Improved scale factor used in cached images by ComponentAnimator. --- .../layout/juce_ComponentAnimator.cpp | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp b/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp index 7c26c99afa..6f28e8be6f 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp @@ -25,9 +25,7 @@ class ComponentAnimator::AnimationTask { public: - AnimationTask (Component* const comp) noexcept : component (comp) - { - } + AnimationTask (Component* c) noexcept : component (c) {} void reset (const Rectangle& finalBounds, float finalAlpha, @@ -65,8 +63,8 @@ public: bool useTimeslice (const int elapsed) { - if (Component* const c = proxy != nullptr ? static_cast (proxy) - : static_cast (component)) + if (Component* const c = proxy != nullptr ? static_cast (proxy) + : static_cast (component)) { msElapsed += elapsed; double newProgress = msElapsed / (double) msTotal; @@ -149,7 +147,10 @@ public: else jassertfalse; // seem to be trying to animate a component that's not visible.. - image = c.createComponentSnapshot (c.getLocalBounds(), false, getDesktopScaleFactor()); + const float scale = (float) Desktop::getInstance().getDisplays() + .getDisplayContaining (getScreenBounds().getCentre()).scale; + + image = c.createComponentSnapshot (c.getLocalBounds(), false, scale); setVisible (true); toBehind (&c); @@ -189,14 +190,8 @@ private: }; //============================================================================== -ComponentAnimator::ComponentAnimator() - : lastTime (0) -{ -} - -ComponentAnimator::~ComponentAnimator() -{ -} +ComponentAnimator::ComponentAnimator() : lastTime (0) {} +ComponentAnimator::~ComponentAnimator() {} //============================================================================== ComponentAnimator::AnimationTask* ComponentAnimator::findTaskFor (Component* const component) const noexcept From 8c15f9ac7da9a69e61863001f885631240f18b12 Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 24 Oct 2014 09:31:24 +0100 Subject: [PATCH 2/2] Fix for AffineTransform::getScaleFactor() for handling negative scaling. --- .../juce_graphics/geometry/juce_AffineTransform.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/juce_graphics/geometry/juce_AffineTransform.cpp b/modules/juce_graphics/geometry/juce_AffineTransform.cpp index 59ebde3cf0..85d6f4e8ed 100644 --- a/modules/juce_graphics/geometry/juce_AffineTransform.cpp +++ b/modules/juce_graphics/geometry/juce_AffineTransform.cpp @@ -193,9 +193,9 @@ AffineTransform AffineTransform::sheared (const float shearX, const float shearY return AffineTransform (mat00 + shearX * mat10, mat01 + shearX * mat11, mat02 + shearX * mat12, - shearY * mat00 + mat10, - shearY * mat01 + mat11, - shearY * mat02 + mat12); + mat10 + shearY * mat00, + mat11 + shearY * mat01, + mat12 + shearY * mat02); } AffineTransform AffineTransform::verticalFlip (const float height) noexcept @@ -211,10 +211,10 @@ AffineTransform AffineTransform::inverted() const noexcept { determinant = 1.0 / determinant; - const float dst00 = (float) (mat11 * determinant); + const float dst00 = (float) ( mat11 * determinant); const float dst10 = (float) (-mat10 * determinant); const float dst01 = (float) (-mat01 * determinant); - const float dst11 = (float) (mat00 * determinant); + const float dst11 = (float) ( mat00 * determinant); return AffineTransform (dst00, dst01, -mat02 * dst00 - mat12 * dst01, dst10, dst11, -mat02 * dst10 - mat12 * dst11); @@ -258,5 +258,5 @@ bool AffineTransform::isOnlyTranslation() const noexcept float AffineTransform::getScaleFactor() const noexcept { - return (mat00 + mat11) / 2.0f; + return (std::abs (mat00) + std::abs (mat11)) / 2.0f; }