1 //========================================================= 2 // MusE 3 // Linux Music Editor 4 // $Id: tlist.h,v 1.8.2.5 2008/01/19 13:33:46 wschweer 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 __TLIST_H__ 25 #define __TLIST_H__ 26 27 #include "type_defs.h" 28 #include "track.h" 29 30 #include <map> 31 #include <QWidget> 32 33 34 // Forward declarations: 35 class QKeyEvent; 36 class QLineEdit; 37 class QSpinBox; 38 class QMouseEvent; 39 class QPaintEvent; 40 class QScrollBar; 41 class QWheelEvent; 42 class QMenu; 43 44 namespace MusECore { 45 class Xml; 46 class Undo; 47 } 48 49 namespace MusEGui { 50 class Header; 51 class PopupMenu; 52 53 //--------------------------------------------------------- 54 // TList 55 //--------------------------------------------------------- 56 57 class TList : public QWidget { 58 Q_OBJECT 59 60 Q_PROPERTY(bool sel3d READ sel3d WRITE setSel3d) 61 Q_PROPERTY(bool curSelBorder READ curSelBorder WRITE setCurSelBorder) 62 Q_PROPERTY(QColor curSelBorderColor READ curSelBorderColor WRITE setCurSelBorderColor) 63 64 public: 65 enum TrackColumn { 66 COL_TRACK_IDX = 0, 67 COL_INPUT_MONITOR, 68 COL_RECORD, 69 COL_MUTE, 70 COL_SOLO, 71 COL_CLASS, 72 COL_NAME, 73 COL_OPORT, 74 COL_OCHANNEL, 75 // COL_TIMELOCK, 76 COL_AUTOMATION, 77 COL_CLEF, 78 COL_CUSTOM_MIDICTRL_OFFSET, 79 COL_NONE = -1 80 }; 81 82 private: 83 bool _sel3d; 84 bool _curSelBorder; 85 QColor _curSelBorderColor; 86 87 int ypos; 88 bool editMode; 89 bool editJustFinished; 90 91 std::map<MusECore::Track*, std::map<int, int> > old_ctrl_hw_states; 92 93 QPixmap bgPixmap; // background Pixmap 94 bool resizeFlag; // true if resize cursor is shown 95 96 QMenu *addTrackMenu{}, *insertTrackMenu{}; 97 Header* header; 98 QScrollBar* _scroll; 99 QLineEdit* editor; 100 QSpinBox* chan_edit; 101 QSpinBox* ctrl_edit; 102 int ctrl_num{}; 103 unsigned ctrl_at_tick{}; 104 MusECore::Track* editTrack; 105 MusECore::Track* editAutomation{}; 106 107 108 int startY{}; 109 int curY{}; 110 int sTrack{}; 111 int dragHeight{}; 112 int dragYoff{}; 113 114 enum { NORMAL, START_DRAG, DRAG, RESIZE} mode; 115 116 virtual void paintEvent(QPaintEvent*) override; 117 virtual void mousePressEvent(QMouseEvent* event) override; 118 virtual void mouseDoubleClickEvent(QMouseEvent*) override; 119 virtual void mouseMoveEvent(QMouseEvent*) override; 120 virtual void mouseReleaseEvent(QMouseEvent*) override; 121 virtual void keyPressEvent(QKeyEvent* e) override; 122 virtual void wheelEvent(QWheelEvent* e) override; 123 virtual QSize sizeHint() const override; 124 virtual QSize minimumSizeHint() const override; 125 126 void showMidiClassPopupMenu(MusECore::Track*, int x, int y); 127 void showAudioOutPopupMenu(MusECore::Track*, int x, int y); 128 void moveSelection(int n); 129 void adjustScrollbar(); 130 void paint(const QRect& r); 131 void redraw(const QRect& r); 132 MusECore::Track* y2Track(int) const; 133 MusECore::TrackList getRecEnabledTracks(); 134 void setHeaderToolTips(); 135 PopupMenu* colorMenu(QColor c, int id, QWidget* parent); 136 void setMute(MusECore::Undo& operations, MusECore::Track *t, bool turnOff, bool state); 137 void changeTrackToType(MusECore::Track *t, MusECore::Track::TrackType trackType); 138 void editTrackName(MusECore::Track *t); 139 void setTrackChannel(MusECore::Track *t, bool isDelta, int channel, int delta, bool doAllTracks = false); 140 void incrementController(MusECore::Track* t, int controllerType, int incrementValue); 141 void addAutoMenuAction(PopupMenu* p, const MusECore::CtrlList *cl); 142 void outputAutoMenuSorted(PopupMenu* p, QList<const MusECore::CtrlList *> &); 143 144 145 protected: 146 bool event(QEvent *) override; 147 148 private slots: 149 void maybeUpdateVolatileCustomColumns(); // updates AFFECT_CPOS-columns when and only when the hwState has changed 150 void returnPressed(); 151 void chanValueFinished(); 152 void ctrlValueFinished(); 153 void instrPopupActivated(QAction*); 154 void songChanged(MusECore::SongChangedStruct_t flags); 155 void changeAutomation(QAction*); 156 void changeAutomationColor(QAction*); 157 void loadTrackDrummap(MusECore::MidiTrack*, const char* filename=NULL); 158 void loadTrackDrummapFromXML(MusECore::MidiTrack*t, MusECore::Xml &xml); 159 void saveTrackDrummap(MusECore::MidiTrack*, bool full, const char* filename=NULL); 160 void copyTrackDrummap(MusECore::MidiTrack*, bool full); 161 162 signals: 163 void keyPressExt(QKeyEvent*); 164 void redirectWheelEvent(QWheelEvent*); 165 void verticalScrollSetYpos(int ypos); 166 167 public slots: 168 void tracklistChanged(); 169 void setYPos(int); 170 void redraw(); 171 void selectTrack(MusECore::Track*, bool deselect=true); 172 void selectTrackAbove(); 173 void selectTrackBelow(); 174 void editTrackNameSlot(); 175 void muteSelectedTracksSlot(); 176 void soloSelectedTracksSlot(); 177 void volumeSelectedTracksSlot(int); 178 void panSelectedTracksSlot(int); 179 180 void setHeader(Header*); 181 182 public: 183 TList(Header*, QWidget* parent, const char* name); setScroll(QScrollBar * s)184 void setScroll(QScrollBar* s) { _scroll = s; } track()185 MusECore::Track* track() const { return editTrack; } 186 void populateAddTrack(); sel3d()187 bool sel3d() const { return _sel3d; } setSel3d(bool sel3d)188 void setSel3d(bool sel3d) { _sel3d = sel3d; } curSelBorder()189 bool curSelBorder() const { return _curSelBorder; } setCurSelBorder(bool curSelBorder)190 void setCurSelBorder(bool curSelBorder) { _curSelBorder = curSelBorder; } curSelBorderColor()191 QColor curSelBorderColor() const { return _curSelBorderColor; } setCurSelBorderColor(const QColor c)192 void setCurSelBorderColor(const QColor c) { _curSelBorderColor = c; } 193 void moveSelectedTracks(bool up, bool full); 194 }; 195 196 } // namespace MusEGui 197 198 #endif 199 200