annotate Source/GUI/MappingListComponent.h @ 56:b4a2d2ae43cf tip

merge
author Andrew McPherson <andrewm@eecs.qmul.ac.uk>
date Fri, 23 Nov 2018 15:48:14 +0000
parents 85577160a0d4
children
rev   line source
andrewm@0 1 /*
andrewm@0 2 TouchKeys: multi-touch musical keyboard control software
andrewm@0 3 Copyright (c) 2013 Andrew McPherson
andrewm@0 4
andrewm@0 5 This program is free software: you can redistribute it and/or modify
andrewm@0 6 it under the terms of the GNU General Public License as published by
andrewm@0 7 the Free Software Foundation, either version 3 of the License, or
andrewm@0 8 (at your option) any later version.
andrewm@0 9
andrewm@0 10 This program is distributed in the hope that it will be useful,
andrewm@0 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
andrewm@0 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
andrewm@0 13 GNU General Public License for more details.
andrewm@0 14
andrewm@0 15 You should have received a copy of the GNU General Public License
andrewm@0 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
andrewm@0 17
andrewm@0 18 =====================================================================
andrewm@0 19
andrewm@0 20 MappingListComponent.h: manages a ListBox to display the current
andrewm@0 21 mappigns associated with a keyboard segment.
andrewm@0 22 */
andrewm@0 23
andrewm@0 24 #ifndef TOUCHKEYS_NO_GUI
andrewm@0 25
andrewm@0 26 #ifndef __MAPPINGLISTCOMPONENT_H_51502151__
andrewm@0 27 #define __MAPPINGLISTCOMPONENT_H_51502151__
andrewm@0 28
andrewm@0 29 #include <vector>
andrewm@41 30 #include <list>
andrewm@0 31 #include "../JuceLibraryCode/JuceHeader.h"
andrewm@0 32 #include "../MainApplicationController.h"
andrewm@0 33 #include "../TouchKeys/MidiKeyboardSegment.h"
andrewm@0 34 #include "MappingListItem.h"
andrewm@0 35 #include "../Mappings/MappingFactory.h"
andrewm@0 36
andrewm@41 37 class MappingExtendedEditorWindow;
andrewm@41 38
andrewm@0 39 //==============================================================================
andrewm@0 40 /*
andrewm@0 41 */
andrewm@0 42 class MappingListComponent : public Component, public ListBoxModel
andrewm@0 43 {
andrewm@0 44 public:
andrewm@0 45 MappingListComponent();
andrewm@0 46 ~MappingListComponent();
andrewm@0 47
andrewm@0 48 //void paint (Graphics&);
andrewm@0 49 void resized();
andrewm@0 50
andrewm@0 51 // *** Mapping management methods ***
andrewm@0 52
andrewm@0 53 // Attach the user interface to the controller and vice-versa
andrewm@0 54 void setMainApplicationController(MainApplicationController *controller) {
andrewm@0 55 controller_ = controller;
andrewm@0 56 if(keyboardSegment_ != 0)
andrewm@0 57 listBox_.updateContent();
andrewm@0 58 }
andrewm@0 59 void setKeyboardSegment(MidiKeyboardSegment *segment) {
andrewm@0 60 keyboardSegment_ = segment;
andrewm@0 61 if(controller_ != 0)
andrewm@0 62 listBox_.updateContent();
andrewm@0 63 }
andrewm@0 64
andrewm@0 65 // Add or delete a mapping based on a Factory class created elsewhere
andrewm@0 66 void addMapping(MappingFactory* factory);
andrewm@0 67 void deleteMapping(MappingFactory* factory);
andrewm@41 68
andrewm@41 69 // Return which segment this component refers to
andrewm@41 70 int segmentNumber() {
andrewm@41 71 if(keyboardSegment_ == 0)
andrewm@41 72 return -1;
andrewm@41 73 return keyboardSegment_->outputPort();
andrewm@41 74 }
andrewm@0 75
andrewm@0 76 // *** ListBox methods ***
andrewm@0 77 int getNumRows();
andrewm@0 78 void paintListBoxItem(int rowNumber,
andrewm@0 79 Graphics& g,
andrewm@0 80 int width, int height,
andrewm@0 81 bool rowIsSelected) {}
andrewm@0 82 Component* refreshComponentForRow(int rowNumber, bool isRowSelected, Component *existingComponentToUpdate);
andrewm@0 83
andrewm@0 84 // *** UI management methods ***
andrewm@0 85 // Return whether a given component is selected or not (called by MappingListItem)
andrewm@0 86 bool isComponentSelected(Component *component);
andrewm@0 87
andrewm@0 88 // Update UI state to reflect underlying system state
andrewm@0 89 void synchronize();
andrewm@0 90
andrewm@41 91 // *** Extended editor window methods ***
andrewm@41 92 // Open an extended editor window for the given component
andrewm@41 93 void openExtendedEditorWindow(MappingFactory *factory);
andrewm@41 94
andrewm@41 95 // Close an extended editor window and remove it from the list
andrewm@41 96 void closeExtendedEditorWindow(MappingExtendedEditorWindow *window);
andrewm@41 97
andrewm@41 98 // Find an extended editor window for a given factory, if it exists
andrewm@41 99 MappingExtendedEditorWindow *extendedEditorWindowForFactory(MappingFactory *factory);
andrewm@41 100
andrewm@0 101 private:
andrewm@41 102 // Sync the UI for the extended editor windows
andrewm@41 103 void synchronizeExtendedEditorWindows();
andrewm@41 104
andrewm@41 105 // Internal helper function for closing window
andrewm@41 106 void closeExtendedEditorWindowHelper(MappingExtendedEditorWindow *window);
andrewm@41 107
andrewm@41 108 // Find the invalid editor windows and clsoe them
andrewm@41 109 void updateExtendedEditorWindows();
andrewm@41 110
andrewm@41 111 // Close all extended editor windows
andrewm@41 112 void clearExtendedEditorWindows();
andrewm@41 113
andrewm@0 114 ListBox listBox_;
andrewm@0 115 MainApplicationController *controller_;
andrewm@0 116 MidiKeyboardSegment *keyboardSegment_;
andrewm@0 117
andrewm@41 118 CriticalSection extendedEditorWindowsMutex_;
andrewm@41 119 list<MappingExtendedEditorWindow*> extendedEditorWindows_;
andrewm@41 120
andrewm@0 121 int lastMappingFactoryIdentifier_;
andrewm@0 122
andrewm@0 123 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MappingListComponent)
andrewm@0 124 };
andrewm@0 125
andrewm@0 126
andrewm@0 127 #endif // __MAPPINGLISTCOMPONENT_H_51502151__
andrewm@0 128
andrewm@0 129 #endif // TOUCHKEYS_NO_GUI