andrewm@0: /* andrewm@0: ============================================================================== andrewm@0: andrewm@0: This is an automatically generated GUI class created by the Introjucer! andrewm@0: andrewm@0: Be careful when adding custom code to these files, as only the code within andrewm@0: the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded andrewm@0: and re-saved. andrewm@0: andrewm@0: Created with Introjucer version: 3.1.0 andrewm@0: andrewm@0: ------------------------------------------------------------------------------ andrewm@0: andrewm@0: The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions" andrewm@0: Copyright 2004-13 by Raw Material Software Ltd. andrewm@0: andrewm@0: ============================================================================== andrewm@0: */ andrewm@0: andrewm@0: //[Headers] You can add your own extra header files here... andrewm@50: #ifndef TOUCHKEYS_NO_GUI andrewm@0: //[/Headers] andrewm@0: andrewm@0: #include "KeyboardZoneComponent.h" andrewm@0: andrewm@0: andrewm@0: //[MiscUserDefs] You can add your own user definitions and misc code here... andrewm@0: //[/MiscUserDefs] andrewm@0: andrewm@0: //============================================================================== andrewm@0: KeyboardZoneComponent::KeyboardZoneComponent () andrewm@0: : controller_(0), keyboardSegment_(0) andrewm@0: { andrewm@5: addAndMakeVisible (mappingListComponent = new MappingListComponent()); andrewm@0: addAndMakeVisible (midiOutputGroupComponent = new GroupComponent ("MIDI input group", andrewm@0: "MIDI Output")); andrewm@0: andrewm@0: addAndMakeVisible (midiOutputDeviceComboBox = new ComboBox ("MIDI input combo box")); andrewm@0: midiOutputDeviceComboBox->setEditableText (false); andrewm@0: midiOutputDeviceComboBox->setJustificationType (Justification::centredLeft); andrewm@0: midiOutputDeviceComboBox->setTextWhenNothingSelected (String::empty); andrewm@0: midiOutputDeviceComboBox->setTextWhenNoChoicesAvailable ("(no choices)"); andrewm@0: midiOutputDeviceComboBox->addListener (this); andrewm@0: andrewm@0: addAndMakeVisible (label4 = new Label ("new label", andrewm@0: "Device:")); andrewm@0: label4->setFont (Font (15.00f, Font::plain)); andrewm@0: label4->setJustificationType (Justification::centredLeft); andrewm@0: label4->setEditable (false, false, false); andrewm@0: label4->setColour (TextEditor::textColourId, Colours::black); andrewm@0: label4->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@0: andrewm@0: addAndMakeVisible (label5 = new Label ("new label", andrewm@0: "Mode:")); andrewm@0: label5->setFont (Font (15.00f, Font::plain)); andrewm@0: label5->setJustificationType (Justification::centredLeft); andrewm@0: label5->setEditable (false, false, false); andrewm@0: label5->setColour (TextEditor::textColourId, Colours::black); andrewm@0: label5->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@0: andrewm@0: addAndMakeVisible (midiOutputModeComboBox = new ComboBox ("MIDI input combo box")); andrewm@0: midiOutputModeComboBox->setEditableText (false); andrewm@0: midiOutputModeComboBox->setJustificationType (Justification::centredLeft); andrewm@0: midiOutputModeComboBox->setTextWhenNothingSelected (String::empty); andrewm@0: midiOutputModeComboBox->setTextWhenNoChoicesAvailable ("(no choices)"); andrewm@0: midiOutputModeComboBox->addListener (this); andrewm@0: andrewm@0: addAndMakeVisible (midiOutputVoiceStealingButton = new ToggleButton ("Voice stealing button")); andrewm@0: midiOutputVoiceStealingButton->setButtonText ("Voice stealing"); andrewm@0: midiOutputVoiceStealingButton->addListener (this); andrewm@0: andrewm@0: addAndMakeVisible (label2 = new Label ("new label", andrewm@0: "Channels:")); andrewm@0: label2->setFont (Font (15.00f, Font::plain)); andrewm@0: label2->setJustificationType (Justification::centredLeft); andrewm@0: label2->setEditable (false, false, false); andrewm@0: label2->setColour (TextEditor::textColourId, Colours::black); andrewm@0: label2->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@0: andrewm@0: addAndMakeVisible (midiOutputChannelLowEditor = new TextEditor ("new text editor")); andrewm@0: midiOutputChannelLowEditor->setMultiLine (false); andrewm@0: midiOutputChannelLowEditor->setReturnKeyStartsNewLine (false); andrewm@0: midiOutputChannelLowEditor->setReadOnly (false); andrewm@0: midiOutputChannelLowEditor->setScrollbarsShown (true); andrewm@0: midiOutputChannelLowEditor->setCaretVisible (true); andrewm@0: midiOutputChannelLowEditor->setPopupMenuEnabled (true); andrewm@0: midiOutputChannelLowEditor->setText (String::empty); andrewm@0: andrewm@0: addAndMakeVisible (midiOutputChannelHighEditor = new TextEditor ("new text editor")); andrewm@0: midiOutputChannelHighEditor->setMultiLine (false); andrewm@0: midiOutputChannelHighEditor->setReturnKeyStartsNewLine (false); andrewm@0: midiOutputChannelHighEditor->setReadOnly (false); andrewm@0: midiOutputChannelHighEditor->setScrollbarsShown (true); andrewm@0: midiOutputChannelHighEditor->setCaretVisible (true); andrewm@0: midiOutputChannelHighEditor->setPopupMenuEnabled (true); andrewm@0: midiOutputChannelHighEditor->setText (String::empty); andrewm@0: andrewm@0: addAndMakeVisible (label3 = new Label ("new label", andrewm@0: "to")); andrewm@0: label3->setFont (Font (15.00f, Font::plain)); andrewm@0: label3->setJustificationType (Justification::centredLeft); andrewm@0: label3->setEditable (false, false, false); andrewm@0: label3->setColour (TextEditor::textColourId, Colours::black); andrewm@0: label3->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@0: andrewm@0: addAndMakeVisible (midiOutputGroupComponent2 = new GroupComponent ("MIDI input group", andrewm@0: "Range")); andrewm@0: andrewm@0: addAndMakeVisible (label7 = new Label ("new label", andrewm@0: "to")); andrewm@0: label7->setFont (Font (15.00f, Font::plain)); andrewm@0: label7->setJustificationType (Justification::centredLeft); andrewm@0: label7->setEditable (false, false, false); andrewm@0: label7->setColour (TextEditor::textColourId, Colours::black); andrewm@0: label7->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@0: andrewm@0: addAndMakeVisible (rangeLowComboBox = new ComboBox ("range low combo box")); andrewm@0: rangeLowComboBox->setEditableText (true); andrewm@0: rangeLowComboBox->setJustificationType (Justification::centredLeft); andrewm@0: rangeLowComboBox->setTextWhenNothingSelected (String::empty); andrewm@0: rangeLowComboBox->setTextWhenNoChoicesAvailable ("(no choices)"); andrewm@0: rangeLowComboBox->addListener (this); andrewm@0: andrewm@0: addAndMakeVisible (rangeHighComboBox = new ComboBox ("range high combo combo box")); andrewm@0: rangeHighComboBox->setEditableText (true); andrewm@0: rangeHighComboBox->setJustificationType (Justification::centredLeft); andrewm@0: rangeHighComboBox->setTextWhenNothingSelected (String::empty); andrewm@0: rangeHighComboBox->setTextWhenNoChoicesAvailable ("(no choices)"); andrewm@0: rangeHighComboBox->addListener (this); andrewm@0: andrewm@0: addAndMakeVisible (label6 = new Label ("new label", andrewm@0: "Transpose:")); andrewm@0: label6->setFont (Font (15.00f, Font::plain)); andrewm@0: label6->setJustificationType (Justification::centredLeft); andrewm@0: label6->setEditable (false, false, false); andrewm@0: label6->setColour (TextEditor::textColourId, Colours::black); andrewm@0: label6->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@0: andrewm@0: addAndMakeVisible (midiOutputTransposeEditor = new TextEditor ("transposition text editor")); andrewm@0: midiOutputTransposeEditor->setMultiLine (false); andrewm@0: midiOutputTransposeEditor->setReturnKeyStartsNewLine (false); andrewm@0: midiOutputTransposeEditor->setReadOnly (false); andrewm@0: midiOutputTransposeEditor->setScrollbarsShown (true); andrewm@0: midiOutputTransposeEditor->setCaretVisible (true); andrewm@0: midiOutputTransposeEditor->setPopupMenuEnabled (true); andrewm@0: midiOutputTransposeEditor->setText (String::empty); andrewm@0: andrewm@0: addAndMakeVisible (label8 = new Label ("new label", andrewm@0: "Mappings:")); andrewm@0: label8->setFont (Font (15.00f, Font::plain)); andrewm@0: label8->setJustificationType (Justification::centredLeft); andrewm@0: label8->setEditable (false, false, false); andrewm@0: label8->setColour (TextEditor::textColourId, Colours::black); andrewm@0: label8->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@0: andrewm@0: addAndMakeVisible (addMappingButton = new TextButton ("add mapping button")); andrewm@0: addMappingButton->setButtonText ("Add Mapping..."); andrewm@0: addMappingButton->addListener (this); andrewm@0: andrewm@5: addAndMakeVisible (label9 = new Label ("new label", andrewm@5: "Pitchwheel range:")); andrewm@5: label9->setFont (Font (15.00f, Font::plain)); andrewm@5: label9->setJustificationType (Justification::centredLeft); andrewm@5: label9->setEditable (false, false, false); andrewm@5: label9->setColour (TextEditor::textColourId, Colours::black); andrewm@5: label9->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@5: andrewm@5: addAndMakeVisible (pitchWheelRangeEditor = new TextEditor ("pitch wheel range editor")); andrewm@5: pitchWheelRangeEditor->setMultiLine (false); andrewm@5: pitchWheelRangeEditor->setReturnKeyStartsNewLine (false); andrewm@5: pitchWheelRangeEditor->setReadOnly (false); andrewm@5: pitchWheelRangeEditor->setScrollbarsShown (true); andrewm@5: pitchWheelRangeEditor->setCaretVisible (true); andrewm@5: pitchWheelRangeEditor->setPopupMenuEnabled (true); andrewm@5: pitchWheelRangeEditor->setText (String::empty); andrewm@5: andrewm@5: addAndMakeVisible (keyboardControllersButton = new TextButton ("keyboard controllers button")); andrewm@8: keyboardControllersButton->setButtonText (" Controllers..."); andrewm@5: keyboardControllersButton->addListener (this); andrewm@5: andrewm@0: andrewm@0: //[UserPreSize] andrewm@0: // Add modes to MIDI mode toggle box andrewm@0: midiOutputModeComboBox->addItem("Passthrough", MidiKeyboardSegment::ModePassThrough + kMidiOutputModeComboBoxOffset); andrewm@0: midiOutputModeComboBox->addItem("Monophonic", MidiKeyboardSegment::ModeMonophonic + kMidiOutputModeComboBoxOffset); andrewm@0: midiOutputModeComboBox->addItem("Polyphonic", MidiKeyboardSegment::ModePolyphonic + kMidiOutputModeComboBoxOffset); andrewm@0: andrewm@0: // Populate the range combo boxes with notes of the 88-key keyboard andrewm@0: for(int note = 12; note <= 127; note++) { andrewm@0: rangeLowComboBox->addItem(MainApplicationController::midiNoteName(note).c_str(), note); andrewm@0: rangeHighComboBox->addItem(MainApplicationController::midiNoteName(note).c_str(), note); andrewm@0: } andrewm@0: andrewm@39: lastSelectedMidiOutputID_ = kInvalidMidiOutputId; andrewm@0: andrewm@0: //[/UserPreSize] andrewm@0: andrewm@0: setSize (552, 400); andrewm@0: andrewm@0: andrewm@0: //[Constructor] You can add your own custom stuff here.. andrewm@0: midiOutputChannelLowEditor->addListener(this); andrewm@0: midiOutputChannelHighEditor->addListener(this); andrewm@0: midiOutputTransposeEditor->addListener(this); andrewm@5: pitchWheelRangeEditor->addListener(this); andrewm@0: addMappingButton->setTriggeredOnMouseDown(true); andrewm@5: keyboardControllersButton->setTriggeredOnMouseDown(true); andrewm@0: //[/Constructor] andrewm@0: } andrewm@0: andrewm@0: KeyboardZoneComponent::~KeyboardZoneComponent() andrewm@0: { andrewm@0: //[Destructor_pre]. You can add your own custom destruction code here.. andrewm@0: //[/Destructor_pre] andrewm@0: andrewm@5: mappingListComponent = nullptr; andrewm@0: midiOutputGroupComponent = nullptr; andrewm@0: midiOutputDeviceComboBox = nullptr; andrewm@0: label4 = nullptr; andrewm@0: label5 = nullptr; andrewm@0: midiOutputModeComboBox = nullptr; andrewm@0: midiOutputVoiceStealingButton = nullptr; andrewm@0: label2 = nullptr; andrewm@0: midiOutputChannelLowEditor = nullptr; andrewm@0: midiOutputChannelHighEditor = nullptr; andrewm@0: label3 = nullptr; andrewm@0: midiOutputGroupComponent2 = nullptr; andrewm@0: label7 = nullptr; andrewm@0: rangeLowComboBox = nullptr; andrewm@0: rangeHighComboBox = nullptr; andrewm@0: label6 = nullptr; andrewm@0: midiOutputTransposeEditor = nullptr; andrewm@0: label8 = nullptr; andrewm@0: addMappingButton = nullptr; andrewm@5: label9 = nullptr; andrewm@5: pitchWheelRangeEditor = nullptr; andrewm@5: keyboardControllersButton = nullptr; andrewm@0: andrewm@0: andrewm@0: //[Destructor]. You can add your own custom destruction code here.. andrewm@0: //[/Destructor] andrewm@0: } andrewm@0: andrewm@0: //============================================================================== andrewm@0: void KeyboardZoneComponent::paint (Graphics& g) andrewm@0: { andrewm@0: //[UserPrePaint] Add your own custom painting code here.. andrewm@0: //[/UserPrePaint] andrewm@0: andrewm@0: g.fillAll (Colour (0xffd2d2d2)); andrewm@0: andrewm@0: //[UserPaint] Add your own custom painting code here.. andrewm@0: //[/UserPaint] andrewm@0: } andrewm@0: andrewm@0: void KeyboardZoneComponent::resized() andrewm@0: { andrewm@5: mappingListComponent->setBounds (0, 168, 552, 260); andrewm@0: midiOutputGroupComponent->setBounds (200, 8, 344, 128); andrewm@0: midiOutputDeviceComboBox->setBounds (264, 32, 264, 24); andrewm@0: label4->setBounds (208, 32, 55, 24); andrewm@0: label5->setBounds (208, 64, 55, 24); andrewm@0: midiOutputModeComboBox->setBounds (264, 64, 152, 24); andrewm@0: midiOutputVoiceStealingButton->setBounds (424, 64, 112, 24); andrewm@0: label2->setBounds (208, 96, 56, 24); andrewm@0: midiOutputChannelLowEditor->setBounds (264, 96, 32, 24); andrewm@0: midiOutputChannelHighEditor->setBounds (320, 96, 32, 24); andrewm@0: label3->setBounds (296, 96, 32, 24); andrewm@0: midiOutputGroupComponent2->setBounds (8, 8, 184, 128); andrewm@0: label7->setBounds (88, 32, 32, 24); andrewm@0: rangeLowComboBox->setBounds (24, 32, 64, 24); andrewm@0: rangeHighComboBox->setBounds (112, 32, 64, 24); andrewm@0: label6->setBounds (392, 96, 80, 24); andrewm@0: midiOutputTransposeEditor->setBounds (472, 96, 56, 24); andrewm@0: label8->setBounds (8, 144, 88, 24); andrewm@0: addMappingButton->setBounds (440, 144, 104, 20); andrewm@5: label9->setBounds (24, 68, 104, 24); andrewm@5: pitchWheelRangeEditor->setBounds (128, 68, 48, 24); andrewm@5: keyboardControllersButton->setBounds (24, 100, 152, 20); andrewm@31: andrewm@0: //[UserResized] Add your own custom resize handling here.. andrewm@31: andrewm@31: // Resize the mapping list to fit the bottom of the window andrewm@38: juce::Rectangle const& ourBounds = getBounds(); andrewm@38: juce::Rectangle mappingBounds = mappingListComponent->getBounds(); andrewm@31: mappingBounds.setHeight(ourBounds.getHeight() - mappingBounds.getY()); andrewm@31: mappingListComponent->setBounds(mappingBounds); andrewm@31: andrewm@0: //[/UserResized] andrewm@0: } andrewm@0: andrewm@0: void KeyboardZoneComponent::comboBoxChanged (ComboBox* comboBoxThatHasChanged) andrewm@0: { andrewm@0: //[UsercomboBoxChanged_Pre] andrewm@0: if(keyboardSegment_ == 0 || controller_ == 0) andrewm@0: return; andrewm@0: //[/UsercomboBoxChanged_Pre] andrewm@0: andrewm@0: if (comboBoxThatHasChanged == midiOutputDeviceComboBox) andrewm@0: { andrewm@0: //[UserComboBoxCode_midiOutputDeviceComboBox] -- add your combo box handling code here.. andrewm@0: andrewm@0: // Look up the selected ID, remembering that Juce indices start at 1 and the first of andrewm@0: // these is "Disabled" followed by "Virtual Output Port" andrewm@0: int selection = midiOutputDeviceComboBox->getSelectedId() - kMidiOutputDeviceComboBoxOffset; andrewm@0: if(selection == 1 - kMidiOutputDeviceComboBoxOffset) { // Disabled andrewm@0: controller_->disableMIDIOutputPort(keyboardSegment_->outputPort()); andrewm@0: } andrewm@0: else if(selection == 2 - kMidiOutputDeviceComboBoxOffset) { // Virtual output andrewm@20: #ifndef JUCE_WINDOWS andrewm@0: char st[20]; andrewm@0: snprintf(st, 20, "TouchKeys %d", keyboardSegment_->outputPort()); andrewm@0: controller_->enableMIDIOutputVirtualPort(keyboardSegment_->outputPort(), st); andrewm@20: #endif andrewm@0: } andrewm@0: else if(selection >= 0 && selection < midiOutputDeviceIDs_.size()) { andrewm@0: int deviceId = midiOutputDeviceIDs_[selection]; andrewm@0: controller_->enableMIDIOutputPort(keyboardSegment_->outputPort(), deviceId); andrewm@0: } andrewm@0: //[/UserComboBoxCode_midiOutputDeviceComboBox] andrewm@0: } andrewm@0: else if (comboBoxThatHasChanged == midiOutputModeComboBox) andrewm@0: { andrewm@0: //[UserComboBoxCode_midiOutputModeComboBox] -- add your combo box handling code here.. andrewm@0: int mode = midiOutputModeComboBox->getSelectedId() - kMidiOutputModeComboBoxOffset; andrewm@0: keyboardSegment_->setMode(mode); andrewm@0: //[/UserComboBoxCode_midiOutputModeComboBox] andrewm@0: } andrewm@0: else if (comboBoxThatHasChanged == rangeLowComboBox) andrewm@0: { andrewm@0: //[UserComboBoxCode_rangeLowComboBox] -- add your combo box handling code here.. andrewm@0: updateSegmentRange(); andrewm@0: //[/UserComboBoxCode_rangeLowComboBox] andrewm@0: } andrewm@0: else if (comboBoxThatHasChanged == rangeHighComboBox) andrewm@0: { andrewm@0: //[UserComboBoxCode_rangeHighComboBox] -- add your combo box handling code here.. andrewm@0: updateSegmentRange(); andrewm@0: //[/UserComboBoxCode_rangeHighComboBox] andrewm@0: } andrewm@0: andrewm@0: //[UsercomboBoxChanged_Post] andrewm@0: //[/UsercomboBoxChanged_Post] andrewm@0: } andrewm@0: andrewm@0: void KeyboardZoneComponent::buttonClicked (Button* buttonThatWasClicked) andrewm@0: { andrewm@0: //[UserbuttonClicked_Pre] andrewm@0: if(keyboardSegment_ == 0) andrewm@0: return; andrewm@0: //[/UserbuttonClicked_Pre] andrewm@0: andrewm@0: if (buttonThatWasClicked == midiOutputVoiceStealingButton) andrewm@0: { andrewm@0: //[UserButtonCode_midiOutputVoiceStealingButton] -- add your button handler code here.. andrewm@0: bool stealing = midiOutputVoiceStealingButton->getToggleState(); andrewm@0: keyboardSegment_->setVoiceStealingEnabled(stealing); andrewm@0: //[/UserButtonCode_midiOutputVoiceStealingButton] andrewm@0: } andrewm@0: else if (buttonThatWasClicked == addMappingButton) andrewm@0: { andrewm@0: //[UserButtonCode_addMappingButton] -- add your button handler code here.. andrewm@0: createMappingListPopup(); andrewm@0: //[/UserButtonCode_addMappingButton] andrewm@0: } andrewm@5: else if (buttonThatWasClicked == keyboardControllersButton) andrewm@5: { andrewm@5: //[UserButtonCode_keyboardControllersButton] -- add your button handler code here.. andrewm@5: createKeyboardControllerPopup(); andrewm@5: //[/UserButtonCode_keyboardControllersButton] andrewm@5: } andrewm@0: andrewm@0: //[UserbuttonClicked_Post] andrewm@0: //[/UserbuttonClicked_Post] andrewm@0: } andrewm@0: andrewm@0: andrewm@0: andrewm@0: //[MiscUserCode] You can add your own definitions of your custom methods or any other code here... andrewm@0: andrewm@0: void KeyboardZoneComponent::textEditorReturnKeyPressed(TextEditor &editor) andrewm@0: { andrewm@0: if(keyboardSegment_ == 0) andrewm@0: return; andrewm@0: andrewm@0: if(&editor == midiOutputChannelLowEditor || andrewm@0: &editor == midiOutputChannelHighEditor) { andrewm@0: // Change range of MIDI output channels andrewm@0: int rangeLow = atoi(midiOutputChannelLowEditor->getText().toUTF8()); andrewm@0: int rangeHigh = atoi(midiOutputChannelHighEditor->getText().toUTF8()); andrewm@0: if(rangeHigh > 16) andrewm@0: rangeHigh = 16; andrewm@0: if(rangeLow > 16) andrewm@0: rangeLow = 16; andrewm@0: if(rangeHigh < 1) andrewm@0: rangeHigh = 1; andrewm@0: if(rangeLow < 1) andrewm@0: rangeLow = 1; andrewm@0: keyboardSegment_->setOutputChannelLowest(rangeLow - 1); // 1-16 --> 0-15 indexing andrewm@0: andrewm@0: int polyphony = rangeHigh - rangeLow + 1; andrewm@0: if(polyphony < 1) andrewm@0: polyphony = 1; andrewm@0: keyboardSegment_->setPolyphony(polyphony); andrewm@0: } andrewm@0: else if(&editor == midiOutputTransposeEditor) { andrewm@0: // Change output transposition (limiting possible range to +/- 4 octaves) andrewm@0: int transpose = atoi(midiOutputTransposeEditor->getText().toUTF8()); andrewm@0: if(transpose < -48) andrewm@0: transpose = -48; andrewm@0: if(transpose > 48) andrewm@0: transpose = 48; andrewm@0: keyboardSegment_->setOutputTransposition(transpose); andrewm@0: } andrewm@5: else if(&editor == pitchWheelRangeEditor) { andrewm@5: float range = atof(pitchWheelRangeEditor->getText().toUTF8()); andrewm@5: keyboardSegment_->setMidiPitchWheelRange(range); andrewm@5: } andrewm@0: } andrewm@0: andrewm@0: void KeyboardZoneComponent::textEditorEscapeKeyPressed(TextEditor &editor) andrewm@0: { andrewm@0: andrewm@0: } andrewm@0: andrewm@0: void KeyboardZoneComponent::textEditorFocusLost(TextEditor &editor) andrewm@0: { andrewm@0: textEditorReturnKeyPressed(editor); andrewm@0: } andrewm@0: andrewm@0: // Update state of GUI to reflect underlying controller andrewm@0: void KeyboardZoneComponent::synchronize(bool forceUpdates) andrewm@0: { andrewm@0: if(keyboardSegment_ == 0 || controller_ == 0) andrewm@0: return; andrewm@31: andrewm@28: if(forceUpdates) { andrewm@28: // Update the controls to reflect the current state andrewm@28: updateOutputDeviceList(); andrewm@28: } andrewm@31: andrewm@0: // Update note ranges andrewm@0: std::pair range = keyboardSegment_->noteRange(); andrewm@0: if(!rangeLowComboBox->hasKeyboardFocus(true) || forceUpdates) { andrewm@0: if(range.first < 12 || range.first > 127) { andrewm@0: rangeLowComboBox->setText(String(range.first)); andrewm@0: } andrewm@0: else andrewm@0: rangeLowComboBox->setSelectedId(range.first, dontSendNotification); andrewm@0: } andrewm@0: if(!rangeHighComboBox->hasKeyboardFocus(true) || forceUpdates) { andrewm@0: if(range.second < 12 || range.second > 127) { andrewm@0: rangeHighComboBox->setText(String(range.second)); andrewm@0: } andrewm@0: else andrewm@0: rangeHighComboBox->setSelectedId(range.second, dontSendNotification); andrewm@0: } andrewm@0: andrewm@0: // Update MIDI output status andrewm@0: int selectedMidiOutputDevice = controller_->selectedMIDIOutputPort(keyboardSegment_->outputPort()); andrewm@28: if(selectedMidiOutputDevice != lastSelectedMidiOutputID_ || forceUpdates) { andrewm@0: if(selectedMidiOutputDevice == MidiOutputController::kMidiOutputNotOpen) andrewm@0: midiOutputDeviceComboBox->setSelectedId(1, dontSendNotification); andrewm@20: #ifndef JUCE_WINDOWS andrewm@0: else if(selectedMidiOutputDevice == MidiOutputController::kMidiVirtualOutputPortNumber) andrewm@0: midiOutputDeviceComboBox->setSelectedId(2, dontSendNotification); andrewm@20: #endif andrewm@0: else { andrewm@0: // Find the output device in the vector andrewm@0: for(int i = 0; i < midiOutputDeviceIDs_.size(); i++) { andrewm@0: if(midiOutputDeviceIDs_[i] == selectedMidiOutputDevice) { andrewm@0: midiOutputDeviceComboBox->setSelectedId(i + kMidiOutputDeviceComboBoxOffset, dontSendNotification); andrewm@0: break; andrewm@0: } andrewm@0: } andrewm@0: } andrewm@0: lastSelectedMidiOutputID_ = selectedMidiOutputDevice; andrewm@0: } andrewm@0: andrewm@0: // Update the mode and the peripheral controls that go with it andrewm@0: int selectedMidiOutputMode = keyboardSegment_->mode(); andrewm@0: midiOutputModeComboBox->setSelectedId(selectedMidiOutputMode + kMidiOutputModeComboBoxOffset, dontSendNotification); andrewm@0: andrewm@0: if(selectedMidiOutputMode == MidiKeyboardSegment::ModePolyphonic) { andrewm@0: midiOutputVoiceStealingButton->setEnabled(true); andrewm@0: midiOutputVoiceStealingButton->setToggleState(keyboardSegment_->voiceStealingEnabled(), dontSendNotification); andrewm@0: } andrewm@0: else { andrewm@0: midiOutputVoiceStealingButton->setEnabled(false); andrewm@0: midiOutputVoiceStealingButton->setToggleState(false, dontSendNotification); andrewm@0: } andrewm@0: andrewm@0: // Update text editors andrewm@5: if(!pitchWheelRangeEditor->hasKeyboardFocus(true) || forceUpdates) { andrewm@5: float value = keyboardSegment_->midiPitchWheelRange(); andrewm@5: char st[16]; andrewm@20: #ifdef _MSC_VER andrewm@20: _snprintf_s(st, 16, _TRUNCATE, "%.1f", value); andrewm@20: #else andrewm@5: snprintf(st, 16, "%.1f", value); andrewm@20: #endif andrewm@5: pitchWheelRangeEditor->setText(st); andrewm@5: } andrewm@0: if(!midiOutputChannelLowEditor->hasKeyboardFocus(true) || forceUpdates) { andrewm@0: int rangeLow = keyboardSegment_->outputChannelLowest() + 1; // 0-15 --> 1-16 andrewm@0: midiOutputChannelLowEditor->setText(String(rangeLow)); andrewm@0: } andrewm@0: if(!midiOutputTransposeEditor->hasKeyboardFocus(true) || forceUpdates) { andrewm@0: int transpose = keyboardSegment_->outputTransposition(); andrewm@0: midiOutputTransposeEditor->setText(String(transpose)); andrewm@0: } andrewm@0: andrewm@0: if(selectedMidiOutputMode == MidiKeyboardSegment::ModePolyphonic) { andrewm@0: midiOutputChannelHighEditor->setEnabled(true); andrewm@0: if(!midiOutputChannelHighEditor->hasKeyboardFocus(true) || forceUpdates) { andrewm@0: int rangeHigh = keyboardSegment_->polyphony() + keyboardSegment_->outputChannelLowest(); andrewm@0: midiOutputChannelHighEditor->setText(String(rangeHigh)); andrewm@0: } andrewm@0: } andrewm@0: else { andrewm@0: midiOutputChannelHighEditor->setEnabled(false); andrewm@0: midiOutputChannelHighEditor->setText("", false); andrewm@0: } andrewm@0: andrewm@0: // Update buttons andrewm@5: //useAftertouchButton->setToggleState(keyboardSegment_->usesKeyboardChannnelPressure(), dontSendNotification); andrewm@5: //usePitchWheelButton->setToggleState(keyboardSegment_->usesKeyboardPitchWheel(), dontSendNotification); andrewm@5: //useControllersButton->setToggleState(keyboardSegment_->usesKeyboardMIDIControllers(), dontSendNotification); andrewm@0: andrewm@0: // Update the mapping list andrewm@0: mappingListComponent->synchronize(); andrewm@0: } andrewm@0: andrewm@0: // Update the range of the keyboard segment andrewm@0: void KeyboardZoneComponent::updateSegmentRange() andrewm@0: { andrewm@0: int selectionLow = rangeLowComboBox->getSelectedId(); andrewm@0: int noteLow = -1; andrewm@0: if(selectionLow == 0) { andrewm@0: // Not one of the predefined values that's selected. Parse the string. andrewm@0: noteLow = MainApplicationController::midiNoteNumberForName((const char *)(rangeLowComboBox->getText().toUTF8())); andrewm@0: } andrewm@0: else { andrewm@0: noteLow = selectionLow; andrewm@0: } andrewm@0: andrewm@0: if(noteLow < 0 || noteLow > 127) { andrewm@0: // Out of range: keep the old value andrewm@0: noteLow = keyboardSegment_->noteRange().first; andrewm@0: } andrewm@0: andrewm@0: int selectionHigh = rangeHighComboBox->getSelectedId(); andrewm@0: int noteHigh = -1; andrewm@0: if(selectionHigh == 0) { andrewm@0: // Not one of the predefined values that's selected. Parse the string. andrewm@0: noteHigh = MainApplicationController::midiNoteNumberForName((const char *)(rangeHighComboBox->getText().toUTF8())); andrewm@0: } andrewm@0: else { andrewm@0: noteHigh = selectionHigh; andrewm@0: } andrewm@0: andrewm@0: if(noteHigh < 0 || noteHigh > 127) { andrewm@0: // Out of range: keep the old value andrewm@0: noteHigh = keyboardSegment_->noteRange().second; andrewm@0: } andrewm@0: andrewm@0: if(noteHigh < noteLow) andrewm@0: noteHigh = noteLow; andrewm@0: keyboardSegment_->setNoteRange(noteLow, noteHigh); andrewm@0: } andrewm@0: andrewm@0: // Update the combo box with the current output devices andrewm@0: void KeyboardZoneComponent::updateOutputDeviceList() andrewm@0: { andrewm@0: if(controller_ == 0 || keyboardSegment_ == 0) andrewm@0: return; andrewm@0: andrewm@0: // *** MIDI output devices *** andrewm@0: vector > devices = controller_->availableMIDIOutputDevices(); andrewm@0: vector >::iterator it; andrewm@0: andrewm@0: midiOutputDeviceComboBox->clear(); andrewm@0: midiOutputDeviceIDs_.clear(); andrewm@0: midiOutputDeviceComboBox->addItem("Disabled", 1); andrewm@20: #ifndef JUCE_WINDOWS andrewm@20: char virtualPortName[24]; andrewm@20: snprintf(virtualPortName, 24, "Virtual Port (%d)", keyboardSegment_->outputPort()); andrewm@20: midiOutputDeviceComboBox->addItem(virtualPortName, 2); andrewm@20: #endif andrewm@31: andrewm@28: // Check whether the currently selected ID still exists while andrewm@28: // we build the list andrewm@28: bool lastSelectedDeviceExists = false; andrewm@0: int counter = kMidiOutputDeviceComboBoxOffset; andrewm@0: for(it = devices.begin(); it != devices.end(); ++it) { andrewm@0: if(it->first < 0) andrewm@0: continue; andrewm@0: midiOutputDeviceComboBox->addItem((*it).second.c_str(), counter); andrewm@0: midiOutputDeviceIDs_.push_back(it->first); andrewm@28: if(it->first == lastSelectedMidiOutputID_) andrewm@28: lastSelectedDeviceExists = true; andrewm@0: counter++; andrewm@0: } andrewm@31: andrewm@39: if(!lastSelectedDeviceExists && lastSelectedMidiOutputID_ != kInvalidMidiOutputId) { andrewm@29: #ifndef JUCE_WINDOWS andrewm@29: if(lastSelectedMidiOutputID_ != MidiOutputController::kMidiVirtualOutputPortNumber) andrewm@29: controller_->disableMIDIOutputPort(keyboardSegment_->outputPort()); andrewm@29: #else // No virtual port on Windows andrewm@28: controller_->disableMIDIOutputPort(keyboardSegment_->outputPort()); andrewm@29: #endif andrewm@28: } andrewm@0: } andrewm@0: andrewm@0: // Create a popup menu containing a list of mapping factories andrewm@0: void KeyboardZoneComponent::createMappingListPopup() andrewm@0: { andrewm@0: if(controller_ == 0) andrewm@0: return; andrewm@0: andrewm@0: PopupMenu menu; andrewm@0: andrewm@49: for(int i = 0; i < MidiKeyboardSegment::numberOfMappingFactories(); i++) { andrewm@49: if(controller_->experimentalMappingsEnabled() || !MidiKeyboardSegment::mappingIsExperimental(i)) andrewm@49: menu.addItem(i + 1, MidiKeyboardSegment::mappingFactoryNameForIndex(i)); andrewm@0: } andrewm@0: andrewm@0: menu.showMenuAsync(PopupMenu::Options().withTargetComponent(addMappingButton), andrewm@0: ModalCallbackFunction::forComponent(staticMappingChosenCallback, this)); andrewm@0: } andrewm@0: andrewm@5: // Create a popup menu allowing selection of which controllers to retransmit andrewm@5: void KeyboardZoneComponent::createKeyboardControllerPopup() andrewm@5: { andrewm@5: if(controller_ == 0 || keyboardSegment_ == 0) andrewm@5: return; andrewm@8: andrewm@5: PopupMenu menu; andrewm@8: andrewm@8: menu.addItem(kKeyboardControllerSendPitchWheelRange, "Send Pitchwheel Range RPN", true, false); andrewm@31: menu.addSeparator(); andrewm@5: menu.addItem(MidiKeyboardSegment::kControlPitchWheel, "Retransmit from Keyboard:", false); andrewm@5: menu.addSeparator(); andrewm@5: menu.addItem(MidiKeyboardSegment::kControlPitchWheel, "Pitch Wheel", true, keyboardSegment_->usesKeyboardPitchWheel()); andrewm@5: menu.addItem(MidiKeyboardSegment::kControlChannelAftertouch, "Aftertouch", true, keyboardSegment_->usesKeyboardChannnelPressure()); andrewm@5: menu.addItem(1, "CC 1 (Mod Wheel)", true, keyboardSegment_->usesKeyboardModWheel()); andrewm@53: menu.addItem(kKeyboardControllerRetransmitPedals, "Pedals", true, keyboardSegment_->usesKeyboardPedals()); andrewm@5: menu.addItem(kKeyboardControllerRetransmitOthers, "Other Controllers", true, keyboardSegment_->usesKeyboardMIDIControllers()); andrewm@8: andrewm@5: menu.showMenuAsync(PopupMenu::Options().withTargetComponent(keyboardControllersButton), andrewm@5: ModalCallbackFunction::forComponent(staticKeyboardControllerChosenCallback, this)); andrewm@5: } andrewm@5: andrewm@0: // Called from the popup menu, indicating the selected item andrewm@0: void KeyboardZoneComponent::mappingChosenCallback(int result) andrewm@0: { andrewm@0: if(controller_ == 0 || keyboardSegment_ == 0) andrewm@0: return; andrewm@0: andrewm@0: // Items are numbered from 1 in the menu but from 0 in the array in the controller andrewm@0: if(result >= 1) { andrewm@49: MappingFactory *newFactory = keyboardSegment_->createMappingFactoryForIndex(result - 1); andrewm@0: andrewm@0: if(newFactory != 0) { andrewm@0: keyboardSegment_->addMappingFactory(newFactory, true); andrewm@0: } andrewm@0: } andrewm@0: } andrewm@5: andrewm@5: // Called from the popup menu, indicated selected controller andrewm@5: void KeyboardZoneComponent::keyboardControllerChosenCallback(int result) andrewm@5: { andrewm@5: if(controller_ == 0 || keyboardSegment_ == 0) andrewm@5: return; andrewm@8: andrewm@5: // Enable or disable retransmitting specific messages andrewm@5: if(result == MidiKeyboardSegment::kControlPitchWheel) { andrewm@5: keyboardSegment_->setUsesKeyboardPitchWheel(!keyboardSegment_->usesKeyboardPitchWheel()); andrewm@5: } andrewm@5: else if(result == MidiKeyboardSegment::kControlChannelAftertouch) { andrewm@5: keyboardSegment_->setUsesKeyboardChannelPressure(!keyboardSegment_->usesKeyboardChannnelPressure()); andrewm@5: } andrewm@5: else if(result == 1) { // ModWheel == CC 1 andrewm@5: keyboardSegment_->setUsesKeyboardModWheel(!keyboardSegment_->usesKeyboardModWheel()); andrewm@5: } andrewm@53: else if(result == kKeyboardControllerRetransmitPedals) { andrewm@53: keyboardSegment_->setUsesKeyboardPedals(!keyboardSegment_->usesKeyboardPedals()); andrewm@53: } andrewm@5: else if(result == kKeyboardControllerRetransmitOthers) { andrewm@5: keyboardSegment_->setUsesKeyboardMIDIControllers(!keyboardSegment_->usesKeyboardMIDIControllers()); andrewm@5: } andrewm@8: else if(result == kKeyboardControllerSendPitchWheelRange) { andrewm@8: // Send a MIDI RPN message now to update the pitch wheel range andrewm@8: keyboardSegment_->sendMidiPitchWheelRange(); andrewm@8: } andrewm@5: } andrewm@0: //[/MiscUserCode] andrewm@0: andrewm@0: andrewm@0: //============================================================================== andrewm@0: #if 0 andrewm@0: /* -- Introjucer information section -- andrewm@0: andrewm@0: This is where the Introjucer stores the metadata that describe this GUI layout, so andrewm@0: make changes in here at your peril! andrewm@0: andrewm@0: BEGIN_JUCER_METADATA andrewm@0: andrewm@0: andrewm@0: andrewm@5: andrewm@0: andrewm@0: andrewm@0: andrewm@0: andrewm@0: END_JUCER_METADATA andrewm@0: */ andrewm@0: #endif andrewm@0: andrewm@0: andrewm@0: //[EndFile] You can add extra defines here... andrewm@50: #endif // TOUCHKEYS_NO_GUI andrewm@0: //[/EndFile]