annotate view/Pane.h @ 1601:4739a1b2266f

This addAction API from Qt 5.6+ is still, unfortunately, too recent for some of our builds
author Chris Cannam
date Wed, 29 Apr 2020 14:23:51 +0100
parents 0f36e0eca6b0
children
rev   line source
Chris@127 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@127 2
Chris@127 3 /*
Chris@127 4 Sonic Visualiser
Chris@127 5 An audio file viewer and annotation editor.
Chris@127 6 Centre for Digital Music, Queen Mary, University of London.
Chris@182 7 This file copyright 2006 Chris Cannam and QMUL.
Chris@127 8
Chris@127 9 This program is free software; you can redistribute it and/or
Chris@127 10 modify it under the terms of the GNU General Public License as
Chris@127 11 published by the Free Software Foundation; either version 2 of the
Chris@127 12 License, or (at your option) any later version. See the file
Chris@127 13 COPYING included with this distribution for more information.
Chris@127 14 */
Chris@127 15
Chris@1354 16 #ifndef SV_PANE_H
Chris@1354 17 #define SV_PANE_H
Chris@127 18
Chris@127 19 #include <QFrame>
Chris@127 20 #include <QPoint>
Chris@127 21
Chris@127 22 #include "base/ZoomConstraint.h"
Chris@128 23 #include "View.h"
Chris@127 24 #include "base/Selection.h"
Chris@127 25
Chris@127 26 class QWidget;
Chris@127 27 class QPaintEvent;
Chris@127 28 class Layer;
Chris@133 29 class Thumbwheel;
Chris@172 30 class Panner;
Chris@189 31 class NotifyingPushButton;
Chris@282 32 class KeyReference;
Chris@1588 33 class QMenu;
Chris@127 34
Chris@127 35 class Pane : public View
Chris@127 36 {
Chris@127 37 Q_OBJECT
Chris@127 38
Chris@127 39 public:
Chris@127 40 Pane(QWidget *parent = 0);
Chris@1588 41 virtual ~Pane();
Chris@1588 42
Chris@1202 43 virtual QString getPropertyContainerIconName() const override { return "pane"; }
Chris@127 44
Chris@127 45 virtual bool shouldIlluminateLocalFeatures(const Layer *layer,
Chris@1266 46 QPoint &pos) const override;
Chris@127 47 virtual bool shouldIlluminateLocalSelection(QPoint &pos,
Chris@1266 48 bool &closeToLeft,
Chris@1266 49 bool &closeToRight) const override;
Chris@127 50
Chris@127 51 void setCentreLineVisible(bool visible);
Chris@127 52 bool getCentreLineVisible() const { return m_centreLineVisible; }
Chris@127 53
Chris@1202 54 virtual sv_frame_t getFirstVisibleFrame() const override;
Chris@222 55
Chris@1202 56 int getVerticalScaleWidth() const;
Chris@276 57
Chris@1202 58 virtual QImage *renderToNewImage() override {
Chris@1202 59 return View::renderToNewImage();
Chris@1202 60 }
Chris@1202 61
Chris@1202 62 virtual QImage *renderPartToNewImage(sv_frame_t f0, sv_frame_t f1) override;
Chris@1202 63
Chris@1202 64 virtual QSize getRenderedImageSize() override {
Chris@1202 65 return View::getRenderedImageSize();
Chris@1202 66 }
Chris@1202 67
Chris@1202 68 virtual QSize getRenderedPartImageSize(sv_frame_t f0, sv_frame_t f1) override;
Chris@227 69
Chris@316 70 virtual void toXml(QTextStream &stream, QString indent = "",
Chris@1202 71 QString extraAttributes = "") const override;
Chris@127 72
Chris@282 73 static void registerShortcuts(KeyReference &kr);
Chris@282 74
matthiasm@822 75 enum PaneType {
matthiasm@822 76 Normal = 0,
matthiasm@822 77 TonyMain = 1,
matthiasm@822 78 TonySelection = 2
matthiasm@822 79 };
matthiasm@822 80
Chris@127 81 signals:
Chris@127 82 void paneInteractedWith();
Chris@127 83 void rightButtonMenuRequested(QPoint position);
Chris@312 84 void dropAccepted(QStringList uriList);
Chris@312 85 void dropAccepted(QString text);
Chris@908 86 void doubleClickSelectInvoked(sv_frame_t frame);
Chris@730 87 void regionOutlined(QRect rect);
Chris@127 88
Chris@127 89 public slots:
cannam@1206 90 // view slots
cannam@1206 91 virtual void toolModeChanged() override;
cannam@1206 92 virtual void zoomWheelsEnabledChanged() override;
Chris@1326 93 virtual void viewZoomLevelChanged(View *, ZoomLevel, bool locked) override;
Chris@1481 94 virtual void modelAlignmentCompletionChanged(ModelId) override;
Chris@127 95
cannam@1206 96 // local slots, not overrides
Chris@1588 97 void horizontalThumbwheelMoved(int value);
Chris@1588 98 void verticalThumbwheelMoved(int value);
Chris@1588 99 void verticalZoomChanged();
Chris@1588 100 void verticalPannerMoved(float x, float y, float w, float h);
Chris@1588 101 void verticalPannerContextMenuRequested(const QPoint &);
Chris@1588 102 void editVerticalPannerExtents();
Chris@1601 103 void resetVerticalPannerExtents();
Chris@133 104
cannam@1206 105 virtual void layerParametersChanged() override;
Chris@437 106
cannam@1206 107 virtual void propertyContainerSelected(View *, PropertyContainer *pc) override;
Chris@132 108
Chris@730 109 void zoomToRegion(QRect r);
Chris@730 110
Chris@189 111 void mouseEnteredWidget();
Chris@189 112 void mouseLeftWidget();
Chris@189 113
Chris@802 114 protected slots:
Chris@802 115 void playbackScheduleTimerElapsed();
Chris@802 116
Chris@127 117 protected:
cannam@1206 118 virtual void paintEvent(QPaintEvent *e) override;
cannam@1206 119 virtual void mousePressEvent(QMouseEvent *e) override;
cannam@1206 120 virtual void mouseReleaseEvent(QMouseEvent *e) override;
cannam@1206 121 virtual void mouseMoveEvent(QMouseEvent *e) override;
cannam@1206 122 virtual void mouseDoubleClickEvent(QMouseEvent *e) override;
cannam@1206 123 virtual void enterEvent(QEvent *e) override;
cannam@1206 124 virtual void leaveEvent(QEvent *e) override;
cannam@1206 125 virtual void wheelEvent(QWheelEvent *e) override;
cannam@1206 126 virtual void resizeEvent(QResizeEvent *e) override;
cannam@1206 127 virtual void dragEnterEvent(QDragEnterEvent *e) override;
cannam@1206 128 virtual void dropEvent(QDropEvent *e) override;
Chris@127 129
Chris@826 130 void wheelVertical(int sign, Qt::KeyboardModifiers);
Chris@826 131 void wheelHorizontal(int sign, Qt::KeyboardModifiers);
Chris@826 132 void wheelHorizontalFine(int pixels, Qt::KeyboardModifiers);
Chris@826 133
Chris@261 134 void drawVerticalScale(QRect r, Layer *, QPainter &);
Chris@261 135 void drawFeatureDescription(Layer *, QPainter &);
Chris@908 136 void drawCentreLine(sv_samplerate_t, QPainter &, bool omitLine);
Chris@1481 137 void drawModelTimeExtents(QRect, QPainter &, ModelId);
Chris@1481 138 void drawDurationAndRate(QRect, ModelId, sv_samplerate_t, QPainter &);
Chris@1481 139 void drawWorkTitle(QRect, QPainter &, ModelId);
Chris@261 140 void drawLayerNames(QRect, QPainter &);
Chris@261 141 void drawEditingSelection(QPainter &);
Chris@1481 142 void drawAlignmentStatus(QRect, QPainter &, ModelId, bool down);
Chris@261 143
cannam@1206 144 virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1) override;
Chris@229 145
Chris@127 146 Selection getSelectionAt(int x, bool &closeToLeft, bool &closeToRight) const;
Chris@127 147
Chris@127 148 bool editSelectionStart(QMouseEvent *e);
Chris@127 149 bool editSelectionDrag(QMouseEvent *e);
Chris@127 150 bool editSelectionEnd(QMouseEvent *e);
Chris@127 151 bool selectionIsBeingEdited() const;
Chris@127 152
Chris@133 153 void updateHeadsUpDisplay();
Chris@174 154 void updateVerticalPanner();
Chris@174 155
Chris@174 156 bool canTopLayerMoveVertical();
Chris@908 157 bool setTopLayerDisplayExtents(double displayMin, double displayMax);
Chris@1537 158 bool getTopLayerDisplayExtents(double &valueMin, double &valueMax,
Chris@1537 159 double &displayMin, double &displayMax,
Chris@1537 160 QString *unit = 0);
Chris@174 161
Chris@174 162 void dragTopLayer(QMouseEvent *e);
Chris@174 163 void dragExtendSelection(QMouseEvent *e);
Chris@189 164 void updateContextHelp(const QPoint *pos);
Chris@259 165 void edgeScrollMaybe(int x);
Chris@133 166
Chris@753 167 Layer *getTopFlexiNoteLayer();
Chris@753 168
Chris@908 169 void schedulePlaybackFrameMove(sv_frame_t frame);
Chris@802 170
Chris@127 171 bool m_identifyFeatures;
Chris@127 172 QPoint m_identifyPoint;
Chris@127 173 QPoint m_clickPos;
Chris@127 174 QPoint m_mousePos;
Chris@127 175 bool m_clickedInRange;
Chris@127 176 bool m_shiftPressed;
Chris@127 177 bool m_ctrlPressed;
Chris@510 178 bool m_altPressed;
Chris@266 179
Chris@127 180 bool m_navigating;
Chris@127 181 bool m_resizing;
Chris@343 182 bool m_editing;
Chris@343 183 bool m_releasing;
Chris@908 184 sv_frame_t m_dragCentreFrame;
Chris@908 185 double m_dragStartMinValue;
Chris@127 186 bool m_centreLineVisible;
Chris@908 187 sv_frame_t m_selectionStartFrame;
Chris@127 188 Selection m_editingSelection;
Chris@127 189 int m_editingSelectionEdge;
Chris@222 190 mutable int m_scaleWidth;
Chris@133 191
Chris@826 192 int m_pendingWheelAngle;
Chris@826 193
Chris@150 194 enum DragMode {
Chris@150 195 UnresolvedDrag,
Chris@150 196 VerticalDrag,
Chris@150 197 HorizontalDrag,
Chris@150 198 FreeDrag
Chris@150 199 };
Chris@150 200 DragMode m_dragMode;
Chris@150 201
Chris@343 202 DragMode updateDragMode(DragMode currentMode,
Chris@343 203 QPoint origin,
Chris@343 204 QPoint currentPoint,
Chris@343 205 bool canMoveHorizontal,
Chris@343 206 bool canMoveVertical,
Chris@343 207 bool resistHorizontal,
Chris@343 208 bool resistVertical);
Chris@343 209
Chris@133 210 QWidget *m_headsUpDisplay;
Chris@172 211 Panner *m_vpan;
Chris@133 212 Thumbwheel *m_hthumb;
Chris@133 213 Thumbwheel *m_vthumb;
Chris@189 214 NotifyingPushButton *m_reset;
Chris@1588 215 QMenu *m_lastVerticalPannerContextMenu;
Chris@262 216
Chris@290 217 bool m_mouseInWidget;
Chris@290 218
Chris@802 219 bool m_playbackFrameMoveScheduled;
Chris@908 220 sv_frame_t m_playbackFrameMoveTo;
Chris@1354 221
Chris@267 222 static QCursor *m_measureCursor1;
Chris@267 223 static QCursor *m_measureCursor2;
Chris@127 224 };
Chris@127 225
Chris@127 226 #endif
Chris@127 227