annotate view/Pane.h @ 316:c0b9eec70639

* Make XmlExportable::toXml the function that is universally overridden (and pure virtual) instead of toXmlString. Tidies up some classes, notably the model classes, significantly. Closes #1794561.
author Chris Cannam
date Thu, 18 Oct 2007 10:15:07 +0000
parents 6de6f78b13a1
children 984c1975f1ff
rev   line source
Chris@127 1
Chris@127 2 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@127 3
Chris@127 4 /*
Chris@127 5 Sonic Visualiser
Chris@127 6 An audio file viewer and annotation editor.
Chris@127 7 Centre for Digital Music, Queen Mary, University of London.
Chris@182 8 This file copyright 2006 Chris Cannam and QMUL.
Chris@127 9
Chris@127 10 This program is free software; you can redistribute it and/or
Chris@127 11 modify it under the terms of the GNU General Public License as
Chris@127 12 published by the Free Software Foundation; either version 2 of the
Chris@127 13 License, or (at your option) any later version. See the file
Chris@127 14 COPYING included with this distribution for more information.
Chris@127 15 */
Chris@127 16
Chris@127 17 #ifndef _PANE_H_
Chris@127 18 #define _PANE_H_
Chris@127 19
Chris@127 20 #include <QFrame>
Chris@127 21 #include <QPoint>
Chris@127 22
Chris@127 23 #include "base/ZoomConstraint.h"
Chris@128 24 #include "View.h"
Chris@127 25 #include "base/Selection.h"
Chris@127 26
Chris@127 27 class QWidget;
Chris@127 28 class QPaintEvent;
Chris@127 29 class Layer;
Chris@133 30 class Thumbwheel;
Chris@172 31 class Panner;
Chris@189 32 class NotifyingPushButton;
Chris@282 33 class KeyReference;
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@127 41 virtual QString getPropertyContainerIconName() const { return "pane"; }
Chris@127 42
Chris@127 43 virtual bool shouldIlluminateLocalFeatures(const Layer *layer,
Chris@127 44 QPoint &pos) const;
Chris@127 45 virtual bool shouldIlluminateLocalSelection(QPoint &pos,
Chris@127 46 bool &closeToLeft,
Chris@127 47 bool &closeToRight) const;
Chris@127 48
Chris@127 49 void setCentreLineVisible(bool visible);
Chris@127 50 bool getCentreLineVisible() const { return m_centreLineVisible; }
Chris@127 51
Chris@222 52 virtual size_t getFirstVisibleFrame() const;
Chris@222 53
Chris@276 54 virtual size_t getVerticalScaleWidth() const;
Chris@276 55
Chris@229 56 virtual QImage *toNewImage(size_t f0, size_t f1);
Chris@229 57 virtual QImage *toNewImage() { return View::toNewImage(); }
Chris@229 58 virtual QSize getImageSize(size_t f0, size_t f1);
Chris@229 59 virtual QSize getImageSize() { return View::getImageSize(); }
Chris@227 60
Chris@316 61 virtual void toXml(QTextStream &stream, QString indent = "",
Chris@316 62 QString extraAttributes = "") const;
Chris@127 63
Chris@282 64 static void registerShortcuts(KeyReference &kr);
Chris@282 65
Chris@127 66 signals:
Chris@127 67 void paneInteractedWith();
Chris@127 68 void rightButtonMenuRequested(QPoint position);
Chris@312 69 void dropAccepted(QStringList uriList);
Chris@312 70 void dropAccepted(QString text);
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@127 76
Chris@132 77 virtual void horizontalThumbwheelMoved(int value);
Chris@132 78 virtual void verticalThumbwheelMoved(int value);
Chris@133 79 virtual void verticalZoomChanged();
Chris@174 80 virtual void verticalPannerMoved(float x, float y, float w, float h);
Chris@188 81 virtual void editVerticalPannerExtents();
Chris@133 82
Chris@133 83 virtual void propertyContainerSelected(View *, PropertyContainer *pc);
Chris@132 84
Chris@189 85 void mouseEnteredWidget();
Chris@189 86 void mouseLeftWidget();
Chris@189 87
Chris@127 88 protected:
Chris@127 89 virtual void paintEvent(QPaintEvent *e);
Chris@127 90 virtual void mousePressEvent(QMouseEvent *e);
Chris@127 91 virtual void mouseReleaseEvent(QMouseEvent *e);
Chris@127 92 virtual void mouseMoveEvent(QMouseEvent *e);
Chris@127 93 virtual void mouseDoubleClickEvent(QMouseEvent *e);
Chris@290 94 virtual void enterEvent(QEvent *e);
Chris@127 95 virtual void leaveEvent(QEvent *e);
Chris@127 96 virtual void wheelEvent(QWheelEvent *e);
Chris@133 97 virtual void resizeEvent(QResizeEvent *e);
Chris@312 98 virtual void dragEnterEvent(QDragEnterEvent *e);
Chris@312 99 virtual void dropEvent(QDropEvent *e);
Chris@127 100
Chris@261 101 void drawVerticalScale(QRect r, Layer *, QPainter &);
Chris@261 102 void drawFeatureDescription(Layer *, QPainter &);
Chris@277 103 void drawCentreLine(int, QPainter &, bool omitLine);
Chris@261 104 void drawDurationAndRate(QRect, const Model *, int, QPainter &);
Chris@261 105 void drawLayerNames(QRect, QPainter &);
Chris@261 106 void drawEditingSelection(QPainter &);
Chris@261 107
Chris@229 108 virtual bool render(QPainter &paint, int x0, size_t f0, size_t f1);
Chris@229 109
Chris@127 110 Selection getSelectionAt(int x, bool &closeToLeft, bool &closeToRight) const;
Chris@127 111
Chris@127 112 bool editSelectionStart(QMouseEvent *e);
Chris@127 113 bool editSelectionDrag(QMouseEvent *e);
Chris@127 114 bool editSelectionEnd(QMouseEvent *e);
Chris@127 115 bool selectionIsBeingEdited() const;
Chris@127 116
Chris@133 117 void updateHeadsUpDisplay();
Chris@174 118 void updateVerticalPanner();
Chris@174 119
Chris@174 120 bool canTopLayerMoveVertical();
Chris@174 121 bool getTopLayerDisplayExtents(float &valueMin, float &valueMax,
Chris@188 122 float &displayMin, float &displayMax,
Chris@188 123 QString *unit = 0);
Chris@174 124 bool setTopLayerDisplayExtents(float displayMin, float displayMax);
Chris@174 125
Chris@174 126 void dragTopLayer(QMouseEvent *e);
Chris@174 127 void dragExtendSelection(QMouseEvent *e);
Chris@174 128 void zoomToRegion(int x0, int y0, int x1, int y1);
Chris@189 129 void updateContextHelp(const QPoint *pos);
Chris@259 130 void edgeScrollMaybe(int x);
Chris@133 131
Chris@127 132 bool m_identifyFeatures;
Chris@127 133 QPoint m_identifyPoint;
Chris@127 134 QPoint m_clickPos;
Chris@127 135 QPoint m_mousePos;
Chris@127 136 bool m_clickedInRange;
Chris@127 137 bool m_shiftPressed;
Chris@127 138 bool m_ctrlPressed;
Chris@266 139
Chris@127 140 bool m_navigating;
Chris@127 141 bool m_resizing;
Chris@127 142 size_t m_dragCentreFrame;
Chris@136 143 float m_dragStartMinValue;
Chris@127 144 bool m_centreLineVisible;
Chris@127 145 size_t m_selectionStartFrame;
Chris@127 146 Selection m_editingSelection;
Chris@127 147 int m_editingSelectionEdge;
Chris@222 148 mutable int m_scaleWidth;
Chris@133 149
Chris@150 150 enum DragMode {
Chris@150 151 UnresolvedDrag,
Chris@150 152 VerticalDrag,
Chris@150 153 HorizontalDrag,
Chris@150 154 FreeDrag
Chris@150 155 };
Chris@150 156 DragMode m_dragMode;
Chris@150 157
Chris@133 158 QWidget *m_headsUpDisplay;
Chris@172 159 Panner *m_vpan;
Chris@133 160 Thumbwheel *m_hthumb;
Chris@133 161 Thumbwheel *m_vthumb;
Chris@189 162 NotifyingPushButton *m_reset;
Chris@262 163
Chris@290 164 bool m_mouseInWidget;
Chris@290 165
Chris@267 166 static QCursor *m_measureCursor1;
Chris@267 167 static QCursor *m_measureCursor2;
Chris@127 168 };
Chris@127 169
Chris@127 170 #endif
Chris@127 171