annotate view/Pane.h @ 267:4ed1446ad604

* more on measurement tool -- pull out some logic from pane to layer &c still more to do
author Chris Cannam
date Thu, 21 Jun 2007 16:12:00 +0000
parents aee39d8c0b83
children 21c7152ddba8
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@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@229 53 virtual QImage *toNewImage(size_t f0, size_t f1);
Chris@229 54 virtual QImage *toNewImage() { return View::toNewImage(); }
Chris@229 55 virtual QSize getImageSize(size_t f0, size_t f1);
Chris@229 56 virtual QSize getImageSize() { return View::getImageSize(); }
Chris@227 57
Chris@127 58 virtual QString toXmlString(QString indent = "",
Chris@127 59 QString extraAttributes = "") const;
Chris@127 60
Chris@127 61 signals:
Chris@127 62 void paneInteractedWith();
Chris@127 63 void rightButtonMenuRequested(QPoint position);
Chris@127 64
Chris@127 65 public slots:
Chris@127 66 virtual void toolModeChanged();
Chris@133 67 virtual void zoomWheelsEnabledChanged();
Chris@222 68 virtual void viewZoomLevelChanged(View *v, unsigned long z, bool locked);
Chris@127 69
Chris@132 70 virtual void horizontalThumbwheelMoved(int value);
Chris@132 71 virtual void verticalThumbwheelMoved(int value);
Chris@133 72 virtual void verticalZoomChanged();
Chris@174 73 virtual void verticalPannerMoved(float x, float y, float w, float h);
Chris@188 74 virtual void editVerticalPannerExtents();
Chris@133 75
Chris@133 76 virtual void propertyContainerSelected(View *, PropertyContainer *pc);
Chris@132 77
Chris@189 78 void mouseEnteredWidget();
Chris@189 79 void mouseLeftWidget();
Chris@189 80
Chris@127 81 protected:
Chris@127 82 virtual void paintEvent(QPaintEvent *e);
Chris@127 83 virtual void mousePressEvent(QMouseEvent *e);
Chris@127 84 virtual void mouseReleaseEvent(QMouseEvent *e);
Chris@127 85 virtual void mouseMoveEvent(QMouseEvent *e);
Chris@127 86 virtual void mouseDoubleClickEvent(QMouseEvent *e);
Chris@127 87 virtual void leaveEvent(QEvent *e);
Chris@127 88 virtual void wheelEvent(QWheelEvent *e);
Chris@133 89 virtual void resizeEvent(QResizeEvent *e);
Chris@127 90
Chris@261 91 void drawVerticalScale(QRect r, Layer *, QPainter &);
Chris@261 92 void drawFeatureDescription(Layer *, QPainter &);
Chris@261 93 void drawCentreLine(int, QPainter &);
Chris@261 94 void drawDurationAndRate(QRect, const Model *, int, QPainter &);
Chris@261 95 void drawLayerNames(QRect, QPainter &);
Chris@261 96 void drawEditingSelection(QPainter &);
Chris@261 97
Chris@229 98 virtual bool render(QPainter &paint, int x0, size_t f0, size_t f1);
Chris@229 99
Chris@127 100 Selection getSelectionAt(int x, bool &closeToLeft, bool &closeToRight) const;
Chris@127 101
Chris@127 102 bool editSelectionStart(QMouseEvent *e);
Chris@127 103 bool editSelectionDrag(QMouseEvent *e);
Chris@127 104 bool editSelectionEnd(QMouseEvent *e);
Chris@127 105 bool selectionIsBeingEdited() const;
Chris@127 106
Chris@133 107 void updateHeadsUpDisplay();
Chris@174 108 void updateVerticalPanner();
Chris@174 109
Chris@174 110 bool canTopLayerMoveVertical();
Chris@174 111 bool getTopLayerDisplayExtents(float &valueMin, float &valueMax,
Chris@188 112 float &displayMin, float &displayMax,
Chris@188 113 QString *unit = 0);
Chris@174 114 bool setTopLayerDisplayExtents(float displayMin, float displayMax);
Chris@174 115
Chris@174 116 void dragTopLayer(QMouseEvent *e);
Chris@174 117 void dragExtendSelection(QMouseEvent *e);
Chris@174 118 void zoomToRegion(int x0, int y0, int x1, int y1);
Chris@189 119 void updateContextHelp(const QPoint *pos);
Chris@259 120 void edgeScrollMaybe(int x);
Chris@133 121
Chris@127 122 bool m_identifyFeatures;
Chris@127 123 QPoint m_identifyPoint;
Chris@127 124 QPoint m_clickPos;
Chris@127 125 QPoint m_mousePos;
Chris@127 126 bool m_clickedInRange;
Chris@127 127 bool m_shiftPressed;
Chris@127 128 bool m_ctrlPressed;
Chris@266 129
Chris@127 130 bool m_navigating;
Chris@127 131 bool m_resizing;
Chris@127 132 size_t m_dragCentreFrame;
Chris@136 133 float m_dragStartMinValue;
Chris@127 134 bool m_centreLineVisible;
Chris@127 135 size_t m_selectionStartFrame;
Chris@127 136 Selection m_editingSelection;
Chris@127 137 int m_editingSelectionEdge;
Chris@222 138 mutable int m_scaleWidth;
Chris@133 139
Chris@150 140 enum DragMode {
Chris@150 141 UnresolvedDrag,
Chris@150 142 VerticalDrag,
Chris@150 143 HorizontalDrag,
Chris@150 144 FreeDrag
Chris@150 145 };
Chris@150 146 DragMode m_dragMode;
Chris@150 147
Chris@133 148 QWidget *m_headsUpDisplay;
Chris@172 149 Panner *m_vpan;
Chris@133 150 Thumbwheel *m_hthumb;
Chris@133 151 Thumbwheel *m_vthumb;
Chris@189 152 NotifyingPushButton *m_reset;
Chris@262 153
Chris@267 154 static QCursor *m_measureCursor1;
Chris@267 155 static QCursor *m_measureCursor2;
Chris@127 156 };
Chris@127 157
Chris@127 158 #endif
Chris@127 159