annotate view/Pane.h @ 716:67b167bb60ab tonioni

Propagate double-click in select mode -- the application might do something meaningful with this
author Chris Cannam
date Fri, 10 Jan 2014 14:17:50 +0000
parents 683c46d7500b
children 711ae36a53a2
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@222 51 virtual size_t getFirstVisibleFrame() const;
Chris@222 52
Chris@276 53 virtual size_t getVerticalScaleWidth() const;
Chris@276 54
Chris@229 55 virtual QImage *toNewImage(size_t f0, size_t f1);
Chris@229 56 virtual QImage *toNewImage() { return View::toNewImage(); }
Chris@229 57 virtual QSize getImageSize(size_t f0, size_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
Chris@127 65 signals:
Chris@127 66 void paneInteractedWith();
Chris@127 67 void rightButtonMenuRequested(QPoint position);
Chris@312 68 void dropAccepted(QStringList uriList);
Chris@312 69 void dropAccepted(QString text);
Chris@716 70 void doubleClickSelectInvoked(size_t frame);
Chris@127 71
Chris@127 72 public slots:
Chris@127 73 virtual void toolModeChanged();
Chris@133 74 virtual void zoomWheelsEnabledChanged();
Chris@222 75 virtual void viewZoomLevelChanged(View *v, unsigned long z, bool locked);
Chris@320 76 virtual void modelAlignmentCompletionChanged();
Chris@127 77
Chris@132 78 virtual void horizontalThumbwheelMoved(int value);
Chris@132 79 virtual void verticalThumbwheelMoved(int value);
Chris@133 80 virtual void verticalZoomChanged();
Chris@174 81 virtual void verticalPannerMoved(float x, float y, float w, float h);
Chris@188 82 virtual void editVerticalPannerExtents();
Chris@133 83
Chris@437 84 virtual void layerParametersChanged();
Chris@437 85
Chris@133 86 virtual void propertyContainerSelected(View *, PropertyContainer *pc);
Chris@132 87
Chris@189 88 void mouseEnteredWidget();
Chris@189 89 void mouseLeftWidget();
Chris@189 90
Chris@127 91 protected:
Chris@127 92 virtual void paintEvent(QPaintEvent *e);
Chris@127 93 virtual void mousePressEvent(QMouseEvent *e);
Chris@127 94 virtual void mouseReleaseEvent(QMouseEvent *e);
Chris@127 95 virtual void mouseMoveEvent(QMouseEvent *e);
Chris@127 96 virtual void mouseDoubleClickEvent(QMouseEvent *e);
Chris@290 97 virtual void enterEvent(QEvent *e);
Chris@127 98 virtual void leaveEvent(QEvent *e);
Chris@127 99 virtual void wheelEvent(QWheelEvent *e);
Chris@133 100 virtual void resizeEvent(QResizeEvent *e);
Chris@312 101 virtual void dragEnterEvent(QDragEnterEvent *e);
Chris@312 102 virtual void dropEvent(QDropEvent *e);
Chris@127 103
Chris@261 104 void drawVerticalScale(QRect r, Layer *, QPainter &);
Chris@261 105 void drawFeatureDescription(Layer *, QPainter &);
Chris@277 106 void drawCentreLine(int, QPainter &, bool omitLine);
Chris@261 107 void drawDurationAndRate(QRect, const Model *, int, QPainter &);
Chris@326 108 void drawWorkTitle(QRect, QPainter &, const Model *);
Chris@261 109 void drawLayerNames(QRect, QPainter &);
Chris@261 110 void drawEditingSelection(QPainter &);
Chris@326 111 void drawAlignmentStatus(QRect, QPainter &, const Model *, bool down);
Chris@261 112
Chris@229 113 virtual bool render(QPainter &paint, int x0, size_t f0, size_t f1);
Chris@229 114
Chris@127 115 Selection getSelectionAt(int x, bool &closeToLeft, bool &closeToRight) const;
Chris@127 116
Chris@127 117 bool editSelectionStart(QMouseEvent *e);
Chris@127 118 bool editSelectionDrag(QMouseEvent *e);
Chris@127 119 bool editSelectionEnd(QMouseEvent *e);
Chris@127 120 bool selectionIsBeingEdited() const;
Chris@127 121
Chris@133 122 void updateHeadsUpDisplay();
Chris@174 123 void updateVerticalPanner();
Chris@174 124
Chris@174 125 bool canTopLayerMoveVertical();
Chris@174 126 bool getTopLayerDisplayExtents(float &valueMin, float &valueMax,
Chris@188 127 float &displayMin, float &displayMax,
Chris@188 128 QString *unit = 0);
Chris@174 129 bool setTopLayerDisplayExtents(float displayMin, float displayMax);
Chris@174 130
Chris@174 131 void dragTopLayer(QMouseEvent *e);
Chris@174 132 void dragExtendSelection(QMouseEvent *e);
Chris@174 133 void zoomToRegion(int x0, int y0, int x1, int y1);
Chris@189 134 void updateContextHelp(const QPoint *pos);
Chris@259 135 void edgeScrollMaybe(int x);
Chris@133 136
Chris@127 137 bool m_identifyFeatures;
Chris@127 138 QPoint m_identifyPoint;
Chris@127 139 QPoint m_clickPos;
Chris@127 140 QPoint m_mousePos;
Chris@127 141 bool m_clickedInRange;
Chris@127 142 bool m_shiftPressed;
Chris@127 143 bool m_ctrlPressed;
Chris@510 144 bool m_altPressed;
Chris@266 145
Chris@127 146 bool m_navigating;
Chris@127 147 bool m_resizing;
Chris@343 148 bool m_editing;
Chris@343 149 bool m_releasing;
Chris@127 150 size_t m_dragCentreFrame;
Chris@136 151 float m_dragStartMinValue;
Chris@127 152 bool m_centreLineVisible;
Chris@127 153 size_t m_selectionStartFrame;
Chris@127 154 Selection m_editingSelection;
Chris@127 155 int m_editingSelectionEdge;
Chris@222 156 mutable int m_scaleWidth;
Chris@133 157
Chris@150 158 enum DragMode {
Chris@150 159 UnresolvedDrag,
Chris@150 160 VerticalDrag,
Chris@150 161 HorizontalDrag,
Chris@150 162 FreeDrag
Chris@150 163 };
Chris@150 164 DragMode m_dragMode;
Chris@150 165
Chris@343 166 DragMode updateDragMode(DragMode currentMode,
Chris@343 167 QPoint origin,
Chris@343 168 QPoint currentPoint,
Chris@343 169 bool canMoveHorizontal,
Chris@343 170 bool canMoveVertical,
Chris@343 171 bool resistHorizontal,
Chris@343 172 bool resistVertical);
Chris@343 173
Chris@133 174 QWidget *m_headsUpDisplay;
Chris@172 175 Panner *m_vpan;
Chris@133 176 Thumbwheel *m_hthumb;
Chris@133 177 Thumbwheel *m_vthumb;
Chris@189 178 NotifyingPushButton *m_reset;
Chris@262 179
Chris@290 180 bool m_mouseInWidget;
Chris@290 181
Chris@267 182 static QCursor *m_measureCursor1;
Chris@267 183 static QCursor *m_measureCursor2;
Chris@127 184 };
Chris@127 185
Chris@127 186 #endif
Chris@127 187