1 /*! 2 * @file inoutbox.h 3 * @brief Member definitions for the InOutBox GUI class. 4 * 5 * 6 * Copyright 2009 - 2017 <qmidiarp-devel@lists.sourceforge.net> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 21 * MA 02110-1301, USA. 22 */ 23 24 #ifndef INOUTBOX_H 25 #define INOUTBOX_H 26 27 #include <QBoxLayout> 28 #include <QGridLayout> 29 #include <QGroupBox> 30 #include <QMessageBox> 31 #include <QToolButton> 32 #include <QPushButton> 33 #include <QAction> 34 #include <QComboBox> 35 #include <QGroupBox> 36 #include <QSpinBox> 37 #include <QLabel> 38 #include <QCheckBox> 39 40 41 #ifdef APPBUILD 42 #include <QInputDialog> 43 44 #include "parstore.h" 45 #endif 46 47 #include "midiworker.h" 48 /*! @brief GUI base class for module widgets, creates an in-out settings box 49 * 50 * The three module widget classes ArpWidget, SeqWidget and LfoWidget 51 * inherit from this class. It provides the input 52 * output settings and widget and handlers and some other small functions 53 * and member variables 54 */ 55 class InOutBox: public QWidget 56 { 57 Q_OBJECT 58 59 public: 60 MidiWorker *midiWorker; 61 #ifdef APPBUILD 62 QString name; /**< @brief The name of this Widget as shown in the DockWidget TitleBar */ 63 GlobStore *globStore; 64 /*! 65 * @brief Constructor for InOutBox. Creates the base class and widget for a module 66 * 67 * 68 * @param p_midiWorker Associated MidiWorker Base Object 69 * @param p_globStore The Application-wide globStore widget 70 * @param portCount Number of available MIDI output ports 71 * @param compactStyle If set to True, Widget will use reduced spacing and small fonts 72 * @param inOutVisible Add the module with visible InOutBox or not 73 * @param name The name of the module preceded by its type (Arp: , etc...) 74 */ 75 InOutBox(MidiWorker *p_midiWorker, GlobStore *p_globStore, int portCount, bool compactStyle, 76 bool inOutVisible, const QString& name); 77 QAction *deleteAction, *renameAction, *cloneAction; 78 int ID; /**< @brief Corresponds to the Engine::midi*List index of the associated MidiSeq */ 79 int parentDockID; /**< @brief The index of the Widget's parent DockWidget in Engine::moduleWindowList */ 80 ParStore *parStore; 81 MidiControl *midiControl; 82 #else 83 InOutBox(bool compactStyle, 84 bool inOutVisible, const QString& name); 85 #endif 86 ~InOutBox(); 87 bool modified; /**< @brief Is set to True if unsaved parameter modifications exist */ 88 bool dataChanged; 89 bool needsGUIUpdate; 90 QLabel *rangeInLabel, *indexInLabel; 91 QGroupBox *inputFilterBox; 92 QComboBox *chIn; // Channel of input events 93 QComboBox *channelOut, *portOut; // Output channel / port (ALSA Sequencer) 94 QSpinBox *indexIn[2]; // Index input 95 QSpinBox *rangeIn[2]; // Parameter that is mapped, [0] low, [1] high boundary 96 QCheckBox *enableRestartByKbd; 97 QCheckBox *enableTrigByKbd; 98 QCheckBox *enableTrigLegato; 99 QCheckBox *enableNoteIn; 100 QCheckBox *enableVelIn; 101 QCheckBox *enableNoteOff; 102 QSpinBox *ccnumberInBox; 103 QSpinBox *ccnumberBox; 104 QAction *hideInOutBoxAction; 105 QToolButton *hideInOutBoxButton; 106 QAction *muteOutAction; 107 QToolButton *muteOut; 108 QAction *deferChangesAction; 109 QToolButton *deferChangesButton; 110 111 QWidget *inOutBoxWidget; 112 113 virtual bool isModified(); 114 virtual void setModified(bool); 115 virtual void checkIfInputFilterSet(); getFramePtr()116 virtual int getFramePtr() { return midiWorker->getFramePtr(); } getNextTick()117 virtual int getNextTick() { return midiWorker->nextTick; } 118 119 #ifdef APPBUILD 120 121 /*! 122 * @brief Writes common module parameters to disk 123 * @param xml XML stream to write to 124 */ 125 virtual void writeCommonData(QXmlStreamWriter& xml); 126 /*! 127 * @brief Reads common module parameters from disk 128 * @param xml XML stream to read from 129 */ 130 virtual void readCommonData(QXmlStreamReader& xml); 131 /*! 132 * @brief Setter for the InOutBox::portOut spinbox setting the output 133 * port of this module. 134 * @param value Number of the output port to send data to 135 * 136 */ 137 virtual void setPortOut(int value); 138 /*! 139 * @brief stores some module parameters in a parameter 140 * list object 141 * 142 * @param ix Position index in the parameter list 143 */ 144 virtual void doStoreParams(int ix) = 0; 145 /*! 146 * @brief Restores some module parameters from the parameter 147 * list object 148 * 149 * @param ix Position index in the parameter list 150 */ 151 virtual void doRestoreParams(int ix) = 0; 152 /** 153 * @brief Copies the new values transferred from the 154 * GrooveWidget into variables used by the main routine. 155 * 156 * @param p_grooveTick Groove amount for timing displacements 157 * @param p_grooveVelocity Groove amount for velocity variations 158 * @param p_grooveLength Groove amount for note length variations 159 */ 160 virtual void newGrooveValues(int p_grooveTick, int p_grooveVelocity, 161 int p_grooveLength); 162 163 /** 164 * @brief Handles MIDI-learned controller events locally in each module 165 * 166 * It is called by Engine::sendController() when a MIDI controller is received. 167 */ 168 virtual void handleController(int ccnumber, int channel, int value) = 0; 169 /*! 170 * @brief Updates the SeqScreen and other GUI elements with data from 171 * the MidiSeq instance. 172 * 173 * It is called by Engine::updateDisplay(), which itself is 174 * connected to the MTimer::timeout event. It runs in the MTimer thread. 175 * It reads the waveform data and other settings from the MidiSeq instance 176 * and sets GUI cursor, wave display and other elements accordingly. This 177 * way, no memory allocations are done within the jack run thread, for 178 * instance by MIDI controllers, since the Qt widgets are not called directly. 179 * This function also checks whether parameter changes from ParStore are 180 * pending and causes them to get transferred if so. 181 */ 182 virtual void updateDisplay() = 0; 183 virtual void updateIndicators(); 184 virtual void checkIfRestore(int *restoreTick, bool *restoreFlag); 185 /*! 186 * @brief allows ignoring one XML element in the XML stream 187 * passed by the caller. 188 * 189 * It also advances the stream read-in. It is used to 190 * ignore unknown elements for both-ways-compatibility 191 * 192 * @param xml reference to QXmlStreamReader containing the open XML stream 193 */ 194 virtual void skipXmlElement(QXmlStreamReader& xml); 195 #endif 196 197 public slots: 198 /*! 199 * @brief Slot for InOutBox::deleteAction. 200 * 201 * This function displays a warning and then emits the 202 * InOutBox::moduleRemove signal to MainWindow with the module ID as 203 * parameter. 204 */ 205 virtual void moduleDelete(); 206 /*! 207 * @brief Slot for InOutBox::renameAction. 208 * 209 * This function queries a new name then emits the InOutBox::dockRename 210 * signal to MainWindow with the new name and the dockWidget ID to rename. 211 */ 212 virtual void moduleRename(); 213 /*! 214 * @brief Slot for InOutBox::cloneAction. 215 * 216 * This function emits the InOutBox::moduleClone() 217 * signal to MainWindow with the module ID and the dockWidget ID. 218 */ 219 virtual void moduleClone(); 220 221 virtual void setInputFilterVisible(bool on); 222 223 /*! 224 * @brief Store common module parameters and call doStoreParams 225 * 226 * Stores common module parameters to ParStore::list and then calls 227 * InOutBox::doStoreParams(), which is reimplemented in each module widget 228 * to store module specific parameters. 229 * 230 * @param ix The storage location index to write to 231 * @param empty Signal an empty location 232 */ 233 virtual void storeParams(int ix, bool empty = 0); 234 /*! 235 * @brief Restore common module parameters and call doRestoreParams 236 * 237 * Restores common module parameters from ParStore::list and then calls 238 * InOutBox::doRestoreParams(), which is reimplemented in each module widget 239 * to restore module specific parameters. 240 * 241 * @param ix The storage location index to read from 242 */ 243 virtual void restoreParams(int ix); 244 /*! 245 * @brief Slot for the InOutBox::channelOut spinbox setting the output 246 * channel of this module. 247 * @param value Number of the output channel to send data to 248 * 249 */ 250 virtual void updateChannelOut(int value); 251 /*! 252 * @brief Slot for the InOutBox::portOut spinbox setting the output 253 * port of this module. 254 * @param value Number of the output port to send data to 255 * 256 */ 257 virtual void updateCcnumberIn(int value); 258 virtual void updatePortOut(int value); 259 virtual void updateChIn(int value); 260 virtual void updateIndexIn(int value); 261 virtual void updateRangeIn(int value); 262 virtual void updateEnableNoteIn(bool on); 263 virtual void updateEnableVelIn(bool on); 264 virtual void updateEnableNoteOff(bool on); 265 virtual void updateEnableRestartByKbd(bool on); 266 virtual void updateEnableTrigByKbd(bool on); 267 virtual void updateTrigLegato(bool on); 268 /*! 269 * @brief Slot for the InOutBox::ccnumberBox spinbox setting the output 270 * controller CC number of this module. 271 * @param val CC number to send data to 272 * 273 */ 274 virtual void updateCcnumber(int val); 275 /*! 276 * @brief Slot for the InOutBox::deferChangesAction. 277 * 278 * Sets a flag in the midi worker causing parameter changes to become 279 * active/inactive only at pattern end. 280 * 281 * @param on Set to True for deferring parameter changes to pattern end 282 */ 283 virtual void updateDeferChanges(bool on); 284 /*! 285 * @brief Slot for the InOutBox::muteOut checkbox. 286 * suppresses output of MIDI data. 287 * 288 * It sets MidiWorker::isMuted and causes a needsGUIUpdate 289 * @param on Set to True for muting this module 290 * 291 */ 292 virtual void setMuted(bool on); 293 294 signals: 295 296 /*! @brief Emitted to MainWindow::removeSeq for module deletion. 297 * @param ID The internal module ID of the module to remove 298 * */ 299 void moduleRemove(int ID); 300 /*! @brief Emitted to MainWindow::renameDock for module rename. 301 * @param mname New name of the module 302 * @param parentDockID parentDockID of the module to rename 303 * */ 304 void dockRename(const QString& mname, int parentDockID); 305 /*! @brief Emitted to MainWindow::cloneSeq for module duplication. 306 * @param ID module ID of the module to clone 307 * */ 308 void moduleClone(int ID); 309 }; 310 #endif 311