2525#include " OnixSource.h"
2626
2727OnixSourceEditor::OnixSourceEditor (GenericProcessor* parentNode, OnixSource* onixSource)
28- : VisualizerEditor(parentNode, " Onix Source" ), thread(onixSource)
28+ : VisualizerEditor(parentNode, " Onix Source" , 200 ), thread(onixSource)
2929{
3030 canvas = nullptr ;
3131
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 );
5398 connectButton->setRadius (3 .0f );
5499 connectButton->setClickingTogglesState (true );
55100 connectButton->setToggleState (false , dontSendNotification);
56101 connectButton->setTooltip (" Press to connect or disconnect from Onix hardware" );
57102 connectButton->addListener (this );
58103 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 ());
64104}
65105
66106void OnixSourceEditor::labelTextChanged (Label* l)
67107{
68- if (l == portVoltageValue .get ())
108+ if (l == portVoltageValueA .get ())
69109 {
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- }
89110 }
90111}
91112
@@ -95,20 +116,20 @@ void OnixSourceEditor::buttonClicked(Button* b)
95116 {
96117 if (connectButton->getToggleState () == true )
97118 {
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 ));
99120
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 ; }
101122
102123 thread->initializeDevices (true );
103124 canvas->refreshTabs ();
104125
105- connectButton->setLabel (" Disconnect " );
126+ connectButton->setLabel (" DISCONNECT " );
106127
107128 if (!thread->foundInputSource ())
108129 {
109130 CoreServices::sendStatusMessage (" No Onix hardware found." );
110131 connectButton->setToggleState (false , NotificationType::dontSendNotification);
111- connectButton->setLabel (" Connect " );
132+ connectButton->setLabel (" CONNECT " );
112133 }
113134 }
114135 else
@@ -119,11 +140,19 @@ void OnixSourceEditor::buttonClicked(Button* b)
119140
120141 canvas->removeTabs ();
121142 thread->disconnectDevices (true );
122- connectButton->setLabel (" Connect " );
143+ connectButton->setLabel (" CONNECT " );
123144 }
124145 }
125146}
126147
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+
127156void OnixSourceEditor::updateSettings ()
128157{
129158 if (canvas != nullptr )
@@ -173,3 +202,16 @@ void OnixSourceEditor::resetCanvas()
173202 }
174203 }
175204}
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