Skip to content

Commit

Permalink
Force CartManager focus traversial
Browse files Browse the repository at this point in the history
  • Loading branch information
asb2m10 committed Aug 27, 2024
1 parent 2cef88f commit e3d7ed3
Show file tree
Hide file tree
Showing 13 changed files with 409 additions and 293 deletions.
15 changes: 9 additions & 6 deletions Documentation/Keybindings.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Dexed key bindings

| Key bindings | Actions |
| ---------------------------- | -----------------------------|
| CTRL+1 to CTRL+6 | Focus on operator 'X' group |
| CTRL+SHIFT+1 TO CTRL+SHIFT+6 | Toggle active operator 'X' |
| CTRL+Q | Focus on global group |
| CTRL+L | Open cartridge manager |
| Key bindings | Actions |
| ---------------------------- | ------------------------------------------ |
| CTRL+1 to CTRL+6 | Focus on operator 'X' group |
| CTRL+SHIFT+1 TO CTRL+SHIFT+6 | Toggle active operator 'X' |
| CTRL+G | Focus on global group |
| CTRL+L | Open cartridge manager |
| CTRL+P | Open parameter dialog |
| CTRL+C | Copy current context on clipboard as hexa |
| CTRL+V | Paste context from clipboard content |
72 changes: 45 additions & 27 deletions Source/CartManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,29 +87,47 @@ class CartBrowserFocusTraverser : public KeyboardFocusTraverser {
}

Component* getNextComponent(Component* current) override {
for (int i=0;i<orders.size();i++) {
bool srcFound = false;
int i;

for (i=0;i<orders.size();i++) {
if ( orders[i] == current ) {
i += 1;
if ( i == orders.size() )
return orders.front();
else
return orders[i];
srcFound = true;
continue;
}

if ( srcFound ) {
ProgramLabel *label = dynamic_cast<ProgramLabel*>(orders[i]);
if ( label != nullptr && !label->isActive() )
continue;
break;
}
}
return root;

if ( i == orders.size() )
return orders.front();
return orders[i];
}

Component* getPreviousComponent(Component* current) override {
for (int i=0;i<orders.size();i++) {
bool srcFound = false;
int i=0;

for(i=orders.size()-1;i>=0;i--) {
if ( orders[i] == current ) {
i -= 1;
if ( i < 0 )
return orders.back();
else
return orders[i];
srcFound = true;
continue;
}
if ( srcFound ) {
ProgramLabel *label = dynamic_cast<ProgramLabel*>(orders[i]);
if ( label != nullptr && !label->isActive() )
continue;
break;
}
}
return root;
if ( i == -1 )
return orders.back();
return orders[i];
}

std::vector<Component*> getAllComponents(Component* parentComponent) override {
Expand Down Expand Up @@ -164,13 +182,18 @@ CartManager::CartManager(DexedAudioProcessorEditor *editor) : Component("CartMan
addAndMakeVisible(activeCartName.get());

focusOrder.push_back(cartBrowser.get());
focusOrder.push_back(activeCart.get());
focusOrder.push_back(browserCart.get());
//focusOrder.push_back(browserCart.get());
for(int i=0;i<32;i++) {
focusOrder.push_back(browserCart->getProgramComponent(i));
}
//focusOrder.push_back(activeCart.get());
for(int i=0;i<32;i++) {
focusOrder.push_back(activeCart->getProgramComponent(i));
}
focusOrder.push_back(closeButton.get());
focusOrder.push_back(loadButton.get());
focusOrder.push_back(saveButton.get());
focusOrder.push_back(fileMgrButton.get());
focusOrder.push_back(activeCartName.get());

/*
*
Expand All @@ -192,16 +215,16 @@ CartManager::~CartManager() {
cartBrowserList.reset(NULL);
}

std::unique_ptr<ComponentTraverser> CartManager::createFocusTraverser() {
std::unique_ptr<ComponentTraverser> CartManager::createKeyboardFocusTraverser() {
return std::make_unique<CartBrowserFocusTraverser>(this, focusOrder);
}

void CartManager::resized() {
float activeSize = ((float) getWidth() - 30) / 8;
float activeSize = 100;

activeCart->setBounds(15, 402, activeSize * 8, 96);
browserCart->setBounds(activeSize * 6 + 15, 10, activeSize * 2, 384);
cartBrowser->setBounds(15, 10, activeSize * 6 - 1, 383);
activeCart->setBounds(14, 402, activeSize * 8, 96);
browserCart->setBounds(activeSize * 6 + 15, 10, activeSize * 2, 385);
cartBrowser->setBounds(14, 10, activeSize * 6 - 4, 385);
closeButton->setBounds(4, getHeight() - 40, 70, 30);
saveButton->setBounds(144, getHeight() - 40, 70, 30);
loadButton->setBounds(74, getHeight() - 40, 70, 30);
Expand Down Expand Up @@ -425,11 +448,6 @@ bool CartManager::keyPressed(const KeyPress& key, Component* originatingComponen
activeCart->setCartridge(mainWindow->processor->currentCart);
return true;
}
if ( key.getKeyCode() == KeyPress::escapeKey ) {
hideCartridgeManager();
return true;
}

return false;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/CartManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class CartManager : public Component, public Button::Listener, public DragAndDr
void initialFocus();
void hideCartridgeManager();

std::unique_ptr<ComponentTraverser> createFocusTraverser() override;
std::unique_ptr< ComponentTraverser> createKeyboardFocusTraverser() override;
};

#endif // CARTMANAGER_H_INCLUDED
102 changes: 93 additions & 9 deletions Source/DXComponents.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,65 @@
#include "../JuceLibraryCode/JuceHeader.h"
#include <stdint.h>

//==============================================================================
// THIS IS A TEMPORY FIX FOR COMBOBOX ACCESSIBILITY
// SEE: https://forum.juce.com/t/bug-combo-box-accessibility-bug/62501/2
// WILL BE REMOVED ONCE WE UPDATE TO JUCE 8
class ComboBoxAccessibilityHandlerFix final : public AccessibilityHandler
{
public:
explicit ComboBoxAccessibilityHandlerFix (ComboBox& comboBoxToWrap)
: AccessibilityHandler (comboBoxToWrap,
AccessibilityRole::comboBox,
getAccessibilityActions (comboBoxToWrap),
{ std::make_unique<ComboBoxValueInterface> (comboBoxToWrap) }),
comboBox (comboBoxToWrap)
{
}

AccessibleState getCurrentState() const override
{
auto state = AccessibilityHandler::getCurrentState().withExpandable();

return comboBox.isPopupActive() ? state.withExpanded() : state.withCollapsed();
}

String getTitle() const override { return comboBox.getTitle(); } // THE FIX IS RIGHT HERE
String getHelp() const override { return comboBox.getTooltip(); }

private:
class ComboBoxValueInterface final : public AccessibilityTextValueInterface
{
public:
explicit ComboBoxValueInterface (ComboBox& comboBoxToWrap)
: comboBox (comboBoxToWrap)
{
}

bool isReadOnly() const override { return true; }
String getCurrentValueAsString() const override { return comboBox.getText(); }
void setValueAsString (const String&) override {}

private:
ComboBox& comboBox;

//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComboBoxValueInterface)
};

static AccessibilityActions getAccessibilityActions (ComboBox& comboBox)
{
return AccessibilityActions().addAction (AccessibilityActionType::press, [&comboBox] { comboBox.showPopup(); })
.addAction (AccessibilityActionType::showMenu, [&comboBox] { comboBox.showPopup(); });
}

ComboBox& comboBox;

//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ComboBoxAccessibilityHandlerFix)
};
//==============================================================================

class EnvDisplay : public Component {
public:
EnvDisplay();
Expand All @@ -40,13 +99,7 @@ class PitchEnvDisplay : public Component {
char vPos;
void paint(Graphics &g);
};
/*
class VuMeter: public Component {
void paint(Graphics &g);
public :
float v;
};
*/

class LcdDisplay : public Component {
public:
LcdDisplay();
Expand All @@ -67,9 +120,15 @@ class ComboBoxImage : public ComboBox {
virtual void showPopup() override;
void setImage(Image image);
void setImage(Image image, int pos[]);

std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override {
return std::make_unique<ComboBoxAccessibilityHandlerFix> (*this);
}

};

class ProgramSelector : public ComboBox {
float accum_wheel;
public:
ProgramSelector() {
setWantsKeyboardFocus(true);
Expand All @@ -80,8 +139,33 @@ class ProgramSelector : public ComboBox {
virtual void mouseWheelMove(const MouseEvent &event, const MouseWheelDetails &wheel) override;
virtual void paint(Graphics &g) override;

private:
float accum_wheel;
std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override {
return std::make_unique<ComboBoxAccessibilityHandlerFix> (*this);
}
};

class FocusLogger final : public juce::FocusChangeListener
{
public:
FocusLogger ()
{
juce::Desktop::getInstance ().addFocusChangeListener (this);
}

~FocusLogger () override
{
juce::Desktop::getInstance ().removeFocusChangeListener (this);
}

void globalFocusChanged (juce::Component * focusedComponent) override
{
if (focusedComponent == nullptr)
return;

DBG ("Component title: " << focusedComponent->getTitle ());
DBG ("Component type: " << typeid (*focusedComponent).name ());
DBG ("---");
}
};

#endif // DXCOMPONENTS_H_INCLUDED
4 changes: 3 additions & 1 deletion Source/DXLookNFeel.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* Copyright (c) 2013-2018 Pascal Gauthier.
* Copyright (c) 2013-2024 Pascal Gauthier.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -114,6 +114,8 @@ DXLookNFeel::DXLookNFeel() {
REG_COLOUR(TreeView::backgroundColourId, background);
REG_COLOUR(DirectoryContentsDisplayComponent::highlightColourId, fillColour);
REG_COLOUR(DirectoryContentsDisplayComponent::textColourId, Colours::white);
REG_COLOUR(DialogWindow::backgroundColourId, background);
REG_COLOUR(ListBox::backgroundColourId, ctrlBackground);

// Register ``Scrollbar::thumbColourId`` to allow its redefinion in ``DexedTheme.xml``.
REG_COLOUR(ScrollBar::thumbColourId, background.darker());
Expand Down
1 change: 0 additions & 1 deletion Source/GlobalEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,6 @@ GlobalEditor::GlobalEditor ()
lfoType->addItem("SINE", 5);
lfoType->addItem("S&HOLD", 6);
lfoType->setImage(lookAndFeel->imageLFO);
lfoType->setTitle("LFO Waveform");

programs = programSelector.get();

Expand Down
3 changes: 0 additions & 3 deletions Source/OperatorEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,6 @@ OperatorEditor::OperatorEditor ()

background = lookAndFeel->imageOperator;
opSwitch->setTitle("Operator switch");
opMode->setTitle("Operator Mode");
kbdLeftCurve->setTitle("Keyboard Left Curve");
kbdRightCurve->setTitle("Keyboard Right Curve");

setWantsKeyboardFocus(true);
//[/Constructor]
Expand Down
69 changes: 69 additions & 0 deletions Source/ParamDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,75 @@ ParamDialog::ParamDialog ()
if ( JUCEApplication::isStandaloneApp() ) {
sysexIn->setVisible(false);
}

// ACCESSIBLITY
pitchRangeUp->setTitle("Pitch Bend Range Up");
pitchRangeDn->setTitle("Pitch Bend Range Down");
pitchStep->setTitle("Pitch Bend Step");
sysexIn->setTitle("Sysex Input");
sysexOut->setTitle("Sysex Output");
sysexChl->setTitle("Sysex Channel");
engineReso->setTitle("Engine Resolution");
showKeyboard->setTitle("Show Keyboard");
whlRange->setTitle("Wheel Range");
ftRange->setTitle("Foot Range");
brRange->setTitle("Breath Range");
atRange->setTitle("After Touch Range");
whlEg->setTitle("Wheel EG");
ftEg->setTitle("Foot EG");
brEg->setTitle("Breath EG");
atEg->setTitle("After Touch EG");
whlAmp->setTitle("Wheel Amp");
ftAmp->setTitle("Foot Amp");
brAmp->setTitle("Breath Amp");
atAmp->setTitle("After Touch Amp");
whlPitch->setTitle("Wheel Pitch");
ftPitch->setTitle("Foot Pitch");
brPitch->setTitle("Breath Pitch");
atPitch->setTitle("After Touch Pitch");
sclButton->setTitle("Scale Button");
kbmButton->setTitle("Keyboard Mapping Button");
showTunButton->setTitle("Show Tuning Button");
resetTuningButton->setTitle("Reset Tuning Button");
transposeScale->setTitle("Transpose Scale");
mpePBRange->setTitle("MPE Pitch Bend Range");
mpeEnabled->setTitle("MPE Enabled");
transposeHelp->setTitle("Transpose Help");
scalingFactor->setTitle("Scaling Factor");

pitchRangeUp->setWantsKeyboardFocus(true);
pitchRangeDn->setWantsKeyboardFocus(true);
pitchStep->setWantsKeyboardFocus(true);
sysexIn->setWantsKeyboardFocus(true);
sysexOut->setWantsKeyboardFocus(true);
sysexChl->setWantsKeyboardFocus(true);
engineReso->setWantsKeyboardFocus(true);
showKeyboard->setWantsKeyboardFocus(true);
whlRange->setWantsKeyboardFocus(true);
ftRange->setWantsKeyboardFocus(true);
brRange->setWantsKeyboardFocus(true);
atRange->setWantsKeyboardFocus(true);
whlEg->setWantsKeyboardFocus(true);
ftEg->setWantsKeyboardFocus(true);
brEg->setWantsKeyboardFocus(true);
atEg->setWantsKeyboardFocus(true);
whlAmp->setWantsKeyboardFocus(true);
ftAmp->setWantsKeyboardFocus(true);
brAmp->setWantsKeyboardFocus(true);
atAmp->setWantsKeyboardFocus(true);
whlPitch->setWantsKeyboardFocus(true);
ftPitch->setWantsKeyboardFocus(true);
brPitch->setWantsKeyboardFocus(true);
atPitch->setWantsKeyboardFocus(true);
sclButton->setWantsKeyboardFocus(true);
kbmButton->setWantsKeyboardFocus(true);
showTunButton->setWantsKeyboardFocus(true);
resetTuningButton->setWantsKeyboardFocus(true);
transposeScale->setWantsKeyboardFocus(true);
mpePBRange->setWantsKeyboardFocus(true);
mpeEnabled->setWantsKeyboardFocus(true);
transposeHelp->setWantsKeyboardFocus(true);
scalingFactor->setWantsKeyboardFocus(true);
//[/Constructor]
}

Expand Down
Loading

0 comments on commit e3d7ed3

Please sign in to comment.