Skip to content

Commit 58f099e

Browse files
committed
Add button to AuxiliaryIO settings tab
- Previously, the AnalogIO button was visible and was used to control both AnalogIO and DigitalIO enable states, but this should be controlled at the highest level (i.e., the AuxiliaryIO device)
1 parent 26c2999 commit 58f099e

File tree

4 files changed

+63
-5
lines changed

4 files changed

+63
-5
lines changed

Source/UI/AnalogIOInterface.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ void AnalogIOInterface::updateSettings()
129129
}
130130
}
131131

132+
void AnalogIOInterface::hideEnableButton()
133+
{
134+
deviceEnableButton->setVisible(false);
135+
}
136+
132137
void AnalogIOInterface::buttonClicked(Button* button)
133138
{
134139
if (button == deviceEnableButton.get())

Source/UI/AnalogIOInterface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ namespace OnixSourcePlugin
4646
void comboBoxChanged(ComboBox* cb) override;
4747
void setInterfaceEnabledState(bool newState) override;
4848

49+
void hideEnableButton();
50+
4951
private:
5052

5153
static const int numChannels = 12;

Source/UI/AuxiliaryIOInterface.cpp

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,26 @@ AuxiliaryIOInterface::AuxiliaryIOInterface(std::shared_ptr<AuxiliaryIO> d, OnixS
3535
{
3636
auto auxiliaryIO = std::static_pointer_cast<AuxiliaryIO>(device);
3737

38-
static int offset = 55;
39-
FontOptions font = FontOptions("Fira Code", "Bold", 22.0f);
40-
4138
analogDigitalLabel = std::make_unique<Label>("analogDigitalLabel", "Analog and Digital IO");
4239
analogDigitalLabel->setBounds(20, 20, 350, 35);
43-
analogDigitalLabel->setFont(font);
40+
analogDigitalLabel->setFont(FontOptions("Fira Code", "Bold", 22.0f));
4441
addAndMakeVisible(analogDigitalLabel.get());
4542

43+
deviceEnableButton = std::make_unique<UtilityButton>(enabledButtonText);
44+
deviceEnableButton->setFont(FontOptions("Fira Code", "Regular", 12.0f));
45+
deviceEnableButton->setRadius(3.0f);
46+
deviceEnableButton->setBounds(20, 60, 100, 22);
47+
deviceEnableButton->setClickingTogglesState(true);
48+
deviceEnableButton->setTooltip("If disabled, AnalogIO and DigitalIO devices will not stream or receive data during acquisition");
49+
deviceEnableButton->setToggleState(true, dontSendNotification);
50+
deviceEnableButton->addListener(this);
51+
addAndMakeVisible(deviceEnableButton.get());
52+
deviceEnableButton->setToggleState(device->isEnabled(), sendNotification);
53+
54+
const int offset = deviceEnableButton->getBottom() + 5;
55+
4656
analogInterface = std::make_unique<AnalogIOInterface>(auxiliaryIO->getAnalogIO(), e, c);
57+
analogInterface->hideEnableButton();
4758
analogViewport = std::make_unique<CustomViewport>(analogInterface.get(), SettingsInterface::Width / 2, SettingsInterface::Height);
4859
analogViewport->setBounds(0, offset, SettingsInterface::Width / 2, SettingsInterface::Height);
4960
addAndMakeVisible(analogViewport.get());
@@ -55,6 +66,41 @@ AuxiliaryIOInterface::AuxiliaryIOInterface(std::shared_ptr<AuxiliaryIO> d, OnixS
5566
}
5667
}
5768

69+
void AuxiliaryIOInterface::buttonClicked(Button* b)
70+
{
71+
if (b == deviceEnableButton.get())
72+
{
73+
device->setEnabled(deviceEnableButton->getToggleState());
74+
75+
if (canvas->foundInputSource())
76+
{
77+
try
78+
{
79+
device->configureDevice();
80+
}
81+
catch (const error_str& e)
82+
{
83+
LOGE(e.what());
84+
b->setToggleState(!b->getToggleState(), dontSendNotification);
85+
return;
86+
}
87+
88+
canvas->resetContext();
89+
}
90+
91+
if (device->isEnabled())
92+
{
93+
deviceEnableButton->setLabel(enabledButtonText);
94+
}
95+
else
96+
{
97+
deviceEnableButton->setLabel(disabledButtonText);
98+
}
99+
100+
CoreServices::updateSignalChain(editor);
101+
}
102+
}
103+
58104
void AuxiliaryIOInterface::setInterfaceEnabledState(bool newState)
59105
{
60106
analogInterface->setInterfaceEnabledState(newState);

Source/UI/AuxiliaryIOInterface.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ namespace OnixSourcePlugin
3636
class AnalogIOInterface;
3737
class DigitalIOInterface;
3838

39-
class AuxiliaryIOInterface : public SettingsInterface
39+
class AuxiliaryIOInterface : public SettingsInterface,
40+
public Button::Listener
4041
{
4142
public:
4243

@@ -49,8 +50,12 @@ namespace OnixSourcePlugin
4950

5051
private:
5152

53+
void buttonClicked(Button* b) override;
54+
5255
void setInterfaceEnabledState(bool newState) override;
5356

57+
std::unique_ptr<UtilityButton> deviceEnableButton;
58+
5459
std::unique_ptr<CustomViewport> analogViewport;
5560
std::unique_ptr<CustomViewport> digitalViewport;
5661

0 commit comments

Comments
 (0)