Chris@127: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@127: Chris@127: /* Chris@127: Sonic Visualiser Chris@127: An audio file viewer and annotation editor. Chris@127: Centre for Digital Music, Queen Mary, University of London. Chris@182: This file copyright 2006 Chris Cannam and QMUL. Chris@127: Chris@127: This program is free software; you can redistribute it and/or Chris@127: modify it under the terms of the GNU General Public License as Chris@127: published by the Free Software Foundation; either version 2 of the Chris@127: License, or (at your option) any later version. See the file Chris@127: COPYING included with this distribution for more information. Chris@127: */ Chris@127: Chris@1270: #ifndef SV_PANESTACK_H Chris@1270: #define SV_PANESTACK_H Chris@127: Chris@127: #include Chris@127: Chris@323: #include Chris@323: Chris@908: #include "base/BaseTypes.h" Chris@908: Chris@127: class QWidget; Chris@127: class QLabel; Chris@127: class QStackedWidget; Chris@1447: class QVBoxLayout; Chris@127: class QSplitter; Chris@495: class QGridLayout; Chris@605: class QPushButton; Chris@127: class View; Chris@127: class Pane; Chris@127: class Layer; Chris@127: class ViewManager; Chris@127: class PropertyContainer; Chris@127: class PropertyStack; Chris@867: class AlignmentView; Chris@127: Chris@127: class PaneStack : public QFrame Chris@127: { Chris@127: Q_OBJECT Chris@127: Chris@127: public: Chris@1526: /// These options are for things that must be set on construction, Chris@1526: /// and can't be changed afterwards Chris@1526: enum class Option { Chris@1526: Default = 0x0, Chris@1526: NoUserResize = 0x1, // Suppress resize handles, auto-size only Chris@1526: NoPropertyStacks = 0x2, // Never create property stacks Chris@1526: NoPaneAccessories = 0x4, // Suppress current-pane and close button Chris@1526: NoCloseOnFirstPane = 0x8, // Omit close button from the top pane Chris@1526: ShowAlignmentViews = 0x10 // Include AlignmentViews between panes Chris@1526: }; Chris@1526: typedef int Options; Chris@1526: Chris@1447: PaneStack(QWidget *parent, Chris@1526: ViewManager *viewManager, Chris@1526: Options options = 0); Chris@127: Chris@1526: Pane *addPane(); // I own the returned value Chris@127: void deletePane(Pane *pane); // Deletes the pane, but _not_ its layers Chris@127: Chris@127: int getPaneCount() const; // Returns only count of visible panes Chris@127: Pane *getPane(int n); // Of visible panes; I own the returned value Chris@277: int getPaneIndex(Pane *pane); // so getPane(index)==pane; -1 if absent Chris@127: Chris@127: void hidePane(Pane *pane); // Also removes pane from getPane/getPaneCount Chris@127: void showPane(Pane *pane); // Returns pane to getPane/getPaneCount Chris@127: Chris@127: int getHiddenPaneCount() const; Chris@127: Pane *getHiddenPane(int n); // I own the returned value Chris@127: Chris@127: void setCurrentPane(Pane *pane); Chris@127: void setCurrentLayer(Pane *pane, Layer *layer); Chris@127: Pane *getCurrentPane(); Chris@127: Chris@1526: /// Runtime-switchable layout style for property stacks Chris@127: enum LayoutStyle { Chris@1526: HiddenPropertyStacksLayout = 0, Chris@127: SinglePropertyStackLayout = 1, Chris@127: PropertyStackPerPaneLayout = 2 Chris@127: }; Chris@127: Chris@127: LayoutStyle getLayoutStyle() const { return m_layoutStyle; } Chris@127: void setLayoutStyle(LayoutStyle style); Chris@127: Chris@235: void setPropertyStackMinWidth(int mw); Chris@235: Chris@320: void sizePanesEqually(); Chris@320: Chris@127: signals: Chris@127: void currentPaneChanged(Pane *pane); Chris@127: void currentLayerChanged(Pane *pane, Layer *layer); Chris@1582: void paneRightButtonMenuRequested(Pane *pane, QPoint position); Chris@1582: void panePropertiesRightButtonMenuRequested(Pane *, QPoint); Chris@1582: void layerPropertiesRightButtonMenuRequested(Pane *, Layer *, QPoint); Chris@363: void propertyStacksResized(int width); Chris@180: void propertyStacksResized(); Chris@189: void contextHelpChanged(const QString &); Chris@127: Chris@271: void paneAdded(Pane *pane); Chris@271: void paneAdded(); Chris@319: void paneHidden(Pane *pane); Chris@319: void paneHidden(); Chris@271: void paneAboutToBeDeleted(Pane *pane); Chris@271: void paneDeleted(); Chris@271: Chris@312: void dropAccepted(Pane *pane, QStringList uriList); Chris@312: void dropAccepted(Pane *pane, QString text); Chris@312: Chris@323: void paneDeleteButtonClicked(Pane *pane); Chris@323: Chris@908: void doubleClickSelectInvoked(sv_frame_t frame); Chris@716: Chris@127: public slots: Chris@127: void propertyContainerAdded(PropertyContainer *); Chris@127: void propertyContainerRemoved(PropertyContainer *); Chris@127: void propertyContainerSelected(View *client, PropertyContainer *); Chris@1582: void propertyContainerContextMenuRequested(View *, PropertyContainer *, Chris@1582: QPoint); Chris@190: void viewSelected(View *v); Chris@127: void paneInteractedWith(); Chris@127: void rightButtonMenuRequested(QPoint); Chris@312: void paneDropAccepted(QStringList); Chris@312: void paneDropAccepted(QString); Chris@323: void paneDeleteButtonClicked(); Chris@500: void indicatorClicked(); Chris@127: Chris@127: protected: Chris@127: Pane *m_currentPane; Chris@127: Chris@127: struct PaneRec Chris@127: { Chris@1266: Pane *pane; Chris@1266: QWidget *propertyStack; Chris@867: QPushButton *xButton; Chris@1266: QLabel *currentIndicator; Chris@867: QFrame *frame; Chris@867: QGridLayout *layout; Chris@867: AlignmentView *alignmentView; Chris@127: }; Chris@127: Chris@127: std::vector m_panes; Chris@127: std::vector m_hiddenPanes; Chris@127: Chris@1526: int m_options; Chris@1526: QSplitter *m_splitter; // constitutes the stack in default mode Chris@1526: QWidget *m_autoResizeStack; // constitutes the stack in NoUserResize mode Chris@1447: QVBoxLayout *m_autoResizeLayout; Chris@1447: Chris@127: QStackedWidget *m_propertyStackStack; Chris@127: Chris@127: ViewManager *m_viewManager; // I don't own this Chris@235: int m_propertyStackMinWidth; Chris@127: void sizePropertyStacks(); Chris@127: Chris@605: void showOrHidePaneAccessories(); Chris@605: Chris@867: void unlinkAlignmentViews(); Chris@867: void relinkAlignmentViews(); Chris@867: Chris@127: LayoutStyle m_layoutStyle; Chris@127: }; Chris@127: Chris@127: #endif Chris@127: