annotate view/Pane.h @ 1085:179ea8a2f650 spectrogram-minor-refactor

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