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@1354: #ifndef SV_PANE_H Chris@1354: #define SV_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@1588: class QMenu; 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@1588: virtual ~Pane(); Chris@1588: Chris@1202: virtual QString getPropertyContainerIconName() const override { return "pane"; } Chris@127: Chris@127: virtual bool shouldIlluminateLocalFeatures(const Layer *layer, Chris@1266: QPoint &pos) const override; Chris@127: virtual bool shouldIlluminateLocalSelection(QPoint &pos, Chris@1266: bool &closeToLeft, Chris@1266: bool &closeToRight) const override; Chris@127: Chris@127: void setCentreLineVisible(bool visible); Chris@127: bool getCentreLineVisible() const { return m_centreLineVisible; } Chris@127: Chris@1202: virtual sv_frame_t getFirstVisibleFrame() const override; Chris@222: Chris@1202: int getVerticalScaleWidth() const; Chris@276: Chris@1202: virtual QImage *renderToNewImage() override { Chris@1202: return View::renderToNewImage(); Chris@1202: } Chris@1202: Chris@1202: virtual QImage *renderPartToNewImage(sv_frame_t f0, sv_frame_t f1) override; Chris@1202: Chris@1202: virtual QSize getRenderedImageSize() override { Chris@1202: return View::getRenderedImageSize(); Chris@1202: } Chris@1202: Chris@1202: virtual QSize getRenderedPartImageSize(sv_frame_t f0, sv_frame_t f1) override; Chris@227: Chris@316: virtual void toXml(QTextStream &stream, QString indent = "", Chris@1202: QString extraAttributes = "") const override; 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@908: void doubleClickSelectInvoked(sv_frame_t frame); Chris@730: void regionOutlined(QRect rect); Chris@127: Chris@127: public slots: cannam@1206: // view slots cannam@1206: virtual void toolModeChanged() override; cannam@1206: virtual void zoomWheelsEnabledChanged() override; Chris@1326: virtual void viewZoomLevelChanged(View *, ZoomLevel, bool locked) override; Chris@1481: virtual void modelAlignmentCompletionChanged(ModelId) override; Chris@127: cannam@1206: // local slots, not overrides Chris@1588: void horizontalThumbwheelMoved(int value); Chris@1588: void verticalThumbwheelMoved(int value); Chris@1588: void verticalZoomChanged(); Chris@1588: void verticalPannerMoved(float x, float y, float w, float h); Chris@1588: void verticalPannerContextMenuRequested(const QPoint &); Chris@1588: void editVerticalPannerExtents(); Chris@1601: void resetVerticalPannerExtents(); Chris@133: cannam@1206: virtual void layerParametersChanged() override; Chris@437: cannam@1206: virtual void propertyContainerSelected(View *, PropertyContainer *pc) override; 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: cannam@1206: virtual void paintEvent(QPaintEvent *e) override; cannam@1206: virtual void mousePressEvent(QMouseEvent *e) override; cannam@1206: virtual void mouseReleaseEvent(QMouseEvent *e) override; cannam@1206: virtual void mouseMoveEvent(QMouseEvent *e) override; cannam@1206: virtual void mouseDoubleClickEvent(QMouseEvent *e) override; cannam@1206: virtual void enterEvent(QEvent *e) override; cannam@1206: virtual void leaveEvent(QEvent *e) override; cannam@1206: virtual void wheelEvent(QWheelEvent *e) override; cannam@1206: virtual void resizeEvent(QResizeEvent *e) override; cannam@1206: virtual void dragEnterEvent(QDragEnterEvent *e) override; cannam@1206: virtual void dropEvent(QDropEvent *e) override; 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@908: void drawCentreLine(sv_samplerate_t, QPainter &, bool omitLine); Chris@1481: void drawModelTimeExtents(QRect, QPainter &, ModelId); Chris@1481: void drawDurationAndRate(QRect, ModelId, sv_samplerate_t, QPainter &); Chris@1481: void drawWorkTitle(QRect, QPainter &, ModelId); Chris@261: void drawLayerNames(QRect, QPainter &); Chris@261: void drawEditingSelection(QPainter &); Chris@1481: void drawAlignmentStatus(QRect, QPainter &, ModelId, bool down); Chris@261: cannam@1206: virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1) override; 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@908: bool setTopLayerDisplayExtents(double displayMin, double displayMax); Chris@1537: bool getTopLayerDisplayExtents(double &valueMin, double &valueMax, Chris@1537: double &displayMin, double &displayMax, Chris@1537: QString *unit = 0); 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@908: void schedulePlaybackFrameMove(sv_frame_t 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@908: sv_frame_t m_dragCentreFrame; Chris@908: double m_dragStartMinValue; Chris@127: bool m_centreLineVisible; Chris@908: sv_frame_t 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@1588: QMenu *m_lastVerticalPannerContextMenu; Chris@262: Chris@290: bool m_mouseInWidget; Chris@290: Chris@802: bool m_playbackFrameMoveScheduled; Chris@908: sv_frame_t m_playbackFrameMoveTo; Chris@1354: Chris@267: static QCursor *m_measureCursor1; Chris@267: static QCursor *m_measureCursor2; Chris@127: }; Chris@127: Chris@127: #endif Chris@127: