Reorganise Line Art Settings and make double box lose focus when clicking off it

pull/241/head
James Ball 2024-04-26 21:21:59 +01:00 zatwierdzone przez James H Ball
rodzic 23bfcaee7d
commit d1ae93f75a
4 zmienionych plików z 33 dodań i 26 usunięć

Wyświetl plik

@ -12,14 +12,11 @@ LineArtComponent::LineArtComponent(OscirenderAudioProcessor& p, OscirenderAudioP
addAndMakeVisible(offsetBox);
rateLabel.setText("Framerate", juce::dontSendNotification);
rateBox.setValue(audioProcessor.animationRate->getValueUnnormalised(), false, 2);
rateBox.setJustification(juce::Justification::left);
offsetLabel.setText("Offset", juce::dontSendNotification);
offsetBox.setValue(audioProcessor.animationOffset->getValueUnnormalised(), false, 2);
offsetBox.setJustification(juce::Justification::left);
audioProcessor.openFile(audioProcessor.currentFile);
update();
auto updateAnimation = [this]() {
@ -31,8 +28,8 @@ LineArtComponent::LineArtComponent(OscirenderAudioProcessor& p, OscirenderAudioP
animate.onClick = updateAnimation;
sync.onClick = updateAnimation;
rateBox.onTextChange = updateAnimation;
offsetBox.onTextChange = updateAnimation;
rateBox.onFocusLost = updateAnimation;
offsetBox.onFocusLost = updateAnimation;
audioProcessor.animateLineArt->addListener(this);
audioProcessor.syncMIDIAnimation->addListener(this);
@ -49,32 +46,28 @@ LineArtComponent::~LineArtComponent() {
void LineArtComponent::resized() {
auto area = getLocalBounds().withTrimmedTop(20).reduced(20);
double rowHeight = 30;
double rowSpace = 5;
double rowHeight = 20;
double rowSpace = 10;
auto animateBounds = area.removeFromTop(rowHeight);
animate.setBounds(animateBounds);
animate.setBounds(animateBounds.removeFromLeft(100));
sync.setBounds(animateBounds.removeFromLeft(100));
area.removeFromTop(rowSpace);
animateBounds = area.removeFromTop(rowHeight);
sync.setBounds(animateBounds);
rateLabel.setBounds(animateBounds.removeFromLeft(80));
rateBox.setBounds(animateBounds.removeFromLeft(60));
area.removeFromTop(rowSpace);
animateBounds = area.removeFromTop(rowHeight);
rateLabel.setBounds(animateBounds.removeFromLeft(100));
rateBox.setBounds(animateBounds);
area.removeFromTop(rowSpace);
animateBounds = area.removeFromTop(rowHeight);
offsetLabel.setBounds(animateBounds.removeFromLeft(100));
offsetBox.setBounds(animateBounds);
area.removeFromTop(rowSpace);
offsetLabel.setBounds(animateBounds.removeFromLeft(80));
offsetBox.setBounds(animateBounds.removeFromLeft(60));
}
void LineArtComponent::update() {
rateBox.setValue(audioProcessor.animationRate->getValueUnnormalised(), true, 2);
offsetBox.setValue(audioProcessor.animationOffset->getValueUnnormalised(), true, 2);
animate.setToggleState(audioProcessor.animateLineArt->getValue(), true);
sync.setToggleState(audioProcessor.syncMIDIAnimation->getValue(), true);
rateBox.setValue(audioProcessor.animationRate->getValueUnnormalised(), false, 2);
offsetBox.setValue(audioProcessor.animationOffset->getValueUnnormalised(), false, 2);
animate.setToggleState(audioProcessor.animateLineArt->getValue(), false);
sync.setToggleState(audioProcessor.syncMIDIAnimation->getValue(), false);
}
void LineArtComponent::parameterValueChanged(int parameterIndex, float newValue) {

Wyświetl plik

@ -23,8 +23,8 @@ private:
juce::ToggleButton sync{"MIDI Sync"};
juce::Label rateLabel{ "Framerate","Framerate"};
juce::Label offsetLabel{ "Offset","Offset" };
DoubleTextBox rateBox{ -256, 256 };
DoubleTextBox offsetBox{ -8192, 8192 };
DoubleTextBox rateBox{ audioProcessor.animationRate->min, audioProcessor.animationRate->max };
DoubleTextBox offsetBox{ audioProcessor.animationOffset->min, audioProcessor.animationRate->max };
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LineArtComponent)
};

Wyświetl plik

@ -54,7 +54,7 @@ void SettingsComponent::resized() {
auto dummyBounds = dummy.getBounds();
if (effectSettings != nullptr) {
effectSettings->setBounds(dummyBounds.removeFromBottom(200));
effectSettings->setBounds(dummyBounds.removeFromBottom(140));
dummyBounds.removeFromBottom(pluginEditor.RESIZER_BAR_SIZE);
}

Wyświetl plik

@ -11,6 +11,7 @@ public:
onTextChange = [this]() {
setText(getText(), false);
};
juce::Desktop::getInstance().addGlobalMouseListener(this);
}
double getValue() {
@ -48,9 +49,22 @@ public:
}
juce::TextEditor::setText(text, sendChangeMessage);
}
void mouseDown(const juce::MouseEvent& e) override {
if (getScreenBounds().contains(e.getScreenPosition())) {
// Delegate mouse clicks inside the editor to the TextEditor
// class so as to not break its functionality.
juce::TextEditor::mouseDown(e);
} else {
// Lose focus when mouse clicks occur outside the editor.
giveAwayKeyboardFocus();
}
}
~DoubleTextBox() override {}
~DoubleTextBox() override {
juce::Desktop::getInstance().removeGlobalMouseListener(this);
}
private:
double minValue;