25
25
#include " OnixSource.h"
26
26
27
27
OnixSourceEditor::OnixSourceEditor (GenericProcessor* parentNode, OnixSource* onixSource)
28
- : VisualizerEditor(parentNode, " Onix Source" ), thread(onixSource)
28
+ : VisualizerEditor(parentNode, " Onix Source" , 200 ), thread(onixSource)
29
29
{
30
30
canvas = nullptr ;
31
31
32
- desiredWidth = 200 ;
33
-
34
- portVoltageLabel = std::make_unique<Label>(" Voltage" , " PORT VOLTAGE [V]" );
35
- portVoltageLabel->setBounds (5 , 20 , 85 , 20 );
36
- portVoltageLabel->setFont (FontOptions (" Fira Code" , " Regular" , 11 .0f ));
37
- portVoltageLabel->setColour (Label::textColourId, Colours::black);
38
- addAndMakeVisible (portVoltageLabel.get ());
39
-
40
- portVoltage = 5 .0f ;
41
- portVoltageValue = std::make_unique<Label>(" VoltageValue" , String (portVoltage));
42
- portVoltageValue->setBounds (10 , 38 , 30 , 13 );
43
- portVoltageValue->setFont (FontOptions (" Fira Code" , " Regular" , 11 .0f ));
44
- portVoltageValue->setEditable (true );
45
- portVoltageValue->setColour (Label::textColourId, Colours::black);
46
- portVoltageValue->setColour (Label::backgroundColourId, Colours::lightgrey);
47
- portVoltageValue->addListener (this );
48
- addAndMakeVisible (portVoltageValue.get ());
49
-
50
- connectButton = std::make_unique<UtilityButton>(" Connect" );
51
- connectButton->setFont (FontOptions (" Fira Code" , " Regular" , 11 .0f ));
52
- connectButton->setBounds (10 , 95 , 65 , 20 );
32
+ FontOptions fontOptionSmall = FontOptions (" Fira Code" , " Regular" , 12 .0f );
33
+ FontOptions fontOptionTitle = FontOptions (" Fira Code" , " Bold" , 15 .0f );
34
+
35
+ portLabelA = std::make_unique<Label>(" portLabelA" , " Port A:" );
36
+ portLabelA->setBounds (4 , 25 , 60 , 16 );
37
+ portLabelA->setFont (fontOptionTitle);
38
+ addAndMakeVisible (portLabelA.get ());
39
+
40
+ headstageComboBoxA = std::make_unique<ComboBox>(" headstageComboBoxA" );
41
+ headstageComboBoxA->setBounds (portLabelA->getRight () + 2 , portLabelA->getY (), 120 , portLabelA->getHeight ());
42
+ headstageComboBoxA->addListener (this );
43
+ headstageComboBoxA->setTooltip (" Select the headstage connected to port A." );
44
+ headstageComboBoxA->addItem (" Select headstage..." , 1 );
45
+ headstageComboBoxA->setItemEnabled (1 , false );
46
+ headstageComboBoxA->addSeparator ();
47
+ // TODO: Add list of available devices here
48
+ addAndMakeVisible (headstageComboBoxA.get ());
49
+
50
+ passthroughEditorA = std::make_unique<ToggleParameterEditor>(onixSource->getParameter (" passthroughA" ));
51
+ passthroughEditorA->setLayout (ParameterEditor::nameHidden);
52
+ passthroughEditorA->setBounds (headstageComboBoxA->getX (), headstageComboBoxA->getBottom () + 4 , 60 , headstageComboBoxA->getHeight ());
53
+ addAndMakeVisible (passthroughEditorA.get ());
54
+
55
+ portVoltageValueA = std::make_unique<Label>(" voltageValueA" , " " );
56
+ portVoltageValueA->setBounds (passthroughEditorA->getRight () + 10 , passthroughEditorA->getY (), 35 , passthroughEditorA->getHeight ());
57
+ portVoltageValueA->setFont (fontOptionSmall);
58
+ portVoltageValueA->setEditable (true );
59
+ portVoltageValueA->setColour (Label::textColourId, Colours::black);
60
+ portVoltageValueA->setColour (Label::backgroundColourId, Colours::lightgrey);
61
+ portVoltageValueA->setTooltip (" Voltage override. If set, overrides the automated voltage discovery algorithm." );
62
+ portVoltageValueA->addListener (this );
63
+ addAndMakeVisible (portVoltageValueA.get ());
64
+
65
+ portLabelB = std::make_unique<Label>(" portLabelB" , " Port B:" );
66
+ portLabelB->setBounds (portLabelA->getX (), passthroughEditorA->getBottom () + 5 , portLabelA->getWidth (), portLabelA->getHeight ());
67
+ portLabelB->setFont (fontOptionTitle);
68
+ addAndMakeVisible (portLabelB.get ());
69
+
70
+ headstageComboBoxB = std::make_unique<ComboBox>(" headstageComboBoxB" );
71
+ headstageComboBoxB->setBounds (portLabelB->getRight (), portLabelB->getY (), headstageComboBoxA->getWidth (), portLabelB->getHeight ());
72
+ headstageComboBoxB->addListener (this );
73
+ headstageComboBoxB->setTooltip (" Select the headstage connected to port B." );
74
+ headstageComboBoxB->addItem (" Select headstage..." , 1 );
75
+ headstageComboBoxB->setItemEnabled (1 , false );
76
+ headstageComboBoxB->addSeparator ();
77
+ // TODO: Add list of available devices here
78
+ addAndMakeVisible (headstageComboBoxB.get ());
79
+
80
+ passthroughEditorB = std::make_unique<ToggleParameterEditor>(onixSource->getParameter (" passthroughB" ));
81
+ passthroughEditorB->setLayout (ParameterEditor::nameHidden);
82
+ passthroughEditorB->setBounds (headstageComboBoxB->getX (), headstageComboBoxB->getBottom () + 4 , passthroughEditorA->getWidth (), passthroughEditorA->getHeight ());
83
+ addAndMakeVisible (passthroughEditorB.get ());
84
+
85
+ portVoltageValueB = std::make_unique<Label>(" voltageValueB" , " " );
86
+ portVoltageValueB->setBounds (passthroughEditorB->getRight () + 10 , passthroughEditorB->getY (), portVoltageValueA->getWidth (), passthroughEditorB->getHeight ());
87
+ portVoltageValueB->setFont (fontOptionSmall);
88
+ portVoltageValueB->setEditable (true );
89
+ portVoltageValueB->setColour (Label::textColourId, Colours::black);
90
+ portVoltageValueB->setColour (Label::backgroundColourId, Colours::lightgrey);
91
+ portVoltageValueB->setTooltip (" Voltage override. If set, overrides the automated voltage discovery algorithm." );
92
+ portVoltageValueB->addListener (this );
93
+ addAndMakeVisible (portVoltageValueB.get ());
94
+
95
+ connectButton = std::make_unique<UtilityButton>(" CONNECT" );
96
+ connectButton->setFont (fontOptionSmall);
97
+ connectButton->setBounds (portLabelB->getX () + 5 , portLabelB->getBottom () + 25 , 70 , 18 );
53
98
connectButton->setRadius (3 .0f );
54
99
connectButton->setClickingTogglesState (true );
55
100
connectButton->setToggleState (false , dontSendNotification);
56
101
connectButton->setTooltip (" Press to connect or disconnect from Onix hardware" );
57
102
connectButton->addListener (this );
58
103
addAndMakeVisible (connectButton.get ());
59
-
60
- passthroughEditor = std::make_unique<ToggleParameterEditor>(onixSource->getParameter (" is_passthrough_A" ), 20 , 95 );
61
- passthroughEditor->setLayout (ParameterEditor::nameOnTop);
62
- passthroughEditor->setBounds (80 , 90 , 100 , 36 );
63
- addAndMakeVisible (passthroughEditor.get ());
64
104
}
65
105
66
106
void OnixSourceEditor::labelTextChanged (Label* l)
67
107
{
68
- if (l == portVoltageValue .get ())
108
+ if (l == portVoltageValueA .get ())
69
109
{
70
- const float minVoltage = 4.5 ;
71
- const float maxVoltage = 6.5 ;
72
-
73
- float voltage = portVoltageValue->getText ().getFloatValue ();
74
-
75
- if (voltage >= minVoltage && voltage <= maxVoltage)
76
- {
77
- portVoltage = voltage;
78
- }
79
- else if (voltage < minVoltage)
80
- {
81
- portVoltage = minVoltage;
82
- portVoltageValue->setText (String (portVoltage), NotificationType::dontSendNotification);
83
- }
84
- else if (voltage > maxVoltage)
85
- {
86
- portVoltage = maxVoltage;
87
- portVoltageValue->setText (String (portVoltage), NotificationType::dontSendNotification);
88
- }
89
110
}
90
111
}
91
112
@@ -95,20 +116,20 @@ void OnixSourceEditor::buttonClicked(Button* b)
95
116
{
96
117
if (connectButton->getToggleState () == true )
97
118
{
98
- int result = thread->setPortVoltage ((oni_dev_idx_t )PortName::PortA, (int )(portVoltage * 10 ));
119
+ int result = thread->setPortVoltage ((oni_dev_idx_t )PortName::PortA, (int )(portVoltageValueA-> getText (). getFloatValue () * 10 ));
99
120
100
- if (result != 0 ) { CoreServices::sendStatusMessage (" Unable to set port voltage to " + String (portVoltage ) + " for Port A." ); return ; }
121
+ if (result != 0 ) { CoreServices::sendStatusMessage (" Unable to set port voltage to " + portVoltageValueA-> getText ( ) + " for Port A." ); return ; }
101
122
102
123
thread->initializeDevices (true );
103
124
canvas->refreshTabs ();
104
125
105
- connectButton->setLabel (" Disconnect " );
126
+ connectButton->setLabel (" DISCONNECT " );
106
127
107
128
if (!thread->foundInputSource ())
108
129
{
109
130
CoreServices::sendStatusMessage (" No Onix hardware found." );
110
131
connectButton->setToggleState (false , NotificationType::dontSendNotification);
111
- connectButton->setLabel (" Connect " );
132
+ connectButton->setLabel (" CONNECT " );
112
133
}
113
134
}
114
135
else
@@ -119,11 +140,19 @@ void OnixSourceEditor::buttonClicked(Button* b)
119
140
120
141
canvas->removeTabs ();
121
142
thread->disconnectDevices (true );
122
- connectButton->setLabel (" Connect " );
143
+ connectButton->setLabel (" CONNECT " );
123
144
}
124
145
}
125
146
}
126
147
148
+ void OnixSourceEditor::comboBoxChanged (ComboBox* cb)
149
+ {
150
+ if (cb == headstageComboBoxA.get ())
151
+ {
152
+ // TODO: Call canvas to remove / add tabs as needed depending on what is chosen
153
+ }
154
+ }
155
+
127
156
void OnixSourceEditor::updateSettings ()
128
157
{
129
158
if (canvas != nullptr )
@@ -173,3 +202,16 @@ void OnixSourceEditor::resetCanvas()
173
202
}
174
203
}
175
204
}
205
+
206
+ float OnixSourceEditor::getPortVoltage (PortName port)
207
+ {
208
+ switch (port)
209
+ {
210
+ case PortName::PortA:
211
+ return 0 .0f ;
212
+ case PortName::PortB:
213
+ return 0 .0f ;
214
+ default :
215
+ return 0 .0f ;
216
+ }
217
+ }
0 commit comments