Skip to content

Commit

Permalink
Imprve StepSequencer Accessibility (#5615)
Browse files Browse the repository at this point in the history
Use grouping at component level to make the displayed hierarchy
seem correct; show the trigger buttons.
  • Loading branch information
baconpaul authored Dec 10, 2021
1 parent f695156 commit 0dd5206
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
17 changes: 16 additions & 1 deletion scripts/pyauto-tests/mod-stepseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
# sxttest.loadPatchByPath(sxt, ["Test Cases", "StepAcc"])
time.sleep(0.2)

mods = sxttest.firstChildByTitle(mf, "Modulators")
l1 = sxttest.firstChildByTitle(mods, "LFO 1");
select = sxttest.firstChildByTitle(l1, "Select");
select.Press()

lct = sxttest.firstChildByTitle(mf, "LFO Controls")
sxttest.recursiveDump(lct, "LFO>")

Expand All @@ -24,10 +29,20 @@

sxttest.recursiveDump(tad, "TAD>")

for i in range(1000):
for i in range(20):
q = random.randint(1, 16)
v = random.uniform(-1, 1)
nm = "Step Value " + str(q)
step = sxttest.firstChildByTitle(lct, nm)
step.AXValue = str(v)
time.sleep(0.2)

mods = sxttest.firstChildByTitle(mf, "Modulators")
l1 = sxttest.firstChildByTitle(mods, "S-LFO 1");
select = sxttest.firstChildByTitle(l1, "Select");
select.Press()
time.sleep(0.2)
stp = sxttest.firstChildByTitle(tad, "Step Sequencer")
stp.Press()
time.sleep(0.2)
sxttest.recursiveDump(tad, "SLFO>")
11 changes: 11 additions & 0 deletions src/surge-xt/gui/AccessibleHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,17 @@ template <typename T> struct OverlayAsAccessibleSlider : public juce::Component
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OverlayAsAccessibleSlider<T>);
};

struct OverlayAsAccessibleContainer : public juce::Component
{
OverlayAsAccessibleContainer(const std::string &desc) : juce::Component()
{
setFocusContainerType(juce::Component::FocusContainerType::focusContainer);
setAccessible(true);
setDescription(desc);
setTitle(desc);
}
};

} // namespace Widgets
} // namespace Surge

Expand Down
34 changes: 30 additions & 4 deletions src/surge-xt/gui/widgets/LFOAndStepDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@ LFOAndStepDisplay::LFOAndStepDisplay()
setAccessible(true);
setFocusContainerType(juce::Component::FocusContainerType::focusContainer);

typeLayer = std::make_unique<OverlayAsAccessibleContainer>("LFO Type");
addAndMakeVisible(*typeLayer);
for (int i = 0; i < n_lfo_types; ++i)
{
auto q = std::make_unique<OverlayAsAccessibleButton<LFOAndStepDisplay>>(this, lt_names[i]);
q->onPress = [this, i](auto *t) { updateShapeTo(i); };
addAndMakeVisible(*q);
typeLayer->addAndMakeVisible(*q);
typeAccOverlays[i] = std::move(q);
}

stepLayer = std::make_unique<OverlayAsAccessibleContainer>("Step Sequencer");
addChildComponent(*stepLayer);
for (int i = 0; i < n_stepseqsteps; ++i)
{
{
Expand All @@ -72,13 +76,13 @@ LFOAndStepDisplay::LFOAndStepDisplay()
repaint();
return;
};
addChildComponent(*q);
stepLayer->addChildComponent(*q);
stepSliderOverlays[i] = std::move(q);
}
{
std::string sn = "Trigger Envelopes " + std::to_string(i + 1);
auto q = std::make_unique<OverlayAsAccessibleButton<LFOAndStepDisplay>>(this, sn);
addChildComponent(*q);
stepLayer->addChildComponent(*q);
stepTriggerOverlays[i] = std::move(q);
}
}
Expand All @@ -97,6 +101,8 @@ void LFOAndStepDisplay::resized()
ss_shift_left = ss_shift_bg.reduced(1, 1).withBottom(ss_shift_bg.getY() + 16);
ss_shift_right = ss_shift_left.translated(0, 16);

typeLayer->setBounds(getLocalBounds());
stepLayer->setBounds(getLocalBounds());
for (int i = 0; i < n_lfo_types; ++i)
{
int xp = (i % 2) * 25 + left_panel.getX();
Expand All @@ -108,7 +114,10 @@ void LFOAndStepDisplay::resized()
}

auto wfw = waveform_display.getWidth() * 1.f / n_stepseqsteps;
auto ssr = waveform_display.withWidth(wfw);
auto ssr = waveform_display.withWidth(wfw).withTrimmedTop(10);
bool showtrig = false;
if (lfoid < n_lfos_voice)
showtrig = true;
for (const auto &q : stepSliderOverlays)
{
q->setBounds(ssr);
Expand All @@ -122,6 +131,21 @@ void LFOAndStepDisplay::resized()
}
ssr = ssr.translated(wfw, 0);
}

ssr = waveform_display.withWidth(wfw).withHeight(10);
for (const auto &q : stepTriggerOverlays)
{
q->setBounds(ssr);
if (lfodata && lfodata->shape.val.i == lt_stepseq)
{
q->setVisible(showtrig);
}
else
{
q->setVisible(false);
}
ssr = ssr.translated(wfw, 0);
}
}

void LFOAndStepDisplay::paint(juce::Graphics &g)
Expand Down Expand Up @@ -2032,6 +2056,8 @@ void LFOAndStepDisplay::setupAccessibility()
showStepSliders = true;
}

stepLayer->setVisible(showStepSliders);

for (const auto &s : stepSliderOverlays)
if (s)
s->setVisible(showStepSliders);
Expand Down
1 change: 1 addition & 0 deletions src/surge-xt/gui/widgets/LFOAndStepDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ struct LFOAndStepDisplay : public juce::Component, public WidgetBaseMixin<LFOAnd
void setupAccessibility();

#if SURGE_JUCE_ACCESSIBLE
std::unique_ptr<juce::Component> typeLayer, stepLayer;
std::array<std::unique_ptr<juce::Component>, n_lfo_types> typeAccOverlays;
std::unique_ptr<juce::AccessibilityHandler> createAccessibilityHandler() override;

Expand Down

0 comments on commit 0dd5206

Please sign in to comment.