From 917e484b04007be27c89e6ccd0f46e5c5bc3fb01 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Wed, 25 Jan 2023 15:18:36 -0500 Subject: [PATCH] Improve slider rename when arrowing through menu sliders Discrete (menu) sliders rebuild on menu change but not arrow so do that. But rebuilding on every arrow is annoying in VO so di it at the end. Also invalidate a few other places Addresses #6822 --- src/surge-xt/gui/SurgeGUIEditor.cpp | 9 +++++++++ .../gui/widgets/MenuForDiscreteParams.cpp | 15 +++++++++++++++ src/surge-xt/gui/widgets/MenuForDiscreteParams.h | 4 +++- .../gui/widgets/OscillatorWaveformDisplay.cpp | 10 ++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/surge-xt/gui/SurgeGUIEditor.cpp b/src/surge-xt/gui/SurgeGUIEditor.cpp index fd0ae1e5627..a4926a1087d 100644 --- a/src/surge-xt/gui/SurgeGUIEditor.cpp +++ b/src/surge-xt/gui/SurgeGUIEditor.cpp @@ -6861,6 +6861,7 @@ void SurgeGUIEditor::setAccessibilityInformationByTitleAndAction(juce::Component const std::string &title, const std::string &action) { + auto currT = c->getTitle().toStdString(); #if MAC c->setDescription(title); c->setTitle(title); @@ -6868,6 +6869,14 @@ void SurgeGUIEditor::setAccessibilityInformationByTitleAndAction(juce::Component c->setDescription(action); c->setTitle(title); #endif + + if (currT != title) + { + if (auto h = c->getAccessibilityHandler()) + { + h->notifyAccessibilityEvent(juce::AccessibilityEvent::titleChanged); + } + } } std::string SurgeGUIEditor::modulatorIndexExtension(int scene, int ms, int index, bool shortV) diff --git a/src/surge-xt/gui/widgets/MenuForDiscreteParams.cpp b/src/surge-xt/gui/widgets/MenuForDiscreteParams.cpp index c12cfd850ce..310f19a5ef5 100644 --- a/src/surge-xt/gui/widgets/MenuForDiscreteParams.cpp +++ b/src/surge-xt/gui/widgets/MenuForDiscreteParams.cpp @@ -377,9 +377,24 @@ bool MenuForDiscreteParams::keyPressed(const juce::KeyPress &key) setValue(nextValueInOrder(value, -dir)); notifyValueChanged(); notifyEndEdit(); + + rebuildOnFocus = true; repaint(); return true; } +void MenuForDiscreteParams::focusLost(juce::Component::FocusChangeType cause) +{ + endHover(); + if (rebuildOnFocus) + { + auto sge = firstListenerOfType(); + if (sge) + { + sge->queue_refresh = true; + } + } +} + } // namespace Widgets } // namespace Surge diff --git a/src/surge-xt/gui/widgets/MenuForDiscreteParams.h b/src/surge-xt/gui/widgets/MenuForDiscreteParams.h index f0a54d16ddf..670f0b22166 100644 --- a/src/surge-xt/gui/widgets/MenuForDiscreteParams.h +++ b/src/surge-xt/gui/widgets/MenuForDiscreteParams.h @@ -143,12 +143,14 @@ struct MenuForDiscreteParams : public juce::Component, bool keyPressed(const juce::KeyPress &key) override; + bool rebuildOnFocus = false; void focusGained(juce::Component::FocusChangeType cause) override { + rebuildOnFocus = false; startHover(getBounds().getBottomLeft().toFloat()); } - void focusLost(juce::Component::FocusChangeType cause) override { endHover(); } + void focusLost(juce::Component::FocusChangeType cause) override; juce::Point mouseDownOrigin; bool isDraggingGlyph{false}; diff --git a/src/surge-xt/gui/widgets/OscillatorWaveformDisplay.cpp b/src/surge-xt/gui/widgets/OscillatorWaveformDisplay.cpp index da0cca6fe2e..34551634c70 100644 --- a/src/surge-xt/gui/widgets/OscillatorWaveformDisplay.cpp +++ b/src/surge-xt/gui/widgets/OscillatorWaveformDisplay.cpp @@ -1891,6 +1891,11 @@ void OscillatorWaveformDisplay::showCustomEditor() customEditorAccOverlay->setTitle("Close Custom Editor"); customEditorAccOverlay->setDescription("Close Custom Editor"); } + + if (auto h = getAccessibilityHandler()) + { + h->notifyAccessibilityEvent(juce::AccessibilityEvent::structureChanged); + } } void OscillatorWaveformDisplay::hideCustomEditor() @@ -1905,6 +1910,11 @@ void OscillatorWaveformDisplay::hideCustomEditor() customEditorAccOverlay->setTitle("Open Custom Editor"); customEditorAccOverlay->setDescription("Open Custom Editor"); + if (auto h = getAccessibilityHandler()) + { + h->notifyAccessibilityEvent(juce::AccessibilityEvent::structureChanged); + } + repaint(); }