andrewm@41: /* andrewm@41: ============================================================================== andrewm@41: andrewm@41: MappingExtendedEditorWindow.h andrewm@41: Created: 18 Jun 2014 10:57:00am andrewm@41: Author: Andrew McPherson andrewm@41: andrewm@41: ============================================================================== andrewm@41: */ andrewm@41: andrewm@41: #ifndef MAPPINGEXTENDEDEDITORWINDOW_H_INCLUDED andrewm@41: #define MAPPINGEXTENDEDEDITORWINDOW_H_INCLUDED andrewm@41: andrewm@50: #ifndef TOUCHKEYS_NO_GUI andrewm@50: andrewm@41: #include "../../JuceLibraryCode/JuceHeader.h" andrewm@41: #include "../TouchKeys/MidiKeyboardSegment.h" andrewm@41: #include "../Mappings/MappingFactory.h" andrewm@41: #include "MappingListComponent.h" andrewm@41: andrewm@41: //============================================================================== andrewm@41: /* andrewm@41: */ andrewm@41: class MappingExtendedEditorWindow : public DocumentWindow andrewm@41: { andrewm@41: public: andrewm@41: MappingExtendedEditorWindow(MappingListComponent& listComponent, andrewm@41: MidiKeyboardSegment& segment, MappingFactory& factory) andrewm@41: : DocumentWindow("", Colours::lightgrey, DocumentWindow::minimiseButton | DocumentWindow::closeButton), andrewm@41: listComponent_(listComponent), segment_(segment), factory_(factory), editor_(0) andrewm@41: { andrewm@41: setUsingNativeTitleBar(true); andrewm@41: setResizable(false, false); andrewm@41: andrewm@41: if((segment_.indexOfMappingFactory(&factory_) >= 0) && factory_.hasExtendedEditor()) { andrewm@41: editor_ = factory_.createExtendedEditor(); andrewm@41: andrewm@41: // Set properties andrewm@41: setContentOwned(editor_, true); andrewm@41: andrewm@41: // Start interface in sync andrewm@41: editor_->synchronize(); andrewm@41: } andrewm@41: andrewm@41: // Show window andrewm@45: setTopLeftPosition(60,60); andrewm@41: setVisible(true); andrewm@41: } andrewm@41: andrewm@41: ~MappingExtendedEditorWindow() andrewm@41: { andrewm@41: } andrewm@41: andrewm@41: // Method used by Juce timer which we will use for periodic UI updates andrewm@41: // from the underlying system state andrewm@41: void synchronize() { andrewm@41: if(editor_ == 0) andrewm@41: return; andrewm@41: editor_->synchronize(); andrewm@41: setName(editor_->getDescription()); andrewm@41: } andrewm@41: andrewm@41: // Check whether this window still points to a valid mapping andrewm@41: bool isValid() { andrewm@41: if(segment_.indexOfMappingFactory(&factory_) < 0) andrewm@41: return false; andrewm@41: return true; andrewm@41: } andrewm@41: andrewm@41: // Return the factory associated with this window andrewm@41: MappingFactory *factory() { andrewm@41: return &factory_; andrewm@41: } andrewm@41: andrewm@41: void closeButtonPressed() { andrewm@41: // Close the window and delete it andrewm@41: listComponent_.closeExtendedEditorWindow(this); andrewm@41: } andrewm@41: andrewm@41: void resized() { andrewm@41: // This method is where you should set the bounds of any child andrewm@41: // components that your component contains.. andrewm@41: } andrewm@41: andrewm@41: private: andrewm@41: MappingListComponent& listComponent_; andrewm@41: MidiKeyboardSegment& segment_; andrewm@41: MappingFactory& factory_; andrewm@41: MappingEditorComponent *editor_; andrewm@41: andrewm@41: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MappingExtendedEditorWindow) andrewm@41: }; andrewm@41: andrewm@50: #endif // TOUCHKEYS_NO_GUI andrewm@41: andrewm@41: #endif // MAPPINGEXTENDEDEDITORWINDOW_H_INCLUDED