1 //========================================================= 2 // MusE 3 // Linux Music Editor 4 // Copyright (C) 1999-2011 by Werner Schweer and others 5 // 6 // compact_patch_edit.h 7 // (C) Copyright 2015-2016 Tim E. Real (terminator356 on sourceforge) 8 // 9 // This program is free software; you can redistribute it and/or 10 // modify it under the terms of the GNU General Public License 11 // as published by the Free Software Foundation; version 2 of 12 // the License, or (at your option) any later version. 13 // 14 // This program is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 // GNU General Public License for more details. 18 // 19 // You should have received a copy of the GNU General Public License 20 // along with this program; if not, write to the Free Software 21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 // 23 //========================================================= 24 25 #ifndef __COMPACT_PATCH_EDIT_H__ 26 #define __COMPACT_PATCH_EDIT_H__ 27 28 #include <QFrame> 29 30 class QMouseEvent; 31 32 namespace MusEGui { 33 34 class ElidedLabel; 35 class LCDPatchEdit; 36 37 //--------------------------------------------------------- 38 // CompactPatchEdit 39 //--------------------------------------------------------- 40 41 class CompactPatchEdit : public QFrame 42 { 43 Q_OBJECT 44 45 Q_PROPERTY( bool style3d READ style3d WRITE setStyle3d ) 46 Q_PROPERTY( int radius READ radius WRITE setRadius ) 47 48 bool _style3d; 49 int _radius; 50 51 public: 52 enum ReadoutOrientation { ReadoutHorizontal = 0, ReadoutVertical }; 53 54 private: 55 ReadoutOrientation _orient; 56 bool _showPatchLabel; 57 int _maxAliasedPointSize; 58 int _id; 59 int _currentPatch; 60 LCDPatchEdit* _patchEdit; 61 ElidedLabel* _patchNameLabel; 62 63 private slots: 64 void patchEditValueChanged(int val, int id); 65 void patchEditDoubleClicked(QPoint p, int id, Qt::MouseButtons buttons, Qt::KeyboardModifiers keys); 66 void patchEditRightClicked(QPoint p, int id); 67 void patchNamePressed(QPoint p, int id, Qt::MouseButtons buttons, Qt::KeyboardModifiers keys); 68 void patchNameReturnPressed(QPoint p, int id, Qt::KeyboardModifiers keys); 69 70 // protected: 71 // virtual void keyPressEvent(QKeyEvent*); 72 73 signals: 74 void patchValueRightClicked(QPoint p, int id); 75 void patchNameClicked(QPoint p, int id); 76 void patchNameRightClicked(QPoint p, int id); 77 void valueChanged(int value, int id); 78 79 public: 80 CompactPatchEdit(QWidget *parent, const char *name = 0, 81 QColor fillColor = QColor()); 82 83 virtual ~CompactPatchEdit(); 84 85 static QSize getMinimumSizeHint(const QFontMetrics& fm, 86 Qt::Orientation orient = Qt::Vertical, 87 int xMargin = 0, 88 int yMargin = 0); 89 id()90 int id() const { return _id; } setId(int i)91 void setId(int i) { _id = i; } 92 93 int value() const; 94 void setValue(int v); 95 void setLastValidValue(int v); 96 void setLastValidBytes(int hbank, int lbank, int prog); 97 98 // Sets up tabbing for the entire patch edit. 99 // Accepts a previousWidget which can be null and returns the last widget in the control, 100 // which allows chaining other widgets. 101 virtual QWidget* setupComponentTabbing(QWidget* previousWidget = 0); 102 103 void setReadoutOrientation(ReadoutOrientation); 104 void setShowPatchLabel(bool); 105 106 void setReadoutColor(const QColor& c); 107 void setBgColor(const QColor& c); 108 void setBgActiveColor(const QColor& c); 109 void setBorderColor(const QColor& c); 110 void setBorderColorPatchEdit(const QColor& c); 111 void setFontColor(const QColor& c); 112 void setFontActiveColor(const QColor& c); 113 void setStyle3d(const bool s); 114 void setRadius(const int r); 115 style3d()116 bool style3d() const { return _style3d; } 117 // void setStyle3d(const bool style3d) { _style3d = style3d; update(); } radius()118 int radius() const { return _radius; } 119 // void setRadius(const int radius) { _radius = radius; update(); } 120 121 // At what point size to switch from aliased text to non-aliased text. Zero means always use anti-aliasing. 122 // Here in CompactPatchEdit, this only affects the CompactSliders so far, not the patch label. 123 // If -1, no value has been set and default is each widget's setting. maxAliasedPointSize()124 int maxAliasedPointSize() const { return _maxAliasedPointSize; } 125 // Sets at what point size to switch from aliased text (brighter, crisper but may look too jagged and unreadable with some fonts) 126 // to non-aliased text (dimmer, fuzzier but looks better). Zero means always use anti-aliasing. Default is each widget's setting. 127 // Here in CompactPatchEdit, this only affects the CompactSliders so far, not the patch label. 128 void setMaxAliasedPointSize(int sz); 129 130 QString patchName() const; 131 void setPatchName(const QString& patchName); 132 // Sets the off state. 133 void setPatchNameOff(bool v); 134 135 //virtual QSize sizeHint() const; 136 }; 137 138 } // namespace MusEGui 139 140 #endif 141