1 //========================================================= 2 // MusE 3 // Linux Music Editor 4 // $Id: arranger.h,v 1.17.2.15 2009/11/14 03:37:48 terminator356 Exp $ 5 // (C) Copyright 1999 Werner Schweer (ws@seh.de) 6 // (C) Copyright 2016 Tim E. Real (terminator356 on sourceforge) 7 // 8 // This program is free software; you can redistribute it and/or 9 // modify it under the terms of the GNU General Public License 10 // as published by the Free Software Foundation; version 2 of 11 // the License, or (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, MA 02110-1301, USA. 21 // 22 //========================================================= 23 24 #ifndef __ARRANGER_H__ 25 #define __ARRANGER_H__ 26 27 #include <vector> 28 #include <QWidget> 29 #include <QString> 30 31 #include "type_defs.h" 32 #include "tools.h" 33 34 35 // Forward declarations: 36 class QKeyEvent; 37 class QPoint; 38 class QComboBox; 39 class QScrollBar; 40 class QVBoxLayout; 41 class QHBoxLayout; 42 class QScrollArea; 43 class QGridLayout; 44 class QToolButton; 45 46 namespace MusECore { 47 class Track; 48 class Xml; 49 class PartList; 50 } 51 52 namespace MusEGui { 53 class ArrangerView; 54 class Header; 55 class LabelCombo; 56 class MTScale; 57 class PosLabel; 58 class ScrollScale; 59 class SpinBox; 60 class Splitter; 61 class TrackInfoWidget; 62 class TList; 63 class ArrangerCanvasLayout; 64 class ArrangerHScrollLayout; 65 class PartCanvas; 66 class CompactToolButton; 67 class RasterizerModel; 68 class RasterLabelCombo; 69 70 //--------------------------------------------------------- 71 // Arranger 72 //--------------------------------------------------------- 73 74 class Arranger : public QWidget { 75 Q_OBJECT 76 77 static QByteArray header_state; 78 79 ArrangerView* _parentWin; 80 QWidget* editor; 81 int _quant, _raster; 82 RasterizerModel *_rasterizerModel; 83 RasterLabelCombo* _rasterCombo; 84 PartCanvas* canvas; 85 ScrollScale* hscroll; 86 QScrollBar* vscroll; 87 QVBoxLayout* tlistLayout; 88 QGridLayout* egrid; 89 QHBoxLayout* bottomHLayout; 90 TList* list; 91 Header* header; 92 MTScale* time; 93 SpinBox* lenEntry; 94 QToolButton* gridOnButton; 95 bool showTrackinfoFlag; 96 TrackInfoWidget* trackInfoWidget; 97 QScrollArea* tracklistScroll; 98 QWidget* tracklist; 99 // The X origin that is applied to any canvases. 100 int _canvasXOrigin; 101 // The X mag minimum that is applied to any ScrollScale controls. 102 // Note that global midi division will also be taken into account. 103 int _minXMag; 104 // The X mag maximum that is applied to any ScrollScale controls. 105 int _maxXMag; 106 107 MusECore::Track* selected; 108 109 Splitter* split; 110 PosLabel* cursorPos; 111 SpinBox* globalTempoSpinBox; 112 SpinBox* globalPitchSpinBox; 113 114 unsigned cursVal; 115 void genTrackInfo(TrackInfoWidget*); 116 void genMidiTrackInfo(); 117 void genWaveTrackInfo(); 118 void switchInfo(int); 119 void trackInfoSongChange(MusECore::SongChangedStruct_t flags); 120 void setHeaderToolTips(); 121 void setHeaderWhatsThis(); 122 void setHeaderStatusTips(); 123 void setHeaderSizes(); 124 void initTracklistHeader(); 125 126 // Sets up a reasonable zoom minimum and/or maximum based on 127 // the current global midi division (ticks per quarter note) 128 // which has a very wide range (48 - 12288). 129 // Also sets the canvas and time scale offsets accordingly. 130 void setupHZoomRange(); 131 132 private slots: 133 void rasterChanged(int raster); 134 void songlenChanged(int); 135 void showTrackInfo(bool); 136 void trackSelectionChanged(); 137 void songChanged(MusECore::SongChangedStruct_t); 138 void setTime(unsigned); 139 void globalPitchChanged(int); 140 void globalTempoChanged(int); 141 void setTempo50(); 142 void setTempo100(); 143 void setTempo200(); 144 void gridOnChanged(bool v); 145 void verticalScrollSetYpos(unsigned); 146 void horizontalZoom(bool zoom_in, const QPoint& glob_pos); 147 void horizontalZoom(int mag, const QPoint& glob_pos); 148 void updateTracklist(); 149 150 signals: 151 void editPart(MusECore::Track*); 152 void dropSongFile(const QString&); 153 void dropMidiFile(const QString&); 154 void startEditor(MusECore::PartList*, int); 155 void toolChanged(int); 156 void setUsedTool(int); 157 158 159 protected: 160 virtual void keyPressEvent(QKeyEvent* event); 161 162 public slots: 163 void dclickPart(MusECore::Track*); 164 void setTool(int); 165 void updateTrackInfo(MusECore::SongChangedStruct_t flags); 166 void configChanged(); 167 void controllerChanged(MusECore::Track *t, int ctrlId); 168 void focusCanvas(); 169 170 public: 171 enum { CMD_CUT_PART, CMD_COPY_PART, CMD_COPY_PART_IN_RANGE, CMD_PASTE_PART, CMD_PASTE_CLONE_PART, 172 CMD_PASTE_PART_TO_TRACK, CMD_PASTE_CLONE_PART_TO_TRACK, CMD_PASTE_DIALOG, CMD_INSERT_EMPTYMEAS }; 173 174 const int arrangerTools = PointerTool | PencilTool | RubberTool | CutTool | GlueTool | MuteTool | 175 AutomationTool | PanTool | ZoomTool; 176 177 struct custom_col_t 178 { 179 enum affected_pos_t {AFFECT_BEGIN, AFFECT_CPOS}; 180 181 int ctrl; 182 QString name; 183 affected_pos_t affected_pos; 184 185 custom_col_t(int c, QString n, affected_pos_t a=AFFECT_BEGIN) 186 { 187 ctrl=c; 188 name=n; 189 affected_pos=a; 190 } 191 }; 192 static std::vector<custom_col_t> custom_columns; 193 194 Arranger(ArrangerView* parent, const char* name = 0); 195 getCanvas()196 PartCanvas* getCanvas() { return canvas; } 197 void reset(); 198 199 void writeStatus(int level, MusECore::Xml&); 200 void readStatus(MusECore::Xml&); 201 void writeConfiguration(int level, MusECore::Xml&); 202 static void readConfiguration(MusECore::Xml&); 203 static void writeCustomColumns(int level, MusECore::Xml&); 204 static void readCustomColumns(MusECore::Xml&); 205 static custom_col_t readOneCustomColumn(MusECore::Xml&); 206 curTrack()207 MusECore::Track* curTrack() const { return selected; } 208 void cmd(int); 209 bool isSingleSelection() const; 210 int selectionSize() const; 211 bool itemsAreSelected() const; 212 void setGlobalTempo(int); 213 void clear(); 214 void songIsClearing() const; 215 void setDefaultSplitterSizes(); 216 void updateHeaderCustomColumns(); 217 void toggleTrackInfo(); 218 void storeSplitterSizes(); 219 cursorValue()220 unsigned cursorValue() { return cursVal; } 221 parentWin()222 ArrangerView* parentWin() const { return _parentWin; } 223 224 int rasterVal() const; 225 bool setRasterVal(int); 226 227 int currentPartColorIndex() const; 228 getTrackList()229 TList *getTrackList() { return list; } 230 }; 231 232 } // namespace MusEGui 233 234 #endif 235 236