Hi @matt,
Here is an example demonstrating the behavior.
On my system (14900k iGPU, 4k 60Hz monitor) with the window maximized, looking at the GPU usage in task manager I go from around 35% when both animations are on the same side to around 45% when they are on opposite sides.
#pragma once
#include <JuceHeader.h>
class TestAnimation : public juce::Component, juce::Timer {
public:
TestAnimation() {
startTimerHz(60);
}
void timerCallback() override {
++mI;
setPath();
}
void resized() override {
setPath();
}
void setPath() {
auto yM = .5f * getHeight();
mPath.clear();
for (int x = 0; x < getWidth(); ++x) {
juce::Point<float> point{ (float)x, yM * (1 + sin(.1f * (x + mI))) };
if (x == 0) {
mPath.startNewSubPath(point);
}
else {
mPath.lineTo(point);
}
}
repaint();
}
void paint(juce::Graphics& g) override {
g.drawRect(getLocalBounds().toFloat());
g.strokePath(mPath, juce::PathStrokeType(1.f, juce::PathStrokeType::curved, juce::PathStrokeType::EndCapStyle::rounded));
}
private:
float mI = 0;
juce::Path mPath;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TestAnimation)
};
class TestComponent : public juce::Component {
public:
TestComponent() {
addAndMakeVisible(mAnimation1);
addAndMakeVisible(mAnimation2);
addAndMakeVisible(mLeft);
addAndMakeVisible(mRight);
addAndMakeVisible(mOpposite);
mLeft.onClick = [this] { mAnimatorPos = 0; resized(); };
mRight.onClick = [this] { mAnimatorPos = 1; resized(); };
mOpposite.onClick = [this] { mAnimatorPos = 2; resized(); };
}
void resized() override {
auto bounds = getLocalBounds();
{
auto buttonBar = bounds.removeFromTop(50);
mLeft.setBounds(buttonBar.removeFromLeft(150).reduced(10));
mRight.setBounds(buttonBar.removeFromLeft(150).reduced(10));
mOpposite.setBounds(buttonBar.removeFromLeft(150).reduced(10));
}
{
bounds = bounds.removeFromTop(400);
switch (mAnimatorPos) {
case 0:
mAnimation1.setBounds(bounds.removeFromLeft(200));
mAnimation2.setBounds(bounds.removeFromLeft(200));
break;
case 1:
mAnimation1.setBounds(bounds.removeFromRight(200));
mAnimation2.setBounds(bounds.removeFromRight(200));
break;
case 2:
mAnimation1.setBounds(bounds.removeFromLeft(200));
mAnimation2.setBounds(bounds.removeFromRight(200));
break;
default:
break;
}
}
}
void paint(juce::Graphics& g) override {
g.fillAll(juce::Colours::white);
}
private:
TestAnimation mAnimation1, mAnimation2;
int mAnimatorPos = 0;
bool mRepaintAll = false;
juce::TextButton mLeft{ "Both Left" }, mRight{ "Both Right" }, mOpposite{ "One Left, One Right" };
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TestComponent)
};
class MainComponent : public juce::Component {
public:
MainComponent() {
//juce::Timer::callAfterDelay(0, [this] {
// auto* peer = getPeer();
// jassert(peer);
// if (peer) peer->setCurrentRenderingEngine(0);
//});
setSize(referenceWidth, referenceWidth / 2);
addAndMakeVisible(component);
addAndMakeVisible(zoomLabel);
refreshZoomLabel();
}
void paint(juce::Graphics& g) override {
g.fillAll(juce::Colours::black);
}
void resized() override {
refreshZoomLabel();
zoomLabel.setBounds(getLocalBounds().removeFromTop(30));
component.setBounds(0, 0, referenceWidth, referenceWidth);
component.setTransform(juce::AffineTransform::scale(getScale()).followedBy(juce::AffineTransform::translation(0,30)));
}
private:
void refreshZoomLabel() {
zoomLabel.setText("zoom: " + juce::String(juce::roundToInt(100 * getScale())) + "%", juce::dontSendNotification);
}
float getScale() {
return (float)getWidth() / referenceWidth;
}
juce::Label zoomLabel;
TestComponent component;
int referenceWidth = 1000;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
};
