annotate view/Pane.h @ 1597:7eb595837eaa

Fixes for mingw
author Chris Cannam
date Thu, 09 Apr 2020 17:09:11 +0100
parents 0f36e0eca6b0
children 4739a1b2266f
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@133 103
cannam@1206 104 virtual void layerParametersChanged() override;
Chris@437 105
cannam@1206 106 virtual void propertyContainerSelected(View *, PropertyContainer *pc) override;
Chris@132 107
Chris@730 108 void zoomToRegion(QRect r);
Chris@730 109
Chris@189 110 void mouseEnteredWidget();
Chris@189 111 void mouseLeftWidget();
Chris@189 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@1537 157 bool getTopLayerDisplayExtents(double &valueMin, double &valueMax,
Chris@1537 158 double &displayMin, double &displayMax,
Chris@1537 159 QString *unit = 0);
Chris@174 160
Chris@174 161 void dragTopLayer(QMouseEvent *e);
Chris@174 162 void dragExtendSelection(QMouseEvent *e);
Chris@189 163 void updateContextHelp(const QPoint *pos);
Chris@259 164 void edgeScrollMaybe(int x);
Chris@133 165
Chris@753 166 Layer *getTopFlexiNoteLayer();
Chris@753 167
Chris@908 168 void schedulePlaybackFrameMove(sv_frame_t frame);
Chris@802 169
Chris@127 170 bool m_identifyFeatures;
Chris@127 171 QPoint m_identifyPoint;
Chris@127 172 QPoint m_clickPos;
Chris@127 173 QPoint m_mousePos;
Chris@127 174 bool m_clickedInRange;
Chris@127 175 bool m_shiftPressed;
Chris@127 176 bool m_ctrlPressed;
Chris@510 177 bool m_altPressed;
Chris@266 178
Chris@127 179 bool m_navigating;
Chris@127 180 bool m_resizing;
Chris@343 181 bool m_editing;
Chris@343 182 bool m_releasing;
Chris@908 183 sv_frame_t m_dragCentreFrame;
Chris@908 184 double m_dragStartMinValue;
Chris@127 185 bool m_centreLineVisible;
Chris@908 186 sv_frame_t m_selectionStartFrame;
Chris@127 187 Selection m_editingSelection;
Chris@127 188 int m_editingSelectionEdge;
Chris@222 189 mutable int m_scaleWidth;
Chris@133 190
Chris@826 191 int m_pendingWheelAngle;
Chris@826 192
Chris@150 193 enum DragMode {
Chris@150 194 UnresolvedDrag,
Chris@150 195 VerticalDrag,
Chris@150 196 HorizontalDrag,
Chris@150 197 FreeDrag
Chris@150 198 };
Chris@150 199 DragMode m_dragMode;
Chris@150 200
Chris@343 201 DragMode updateDragMode(DragMode currentMode,
Chris@343 202 QPoint origin,
Chris@343 203 QPoint currentPoint,
Chris@343 204 bool canMoveHorizontal,
Chris@343 205 bool canMoveVertical,
Chris@343 206 bool resistHorizontal,
Chris@343 207 bool resistVertical);
Chris@343 208
Chris@133 209 QWidget *m_headsUpDisplay;
Chris@172 210 Panner *m_vpan;
Chris@133 211 Thumbwheel *m_hthumb;
Chris@133 212 Thumbwheel *m_vthumb;
Chris@189 213 NotifyingPushButton *m_reset;
Chris@1588 214 QMenu *m_lastVerticalPannerContextMenu;
Chris@262 215
Chris@290 216 bool m_mouseInWidget;
Chris@290 217
Chris@802 218 bool m_playbackFrameMoveScheduled;
Chris@908 219 sv_frame_t m_playbackFrameMoveTo;
Chris@1354 220
Chris@267 221 static QCursor *m_measureCursor1;
Chris@267 222 static QCursor *m_measureCursor2;
Chris@127 223 };
Chris@127 224
Chris@127 225 #endif
Chris@127 226