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

merge
author Andrew McPherson <andrewm@eecs.qmul.ac.uk>
date Fri, 23 Nov 2018 15:48:14 +0000
parents ff5d65c69e73
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 MainWindow.h: the control window, plus menu bar and Juce application methods
andrewm@0 21 */
andrewm@0 22
andrewm@0 23 #ifndef MAINWINDOW_H_INCLUDED
andrewm@0 24 #define MAINWINDOW_H_INCLUDED
andrewm@0 25
andrewm@50 26 #ifndef TOUCHKEYS_NO_GUI
andrewm@50 27
andrewm@0 28 #include "../../JuceLibraryCode/JuceHeader.h"
andrewm@0 29 #include "ControlWindowMainComponent.h"
andrewm@0 30 #include "../MainApplicationController.h"
andrewm@0 31
andrewm@0 32 //==============================================================================
andrewm@0 33 /*
andrewm@0 34 */
andrewm@0 35
andrewm@0 36 class MainWindow : public DocumentWindow, public Timer,
andrewm@0 37 public MenuBarModel, public ApplicationCommandTarget
andrewm@0 38 {
andrewm@0 39 private:
andrewm@0 40 // Commands this application responds to
andrewm@0 41 enum CommandIDs
andrewm@0 42 {
andrewm@0 43 // File menu
andrewm@33 44 kCommandClearPreset = 0x2001,
andrewm@0 45 kCommandOpenPreset,
andrewm@0 46 kCommandSavePreset,
andrewm@0 47
andrewm@0 48 // Edit menu
andrewm@0 49 // (all standard)
andrewm@0 50
andrewm@0 51 // Control menu
andrewm@0 52 kCommandRescanDevices = 0x2020,
andrewm@31 53 kCommandLoggingStartStop,
andrewm@31 54 kCommandLoggingPlay,
andrewm@0 55 kCommandEnableExperimentalMappings,
andrewm@17 56 kCommandTestTouchkeySensors,
andrewm@53 57 kCommandJumpToBootloader,
andrewm@41 58 kCommandPreferences,
andrewm@0 59
andrewm@0 60 // Window menu
andrewm@0 61 kCommandShowControlWindow = 0x2030,
andrewm@0 62 kCommandShowKeyboardWindow
andrewm@0 63 };
andrewm@0 64
andrewm@0 65 public:
andrewm@0 66 MainWindow(MainApplicationController& controller);
andrewm@0 67 ~MainWindow();
andrewm@0 68
andrewm@0 69 void closeButtonPressed()
andrewm@0 70 {
andrewm@0 71 // This is called when the user tries to close this window. Here, we'll just
andrewm@0 72 // ask the app to quit when this happens, but you can change this to do
andrewm@0 73 // whatever you need.
andrewm@0 74 JUCEApplication::getInstance()->systemRequestedQuit();
andrewm@0 75 }
andrewm@0 76
andrewm@0 77 // Method used by Juce timer which we will use for periodic UI updates
andrewm@0 78 // from the underlying system state, in a configuration similar to how the
andrewm@0 79 // Juce audio plugins work
andrewm@0 80 void timerCallback();
andrewm@0 81
andrewm@0 82 // ***** Menu Bar methods *****
andrewm@0 83
andrewm@0 84 StringArray getMenuBarNames();
andrewm@0 85 PopupMenu getMenuForIndex (int menuIndex, const String& menuName);
andrewm@0 86 void menuItemSelected (int menuItemID, int topLevelMenuIndex);
andrewm@0 87
andrewm@0 88 // ***** Application Command Manager methods *****
andrewm@0 89
andrewm@0 90 // this will return the next parent component that is an ApplicationCommandTarget (in this
andrewm@0 91 // case, there probably isn't one, but it's best to use this method in your own apps).
andrewm@0 92 ApplicationCommandTarget* getNextCommandTarget();
andrewm@0 93
andrewm@0 94 // this returns the set of all commands that this target can perform..
andrewm@0 95 void getAllCommands (Array <CommandID>& commands);
andrewm@0 96
andrewm@0 97 // This method is used when something needs to find out the details about one of the commands
andrewm@0 98 // that this object can perform..
andrewm@0 99 void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result);
andrewm@0 100
andrewm@0 101 // Perform a command
andrewm@0 102 bool perform (const InvocationInfo& info);
andrewm@0 103
andrewm@37 104 // Callback for alert box
andrewm@37 105 static void alertBoxResultChosen(int result, MainWindow *item);
andrewm@37 106
andrewm@37 107 // Clear preset (called from alert box
andrewm@37 108 void clearPreset() { controller_.clearPreset(); }
andrewm@37 109
andrewm@0 110 /* Note: Be careful if you override any DocumentWindow methods - the base
andrewm@0 111 class uses a lot of them, so by overriding you might break its functionality.
andrewm@0 112 It's best to do all your work in your content component instead, but if
andrewm@0 113 you really have to override any DocumentWindow methods, make sure your
andrewm@0 114 subclass also calls the superclass's method.
andrewm@0 115 */
andrewm@0 116
andrewm@0 117 private:
andrewm@0 118 // The command manager object used to dispatch command events
andrewm@0 119 MainApplicationController& controller_;
andrewm@0 120 ApplicationCommandManager commandManager_;
andrewm@0 121 ControlWindowMainComponent mainComponent_;
andrewm@0 122
andrewm@0 123 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
andrewm@0 124 };
andrewm@0 125
andrewm@50 126 #endif // TOUCHKEYS_NO_GUI
andrewm@0 127
andrewm@0 128 #endif // MAINWINDOW_H_INCLUDED