andrewm@55: /* andrewm@55: ============================================================================== andrewm@55: andrewm@55: This is an automatically generated GUI class created by the Introjucer! andrewm@55: andrewm@55: Be careful when adding custom code to these files, as only the code within andrewm@55: the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded andrewm@55: and re-saved. andrewm@55: andrewm@55: Created with Introjucer version: 3.1.0 andrewm@55: andrewm@55: ------------------------------------------------------------------------------ andrewm@55: andrewm@55: The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions" andrewm@55: Copyright 2004-13 by Raw Material Software Ltd. andrewm@55: andrewm@55: ============================================================================== andrewm@55: */ andrewm@55: andrewm@55: andrewm@55: //[Headers] You can add your own extra header files here... andrewm@55: #ifndef TOUCHKEYS_NO_GUI andrewm@55: #include "KeyboardZoneComponent.h" andrewm@55: //[/Headers] andrewm@55: andrewm@55: #include "ControlWindowMainComponent.h" andrewm@55: andrewm@55: andrewm@55: //[MiscUserDefs] You can add your own user definitions and misc code here... andrewm@55: //[/MiscUserDefs] andrewm@55: andrewm@55: //============================================================================== andrewm@55: ControlWindowMainComponent::ControlWindowMainComponent () andrewm@55: : controller_(0) andrewm@55: { andrewm@55: addAndMakeVisible (midiInputGroupComponent = new GroupComponent ("MIDI input group", andrewm@55: "MIDI Input")); andrewm@55: andrewm@55: addAndMakeVisible (midiInputDeviceComboBox = new ComboBox ("MIDI input combo box")); andrewm@55: midiInputDeviceComboBox->setEditableText (false); andrewm@55: midiInputDeviceComboBox->setJustificationType (Justification::centredLeft); andrewm@55: midiInputDeviceComboBox->setTextWhenNothingSelected (String::empty); andrewm@55: midiInputDeviceComboBox->setTextWhenNoChoicesAvailable ("(no choices)"); andrewm@55: midiInputDeviceComboBox->addListener (this); andrewm@55: andrewm@55: addAndMakeVisible (label = new Label ("new label", andrewm@55: "Keyboard:")); andrewm@55: label->setFont (Font (15.00f, Font::plain)); andrewm@55: label->setJustificationType (Justification::centredLeft); andrewm@55: label->setEditable (false, false, false); andrewm@55: label->setColour (TextEditor::textColourId, Colours::black); andrewm@55: label->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@55: andrewm@55: addAndMakeVisible (groupComponent = new GroupComponent ("new group", andrewm@55: "TouchKeys")); andrewm@55: andrewm@55: addAndMakeVisible (label2 = new Label ("new label", andrewm@55: "Device:\n")); andrewm@55: label2->setFont (Font (15.00f, Font::plain)); andrewm@55: label2->setJustificationType (Justification::centredLeft); andrewm@55: label2->setEditable (false, false, false); andrewm@55: label2->setColour (TextEditor::textColourId, Colours::black); andrewm@55: label2->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@55: andrewm@55: addAndMakeVisible (touchkeyDeviceComboBox = new ComboBox ("TouchKeys combo box")); andrewm@55: touchkeyDeviceComboBox->setEditableText (false); andrewm@55: touchkeyDeviceComboBox->setJustificationType (Justification::centredLeft); andrewm@55: touchkeyDeviceComboBox->setTextWhenNothingSelected (String::empty); andrewm@55: touchkeyDeviceComboBox->setTextWhenNoChoicesAvailable ("(no choices)"); andrewm@55: touchkeyDeviceComboBox->addListener (this); andrewm@55: andrewm@55: addAndMakeVisible (label3 = new Label ("new label", andrewm@55: "Status:\n")); andrewm@55: label3->setFont (Font (15.00f, Font::plain)); andrewm@55: label3->setJustificationType (Justification::centredLeft); andrewm@55: label3->setEditable (false, false, false); andrewm@55: label3->setColour (TextEditor::textColourId, Colours::black); andrewm@55: label3->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@55: andrewm@55: addAndMakeVisible (touchkeyStartButton = new TextButton ("TouchKeys start button")); andrewm@55: touchkeyStartButton->setButtonText ("Start"); andrewm@55: touchkeyStartButton->addListener (this); andrewm@55: andrewm@55: addAndMakeVisible (touchkeyStatusLabel = new Label ("TouchKeys status label", andrewm@55: "not running")); andrewm@55: touchkeyStatusLabel->setFont (Font (15.00f, Font::plain)); andrewm@55: touchkeyStatusLabel->setJustificationType (Justification::centredLeft); andrewm@55: touchkeyStatusLabel->setEditable (false, false, false); andrewm@55: touchkeyStatusLabel->setColour (TextEditor::textColourId, Colours::black); andrewm@55: touchkeyStatusLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@55: andrewm@55: addAndMakeVisible (oscGroupComponent = new GroupComponent ("OSC group", andrewm@55: "OSC Output")); andrewm@55: andrewm@55: addAndMakeVisible (label7 = new Label ("new label", andrewm@55: "Host:")); andrewm@55: label7->setFont (Font (15.00f, Font::plain)); andrewm@55: label7->setJustificationType (Justification::centredLeft); andrewm@55: label7->setEditable (false, false, false); andrewm@55: label7->setColour (TextEditor::textColourId, Colours::black); andrewm@55: label7->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@55: andrewm@55: addAndMakeVisible (oscHostTextEditor = new TextEditor ("new text editor")); andrewm@55: oscHostTextEditor->setMultiLine (false); andrewm@55: oscHostTextEditor->setReturnKeyStartsNewLine (false); andrewm@55: oscHostTextEditor->setReadOnly (false); andrewm@55: oscHostTextEditor->setScrollbarsShown (true); andrewm@55: oscHostTextEditor->setCaretVisible (true); andrewm@55: oscHostTextEditor->setPopupMenuEnabled (true); andrewm@55: oscHostTextEditor->setText ("127.0.0.1"); andrewm@55: andrewm@55: addAndMakeVisible (label8 = new Label ("new label", andrewm@55: "Port:")); andrewm@55: label8->setFont (Font (15.00f, Font::plain)); andrewm@55: label8->setJustificationType (Justification::centredLeft); andrewm@55: label8->setEditable (false, false, false); andrewm@55: label8->setColour (TextEditor::textColourId, Colours::black); andrewm@55: label8->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@55: andrewm@55: addAndMakeVisible (oscPortTextEditor = new TextEditor ("new text editor")); andrewm@55: oscPortTextEditor->setMultiLine (false); andrewm@55: oscPortTextEditor->setReturnKeyStartsNewLine (false); andrewm@55: oscPortTextEditor->setReadOnly (false); andrewm@55: oscPortTextEditor->setScrollbarsShown (true); andrewm@55: oscPortTextEditor->setCaretVisible (true); andrewm@55: oscPortTextEditor->setPopupMenuEnabled (true); andrewm@55: oscPortTextEditor->setText ("8000"); andrewm@55: andrewm@55: addAndMakeVisible (oscEnableButton = new ToggleButton ("OSC enable button")); andrewm@55: oscEnableButton->setButtonText ("Enable OSC output"); andrewm@55: oscEnableButton->addListener (this); andrewm@55: andrewm@55: addAndMakeVisible (oscEnableRawButton = new ToggleButton ("OSC enable raw button")); andrewm@55: oscEnableRawButton->setButtonText ("Send raw frames"); andrewm@55: oscEnableRawButton->addListener (this); andrewm@55: andrewm@55: addAndMakeVisible (label4 = new Label ("new label", andrewm@55: "Lowest Octave:")); andrewm@55: label4->setFont (Font (15.00f, Font::plain)); andrewm@55: label4->setJustificationType (Justification::centredLeft); andrewm@55: label4->setEditable (false, false, false); andrewm@55: label4->setColour (TextEditor::textColourId, Colours::black); andrewm@55: label4->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@55: andrewm@55: addAndMakeVisible (touchkeyOctaveComboBox = new ComboBox ("TouchKeys octave box")); andrewm@55: touchkeyOctaveComboBox->setEditableText (false); andrewm@55: touchkeyOctaveComboBox->setJustificationType (Justification::centredLeft); andrewm@55: touchkeyOctaveComboBox->setTextWhenNothingSelected (String::empty); andrewm@55: touchkeyOctaveComboBox->setTextWhenNoChoicesAvailable ("(no choices)"); andrewm@55: touchkeyOctaveComboBox->addListener (this); andrewm@55: andrewm@55: addAndMakeVisible (oscInputGroupComponent = new GroupComponent ("MIDI input group", andrewm@55: "OSC Input")); andrewm@55: andrewm@55: addAndMakeVisible (oscInputEnableButton = new ToggleButton ("OSC input enable button")); andrewm@55: oscInputEnableButton->setButtonText ("Enable OSC input"); andrewm@55: oscInputEnableButton->addListener (this); andrewm@55: andrewm@55: addAndMakeVisible (label6 = new Label ("new label", andrewm@55: "Port:")); andrewm@55: label6->setFont (Font (15.00f, Font::plain)); andrewm@55: label6->setJustificationType (Justification::centredLeft); andrewm@55: label6->setEditable (false, false, false); andrewm@55: label6->setColour (TextEditor::textColourId, Colours::black); andrewm@55: label6->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@55: andrewm@55: addAndMakeVisible (oscInputPortTextEditor = new TextEditor ("new text editor")); andrewm@55: oscInputPortTextEditor->setMultiLine (false); andrewm@55: oscInputPortTextEditor->setReturnKeyStartsNewLine (false); andrewm@55: oscInputPortTextEditor->setReadOnly (false); andrewm@55: oscInputPortTextEditor->setScrollbarsShown (true); andrewm@55: oscInputPortTextEditor->setCaretVisible (true); andrewm@55: oscInputPortTextEditor->setPopupMenuEnabled (true); andrewm@55: oscInputPortTextEditor->setText ("8001"); andrewm@55: andrewm@55: addAndMakeVisible (keyboardZoneTabbedComponent = new TabbedComponent (TabbedButtonBar::TabsAtTop)); andrewm@55: keyboardZoneTabbedComponent->setTabBarDepth (30); andrewm@55: keyboardZoneTabbedComponent->setCurrentTabIndex (-1); andrewm@55: andrewm@55: addAndMakeVisible (addZoneButton = new TextButton ("add zone button")); andrewm@55: addZoneButton->setButtonText ("Add"); andrewm@55: addZoneButton->addListener (this); andrewm@55: andrewm@55: addAndMakeVisible (removeZoneButton = new TextButton ("remove zone button")); andrewm@55: removeZoneButton->setButtonText ("Del"); andrewm@55: removeZoneButton->addListener (this); andrewm@55: andrewm@55: addAndMakeVisible (touchkeyAutodetectButton = new TextButton ("TouchKeys autodetect button")); andrewm@55: touchkeyAutodetectButton->setButtonText ("Detect"); andrewm@55: touchkeyAutodetectButton->addListener (this); andrewm@55: andrewm@55: addAndMakeVisible (midiInputAuxDeviceComboBox = new ComboBox ("MIDI input aux combo box")); andrewm@55: midiInputAuxDeviceComboBox->setEditableText (false); andrewm@55: midiInputAuxDeviceComboBox->setJustificationType (Justification::centredLeft); andrewm@55: midiInputAuxDeviceComboBox->setTextWhenNothingSelected (String::empty); andrewm@55: midiInputAuxDeviceComboBox->setTextWhenNoChoicesAvailable ("(no choices)"); andrewm@55: midiInputAuxDeviceComboBox->addListener (this); andrewm@55: andrewm@55: addAndMakeVisible (label5 = new Label ("new label", andrewm@55: "Aux:")); andrewm@55: label5->setFont (Font (15.00f, Font::plain)); andrewm@55: label5->setJustificationType (Justification::centredRight); andrewm@55: label5->setEditable (false, false, false); andrewm@55: label5->setColour (TextEditor::textColourId, Colours::black); andrewm@55: label5->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@55: andrewm@55: andrewm@55: //[UserPreSize] andrewm@55: lastSelectedMidiInputID_ = -1; andrewm@55: lastSelectedMidiAuxInputID_ = -1; andrewm@55: lastSegmentUniqueIdentifier_ = -1; andrewm@55: andrewm@55: // Add octave labels to combo box andrewm@55: for(int i = 0; i <= kTouchkeysMaxOctave; i++) { andrewm@55: touchkeyOctaveComboBox->addItem("C" + String(i), i + kTouchkeysComponentComboBoxOffset); andrewm@55: } andrewm@55: //[/UserPreSize] andrewm@55: andrewm@55: setSize (872, 444); andrewm@55: andrewm@55: andrewm@55: //[Constructor] You can add your own custom stuff here.. andrewm@55: oscHostTextEditor->addListener(this); andrewm@55: oscPortTextEditor->addListener(this); andrewm@55: oscInputPortTextEditor->addListener(this); andrewm@55: //[/Constructor] andrewm@55: } andrewm@55: andrewm@55: ControlWindowMainComponent::~ControlWindowMainComponent() andrewm@55: { andrewm@55: //[Destructor_pre]. You can add your own custom destruction code here.. andrewm@55: //[/Destructor_pre] andrewm@55: andrewm@55: midiInputGroupComponent = nullptr; andrewm@55: midiInputDeviceComboBox = nullptr; andrewm@55: label = nullptr; andrewm@55: groupComponent = nullptr; andrewm@55: label2 = nullptr; andrewm@55: touchkeyDeviceComboBox = nullptr; andrewm@55: label3 = nullptr; andrewm@55: touchkeyStartButton = nullptr; andrewm@55: touchkeyStatusLabel = nullptr; andrewm@55: oscGroupComponent = nullptr; andrewm@55: label7 = nullptr; andrewm@55: oscHostTextEditor = nullptr; andrewm@55: label8 = nullptr; andrewm@55: oscPortTextEditor = nullptr; andrewm@55: oscEnableButton = nullptr; andrewm@55: oscEnableRawButton = nullptr; andrewm@55: label4 = nullptr; andrewm@55: touchkeyOctaveComboBox = nullptr; andrewm@55: oscInputGroupComponent = nullptr; andrewm@55: oscInputEnableButton = nullptr; andrewm@55: label6 = nullptr; andrewm@55: oscInputPortTextEditor = nullptr; andrewm@55: keyboardZoneTabbedComponent = nullptr; andrewm@55: addZoneButton = nullptr; andrewm@55: removeZoneButton = nullptr; andrewm@55: touchkeyAutodetectButton = nullptr; andrewm@55: midiInputAuxDeviceComboBox = nullptr; andrewm@55: label5 = nullptr; andrewm@55: andrewm@55: andrewm@55: //[Destructor]. You can add your own custom destruction code here.. andrewm@55: //[/Destructor] andrewm@55: } andrewm@55: andrewm@55: //============================================================================== andrewm@55: void ControlWindowMainComponent::paint (Graphics& g) andrewm@55: { andrewm@55: //[UserPrePaint] Add your own custom painting code here.. andrewm@55: //[/UserPrePaint] andrewm@55: andrewm@55: g.fillAll (Colour (0xffd2d2d2)); andrewm@55: andrewm@55: //[UserPaint] Add your own custom painting code here.. andrewm@55: //[/UserPaint] andrewm@55: } andrewm@55: andrewm@55: void ControlWindowMainComponent::resized() andrewm@55: { andrewm@55: midiInputGroupComponent->setBounds (8, 144, 304, 96); andrewm@55: midiInputDeviceComboBox->setBounds (80, 168, 216, 24); andrewm@55: label->setBounds (16, 168, 64, 24); andrewm@55: groupComponent->setBounds (8, 8, 304, 128); andrewm@55: label2->setBounds (16, 32, 60, 24); andrewm@55: touchkeyDeviceComboBox->setBounds (72, 32, 224, 24); andrewm@55: label3->setBounds (16, 96, 60, 24); andrewm@55: touchkeyStartButton->setBounds (216, 96, 79, 24); andrewm@55: touchkeyStatusLabel->setBounds (72, 96, 136, 24); andrewm@55: oscGroupComponent->setBounds (8, 320, 304, 96); andrewm@55: label7->setBounds (16, 376, 55, 24); andrewm@55: oscHostTextEditor->setBounds (64, 376, 128, 24); andrewm@55: label8->setBounds (200, 376, 40, 24); andrewm@55: oscPortTextEditor->setBounds (240, 376, 56, 24); andrewm@55: oscEnableButton->setBounds (24, 344, 144, 24); andrewm@55: oscEnableRawButton->setBounds (176, 344, 144, 24); andrewm@55: label4->setBounds (16, 64, 104, 24); andrewm@55: touchkeyOctaveComboBox->setBounds (120, 64, 88, 24); andrewm@55: oscInputGroupComponent->setBounds (8, 248, 304, 64); andrewm@55: oscInputEnableButton->setBounds (24, 272, 152, 24); andrewm@55: label6->setBounds (200, 272, 40, 24); andrewm@55: oscInputPortTextEditor->setBounds (240, 272, 56, 24); andrewm@55: keyboardZoneTabbedComponent->setBounds (320, 0, 552, 464); andrewm@55: addZoneButton->setBounds (776, 4, 38, 20); andrewm@55: removeZoneButton->setBounds (824, 4, 38, 20); andrewm@55: touchkeyAutodetectButton->setBounds (216, 64, 79, 24); andrewm@55: midiInputAuxDeviceComboBox->setBounds (80, 200, 216, 24); andrewm@55: label5->setBounds (24, 200, 55, 24); andrewm@55: //[UserResized] Add your own custom resize handling here.. andrewm@55: andrewm@55: // Resize KeyboardZoneComponent to fit new bounds andrewm@55: juce::Rectangle const& ourBounds = getBounds(); andrewm@55: juce::Rectangle keyboardZoneBounds = keyboardZoneTabbedComponent->getBounds(); andrewm@55: keyboardZoneBounds.setHeight(ourBounds.getHeight() - keyboardZoneBounds.getY()); andrewm@55: keyboardZoneTabbedComponent->setBounds(keyboardZoneBounds); andrewm@55: //[/UserResized] andrewm@55: } andrewm@55: andrewm@55: void ControlWindowMainComponent::comboBoxChanged (ComboBox* comboBoxThatHasChanged) andrewm@55: { andrewm@55: //[UsercomboBoxChanged_Pre] andrewm@55: if(controller_ == 0) andrewm@55: return; andrewm@55: //[/UsercomboBoxChanged_Pre] andrewm@55: andrewm@55: if (comboBoxThatHasChanged == midiInputDeviceComboBox) andrewm@55: { andrewm@55: //[UserComboBoxCode_midiInputDeviceComboBox] -- add your combo box handling code here.. andrewm@55: andrewm@55: // Look up the selected ID, remembering that Juce indices start at 1 and the first of andrewm@55: // these is "Disabled" andrewm@55: int selection = midiInputDeviceComboBox->getSelectedId() - kMidiInputDeviceComboBoxOffset; andrewm@55: if(selection == 1 - kMidiInputDeviceComboBoxOffset) { // Disabled andrewm@55: if(controller_->midiTouchkeysStandaloneModeIsEnabled()) andrewm@55: controller_->midiTouchkeysStandaloneModeDisable(); andrewm@55: controller_->disablePrimaryMIDIInputPort(); andrewm@55: } andrewm@55: else if(selection == 2 - kMidiInputDeviceComboBoxOffset) { // Standalone mode andrewm@55: controller_->disablePrimaryMIDIInputPort(); andrewm@55: controller_->midiTouchkeysStandaloneModeEnable(); andrewm@55: } andrewm@55: else if(selection >= 0 && selection < midiInputDeviceIDs_.size()) { andrewm@55: int deviceId = midiInputDeviceIDs_[selection]; andrewm@55: if(controller_->midiTouchkeysStandaloneModeIsEnabled()) andrewm@55: controller_->midiTouchkeysStandaloneModeDisable(); andrewm@55: controller_->enableMIDIInputPort(deviceId, true); andrewm@55: } andrewm@55: //[/UserComboBoxCode_midiInputDeviceComboBox] andrewm@55: } andrewm@55: else if (comboBoxThatHasChanged == touchkeyDeviceComboBox) andrewm@55: { andrewm@55: //[UserComboBoxCode_touchkeyDeviceComboBox] -- add your combo box handling code here.. andrewm@55: // Nothing to do here right away -- wait until start button is pressed andrewm@55: //[/UserComboBoxCode_touchkeyDeviceComboBox] andrewm@55: } andrewm@55: else if (comboBoxThatHasChanged == touchkeyOctaveComboBox) andrewm@55: { andrewm@55: //[UserComboBoxCode_touchkeyOctaveComboBox] -- add your combo box handling code here.. andrewm@55: int octave = touchkeyOctaveComboBox->getSelectedId() - kTouchkeysComponentComboBoxOffset; andrewm@55: andrewm@55: // Convert octave number to MIDI note (C4 = 60) andrewm@55: if(controller_ != 0) andrewm@55: controller_->touchkeyDeviceSetLowestMidiNote((octave + 1)*12); andrewm@55: //[/UserComboBoxCode_touchkeyOctaveComboBox] andrewm@55: } andrewm@55: else if (comboBoxThatHasChanged == midiInputAuxDeviceComboBox) andrewm@55: { andrewm@55: //[UserComboBoxCode_midiInputAuxDeviceComboBox] -- add your combo box handling code here.. andrewm@55: andrewm@55: // Look up the selected ID, remembering that Juce indices start at 1 and the first of andrewm@55: // these is "Disabled" andrewm@55: int selection = midiInputAuxDeviceComboBox->getSelectedId() - kMidiInputDeviceComboBoxOffset; andrewm@55: if(selection == 1 - kMidiInputDeviceComboBoxOffset) { // Disabled andrewm@55: // Disable all aux ports andrewm@55: controller_->disableAllMIDIInputPorts(true); andrewm@55: } andrewm@55: else if(selection == 2 - kMidiInputDeviceComboBoxOffset) { andrewm@55: // Shouldn't happen; standalone mode not an aux feature andrewm@55: controller_->disableAllMIDIInputPorts(true); andrewm@55: } andrewm@55: else if(selection >= 0 && selection < midiInputDeviceIDs_.size()) { andrewm@55: int deviceId = midiInputDeviceIDs_[selection]; andrewm@55: // Enable this aux port andrewm@55: controller_->disableAllMIDIInputPorts(true); andrewm@55: controller_->enableMIDIInputPort(deviceId, false); andrewm@55: } andrewm@55: //[/UserComboBoxCode_midiInputAuxDeviceComboBox] andrewm@55: } andrewm@55: andrewm@55: //[UsercomboBoxChanged_Post] andrewm@55: //[/UsercomboBoxChanged_Post] andrewm@55: } andrewm@55: andrewm@55: void ControlWindowMainComponent::buttonClicked (Button* buttonThatWasClicked) andrewm@55: { andrewm@55: //[UserbuttonClicked_Pre] andrewm@55: if(controller_ == 0) andrewm@55: return; andrewm@55: //[/UserbuttonClicked_Pre] andrewm@55: andrewm@55: if (buttonThatWasClicked == touchkeyStartButton) andrewm@55: { andrewm@55: //[UserButtonCode_touchkeyStartButton] -- add your button handler code here.. andrewm@55: #ifdef ENABLE_TOUCHKEYS_SENSOR_TEST andrewm@55: if(controller_->touchkeySensorTestIsRunning()) { andrewm@55: // TouchKeys were performing a sensor test. Stop the test. andrewm@55: controller_->touchkeySensorTestStop(); andrewm@55: } andrewm@55: else if(controller_->touchkeyDeviceIsRunning()) { andrewm@55: #else andrewm@55: if(controller_->touchkeyDeviceIsRunning()) { andrewm@55: #endif andrewm@55: // TouchKeys were running. Stop and close. andrewm@55: controller_->closeTouchkeyDevice(); andrewm@55: } andrewm@55: else { andrewm@55: // TouchKeys weren't running. Open and start. andrewm@55: String devName = controller_->touchkeyDevicePrefix().c_str(); andrewm@55: devName += touchkeyDeviceComboBox->getText(); andrewm@55: andrewm@55: // This will attempt to start the device and update the state accordingly andrewm@55: controller_->touchkeyDeviceStartupSequence(devName.toUTF8()); andrewm@55: } andrewm@55: //[/UserButtonCode_touchkeyStartButton] andrewm@55: } andrewm@55: else if (buttonThatWasClicked == oscEnableButton) andrewm@55: { andrewm@55: //[UserButtonCode_oscEnableButton] -- add your button handler code here.. andrewm@55: controller_->oscTransmitSetEnabled(oscEnableButton->getToggleState()); andrewm@55: //[/UserButtonCode_oscEnableButton] andrewm@55: } andrewm@55: else if (buttonThatWasClicked == oscEnableRawButton) andrewm@55: { andrewm@55: //[UserButtonCode_oscEnableRawButton] -- add your button handler code here.. andrewm@55: controller_->oscTransmitSetRawDataEnabled(oscEnableRawButton->getToggleState()); andrewm@55: //[/UserButtonCode_oscEnableRawButton] andrewm@55: } andrewm@55: else if (buttonThatWasClicked == oscInputEnableButton) andrewm@55: { andrewm@55: //[UserButtonCode_oscInputEnableButton] -- add your button handler code here.. andrewm@55: controller_->oscReceiveSetEnabled(oscInputEnableButton->getToggleState()); andrewm@55: //[/UserButtonCode_oscInputEnableButton] andrewm@55: } andrewm@55: else if (buttonThatWasClicked == addZoneButton) andrewm@55: { andrewm@55: //[UserButtonCode_addZoneButton] -- add your button handler code here.. andrewm@55: controller_->midiSegmentAdd(); andrewm@55: //[/UserButtonCode_addZoneButton] andrewm@55: } andrewm@55: else if (buttonThatWasClicked == removeZoneButton) andrewm@55: { andrewm@55: //[UserButtonCode_removeZoneButton] -- add your button handler code here.. andrewm@55: int tabIndex = keyboardZoneTabbedComponent->getCurrentTabIndex(); andrewm@55: if(tabIndex != 0) { andrewm@55: KeyboardZoneComponent* selectedComponent = static_cast (keyboardZoneTabbedComponent->getTabContentComponent(tabIndex)); andrewm@55: controller_->midiSegmentRemove(selectedComponent->keyboardSegment()); andrewm@55: } andrewm@55: //[/UserButtonCode_removeZoneButton] andrewm@55: } andrewm@55: else if (buttonThatWasClicked == touchkeyAutodetectButton) andrewm@55: { andrewm@55: //[UserButtonCode_touchkeyAutodetectButton] -- add your button handler code here.. andrewm@55: if(controller_->touchkeyDeviceIsAutodetecting()) andrewm@55: controller_->touchkeyDeviceStopAutodetecting(); andrewm@55: else andrewm@55: controller_->touchkeyDeviceAutodetectLowestMidiNote(); andrewm@55: //[/UserButtonCode_touchkeyAutodetectButton] andrewm@55: } andrewm@55: andrewm@55: //[UserbuttonClicked_Post] andrewm@55: //[/UserbuttonClicked_Post] andrewm@55: } andrewm@55: andrewm@55: andrewm@55: andrewm@55: //[MiscUserCode] You can add your own definitions of your custom methods or any other code here... andrewm@55: andrewm@55: void ControlWindowMainComponent::textEditorReturnKeyPressed(TextEditor &editor) andrewm@55: { andrewm@55: if(controller_ == 0) andrewm@55: return; andrewm@55: if(&editor == oscHostTextEditor || &editor == oscPortTextEditor) andrewm@55: updateOscHostPort(); andrewm@55: else if(&editor == oscInputPortTextEditor) { andrewm@55: int port = atoi(oscInputPortTextEditor->getText().toUTF8()); andrewm@55: controller_->oscReceiveSetPort(port); andrewm@55: } andrewm@55: } andrewm@55: andrewm@55: void ControlWindowMainComponent::textEditorEscapeKeyPressed(TextEditor &editor) andrewm@55: { andrewm@55: // Nothing to do here andrewm@55: } andrewm@55: andrewm@55: void ControlWindowMainComponent::textEditorFocusLost(TextEditor &editor) andrewm@55: { andrewm@55: textEditorReturnKeyPressed(editor); andrewm@55: } andrewm@55: andrewm@55: // Update list of TouchKeys and MIDI input devices andrewm@55: void ControlWindowMainComponent::updateInputDeviceList() andrewm@55: { andrewm@55: if(controller_ == 0) andrewm@55: return; andrewm@55: andrewm@55: // *** TouchKeys devices *** andrewm@55: vector tkdevices = controller_->availableTouchkeyDevices(); andrewm@55: vector::iterator tkit; andrewm@55: int counter; andrewm@55: andrewm@55: touchkeyDeviceComboBox->clear(); andrewm@55: andrewm@55: if(tkdevices.size() == 0) { andrewm@55: touchkeyDeviceComboBox->addItem("No devices", 1); andrewm@55: touchkeyDeviceComboBox->setSelectedId(1, dontSendNotification); andrewm@55: touchkeyDeviceComboBox->setEnabled(false); andrewm@55: touchkeyStartButton->setEnabled(false); andrewm@55: } andrewm@55: else { andrewm@55: counter = 1; andrewm@55: for(tkit = tkdevices.begin(); tkit != tkdevices.end(); ++tkit) { andrewm@55: touchkeyDeviceComboBox->addItem(tkit->c_str(), counter++); andrewm@55: } andrewm@55: touchkeyDeviceComboBox->setSelectedId(1, dontSendNotification); andrewm@55: touchkeyDeviceComboBox->setEnabled(true); andrewm@55: touchkeyStartButton->setEnabled(true); andrewm@55: } andrewm@55: andrewm@55: // *** MIDI input devices *** andrewm@55: vector > devices = controller_->availableMIDIInputDevices(); andrewm@55: vector >::iterator it; andrewm@55: andrewm@55: midiInputDeviceComboBox->clear(); andrewm@55: midiInputDeviceIDs_.clear(); andrewm@55: midiInputDeviceComboBox->addItem("Disabled", 1); andrewm@55: midiInputDeviceComboBox->addItem("TouchKeys Standalone", 2); andrewm@55: andrewm@55: midiInputAuxDeviceComboBox->clear(); andrewm@55: midiInputAuxDeviceComboBox->addItem("Disabled", 1); andrewm@55: andrewm@55: counter = kMidiInputDeviceComboBoxOffset; andrewm@55: andrewm@55: // Check whether the currently selected ID still exists while andrewm@55: // we build the list andrewm@55: bool lastSelectedDeviceExists = false; andrewm@55: bool lastSelectedAuxDeviceExists = false; andrewm@55: for(it = devices.begin(); it != devices.end(); ++it) { andrewm@55: midiInputDeviceComboBox->addItem((*it).second.c_str(), counter); andrewm@55: midiInputAuxDeviceComboBox->addItem((*it).second.c_str(), counter); andrewm@55: midiInputDeviceIDs_.push_back(it->first); andrewm@55: if(it->first == lastSelectedMidiInputID_) andrewm@55: lastSelectedDeviceExists = true; andrewm@55: if(it->first == lastSelectedMidiAuxInputID_) andrewm@55: lastSelectedAuxDeviceExists = true; andrewm@55: counter++; andrewm@55: } andrewm@55: andrewm@55: if(!lastSelectedDeviceExists && lastSelectedMidiInputID_ >= 0) andrewm@55: controller_->disablePrimaryMIDIInputPort(); andrewm@55: if(!lastSelectedAuxDeviceExists && lastSelectedMidiAuxInputID_ >= 0) andrewm@55: controller_->disableAllMIDIInputPorts(true); andrewm@55: } andrewm@55: andrewm@55: void ControlWindowMainComponent::updateOscHostPort() andrewm@55: { andrewm@55: if(controller_ == 0) andrewm@55: return; andrewm@55: andrewm@55: String oscHost = oscHostTextEditor->getText(); andrewm@55: String oscPort = oscPortTextEditor->getText(); andrewm@55: controller_->oscTransmitClearAddresses(); andrewm@55: controller_->oscTransmitAddAddress(oscHost.toUTF8(), oscPort.toUTF8()); andrewm@55: } andrewm@55: andrewm@55: // Synchronize the UI state with the underlying state of the controller andrewm@55: void ControlWindowMainComponent::synchronize() { andrewm@55: if(controller_ == 0) andrewm@55: return; andrewm@55: andrewm@55: bool devicesUpdated = false; andrewm@55: andrewm@55: if(controller_->devicesShouldUpdate() != lastControllerUpdateDeviceCount_) { andrewm@55: lastControllerUpdateDeviceCount_ = controller_->devicesShouldUpdate(); andrewm@55: updateInputDeviceList(); andrewm@55: devicesUpdated = true; andrewm@55: } andrewm@55: andrewm@55: // Update TouchKeys status andrewm@55: #ifdef ENABLE_TOUCHKEYS_SENSOR_TEST andrewm@55: if(controller_->touchkeySensorTestIsRunning()) { andrewm@55: touchkeyStartButton->setButtonText("Stop"); andrewm@55: touchkeyStatusLabel->setText("Testing", dontSendNotification); andrewm@55: } andrewm@55: else if(controller_->touchkeyDeviceIsRunning()) { andrewm@55: #else andrewm@55: if(controller_->touchkeyDeviceIsRunning()) { andrewm@55: #endif andrewm@55: touchkeyStartButton->setButtonText("Stop"); andrewm@55: touchkeyStatusLabel->setText("Running", dontSendNotification); andrewm@55: } andrewm@55: else if(controller_->touchkeyDeviceErrorOccurred()) { andrewm@55: touchkeyStartButton->setButtonText("Start"); andrewm@55: touchkeyStatusLabel->setText(controller_->touchkeyDeviceErrorMessage().c_str(), dontSendNotification); andrewm@55: } andrewm@55: else { andrewm@55: touchkeyStartButton->setButtonText("Start"); andrewm@55: touchkeyStatusLabel->setText("Not running", dontSendNotification); andrewm@55: } andrewm@55: andrewm@55: // Update MIDI input status andrewm@55: if(controller_->midiTouchkeysStandaloneModeIsEnabled()) { andrewm@55: midiInputDeviceComboBox->setSelectedId(2, dontSendNotification); andrewm@55: } andrewm@55: else { andrewm@55: // First query the primary port andrewm@55: int selectedPrimaryPort = controller_->selectedMIDIPrimaryInputPort(); andrewm@55: if(selectedPrimaryPort < 0) { andrewm@55: midiInputDeviceComboBox->setSelectedId(1, dontSendNotification); andrewm@55: } andrewm@55: else if(selectedPrimaryPort != lastSelectedMidiInputID_ || devicesUpdated){ andrewm@55: // Input has changed from before. Find it in vector andrewm@55: // If there is more than one selected ID, we will only take the first one for andrewm@55: // the current UI. This affects the display but not the functionality. andrewm@55: for(int i = 0; i < midiInputDeviceIDs_.size(); i++) { andrewm@55: if(midiInputDeviceIDs_[i] == selectedPrimaryPort) { andrewm@55: midiInputDeviceComboBox->setSelectedId(i + kMidiInputDeviceComboBoxOffset, dontSendNotification); andrewm@55: break; andrewm@55: } andrewm@55: } andrewm@55: // ...and cache this as the last ID so we don't search again next time andrewm@55: lastSelectedMidiInputID_ = selectedPrimaryPort; andrewm@55: andrewm@55: // Now disable this item in the auxiliary combo box andrewm@55: for(int i = 0; i < midiInputAuxDeviceComboBox->getNumItems(); i++) { andrewm@55: int itemId = midiInputAuxDeviceComboBox->getItemId(i) - kMidiInputDeviceComboBoxOffset; andrewm@55: if(itemId >= 0) { andrewm@55: midiInputAuxDeviceComboBox->setItemEnabled(midiInputAuxDeviceComboBox->getItemId(i), andrewm@55: (itemId != selectedPrimaryPort)); andrewm@55: } andrewm@55: } andrewm@55: } andrewm@55: } andrewm@55: andrewm@55: // Then get all aux ports and display the first one andrewm@55: const std::vector& selectedMidiInputDevices(controller_->selectedMIDIAuxInputPorts()); andrewm@55: if(selectedMidiInputDevices.empty()) { andrewm@55: midiInputAuxDeviceComboBox->setSelectedId(1, dontSendNotification); andrewm@55: } andrewm@55: else if(selectedMidiInputDevices.front() != lastSelectedMidiAuxInputID_ || devicesUpdated){ andrewm@55: // Input has changed from before. Find it in vector andrewm@55: // If there is more than one selected ID, we will only take the first one for andrewm@55: // the current UI. This affects the display but not the functionality. andrewm@55: for(int i = 0; i < midiInputDeviceIDs_.size(); i++) { andrewm@55: if(midiInputDeviceIDs_[i] == selectedMidiInputDevices.front()) { andrewm@55: midiInputAuxDeviceComboBox->setSelectedId(i + kMidiInputDeviceComboBoxOffset, dontSendNotification); andrewm@55: break; andrewm@55: } andrewm@55: } andrewm@55: // ...and cache this as the last ID so we don't search again next time andrewm@55: lastSelectedMidiAuxInputID_ = selectedMidiInputDevices.front(); andrewm@55: } andrewm@55: andrewm@55: // Update OSC status andrewm@55: oscEnableButton->setToggleState(controller_->oscTransmitEnabled(), dontSendNotification); andrewm@55: oscEnableRawButton->setToggleState(controller_->oscTransmitRawDataEnabled(), dontSendNotification); andrewm@55: oscInputEnableButton->setToggleState(controller_->oscReceiveEnabled(), dontSendNotification); andrewm@55: andrewm@55: // Update the OSC fields only if the text editors aren't active andrewm@55: if(!oscHostTextEditor->hasKeyboardFocus(true) && !oscPortTextEditor->hasKeyboardFocus(true)) { andrewm@55: const std::vector& oscAddresses = controller_->oscTransmitAddresses(); andrewm@55: if(oscAddresses.empty()) { andrewm@55: oscHostTextEditor->setText("", false); andrewm@55: oscPortTextEditor->setText("", false); andrewm@55: } andrewm@55: else { andrewm@55: // Take the first address to display in the text editor. As with MIDI input, andrewm@55: // this doesn't affect the functionality, only the UI display. andrewm@55: lo_address firstAddress = oscAddresses.front(); andrewm@55: andrewm@55: oscHostTextEditor->setText(lo_address_get_hostname(firstAddress), false); andrewm@55: oscPortTextEditor->setText(lo_address_get_port(firstAddress), false); andrewm@55: } andrewm@55: } andrewm@55: if(!oscInputPortTextEditor->hasKeyboardFocus(true)) { andrewm@55: int port = controller_->oscReceivePort(); andrewm@55: oscInputPortTextEditor->setText(String(port), false); andrewm@55: } andrewm@55: andrewm@55: // Set the octave button andrewm@55: int octave = (controller_->touchkeyDeviceLowestMidiNote() / 12) - 1; andrewm@55: if(octave >= 0 && octave <= kTouchkeysMaxOctave) andrewm@55: touchkeyOctaveComboBox->setSelectedId(octave + kTouchkeysComponentComboBoxOffset, dontSendNotification); andrewm@55: andrewm@55: // Enable or disable the autodetect button depending on the device status andrewm@55: if(!controller_->touchkeyDeviceIsRunning()) { andrewm@55: touchkeyAutodetectButton->setEnabled(false); andrewm@55: } andrewm@55: else if(controller_->touchkeyDeviceIsAutodetecting()) { andrewm@55: touchkeyAutodetectButton->setEnabled(true); andrewm@55: touchkeyAutodetectButton->setButtonText("Cancel"); andrewm@55: } andrewm@55: else { andrewm@55: touchkeyAutodetectButton->setEnabled(true); andrewm@55: touchkeyAutodetectButton->setButtonText("Detect"); andrewm@55: } andrewm@55: andrewm@55: // Update segments list if it has changed andrewm@55: if(lastSegmentUniqueIdentifier_ != controller_->midiSegmentUniqueIdentifier()) andrewm@55: updateKeyboardSegments(); andrewm@55: andrewm@55: // Synchronize every tab component andrewm@55: for(int tab = 0; tab < keyboardZoneTabbedComponent->getNumTabs(); tab++) { andrewm@55: KeyboardZoneComponent *component = static_cast (keyboardZoneTabbedComponent->getTabContentComponent(tab)); andrewm@55: component->synchronize(devicesUpdated); andrewm@55: } andrewm@55: andrewm@55: // Update add/remove buttons andrewm@55: if(keyboardZoneTabbedComponent->getCurrentTabIndex() <= 0) { andrewm@55: removeZoneButton->setEnabled(false); andrewm@55: } andrewm@55: else { andrewm@55: removeZoneButton->setEnabled(true); andrewm@55: } andrewm@55: if(controller_->midiSegmentsCount() >= 8) andrewm@55: addZoneButton->setEnabled(false); andrewm@55: else andrewm@55: addZoneButton->setEnabled(true); andrewm@55: } andrewm@55: andrewm@55: // Return the currently selected TouchKeys string andrewm@55: String ControlWindowMainComponent::currentTouchkeysSelectedPath() andrewm@55: { andrewm@55: String devName = controller_->touchkeyDevicePrefix().c_str(); andrewm@55: devName += touchkeyDeviceComboBox->getText(); andrewm@55: andrewm@55: return devName; andrewm@55: } andrewm@55: andrewm@55: // Update the state of the keyboard segment tab bar. Called only when segments change andrewm@55: void ControlWindowMainComponent::updateKeyboardSegments() andrewm@55: { andrewm@55: if(controller_ == 0) andrewm@55: return; andrewm@55: // Update the identifier to say we've matched the current state of the segments andrewm@55: lastSegmentUniqueIdentifier_ = controller_->midiSegmentUniqueIdentifier(); andrewm@55: andrewm@55: // Save the current selected index in case we later remove it andrewm@55: int currentlySelectedIndex = keyboardZoneTabbedComponent->getCurrentTabIndex(); andrewm@55: andrewm@55: KeyboardZoneComponent* currentlySelectedComponent = static_cast (keyboardZoneTabbedComponent->getTabContentComponent(currentlySelectedIndex)); andrewm@55: MidiKeyboardSegment* currentlySelectedSegment = 0; andrewm@55: if(currentlySelectedComponent != 0) andrewm@55: currentlySelectedSegment = currentlySelectedComponent->keyboardSegment(); andrewm@55: bool selectedNewTab = false; andrewm@55: andrewm@55: // First, go through the segments and create tabs as needed andrewm@55: int maxNumSegments = controller_->midiSegmentsCount(); andrewm@55: for(int i = 0; i < maxNumSegments; i++) { andrewm@55: MidiKeyboardSegment* segment = controller_->midiSegment(i); andrewm@55: bool matched = false; andrewm@55: if(segment == 0) andrewm@55: continue; andrewm@55: // Look for this segment among the tabs we already have andrewm@55: for(int tab = 0; tab < keyboardZoneTabbedComponent->getNumTabs(); tab++) { andrewm@55: KeyboardZoneComponent *component = static_cast (keyboardZoneTabbedComponent->getTabContentComponent(tab)); andrewm@55: if(component->keyboardSegment() == segment && component->keyboardZone() == segment->outputPort()) { andrewm@55: // Found it... andrewm@55: matched = true; andrewm@55: break; andrewm@55: } andrewm@55: } andrewm@55: // If we didn't find it, add a tab for this segment andrewm@55: if(!matched) { andrewm@55: KeyboardZoneComponent *newComponent = new KeyboardZoneComponent(); andrewm@55: newComponent->setMainApplicationController(controller_); andrewm@55: newComponent->setKeyboardSegment(segment, segment->outputPort()); andrewm@55: andrewm@55: char name[16]; andrewm@55: #ifdef _MSC_VER andrewm@55: _snprintf_s(name, 16, _TRUNCATE, "Zone %d", segment->outputPort()); andrewm@55: #else andrewm@55: snprintf(name, 16, "Zone %d", segment->outputPort()); andrewm@55: #endif andrewm@55: andrewm@55: // Add the component, telling the tab manager to take charge of deleting it at the end andrewm@55: keyboardZoneTabbedComponent->addTab(name, Colours::lightgrey, newComponent, true); andrewm@55: keyboardZoneTabbedComponent->setCurrentTabIndex(keyboardZoneTabbedComponent->getNumTabs() - 1); andrewm@55: selectedNewTab = true; andrewm@55: andrewm@55: //std::cout << "Adding tab for segment " << segment << endl; andrewm@55: } andrewm@55: } andrewm@55: andrewm@55: // Now go through the other way and remove tabs that are no longer needed andrewm@55: // Iterate through each tab: find a match in the segments andrewm@55: int tab = 0; andrewm@55: while(tab < keyboardZoneTabbedComponent->getNumTabs()) { andrewm@55: KeyboardZoneComponent *component = static_cast (keyboardZoneTabbedComponent->getTabContentComponent(tab)); andrewm@55: MidiKeyboardSegment *segment = component->keyboardSegment(); andrewm@55: bool matched = false; andrewm@55: andrewm@55: for(int i = 0; i < maxNumSegments; i++) { andrewm@55: if(segment == controller_->midiSegment(i) && component->keyboardZone() == segment->outputPort()) { andrewm@55: matched = true; andrewm@55: break; andrewm@55: } andrewm@55: } andrewm@55: if(segment == 0 || !matched) { andrewm@55: // This tab holds a nonexistent segment and should be removed andrewm@55: keyboardZoneTabbedComponent->removeTab(tab); andrewm@55: andrewm@55: if(currentlySelectedSegment == segment) { andrewm@55: // The currently selected tab has been removed. Select the prior one. andrewm@55: if(currentlySelectedIndex > 0) { andrewm@55: int indexToSelect = currentlySelectedIndex - 1; andrewm@55: if(indexToSelect >= keyboardZoneTabbedComponent->getNumTabs()) andrewm@55: indexToSelect = keyboardZoneTabbedComponent->getNumTabs() - 1; andrewm@55: if(indexToSelect < 0) andrewm@55: indexToSelect = 0; andrewm@55: keyboardZoneTabbedComponent->setCurrentTabIndex(indexToSelect); andrewm@55: } andrewm@55: else andrewm@55: keyboardZoneTabbedComponent->setCurrentTabIndex(0); andrewm@55: } andrewm@55: andrewm@55: // And we have to start over again since the tab indexing has changed andrewm@55: tab = 0; andrewm@55: } andrewm@55: else // Found a match: check the next tab andrewm@55: tab++; andrewm@55: // Eventually, we get to the end of the list of tabs an we know every existing tab matches a segment andrewm@55: } andrewm@55: } andrewm@55: andrewm@55: //[/MiscUserCode] andrewm@55: andrewm@55: andrewm@55: //============================================================================== andrewm@55: #if 0 andrewm@55: /* -- Introjucer information section -- andrewm@55: andrewm@55: This is where the Introjucer stores the metadata that describe this GUI layout, so andrewm@55: make changes in here at your peril! andrewm@55: andrewm@55: BEGIN_JUCER_METADATA andrewm@55: andrewm@55: andrewm@55: andrewm@55: andrewm@55: andrewm@55: andrewm@55: andrewm@55: END_JUCER_METADATA andrewm@55: */ andrewm@55: #endif andrewm@55: andrewm@55: andrewm@55: //[EndFile] You can add extra defines here... andrewm@55: #endif // TOUCHKEYS_NO_GUI andrewm@55: //[/EndFile]