annotate view/Pane.h @ 1326:97c68bffbda6 zoom

More ZoomLevel updates
author Chris Cannam
date Thu, 20 Sep 2018 10:45:24 +0100
parents a34a2a25907c
children 40b9a495a0e0
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@127 16 #ifndef _PANE_H_
Chris@127 17 #define _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;
cannam@1206 91 virtual void modelAlignmentCompletionChanged() 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@802 109 protected slots:
Chris@802 110 void playbackScheduleTimerElapsed();
Chris@802 111
Chris@127 112 protected:
cannam@1206 113 virtual void paintEvent(QPaintEvent *e) override;
cannam@1206 114 virtual void mousePressEvent(QMouseEvent *e) override;
cannam@1206 115 virtual void mouseReleaseEvent(QMouseEvent *e) override;
cannam@1206 116 virtual void mouseMoveEvent(QMouseEvent *e) override;
cannam@1206 117 virtual void mouseDoubleClickEvent(QMouseEvent *e) override;
cannam@1206 118 virtual void enterEvent(QEvent *e) override;
cannam@1206 119 virtual void leaveEvent(QEvent *e) override;
cannam@1206 120 virtual void wheelEvent(QWheelEvent *e) override;
cannam@1206 121 virtual void resizeEvent(QResizeEvent *e) override;
cannam@1206 122 virtual void dragEnterEvent(QDragEnterEvent *e) override;
cannam@1206 123 virtual void dropEvent(QDropEvent *e) override;
Chris@127 124
Chris@826 125 void wheelVertical(int sign, Qt::KeyboardModifiers);
Chris@826 126 void wheelHorizontal(int sign, Qt::KeyboardModifiers);
Chris@826 127 void wheelHorizontalFine(int pixels, Qt::KeyboardModifiers);
Chris@826 128
Chris@261 129 void drawVerticalScale(QRect r, Layer *, QPainter &);
Chris@261 130 void drawFeatureDescription(Layer *, QPainter &);
Chris@908 131 void drawCentreLine(sv_samplerate_t, QPainter &, bool omitLine);
Chris@759 132 void drawModelTimeExtents(QRect, QPainter &, const Model *);
Chris@908 133 void drawDurationAndRate(QRect, const Model *, sv_samplerate_t, QPainter &);
Chris@326 134 void drawWorkTitle(QRect, QPainter &, const Model *);
Chris@261 135 void drawLayerNames(QRect, QPainter &);
Chris@261 136 void drawEditingSelection(QPainter &);
Chris@326 137 void drawAlignmentStatus(QRect, QPainter &, const Model *, bool down);
Chris@261 138
cannam@1206 139 virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1) override;
Chris@229 140
Chris@127 141 Selection getSelectionAt(int x, bool &closeToLeft, bool &closeToRight) const;
Chris@127 142
Chris@127 143 bool editSelectionStart(QMouseEvent *e);
Chris@127 144 bool editSelectionDrag(QMouseEvent *e);
Chris@127 145 bool editSelectionEnd(QMouseEvent *e);
Chris@127 146 bool selectionIsBeingEdited() const;
Chris@127 147
Chris@133 148 void updateHeadsUpDisplay();
Chris@174 149 void updateVerticalPanner();
Chris@174 150
Chris@174 151 bool canTopLayerMoveVertical();
Chris@908 152 bool getTopLayerDisplayExtents(double &valueMin, double &valueMax,
Chris@908 153 double &displayMin, double &displayMax,
Chris@188 154 QString *unit = 0);
Chris@908 155 bool setTopLayerDisplayExtents(double displayMin, double displayMax);
Chris@174 156
Chris@174 157 void dragTopLayer(QMouseEvent *e);
Chris@174 158 void dragExtendSelection(QMouseEvent *e);
Chris@189 159 void updateContextHelp(const QPoint *pos);
Chris@259 160 void edgeScrollMaybe(int x);
Chris@133 161
Chris@753 162 Layer *getTopFlexiNoteLayer();
Chris@753 163
Chris@908 164 void schedulePlaybackFrameMove(sv_frame_t frame);
Chris@802 165
Chris@127 166 bool m_identifyFeatures;
Chris@127 167 QPoint m_identifyPoint;
Chris@127 168 QPoint m_clickPos;
Chris@127 169 QPoint m_mousePos;
Chris@127 170 bool m_clickedInRange;
Chris@127 171 bool m_shiftPressed;
Chris@127 172 bool m_ctrlPressed;
Chris@510 173 bool m_altPressed;
Chris@266 174
Chris@127 175 bool m_navigating;
Chris@127 176 bool m_resizing;
Chris@343 177 bool m_editing;
Chris@343 178 bool m_releasing;
Chris@908 179 sv_frame_t m_dragCentreFrame;
Chris@908 180 double m_dragStartMinValue;
Chris@127 181 bool m_centreLineVisible;
Chris@908 182 sv_frame_t m_selectionStartFrame;
Chris@127 183 Selection m_editingSelection;
Chris@127 184 int m_editingSelectionEdge;
Chris@222 185 mutable int m_scaleWidth;
Chris@133 186
Chris@826 187 int m_pendingWheelAngle;
Chris@826 188
Chris@150 189 enum DragMode {
Chris@150 190 UnresolvedDrag,
Chris@150 191 VerticalDrag,
Chris@150 192 HorizontalDrag,
Chris@150 193 FreeDrag
Chris@150 194 };
Chris@150 195 DragMode m_dragMode;
Chris@150 196
Chris@343 197 DragMode updateDragMode(DragMode currentMode,
Chris@343 198 QPoint origin,
Chris@343 199 QPoint currentPoint,
Chris@343 200 bool canMoveHorizontal,
Chris@343 201 bool canMoveVertical,
Chris@343 202 bool resistHorizontal,
Chris@343 203 bool resistVertical);
Chris@343 204
Chris@133 205 QWidget *m_headsUpDisplay;
Chris@172 206 Panner *m_vpan;
Chris@133 207 Thumbwheel *m_hthumb;
Chris@133 208 Thumbwheel *m_vthumb;
Chris@189 209 NotifyingPushButton *m_reset;
Chris@262 210
Chris@290 211 bool m_mouseInWidget;
Chris@290 212
Chris@802 213 bool m_playbackFrameMoveScheduled;
Chris@908 214 sv_frame_t m_playbackFrameMoveTo;
Chris@802 215
Chris@267 216 static QCursor *m_measureCursor1;
Chris@267 217 static QCursor *m_measureCursor2;
Chris@127 218 };
Chris@127 219
Chris@127 220 #endif
Chris@127 221