svgui
1.9
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Sonic Visualiser 00005 An audio file viewer and annotation editor. 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file copyright 2006 Chris Cannam and QMUL. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #ifndef _PANE_H_ 00017 #define _PANE_H_ 00018 00019 #include <QFrame> 00020 #include <QPoint> 00021 00022 #include "base/ZoomConstraint.h" 00023 #include "View.h" 00024 #include "base/Selection.h" 00025 00026 class QWidget; 00027 class QPaintEvent; 00028 class Layer; 00029 class Thumbwheel; 00030 class Panner; 00031 class NotifyingPushButton; 00032 class KeyReference; 00033 00034 class Pane : public View 00035 { 00036 Q_OBJECT 00037 00038 public: 00039 Pane(QWidget *parent = 0); 00040 virtual QString getPropertyContainerIconName() const { return "pane"; } 00041 00042 virtual bool shouldIlluminateLocalFeatures(const Layer *layer, 00043 QPoint &pos) const; 00044 virtual bool shouldIlluminateLocalSelection(QPoint &pos, 00045 bool &closeToLeft, 00046 bool &closeToRight) const; 00047 00048 void setCentreLineVisible(bool visible); 00049 bool getCentreLineVisible() const { return m_centreLineVisible; } 00050 00051 virtual int getFirstVisibleFrame() const; 00052 00053 virtual int getVerticalScaleWidth() const; 00054 00055 virtual QImage *toNewImage(int f0, int f1); 00056 virtual QImage *toNewImage() { return View::toNewImage(); } 00057 virtual QSize getImageSize(int f0, int f1); 00058 virtual QSize getImageSize() { return View::getImageSize(); } 00059 00060 virtual void toXml(QTextStream &stream, QString indent = "", 00061 QString extraAttributes = "") const; 00062 00063 static void registerShortcuts(KeyReference &kr); 00064 00065 enum PaneType { 00066 Normal = 0, 00067 TonyMain = 1, 00068 TonySelection = 2 00069 }; 00070 00071 signals: 00072 void paneInteractedWith(); 00073 void rightButtonMenuRequested(QPoint position); 00074 void dropAccepted(QStringList uriList); 00075 void dropAccepted(QString text); 00076 void doubleClickSelectInvoked(int frame); 00077 void regionOutlined(QRect rect); 00078 00079 public slots: 00080 virtual void toolModeChanged(); 00081 virtual void zoomWheelsEnabledChanged(); 00082 virtual void viewZoomLevelChanged(View *v, int z, bool locked); 00083 virtual void modelAlignmentCompletionChanged(); 00084 00085 virtual void horizontalThumbwheelMoved(int value); 00086 virtual void verticalThumbwheelMoved(int value); 00087 virtual void verticalZoomChanged(); 00088 virtual void verticalPannerMoved(float x, float y, float w, float h); 00089 virtual void editVerticalPannerExtents(); 00090 00091 virtual void layerParametersChanged(); 00092 00093 virtual void propertyContainerSelected(View *, PropertyContainer *pc); 00094 00095 void zoomToRegion(QRect r); 00096 00097 void mouseEnteredWidget(); 00098 void mouseLeftWidget(); 00099 00100 protected slots: 00101 void playbackScheduleTimerElapsed(); 00102 00103 protected: 00104 virtual void paintEvent(QPaintEvent *e); 00105 virtual void mousePressEvent(QMouseEvent *e); 00106 virtual void mouseReleaseEvent(QMouseEvent *e); 00107 virtual void mouseMoveEvent(QMouseEvent *e); 00108 virtual void mouseDoubleClickEvent(QMouseEvent *e); 00109 virtual void enterEvent(QEvent *e); 00110 virtual void leaveEvent(QEvent *e); 00111 virtual void wheelEvent(QWheelEvent *e); 00112 virtual void resizeEvent(QResizeEvent *e); 00113 virtual void dragEnterEvent(QDragEnterEvent *e); 00114 virtual void dropEvent(QDropEvent *e); 00115 00116 void wheelVertical(int sign, Qt::KeyboardModifiers); 00117 void wheelHorizontal(int sign, Qt::KeyboardModifiers); 00118 void wheelHorizontalFine(int pixels, Qt::KeyboardModifiers); 00119 00120 void drawVerticalScale(QRect r, Layer *, QPainter &); 00121 void drawFeatureDescription(Layer *, QPainter &); 00122 void drawCentreLine(int, QPainter &, bool omitLine); 00123 void drawModelTimeExtents(QRect, QPainter &, const Model *); 00124 void drawDurationAndRate(QRect, const Model *, int, QPainter &); 00125 void drawWorkTitle(QRect, QPainter &, const Model *); 00126 void drawLayerNames(QRect, QPainter &); 00127 void drawEditingSelection(QPainter &); 00128 void drawAlignmentStatus(QRect, QPainter &, const Model *, bool down); 00129 00130 virtual bool render(QPainter &paint, int x0, int f0, int f1); 00131 00132 Selection getSelectionAt(int x, bool &closeToLeft, bool &closeToRight) const; 00133 00134 bool editSelectionStart(QMouseEvent *e); 00135 bool editSelectionDrag(QMouseEvent *e); 00136 bool editSelectionEnd(QMouseEvent *e); 00137 bool selectionIsBeingEdited() const; 00138 00139 void updateHeadsUpDisplay(); 00140 void updateVerticalPanner(); 00141 00142 bool canTopLayerMoveVertical(); 00143 bool getTopLayerDisplayExtents(float &valueMin, float &valueMax, 00144 float &displayMin, float &displayMax, 00145 QString *unit = 0); 00146 bool setTopLayerDisplayExtents(float displayMin, float displayMax); 00147 00148 void dragTopLayer(QMouseEvent *e); 00149 void dragExtendSelection(QMouseEvent *e); 00150 void updateContextHelp(const QPoint *pos); 00151 void edgeScrollMaybe(int x); 00152 00153 Layer *getTopFlexiNoteLayer(); 00154 00155 void schedulePlaybackFrameMove(int frame); 00156 00157 bool m_identifyFeatures; 00158 QPoint m_identifyPoint; 00159 QPoint m_clickPos; 00160 QPoint m_mousePos; 00161 bool m_clickedInRange; 00162 bool m_shiftPressed; 00163 bool m_ctrlPressed; 00164 bool m_altPressed; 00165 00166 bool m_navigating; 00167 bool m_resizing; 00168 bool m_editing; 00169 bool m_releasing; 00170 int m_dragCentreFrame; 00171 float m_dragStartMinValue; 00172 bool m_centreLineVisible; 00173 int m_selectionStartFrame; 00174 Selection m_editingSelection; 00175 int m_editingSelectionEdge; 00176 mutable int m_scaleWidth; 00177 00178 int m_pendingWheelAngle; 00179 00180 enum DragMode { 00181 UnresolvedDrag, 00182 VerticalDrag, 00183 HorizontalDrag, 00184 FreeDrag 00185 }; 00186 DragMode m_dragMode; 00187 00188 DragMode updateDragMode(DragMode currentMode, 00189 QPoint origin, 00190 QPoint currentPoint, 00191 bool canMoveHorizontal, 00192 bool canMoveVertical, 00193 bool resistHorizontal, 00194 bool resistVertical); 00195 00196 QWidget *m_headsUpDisplay; 00197 Panner *m_vpan; 00198 Thumbwheel *m_hthumb; 00199 Thumbwheel *m_vthumb; 00200 NotifyingPushButton *m_reset; 00201 00202 bool m_mouseInWidget; 00203 00204 bool m_playbackFrameMoveScheduled; 00205 int m_playbackFrameMoveTo; 00206 00207 static QCursor *m_measureCursor1; 00208 static QCursor *m_measureCursor2; 00209 }; 00210 00211 #endif 00212