annotate view/Pane.h @ 822:d974ed657176 tonioni

code to remove duration/sample rate from panes
author matthiasm
date Wed, 16 Jul 2014 14:35:00 +0100
parents 40c6c9344ff6
children 43256b925e15
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@806 51 virtual int getFirstVisibleFrame() const;
Chris@222 52
Chris@806 53 virtual int getVerticalScaleWidth() const;
Chris@276 54
Chris@806 55 virtual QImage *toNewImage(int f0, int f1);
Chris@229 56 virtual QImage *toNewImage() { return View::toNewImage(); }
Chris@806 57 virtual QSize getImageSize(int f0, int 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@806 76 void doubleClickSelectInvoked(int 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@261 116 void drawVerticalScale(QRect r, Layer *, QPainter &);
Chris@261 117 void drawFeatureDescription(Layer *, QPainter &);
Chris@277 118 void drawCentreLine(int, QPainter &, bool omitLine);
Chris@759 119 void drawModelTimeExtents(QRect, QPainter &, const Model *);
Chris@261 120 void drawDurationAndRate(QRect, const Model *, int, QPainter &);
Chris@326 121 void drawWorkTitle(QRect, QPainter &, const Model *);
Chris@261 122 void drawLayerNames(QRect, QPainter &);
Chris@261 123 void drawEditingSelection(QPainter &);
Chris@326 124 void drawAlignmentStatus(QRect, QPainter &, const Model *, bool down);
Chris@261 125
Chris@806 126 virtual bool render(QPainter &paint, int x0, int f0, int f1);
Chris@229 127
Chris@127 128 Selection getSelectionAt(int x, bool &closeToLeft, bool &closeToRight) const;
Chris@127 129
Chris@127 130 bool editSelectionStart(QMouseEvent *e);
Chris@127 131 bool editSelectionDrag(QMouseEvent *e);
Chris@127 132 bool editSelectionEnd(QMouseEvent *e);
Chris@127 133 bool selectionIsBeingEdited() const;
Chris@127 134
Chris@133 135 void updateHeadsUpDisplay();
Chris@174 136 void updateVerticalPanner();
Chris@174 137
Chris@174 138 bool canTopLayerMoveVertical();
Chris@174 139 bool getTopLayerDisplayExtents(float &valueMin, float &valueMax,
Chris@188 140 float &displayMin, float &displayMax,
Chris@188 141 QString *unit = 0);
Chris@174 142 bool setTopLayerDisplayExtents(float displayMin, float displayMax);
Chris@174 143
Chris@174 144 void dragTopLayer(QMouseEvent *e);
Chris@174 145 void dragExtendSelection(QMouseEvent *e);
Chris@189 146 void updateContextHelp(const QPoint *pos);
Chris@259 147 void edgeScrollMaybe(int x);
Chris@133 148
Chris@753 149 Layer *getTopFlexiNoteLayer();
Chris@753 150
Chris@802 151 void schedulePlaybackFrameMove(int frame);
Chris@802 152
Chris@127 153 bool m_identifyFeatures;
Chris@127 154 QPoint m_identifyPoint;
Chris@127 155 QPoint m_clickPos;
Chris@127 156 QPoint m_mousePos;
Chris@127 157 bool m_clickedInRange;
Chris@127 158 bool m_shiftPressed;
Chris@127 159 bool m_ctrlPressed;
Chris@510 160 bool m_altPressed;
Chris@266 161
Chris@127 162 bool m_navigating;
Chris@127 163 bool m_resizing;
Chris@343 164 bool m_editing;
Chris@343 165 bool m_releasing;
Chris@806 166 int m_dragCentreFrame;
Chris@136 167 float m_dragStartMinValue;
Chris@127 168 bool m_centreLineVisible;
Chris@806 169 int m_selectionStartFrame;
Chris@127 170 Selection m_editingSelection;
Chris@127 171 int m_editingSelectionEdge;
Chris@222 172 mutable int m_scaleWidth;
Chris@133 173
Chris@150 174 enum DragMode {
Chris@150 175 UnresolvedDrag,
Chris@150 176 VerticalDrag,
Chris@150 177 HorizontalDrag,
Chris@150 178 FreeDrag
Chris@150 179 };
Chris@150 180 DragMode m_dragMode;
Chris@150 181
Chris@343 182 DragMode updateDragMode(DragMode currentMode,
Chris@343 183 QPoint origin,
Chris@343 184 QPoint currentPoint,
Chris@343 185 bool canMoveHorizontal,
Chris@343 186 bool canMoveVertical,
Chris@343 187 bool resistHorizontal,
Chris@343 188 bool resistVertical);
Chris@343 189
Chris@133 190 QWidget *m_headsUpDisplay;
Chris@172 191 Panner *m_vpan;
Chris@133 192 Thumbwheel *m_hthumb;
Chris@133 193 Thumbwheel *m_vthumb;
Chris@189 194 NotifyingPushButton *m_reset;
Chris@262 195
Chris@290 196 bool m_mouseInWidget;
Chris@290 197
Chris@802 198 bool m_playbackFrameMoveScheduled;
Chris@802 199 int m_playbackFrameMoveTo;
Chris@802 200
Chris@267 201 static QCursor *m_measureCursor1;
Chris@267 202 static QCursor *m_measureCursor2;
Chris@127 203 };
Chris@127 204
Chris@127 205 #endif
Chris@127 206