From 3db0a94254a3a8e99258a2c4f13642aa705064e7 Mon Sep 17 00:00:00 2001 From: James Ball Date: Wed, 5 Jul 2023 18:14:04 +0100 Subject: [PATCH] Make components align in ObjComponent and reset more things when resetting rotation --- Source/ObjComponent.cpp | 18 ++++++++++++++++++ Source/components/EffectComponent.cpp | 5 +++++ Source/components/EffectComponent.h | 2 ++ 3 files changed, 25 insertions(+) diff --git a/Source/ObjComponent.cpp b/Source/ObjComponent.cpp index db6a0ca..51b2b22 100644 --- a/Source/ObjComponent.cpp +++ b/Source/ObjComponent.cpp @@ -63,10 +63,24 @@ ObjComponent::ObjComponent(OscirenderAudioProcessor& p, OscirenderAudioProcessor addAndMakeVisible(mouseRotate); resetRotation.onClick = [this] { + fixedRotateX->setToggleState(false, juce::NotificationType::dontSendNotification); + fixedRotateY->setToggleState(false, juce::NotificationType::dontSendNotification); + fixedRotateZ->setToggleState(false, juce::NotificationType::dontSendNotification); + rotateX.slider.setValue(0); rotateY.slider.setValue(0); rotateZ.slider.setValue(0); + rotateSpeed.slider.setValue(0); + mouseRotate.setToggleState(false, juce::NotificationType::dontSendNotification); + + juce::SpinLock::ScopedLockType lock(audioProcessor.parsersLock); + audioProcessor.currentRotateX.setValue(0); + audioProcessor.currentRotateY.setValue(0); + audioProcessor.currentRotateZ.setValue(0); + audioProcessor.currentRotateX.apply(); + audioProcessor.currentRotateY.apply(); + audioProcessor.currentRotateZ.apply(); }; auto doc = juce::XmlDocument::parse(BinaryData::fixed_rotate_svg); @@ -129,6 +143,10 @@ void ObjComponent::resized() { rotateZ.setBounds(area.removeFromTop(rowHeight)); rotateSpeed.setBounds(area.removeFromTop(rowHeight)); + // TODO this is a bit of a hack + focalLength.setRightPadding(25); + rotateSpeed.setRightPadding(25); + area.removeFromTop(10); auto row = area.removeFromTop(rowHeight); resetRotation.setBounds(row.removeFromLeft(120)); diff --git a/Source/components/EffectComponent.cpp b/Source/components/EffectComponent.cpp index 43f4748..7e252bd 100644 --- a/Source/components/EffectComponent.cpp +++ b/Source/components/EffectComponent.cpp @@ -33,6 +33,7 @@ void EffectComponent::resized() { auto sliderRight = getWidth() - 140; auto bounds = getLocalBounds(); bounds.removeFromRight(10); + bounds.removeFromRight(rightPadding); for (auto& component : components) { component->setBounds(bounds.removeFromRight(25)); @@ -61,6 +62,10 @@ void EffectComponent::addComponent(std::shared_ptr component) { addAndMakeVisible(component.get()); } +void EffectComponent::setRightPadding(double padding) { + rightPadding = padding; +} + void EffectComponent::setCheckboxVisible(bool visible) { checkboxVisible = visible; } diff --git a/Source/components/EffectComponent.h b/Source/components/EffectComponent.h index 19239aa..8697e93 100644 --- a/Source/components/EffectComponent.h +++ b/Source/components/EffectComponent.h @@ -16,6 +16,7 @@ public: void setCheckboxVisible(bool visible); void addComponent(std::shared_ptr component); + void setRightPadding(double padding); juce::Slider slider; juce::String id; @@ -27,6 +28,7 @@ private: bool checkboxVisible = true; juce::Rectangle textBounds; std::vector> components; + double rightPadding = 0; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(EffectComponent) };