1 //========================================================= 2 // MusE 3 // Linux Music Editor 4 // trackinfo_layout.h 5 // (C) Copyright 2016 Tim E. Real (terminator356 on sourceforge) 6 // 7 // This program is free software; you can redistribute it and/or 8 // modify it under the terms of the GNU General Public License 9 // as published by the Free Software Foundation; version 2 of 10 // the License, or (at your option) any later version. 11 // 12 // This program is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 // GNU General Public License for more details. 16 // 17 // You should have received a copy of the GNU General Public License 18 // along with this program; if not, write to the Free Software 19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 // 21 //========================================================= 22 23 #ifndef __TRACKINFO_LAYOUT_H__ 24 #define __TRACKINFO_LAYOUT_H__ 25 26 #include <QWidget> 27 #include <QLayout> 28 #include <QGridLayout> 29 #include <QHBoxLayout> 30 31 class QLayoutItem; 32 class QSize; 33 class QRect; 34 35 namespace MusEGui { 36 37 class Splitter; 38 class ScrollBar; 39 class WidgetStack; 40 //class CompactToolButton; 41 42 //--------------------------------------------------------- 43 // TrackInfoLayout 44 // For laying out a widget stack and scrollbar which always appears 45 // to the right of the stack instead of intruding into its space. 46 // An optional Splitter will be resized when the scrollbar appears. 47 //--------------------------------------------------------- 48 49 class TrackInfoLayout : public QHBoxLayout 50 { 51 Q_OBJECT 52 53 bool _inSetGeometry; 54 WidgetStack* _stack; 55 ScrollBar* _sb; 56 QLayoutItem* _stackLi; 57 QLayoutItem* _sbLi; 58 59 bool _sbShowPending; 60 61 // This is not actually in the layout, but used and/or adjusted anyway. 62 Splitter* _splitter; 63 64 public: 65 TrackInfoLayout(QWidget *parent, WidgetStack* stack, ScrollBar* sb, Splitter* splitter = 0); 66 virtual ~TrackInfoLayout(); 67 68 virtual QSize sizeHint() const; 69 // virtual QSize minimumSize() const; 70 // virtual QSize maximumSize() const; 71 72 virtual void setGeometry(const QRect &rect); 73 }; 74 75 //--------------------------------------------------------- 76 // TrackInfoWidget 77 // Widget for containing a trackinfo layout. 78 //--------------------------------------------------------- 79 80 class TrackInfoWidget : public QWidget 81 { 82 Q_OBJECT 83 84 private: 85 WidgetStack* _stack; 86 ScrollBar* _scrollBar; 87 TrackInfoLayout* _trackInfoLayout; 88 89 void doResize(const QSize&); 90 void doMove(); 91 92 private slots: 93 void scrollValueChanged(int); 94 95 protected: 96 //virtual void wheelEvent(QWheelEvent* e); 97 virtual void resizeEvent(QResizeEvent*); 98 99 100 public: 101 TrackInfoWidget(QWidget* parent = 0, Qt::WindowFlags f = Qt::Widget); 102 103 // Wrappers/catchers for stack functions: 104 void raiseWidget(int idx); 105 void addWidget(QWidget* w, unsigned int idx); 106 QWidget* getWidget(unsigned int idx); 107 QWidget* visibleWidget() const; 108 int curIdx() const; 109 }; 110 111 } 112 113 #endif 114 115