Chris@127: 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@127: #ifndef _PANE_H_ Chris@127: #define _PANE_H_ Chris@127: Chris@127: #include Chris@127: #include Chris@127: Chris@127: #include "base/ZoomConstraint.h" Chris@128: #include "View.h" Chris@127: #include "base/Selection.h" Chris@127: Chris@127: class QWidget; Chris@127: class QPaintEvent; Chris@127: class Layer; Chris@133: class Thumbwheel; Chris@172: class Panner; Chris@189: class NotifyingPushButton; Chris@282: class KeyReference; Chris@127: Chris@127: class Pane : public View Chris@127: { Chris@127: Q_OBJECT Chris@127: Chris@127: public: Chris@127: Pane(QWidget *parent = 0); Chris@127: virtual QString getPropertyContainerIconName() const { return "pane"; } Chris@127: Chris@127: virtual bool shouldIlluminateLocalFeatures(const Layer *layer, Chris@127: QPoint &pos) const; Chris@127: virtual bool shouldIlluminateLocalSelection(QPoint &pos, Chris@127: bool &closeToLeft, Chris@127: bool &closeToRight) const; Chris@127: Chris@127: void setCentreLineVisible(bool visible); Chris@127: bool getCentreLineVisible() const { return m_centreLineVisible; } Chris@127: Chris@222: virtual size_t getFirstVisibleFrame() const; Chris@222: Chris@276: virtual size_t getVerticalScaleWidth() const; Chris@276: Chris@229: virtual QImage *toNewImage(size_t f0, size_t f1); Chris@229: virtual QImage *toNewImage() { return View::toNewImage(); } Chris@229: virtual QSize getImageSize(size_t f0, size_t f1); Chris@229: virtual QSize getImageSize() { return View::getImageSize(); } Chris@227: Chris@127: virtual QString toXmlString(QString indent = "", Chris@127: QString extraAttributes = "") const; Chris@127: Chris@282: static void registerShortcuts(KeyReference &kr); Chris@282: Chris@127: signals: Chris@127: void paneInteractedWith(); Chris@127: void rightButtonMenuRequested(QPoint position); Chris@312: void dropAccepted(QStringList uriList); Chris@312: void dropAccepted(QString text); Chris@127: Chris@127: public slots: Chris@127: virtual void toolModeChanged(); Chris@133: virtual void zoomWheelsEnabledChanged(); Chris@222: virtual void viewZoomLevelChanged(View *v, unsigned long z, bool locked); Chris@127: Chris@132: virtual void horizontalThumbwheelMoved(int value); Chris@132: virtual void verticalThumbwheelMoved(int value); Chris@133: virtual void verticalZoomChanged(); Chris@174: virtual void verticalPannerMoved(float x, float y, float w, float h); Chris@188: virtual void editVerticalPannerExtents(); Chris@133: Chris@133: virtual void propertyContainerSelected(View *, PropertyContainer *pc); Chris@132: Chris@189: void mouseEnteredWidget(); Chris@189: void mouseLeftWidget(); Chris@189: Chris@127: protected: Chris@127: virtual void paintEvent(QPaintEvent *e); Chris@127: virtual void mousePressEvent(QMouseEvent *e); Chris@127: virtual void mouseReleaseEvent(QMouseEvent *e); Chris@127: virtual void mouseMoveEvent(QMouseEvent *e); Chris@127: virtual void mouseDoubleClickEvent(QMouseEvent *e); Chris@290: virtual void enterEvent(QEvent *e); Chris@127: virtual void leaveEvent(QEvent *e); Chris@127: virtual void wheelEvent(QWheelEvent *e); Chris@133: virtual void resizeEvent(QResizeEvent *e); Chris@312: virtual void dragEnterEvent(QDragEnterEvent *e); Chris@312: virtual void dropEvent(QDropEvent *e); Chris@127: Chris@261: void drawVerticalScale(QRect r, Layer *, QPainter &); Chris@261: void drawFeatureDescription(Layer *, QPainter &); Chris@277: void drawCentreLine(int, QPainter &, bool omitLine); Chris@261: void drawDurationAndRate(QRect, const Model *, int, QPainter &); Chris@261: void drawLayerNames(QRect, QPainter &); Chris@261: void drawEditingSelection(QPainter &); Chris@261: Chris@229: virtual bool render(QPainter &paint, int x0, size_t f0, size_t f1); Chris@229: Chris@127: Selection getSelectionAt(int x, bool &closeToLeft, bool &closeToRight) const; Chris@127: Chris@127: bool editSelectionStart(QMouseEvent *e); Chris@127: bool editSelectionDrag(QMouseEvent *e); Chris@127: bool editSelectionEnd(QMouseEvent *e); Chris@127: bool selectionIsBeingEdited() const; Chris@127: Chris@133: void updateHeadsUpDisplay(); Chris@174: void updateVerticalPanner(); Chris@174: Chris@174: bool canTopLayerMoveVertical(); Chris@174: bool getTopLayerDisplayExtents(float &valueMin, float &valueMax, Chris@188: float &displayMin, float &displayMax, Chris@188: QString *unit = 0); Chris@174: bool setTopLayerDisplayExtents(float displayMin, float displayMax); Chris@174: Chris@174: void dragTopLayer(QMouseEvent *e); Chris@174: void dragExtendSelection(QMouseEvent *e); Chris@174: void zoomToRegion(int x0, int y0, int x1, int y1); Chris@189: void updateContextHelp(const QPoint *pos); Chris@259: void edgeScrollMaybe(int x); Chris@133: Chris@127: bool m_identifyFeatures; Chris@127: QPoint m_identifyPoint; Chris@127: QPoint m_clickPos; Chris@127: QPoint m_mousePos; Chris@127: bool m_clickedInRange; Chris@127: bool m_shiftPressed; Chris@127: bool m_ctrlPressed; Chris@266: Chris@127: bool m_navigating; Chris@127: bool m_resizing; Chris@127: size_t m_dragCentreFrame; Chris@136: float m_dragStartMinValue; Chris@127: bool m_centreLineVisible; Chris@127: size_t m_selectionStartFrame; Chris@127: Selection m_editingSelection; Chris@127: int m_editingSelectionEdge; Chris@222: mutable int m_scaleWidth; Chris@133: Chris@150: enum DragMode { Chris@150: UnresolvedDrag, Chris@150: VerticalDrag, Chris@150: HorizontalDrag, Chris@150: FreeDrag Chris@150: }; Chris@150: DragMode m_dragMode; Chris@150: Chris@133: QWidget *m_headsUpDisplay; Chris@172: Panner *m_vpan; Chris@133: Thumbwheel *m_hthumb; Chris@133: Thumbwheel *m_vthumb; Chris@189: NotifyingPushButton *m_reset; Chris@262: Chris@290: bool m_mouseInWidget; Chris@290: Chris@267: static QCursor *m_measureCursor1; Chris@267: static QCursor *m_measureCursor2; Chris@127: }; Chris@127: Chris@127: #endif Chris@127: