andrewm@0: /*
andrewm@0: TouchKeys: multi-touch musical keyboard control software
andrewm@0: Copyright (c) 2013 Andrew McPherson
andrewm@0:
andrewm@0: This program is free software: you can redistribute it and/or modify
andrewm@0: it under the terms of the GNU General Public License as published by
andrewm@0: the Free Software Foundation, either version 3 of the License, or
andrewm@0: (at your option) any later version.
andrewm@0:
andrewm@0: This program is distributed in the hope that it will be useful,
andrewm@0: but WITHOUT ANY WARRANTY; without even the implied warranty of
andrewm@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
andrewm@0: GNU General Public License for more details.
andrewm@0:
andrewm@0: You should have received a copy of the GNU General Public License
andrewm@0: along with this program. If not, see .
andrewm@0:
andrewm@0: =====================================================================
andrewm@0:
andrewm@0: MappingListComponent.h: manages a ListBox to display the current
andrewm@0: mappigns associated with a keyboard segment.
andrewm@0: */
andrewm@0:
andrewm@0: #ifndef TOUCHKEYS_NO_GUI
andrewm@0:
andrewm@0: #ifndef __MAPPINGLISTCOMPONENT_H_51502151__
andrewm@0: #define __MAPPINGLISTCOMPONENT_H_51502151__
andrewm@0:
andrewm@0: #include
andrewm@41: #include
andrewm@0: #include "../JuceLibraryCode/JuceHeader.h"
andrewm@0: #include "../MainApplicationController.h"
andrewm@0: #include "../TouchKeys/MidiKeyboardSegment.h"
andrewm@0: #include "MappingListItem.h"
andrewm@0: #include "../Mappings/MappingFactory.h"
andrewm@0:
andrewm@41: class MappingExtendedEditorWindow;
andrewm@41:
andrewm@0: //==============================================================================
andrewm@0: /*
andrewm@0: */
andrewm@0: class MappingListComponent : public Component, public ListBoxModel
andrewm@0: {
andrewm@0: public:
andrewm@0: MappingListComponent();
andrewm@0: ~MappingListComponent();
andrewm@0:
andrewm@0: //void paint (Graphics&);
andrewm@0: void resized();
andrewm@0:
andrewm@0: // *** Mapping management methods ***
andrewm@0:
andrewm@0: // Attach the user interface to the controller and vice-versa
andrewm@0: void setMainApplicationController(MainApplicationController *controller) {
andrewm@0: controller_ = controller;
andrewm@0: if(keyboardSegment_ != 0)
andrewm@0: listBox_.updateContent();
andrewm@0: }
andrewm@0: void setKeyboardSegment(MidiKeyboardSegment *segment) {
andrewm@0: keyboardSegment_ = segment;
andrewm@0: if(controller_ != 0)
andrewm@0: listBox_.updateContent();
andrewm@0: }
andrewm@0:
andrewm@0: // Add or delete a mapping based on a Factory class created elsewhere
andrewm@0: void addMapping(MappingFactory* factory);
andrewm@0: void deleteMapping(MappingFactory* factory);
andrewm@41:
andrewm@41: // Return which segment this component refers to
andrewm@41: int segmentNumber() {
andrewm@41: if(keyboardSegment_ == 0)
andrewm@41: return -1;
andrewm@41: return keyboardSegment_->outputPort();
andrewm@41: }
andrewm@0:
andrewm@0: // *** ListBox methods ***
andrewm@0: int getNumRows();
andrewm@0: void paintListBoxItem(int rowNumber,
andrewm@0: Graphics& g,
andrewm@0: int width, int height,
andrewm@0: bool rowIsSelected) {}
andrewm@0: Component* refreshComponentForRow(int rowNumber, bool isRowSelected, Component *existingComponentToUpdate);
andrewm@0:
andrewm@0: // *** UI management methods ***
andrewm@0: // Return whether a given component is selected or not (called by MappingListItem)
andrewm@0: bool isComponentSelected(Component *component);
andrewm@0:
andrewm@0: // Update UI state to reflect underlying system state
andrewm@0: void synchronize();
andrewm@0:
andrewm@41: // *** Extended editor window methods ***
andrewm@41: // Open an extended editor window for the given component
andrewm@41: void openExtendedEditorWindow(MappingFactory *factory);
andrewm@41:
andrewm@41: // Close an extended editor window and remove it from the list
andrewm@41: void closeExtendedEditorWindow(MappingExtendedEditorWindow *window);
andrewm@41:
andrewm@41: // Find an extended editor window for a given factory, if it exists
andrewm@41: MappingExtendedEditorWindow *extendedEditorWindowForFactory(MappingFactory *factory);
andrewm@41:
andrewm@0: private:
andrewm@41: // Sync the UI for the extended editor windows
andrewm@41: void synchronizeExtendedEditorWindows();
andrewm@41:
andrewm@41: // Internal helper function for closing window
andrewm@41: void closeExtendedEditorWindowHelper(MappingExtendedEditorWindow *window);
andrewm@41:
andrewm@41: // Find the invalid editor windows and clsoe them
andrewm@41: void updateExtendedEditorWindows();
andrewm@41:
andrewm@41: // Close all extended editor windows
andrewm@41: void clearExtendedEditorWindows();
andrewm@41:
andrewm@0: ListBox listBox_;
andrewm@0: MainApplicationController *controller_;
andrewm@0: MidiKeyboardSegment *keyboardSegment_;
andrewm@0:
andrewm@41: CriticalSection extendedEditorWindowsMutex_;
andrewm@41: list extendedEditorWindows_;
andrewm@41:
andrewm@0: int lastMappingFactoryIdentifier_;
andrewm@0:
andrewm@0: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MappingListComponent)
andrewm@0: };
andrewm@0:
andrewm@0:
andrewm@0: #endif // __MAPPINGLISTCOMPONENT_H_51502151__
andrewm@0:
andrewm@0: #endif // TOUCHKEYS_NO_GUI