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@806: virtual int getFirstVisibleFrame() const; Chris@222: Chris@806: virtual int getVerticalScaleWidth() const; Chris@276: Chris@806: virtual QImage *toNewImage(int f0, int f1); Chris@229: virtual QImage *toNewImage() { return View::toNewImage(); } Chris@806: virtual QSize getImageSize(int f0, int f1); Chris@229: virtual QSize getImageSize() { return View::getImageSize(); } Chris@227: Chris@316: virtual void toXml(QTextStream &stream, QString indent = "", Chris@316: QString extraAttributes = "") const; Chris@127: Chris@282: static void registerShortcuts(KeyReference &kr); Chris@282: matthiasm@822: enum PaneType { matthiasm@822: Normal = 0, matthiasm@822: TonyMain = 1, matthiasm@822: TonySelection = 2 matthiasm@822: }; matthiasm@822: 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@806: void doubleClickSelectInvoked(int frame); Chris@730: void regionOutlined(QRect rect); Chris@127: Chris@127: public slots: Chris@127: virtual void toolModeChanged(); Chris@133: virtual void zoomWheelsEnabledChanged(); Chris@806: virtual void viewZoomLevelChanged(View *v, int z, bool locked); Chris@320: virtual void modelAlignmentCompletionChanged(); 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@437: virtual void layerParametersChanged(); Chris@437: Chris@133: virtual void propertyContainerSelected(View *, PropertyContainer *pc); Chris@132: Chris@730: void zoomToRegion(QRect r); Chris@730: Chris@189: void mouseEnteredWidget(); Chris@189: void mouseLeftWidget(); Chris@189: Chris@802: protected slots: Chris@802: void playbackScheduleTimerElapsed(); Chris@802: 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@826: void wheelVertical(int sign, Qt::KeyboardModifiers); Chris@826: void wheelHorizontal(int sign, Qt::KeyboardModifiers); Chris@826: void wheelHorizontalFine(int pixels, Qt::KeyboardModifiers); Chris@826: Chris@261: void drawVerticalScale(QRect r, Layer *, QPainter &); Chris@261: void drawFeatureDescription(Layer *, QPainter &); Chris@277: void drawCentreLine(int, QPainter &, bool omitLine); Chris@759: void drawModelTimeExtents(QRect, QPainter &, const Model *); Chris@261: void drawDurationAndRate(QRect, const Model *, int, QPainter &); Chris@326: void drawWorkTitle(QRect, QPainter &, const Model *); Chris@261: void drawLayerNames(QRect, QPainter &); Chris@261: void drawEditingSelection(QPainter &); Chris@326: void drawAlignmentStatus(QRect, QPainter &, const Model *, bool down); Chris@261: Chris@806: virtual bool render(QPainter &paint, int x0, int f0, int 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@189: void updateContextHelp(const QPoint *pos); Chris@259: void edgeScrollMaybe(int x); Chris@133: Chris@753: Layer *getTopFlexiNoteLayer(); Chris@753: Chris@802: void schedulePlaybackFrameMove(int frame); Chris@802: 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@510: bool m_altPressed; Chris@266: Chris@127: bool m_navigating; Chris@127: bool m_resizing; Chris@343: bool m_editing; Chris@343: bool m_releasing; Chris@806: int m_dragCentreFrame; Chris@136: float m_dragStartMinValue; Chris@127: bool m_centreLineVisible; Chris@806: int m_selectionStartFrame; Chris@127: Selection m_editingSelection; Chris@127: int m_editingSelectionEdge; Chris@222: mutable int m_scaleWidth; Chris@133: Chris@826: int m_pendingWheelAngle; Chris@826: 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@343: DragMode updateDragMode(DragMode currentMode, Chris@343: QPoint origin, Chris@343: QPoint currentPoint, Chris@343: bool canMoveHorizontal, Chris@343: bool canMoveVertical, Chris@343: bool resistHorizontal, Chris@343: bool resistVertical); Chris@343: 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@802: bool m_playbackFrameMoveScheduled; Chris@802: int m_playbackFrameMoveTo; Chris@802: Chris@267: static QCursor *m_measureCursor1; Chris@267: static QCursor *m_measureCursor2; Chris@127: }; Chris@127: Chris@127: #endif Chris@127: