annotate view/Pane.h @ 1522:d5ef91dc2ea7

Merge from branch time-frequency-boxes
author Chris Cannam
date Wed, 25 Sep 2019 13:48:04 +0100
parents 235e08aa2d5d
children 4f8c72adbf43
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@127 33
Chris@127 34 class Pane : public View
Chris@127 35 {
Chris@127 36 Q_OBJECT
Chris@127 37
Chris@127 38 public:
Chris@127 39 Pane(QWidget *parent = 0);
Chris@1202 40 virtual QString getPropertyContainerIconName() const override { return "pane"; }
Chris@127 41
Chris@127 42 virtual bool shouldIlluminateLocalFeatures(const Layer *layer,
Chris@1266 43 QPoint &pos) const override;
Chris@127 44 virtual bool shouldIlluminateLocalSelection(QPoint &pos,
Chris@1266 45 bool &closeToLeft,
Chris@1266 46 bool &closeToRight) const override;
Chris@127 47
Chris@127 48 void setCentreLineVisible(bool visible);
Chris@127 49 bool getCentreLineVisible() const { return m_centreLineVisible; }
Chris@127 50
Chris@1202 51 virtual sv_frame_t getFirstVisibleFrame() const override;
Chris@222 52
Chris@1202 53 int getVerticalScaleWidth() const;
Chris@276 54
Chris@1202 55 virtual QImage *renderToNewImage() override {
Chris@1202 56 return View::renderToNewImage();
Chris@1202 57 }
Chris@1202 58
Chris@1202 59 virtual QImage *renderPartToNewImage(sv_frame_t f0, sv_frame_t f1) override;
Chris@1202 60
Chris@1202 61 virtual QSize getRenderedImageSize() override {
Chris@1202 62 return View::getRenderedImageSize();
Chris@1202 63 }
Chris@1202 64
Chris@1202 65 virtual QSize getRenderedPartImageSize(sv_frame_t f0, sv_frame_t f1) override;
Chris@227 66
Chris@316 67 virtual void toXml(QTextStream &stream, QString indent = "",
Chris@1202 68 QString extraAttributes = "") const override;
Chris@127 69
Chris@282 70 static void registerShortcuts(KeyReference &kr);
Chris@282 71
matthiasm@822 72 enum PaneType {
matthiasm@822 73 Normal = 0,
matthiasm@822 74 TonyMain = 1,
matthiasm@822 75 TonySelection = 2
matthiasm@822 76 };
matthiasm@822 77
Chris@127 78 signals:
Chris@127 79 void paneInteractedWith();
Chris@127 80 void rightButtonMenuRequested(QPoint position);
Chris@312 81 void dropAccepted(QStringList uriList);
Chris@312 82 void dropAccepted(QString text);
Chris@908 83 void doubleClickSelectInvoked(sv_frame_t frame);
Chris@730 84 void regionOutlined(QRect rect);
Chris@127 85
Chris@127 86 public slots:
cannam@1206 87 // view slots
cannam@1206 88 virtual void toolModeChanged() override;
cannam@1206 89 virtual void zoomWheelsEnabledChanged() override;
Chris@1326 90 virtual void viewZoomLevelChanged(View *, ZoomLevel, bool locked) override;
Chris@1481 91 virtual void modelAlignmentCompletionChanged(ModelId) override;
Chris@127 92
cannam@1206 93 // local slots, not overrides
Chris@132 94 virtual void horizontalThumbwheelMoved(int value);
Chris@132 95 virtual void verticalThumbwheelMoved(int value);
Chris@133 96 virtual void verticalZoomChanged();
Chris@174 97 virtual void verticalPannerMoved(float x, float y, float w, float h);
Chris@188 98 virtual void editVerticalPannerExtents();
Chris@133 99
cannam@1206 100 virtual void layerParametersChanged() override;
Chris@437 101
cannam@1206 102 virtual void propertyContainerSelected(View *, PropertyContainer *pc) override;
Chris@132 103
Chris@730 104 void zoomToRegion(QRect r);
Chris@730 105
Chris@189 106 void mouseEnteredWidget();
Chris@189 107 void mouseLeftWidget();
Chris@189 108
Chris@1519 109 bool getTopLayerDisplayExtents(double &valueMin, double &valueMax,
Chris@1519 110 double &displayMin, double &displayMax,
Chris@1519 111 QString *unit = 0);
Chris@1519 112
Chris@802 113 protected slots:
Chris@802 114 void playbackScheduleTimerElapsed();
Chris@802 115
Chris@127 116 protected:
cannam@1206 117 virtual void paintEvent(QPaintEvent *e) override;
cannam@1206 118 virtual void mousePressEvent(QMouseEvent *e) override;
cannam@1206 119 virtual void mouseReleaseEvent(QMouseEvent *e) override;
cannam@1206 120 virtual void mouseMoveEvent(QMouseEvent *e) override;
cannam@1206 121 virtual void mouseDoubleClickEvent(QMouseEvent *e) override;
cannam@1206 122 virtual void enterEvent(QEvent *e) override;
cannam@1206 123 virtual void leaveEvent(QEvent *e) override;
cannam@1206 124 virtual void wheelEvent(QWheelEvent *e) override;
cannam@1206 125 virtual void resizeEvent(QResizeEvent *e) override;
cannam@1206 126 virtual void dragEnterEvent(QDragEnterEvent *e) override;
cannam@1206 127 virtual void dropEvent(QDropEvent *e) override;
Chris@127 128
Chris@826 129 void wheelVertical(int sign, Qt::KeyboardModifiers);
Chris@826 130 void wheelHorizontal(int sign, Qt::KeyboardModifiers);
Chris@826 131 void wheelHorizontalFine(int pixels, Qt::KeyboardModifiers);
Chris@826 132
Chris@261 133 void drawVerticalScale(QRect r, Layer *, QPainter &);
Chris@261 134 void drawFeatureDescription(Layer *, QPainter &);
Chris@908 135 void drawCentreLine(sv_samplerate_t, QPainter &, bool omitLine);
Chris@1481 136 void drawModelTimeExtents(QRect, QPainter &, ModelId);
Chris@1481 137 void drawDurationAndRate(QRect, ModelId, sv_samplerate_t, QPainter &);
Chris@1481 138 void drawWorkTitle(QRect, QPainter &, ModelId);
Chris@261 139 void drawLayerNames(QRect, QPainter &);
Chris@261 140 void drawEditingSelection(QPainter &);
Chris@1481 141 void drawAlignmentStatus(QRect, QPainter &, ModelId, bool down);
Chris@261 142
cannam@1206 143 virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1) override;
Chris@229 144
Chris@127 145 Selection getSelectionAt(int x, bool &closeToLeft, bool &closeToRight) const;
Chris@127 146
Chris@127 147 bool editSelectionStart(QMouseEvent *e);
Chris@127 148 bool editSelectionDrag(QMouseEvent *e);
Chris@127 149 bool editSelectionEnd(QMouseEvent *e);
Chris@127 150 bool selectionIsBeingEdited() const;
Chris@127 151
Chris@133 152 void updateHeadsUpDisplay();
Chris@174 153 void updateVerticalPanner();
Chris@174 154
Chris@174 155 bool canTopLayerMoveVertical();
Chris@908 156 bool setTopLayerDisplayExtents(double displayMin, double displayMax);
Chris@174 157
Chris@174 158 void dragTopLayer(QMouseEvent *e);
Chris@174 159 void dragExtendSelection(QMouseEvent *e);
Chris@189 160 void updateContextHelp(const QPoint *pos);
Chris@259 161 void edgeScrollMaybe(int x);
Chris@133 162
Chris@753 163 Layer *getTopFlexiNoteLayer();
Chris@753 164
Chris@908 165 void schedulePlaybackFrameMove(sv_frame_t frame);
Chris@802 166
Chris@127 167 bool m_identifyFeatures;
Chris@127 168 QPoint m_identifyPoint;
Chris@127 169 QPoint m_clickPos;
Chris@127 170 QPoint m_mousePos;
Chris@127 171 bool m_clickedInRange;
Chris@127 172 bool m_shiftPressed;
Chris@127 173 bool m_ctrlPressed;
Chris@510 174 bool m_altPressed;
Chris@266 175
Chris@127 176 bool m_navigating;
Chris@127 177 bool m_resizing;
Chris@343 178 bool m_editing;
Chris@343 179 bool m_releasing;
Chris@908 180 sv_frame_t m_dragCentreFrame;
Chris@908 181 double m_dragStartMinValue;
Chris@127 182 bool m_centreLineVisible;
Chris@908 183 sv_frame_t m_selectionStartFrame;
Chris@127 184 Selection m_editingSelection;
Chris@127 185 int m_editingSelectionEdge;
Chris@222 186 mutable int m_scaleWidth;
Chris@133 187
Chris@826 188 int m_pendingWheelAngle;
Chris@826 189
Chris@150 190 enum DragMode {
Chris@150 191 UnresolvedDrag,
Chris@150 192 VerticalDrag,
Chris@150 193 HorizontalDrag,
Chris@150 194 FreeDrag
Chris@150 195 };
Chris@150 196 DragMode m_dragMode;
Chris@150 197
Chris@343 198 DragMode updateDragMode(DragMode currentMode,
Chris@343 199 QPoint origin,
Chris@343 200 QPoint currentPoint,
Chris@343 201 bool canMoveHorizontal,
Chris@343 202 bool canMoveVertical,
Chris@343 203 bool resistHorizontal,
Chris@343 204 bool resistVertical);
Chris@343 205
Chris@133 206 QWidget *m_headsUpDisplay;
Chris@172 207 Panner *m_vpan;
Chris@133 208 Thumbwheel *m_hthumb;
Chris@133 209 Thumbwheel *m_vthumb;
Chris@189 210 NotifyingPushButton *m_reset;
Chris@262 211
Chris@290 212 bool m_mouseInWidget;
Chris@290 213
Chris@802 214 bool m_playbackFrameMoveScheduled;
Chris@908 215 sv_frame_t m_playbackFrameMoveTo;
Chris@1354 216
Chris@267 217 static QCursor *m_measureCursor1;
Chris@267 218 static QCursor *m_measureCursor2;
Chris@127 219 };
Chris@127 220
Chris@127 221 #endif
Chris@127 222