# HG changeset patch # User Andrew McPherson # Date 1395274440 0 # Node ID 88287c1c2c924e69e96d4a9d740a88f502045b19 # Parent f2797a9d3d208f3b32b0bf65135be94fe4b2e389 Added an auxiliary MIDI input control, and moved the logging out of the window into the menu to make space in the GUI. Also updated the main window to be rescalable vertically for showing more mappings. diff -r f2797a9d3d20 -r 88287c1c2c92 Source/GUI/ControlWindowMainComponent.cpp --- a/Source/GUI/ControlWindowMainComponent.cpp Sat Mar 08 16:27:09 2014 +0000 +++ b/Source/GUI/ControlWindowMainComponent.cpp Thu Mar 20 00:14:00 2014 +0000 @@ -31,9 +31,6 @@ ControlWindowMainComponent::ControlWindowMainComponent () : controller_(0) { - addAndMakeVisible (dataLoggingGroupComponent = new GroupComponent ("MIDI input group", - "Data Logging")); - addAndMakeVisible (midiInputGroupComponent = new GroupComponent ("MIDI input group", "MIDI Input")); @@ -45,7 +42,7 @@ midiInputDeviceComboBox->addListener (this); addAndMakeVisible (label = new Label ("new label", - "Device:")); + "Keyboard:")); label->setFont (Font (15.00f, Font::plain)); label->setJustificationType (Justification::centredLeft); label->setEditable (false, false, false); @@ -150,10 +147,6 @@ touchkeyOctaveComboBox->setTextWhenNoChoicesAvailable ("(no choices)"); touchkeyOctaveComboBox->addListener (this); - addAndMakeVisible (loggingButton = new TextButton ("logging button")); - loggingButton->setButtonText ("Start Logging"); - loggingButton->addListener (this); - addAndMakeVisible (oscInputGroupComponent = new GroupComponent ("MIDI input group", "OSC Input")); @@ -178,10 +171,6 @@ oscInputPortTextEditor->setPopupMenuEnabled (true); oscInputPortTextEditor->setText ("8001"); - addAndMakeVisible (playLogButton = new TextButton ("play log button")); - playLogButton->setButtonText ("Play Log..."); - playLogButton->addListener (this); - addAndMakeVisible (keyboardZoneTabbedComponent = new TabbedComponent (TabbedButtonBar::TabsAtTop)); keyboardZoneTabbedComponent->setTabBarDepth (30); keyboardZoneTabbedComponent->setCurrentTabIndex (-1); @@ -198,9 +187,25 @@ touchkeyAutodetectButton->setButtonText ("Detect"); touchkeyAutodetectButton->addListener (this); + addAndMakeVisible (midiInputAuxDeviceComboBox = new ComboBox ("MIDI input aux combo box")); + midiInputAuxDeviceComboBox->setEditableText (false); + midiInputAuxDeviceComboBox->setJustificationType (Justification::centredLeft); + midiInputAuxDeviceComboBox->setTextWhenNothingSelected (String::empty); + midiInputAuxDeviceComboBox->setTextWhenNoChoicesAvailable ("(no choices)"); + midiInputAuxDeviceComboBox->addListener (this); + + addAndMakeVisible (label5 = new Label ("new label", + "Aux:")); + label5->setFont (Font (15.00f, Font::plain)); + label5->setJustificationType (Justification::centredRight); + label5->setEditable (false, false, false); + label5->setColour (TextEditor::textColourId, Colours::black); + label5->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); + //[UserPreSize] lastSelectedMidiInputID_ = -1; + lastSelectedMidiAuxInputID_ = -1; lastSegmentUniqueIdentifier_ = -1; // Add octave labels to combo box @@ -224,7 +229,6 @@ //[Destructor_pre]. You can add your own custom destruction code here.. //[/Destructor_pre] - dataLoggingGroupComponent = nullptr; midiInputGroupComponent = nullptr; midiInputDeviceComboBox = nullptr; label = nullptr; @@ -243,16 +247,16 @@ oscEnableRawButton = nullptr; label4 = nullptr; touchkeyOctaveComboBox = nullptr; - loggingButton = nullptr; oscInputGroupComponent = nullptr; oscInputEnableButton = nullptr; label6 = nullptr; oscInputPortTextEditor = nullptr; - playLogButton = nullptr; keyboardZoneTabbedComponent = nullptr; addZoneButton = nullptr; removeZoneButton = nullptr; touchkeyAutodetectButton = nullptr; + midiInputAuxDeviceComboBox = nullptr; + label5 = nullptr; //[Destructor]. You can add your own custom destruction code here.. @@ -273,36 +277,41 @@ void ControlWindowMainComponent::resized() { - dataLoggingGroupComponent->setBounds (8, 392, 304, 64); - midiInputGroupComponent->setBounds (8, 144, 304, 64); - midiInputDeviceComboBox->setBounds (72, 168, 224, 24); - label->setBounds (16, 168, 55, 24); + midiInputGroupComponent->setBounds (8, 144, 304, 96); + midiInputDeviceComboBox->setBounds (80, 168, 216, 24); + label->setBounds (16, 168, 64, 24); groupComponent->setBounds (8, 8, 304, 128); label2->setBounds (16, 32, 60, 24); touchkeyDeviceComboBox->setBounds (72, 32, 224, 24); label3->setBounds (16, 96, 60, 24); touchkeyStartButton->setBounds (216, 96, 79, 24); touchkeyStatusLabel->setBounds (72, 96, 136, 24); - oscGroupComponent->setBounds (8, 288, 304, 96); - label7->setBounds (16, 344, 55, 24); - oscHostTextEditor->setBounds (64, 344, 128, 24); - label8->setBounds (200, 344, 40, 24); - oscPortTextEditor->setBounds (240, 344, 56, 24); - oscEnableButton->setBounds (24, 312, 144, 24); - oscEnableRawButton->setBounds (176, 312, 144, 24); + oscGroupComponent->setBounds (8, 320, 304, 96); + label7->setBounds (16, 376, 55, 24); + oscHostTextEditor->setBounds (64, 376, 128, 24); + label8->setBounds (200, 376, 40, 24); + oscPortTextEditor->setBounds (240, 376, 56, 24); + oscEnableButton->setBounds (24, 344, 144, 24); + oscEnableRawButton->setBounds (176, 344, 144, 24); label4->setBounds (16, 64, 104, 24); touchkeyOctaveComboBox->setBounds (120, 64, 88, 24); - loggingButton->setBounds (24, 416, 128, 24); - oscInputGroupComponent->setBounds (8, 216, 304, 64); - oscInputEnableButton->setBounds (24, 240, 152, 24); - label6->setBounds (200, 240, 40, 24); - oscInputPortTextEditor->setBounds (240, 240, 56, 24); - playLogButton->setBounds (168, 416, 128, 24); + oscInputGroupComponent->setBounds (8, 248, 304, 64); + oscInputEnableButton->setBounds (24, 272, 152, 24); + label6->setBounds (200, 272, 40, 24); + oscInputPortTextEditor->setBounds (240, 272, 56, 24); keyboardZoneTabbedComponent->setBounds (320, 0, 552, 464); addZoneButton->setBounds (776, 4, 38, 20); removeZoneButton->setBounds (824, 4, 38, 20); touchkeyAutodetectButton->setBounds (216, 64, 79, 24); + midiInputAuxDeviceComboBox->setBounds (80, 200, 216, 24); + label5->setBounds (24, 200, 55, 24); //[UserResized] Add your own custom resize handling here.. + + // Resize KeyboardZoneComponent to fit new bounds + Rectangle const& ourBounds = getBounds(); + Rectangle keyboardZoneBounds = keyboardZoneTabbedComponent->getBounds(); + keyboardZoneBounds.setHeight(ourBounds.getHeight() - keyboardZoneBounds.getY()); + keyboardZoneTabbedComponent->setBounds(keyboardZoneBounds); //[/UserResized] } @@ -323,18 +332,17 @@ if(selection == 1 - kMidiInputDeviceComboBoxOffset) { // Disabled if(controller_->midiTouchkeysStandaloneModeIsEnabled()) controller_->midiTouchkeysStandaloneModeDisable(); - controller_->disableAllMIDIInputPorts(); + controller_->disablePrimaryMIDIInputPort(); } else if(selection == 2 - kMidiInputDeviceComboBoxOffset) { // Standalone mode - controller_->disableAllMIDIInputPorts(); + controller_->disablePrimaryMIDIInputPort(); controller_->midiTouchkeysStandaloneModeEnable(); } else if(selection >= 0 && selection < midiInputDeviceIDs_.size()) { int deviceId = midiInputDeviceIDs_[selection]; if(controller_->midiTouchkeysStandaloneModeIsEnabled()) controller_->midiTouchkeysStandaloneModeDisable(); - controller_->disableAllMIDIInputPorts(); - controller_->enableMIDIInputPort(deviceId); + controller_->enableMIDIInputPort(deviceId, true); } //[/UserComboBoxCode_midiInputDeviceComboBox] } @@ -354,6 +362,29 @@ controller_->touchkeyDeviceSetLowestMidiNote((octave + 1)*12); //[/UserComboBoxCode_touchkeyOctaveComboBox] } + else if (comboBoxThatHasChanged == midiInputAuxDeviceComboBox) + { + //[UserComboBoxCode_midiInputAuxDeviceComboBox] -- add your combo box handling code here.. + + // Look up the selected ID, remembering that Juce indices start at 1 and the first of + // these is "Disabled" + int selection = midiInputAuxDeviceComboBox->getSelectedId() - kMidiInputDeviceComboBoxOffset; + if(selection == 1 - kMidiInputDeviceComboBoxOffset) { // Disabled + // Disable all aux ports + controller_->disableAllMIDIInputPorts(true); + } + else if(selection == 2 - kMidiInputDeviceComboBoxOffset) { + // Shouldn't happen; standalone mode not an aux feature + controller_->disableAllMIDIInputPorts(true); + } + else if(selection >= 0 && selection < midiInputDeviceIDs_.size()) { + int deviceId = midiInputDeviceIDs_[selection]; + // Enable this aux port + controller_->disableAllMIDIInputPorts(true); + controller_->enableMIDIInputPort(deviceId, false); + } + //[/UserComboBoxCode_midiInputAuxDeviceComboBox] + } //[UsercomboBoxChanged_Post] //[/UsercomboBoxChanged_Post] @@ -403,26 +434,12 @@ controller_->oscTransmitSetRawDataEnabled(oscEnableRawButton->getToggleState()); //[/UserButtonCode_oscEnableRawButton] } - else if (buttonThatWasClicked == loggingButton) - { - //[UserButtonCode_loggingButton] -- add your button handler code here.. - if(controller_->isLogging()) - controller_->stopLogging(); - else - controller_->startLogging(); - //[/UserButtonCode_loggingButton] - } else if (buttonThatWasClicked == oscInputEnableButton) { //[UserButtonCode_oscInputEnableButton] -- add your button handler code here.. controller_->oscReceiveSetEnabled(oscInputEnableButton->getToggleState()); //[/UserButtonCode_oscInputEnableButton] } - else if (buttonThatWasClicked == playLogButton) - { - //[UserButtonCode_playLogButton] -- add your button handler code here.. - //[/UserButtonCode_playLogButton] - } else if (buttonThatWasClicked == addZoneButton) { //[UserButtonCode_addZoneButton] -- add your button handler code here.. @@ -516,21 +533,31 @@ midiInputDeviceIDs_.clear(); midiInputDeviceComboBox->addItem("Disabled", 1); midiInputDeviceComboBox->addItem("TouchKeys Standalone", 2); + + midiInputAuxDeviceComboBox->clear(); + midiInputAuxDeviceComboBox->addItem("Disabled", 1); + counter = kMidiInputDeviceComboBoxOffset; - + // Check whether the currently selected ID still exists while // we build the list bool lastSelectedDeviceExists = false; + bool lastSelectedAuxDeviceExists = false; for(it = devices.begin(); it != devices.end(); ++it) { midiInputDeviceComboBox->addItem((*it).second.c_str(), counter); + midiInputAuxDeviceComboBox->addItem((*it).second.c_str(), counter); midiInputDeviceIDs_.push_back(it->first); if(it->first == lastSelectedMidiInputID_) lastSelectedDeviceExists = true; + if(it->first == lastSelectedMidiAuxInputID_) + lastSelectedAuxDeviceExists = true; counter++; } - + if(!lastSelectedDeviceExists) - controller_->disableAllMIDIInputPorts(); + controller_->disablePrimaryMIDIInputPort(); + if(!lastSelectedAuxDeviceExists) + controller_->disableAllMIDIInputPorts(true); } void ControlWindowMainComponent::updateOscHostPort() @@ -548,9 +575,9 @@ void ControlWindowMainComponent::synchronize() { if(controller_ == 0) return; - + bool devicesUpdated = false; - + if(controller_->devicesShouldUpdate() != lastControllerUpdateDeviceCount_) { lastControllerUpdateDeviceCount_ = controller_->devicesShouldUpdate(); updateInputDeviceList(); @@ -584,24 +611,53 @@ midiInputDeviceComboBox->setSelectedId(2, dontSendNotification); } else { - const std::vector& selectedMidiInputDevices(controller_->selectedMIDIInputPorts()); - if(selectedMidiInputDevices.empty()) { + // First query the primary port + int selectedPrimaryPort = controller_->selectedMIDIPrimaryInputPort(); + if(selectedPrimaryPort < 0) { midiInputDeviceComboBox->setSelectedId(1, dontSendNotification); } - else if(selectedMidiInputDevices.front() != lastSelectedMidiInputID_ || devicesUpdated){ + else if(selectedPrimaryPort != lastSelectedMidiInputID_ || devicesUpdated){ // Input has changed from before. Find it in vector // If there is more than one selected ID, we will only take the first one for // the current UI. This affects the display but not the functionality. for(int i = 0; i < midiInputDeviceIDs_.size(); i++) { - if(midiInputDeviceIDs_[i] == selectedMidiInputDevices.front()) { + if(midiInputDeviceIDs_[i] == selectedPrimaryPort) { midiInputDeviceComboBox->setSelectedId(i + kMidiInputDeviceComboBoxOffset, dontSendNotification); break; } } // ...and cache this as the last ID so we don't search again next time - lastSelectedMidiInputID_ = selectedMidiInputDevices.front(); + lastSelectedMidiInputID_ = selectedPrimaryPort; + + // Now disable this item in the auxiliary combo box + for(int i = 0; i < midiInputAuxDeviceComboBox->getNumItems(); i++) { + int itemId = midiInputAuxDeviceComboBox->getItemId(i) - kMidiInputDeviceComboBoxOffset; + if(itemId >= 0) { + midiInputAuxDeviceComboBox->setItemEnabled(midiInputAuxDeviceComboBox->getItemId(i), + (itemId != selectedPrimaryPort)); + } + } } } + + // Then get all aux ports and display the first one + const std::vector& selectedMidiInputDevices(controller_->selectedMIDIAuxInputPorts()); + if(selectedMidiInputDevices.empty()) { + midiInputAuxDeviceComboBox->setSelectedId(1, dontSendNotification); + } + else if(selectedMidiInputDevices.front() != lastSelectedMidiAuxInputID_ || devicesUpdated){ + // Input has changed from before. Find it in vector + // If there is more than one selected ID, we will only take the first one for + // the current UI. This affects the display but not the functionality. + for(int i = 0; i < midiInputDeviceIDs_.size(); i++) { + if(midiInputDeviceIDs_[i] == selectedMidiInputDevices.front()) { + midiInputAuxDeviceComboBox->setSelectedId(i + kMidiInputDeviceComboBoxOffset, dontSendNotification); + break; + } + } + // ...and cache this as the last ID so we don't search again next time + lastSelectedMidiAuxInputID_ = selectedMidiInputDevices.front(); + } // Update OSC status oscEnableButton->setToggleState(controller_->oscTransmitEnabled(), dontSendNotification); @@ -647,13 +703,6 @@ touchkeyAutodetectButton->setButtonText("Detect"); } - // Set the text on the logging button - if(controller_->isLogging()) { - loggingButton->setButtonText("Stop Logging"); - } - else - loggingButton->setButtonText("Start Logging"); - // Update segments list if it has changed if(lastSegmentUniqueIdentifier_ != controller_->midiSegmentUniqueIdentifier()) updateKeyboardSegments(); @@ -792,19 +841,17 @@ - + virtualName="" explicitFocusOrder="0" pos="8 144 304 96" title="MIDI Input"/> END_JUCER_METADATA diff -r f2797a9d3d20 -r 88287c1c2c92 Source/GUI/ControlWindowMainComponent.h --- a/Source/GUI/ControlWindowMainComponent.h Sat Mar 08 16:27:09 2014 +0000 +++ b/Source/GUI/ControlWindowMainComponent.h Thu Mar 20 00:14:00 2014 +0000 @@ -89,13 +89,13 @@ MainApplicationController *controller_; // Pointer to the main application controller std::vector midiInputDeviceIDs_; int lastSelectedMidiInputID_; + int lastSelectedMidiAuxInputID_; int lastSegmentUniqueIdentifier_; - + int lastControllerUpdateDeviceCount_; //[/UserVariables] //============================================================================== - ScopedPointer dataLoggingGroupComponent; ScopedPointer midiInputGroupComponent; ScopedPointer midiInputDeviceComboBox; ScopedPointer