annotate layer/NoteLayer.h @ 58:01ab51f72e84

* Set indent-tabs-mode to nil in Emacs mode direction
author Chris Cannam
date Mon, 20 Mar 2006 11:40:39 +0000
parents ad214997dddb
children 705f05ab42e3
rev   line source
Chris@58 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@30 2
Chris@30 3 /*
Chris@30 4 A waveform viewer and audio annotation editor.
Chris@30 5 Chris Cannam, Queen Mary University of London, 2005-2006
Chris@30 6
Chris@30 7 This is experimental software. Not for distribution.
Chris@30 8 */
Chris@30 9
Chris@30 10 #ifndef _NOTE_LAYER_H_
Chris@30 11 #define _NOTE_LAYER_H_
Chris@30 12
Chris@30 13 #include "base/Layer.h"
Chris@30 14 #include "model/NoteModel.h"
Chris@30 15
Chris@30 16 #include <QObject>
Chris@30 17 #include <QColor>
Chris@30 18
Chris@30 19 class View;
Chris@30 20 class QPainter;
Chris@30 21
Chris@30 22 class NoteLayer : public Layer
Chris@30 23 {
Chris@30 24 Q_OBJECT
Chris@30 25
Chris@30 26 public:
Chris@44 27 NoteLayer();
Chris@30 28
Chris@44 29 virtual void paint(View *v, QPainter &paint, QRect rect) const;
Chris@30 30
Chris@44 31 virtual QString getFeatureDescription(View *v, QPoint &) const;
Chris@30 32
Chris@44 33 virtual bool snapToFeatureFrame(View *v, int &frame,
Chris@30 34 size_t &resolution,
Chris@30 35 SnapType snap) const;
Chris@30 36
Chris@44 37 virtual void drawStart(View *v, QMouseEvent *);
Chris@44 38 virtual void drawDrag(View *v, QMouseEvent *);
Chris@44 39 virtual void drawEnd(View *v, QMouseEvent *);
Chris@30 40
Chris@44 41 virtual void editStart(View *v, QMouseEvent *);
Chris@44 42 virtual void editDrag(View *v, QMouseEvent *);
Chris@44 43 virtual void editEnd(View *v, QMouseEvent *);
Chris@30 44
Chris@43 45 virtual void moveSelection(Selection s, size_t newStartFrame);
Chris@43 46 virtual void resizeSelection(Selection s, Selection newSize);
Chris@43 47
Chris@30 48 virtual const Model *getModel() const { return m_model; }
Chris@30 49 void setModel(NoteModel *model);
Chris@30 50
Chris@30 51 virtual PropertyList getProperties() const;
Chris@30 52 virtual PropertyType getPropertyType(const PropertyName &) const;
Chris@30 53 virtual int getPropertyRangeAndValue(const PropertyName &,
Chris@30 54 int *min, int *max) const;
Chris@30 55 virtual QString getPropertyValueLabel(const PropertyName &,
Chris@30 56 int value) const;
Chris@30 57 virtual void setProperty(const PropertyName &, int value);
Chris@30 58
Chris@30 59 void setBaseColour(QColor);
Chris@30 60 QColor getBaseColour() const { return m_colour; }
Chris@30 61
Chris@30 62 enum VerticalScale {
Chris@30 63 MinMaxRangeScale,
Chris@30 64 MIDIRangeScale,
Chris@30 65 FrequencyScale
Chris@30 66 };
Chris@30 67
Chris@30 68 void setVerticalScale(VerticalScale scale);
Chris@30 69 VerticalScale getVerticalScale() const { return m_verticalScale; }
Chris@30 70
Chris@44 71 virtual bool isLayerScrollable(const View *v) const;
Chris@30 72
Chris@30 73 virtual bool isLayerEditable() const { return true; }
Chris@30 74
Chris@30 75 virtual int getCompletion() const { return m_model->getCompletion(); }
Chris@30 76
Chris@30 77 virtual QString toXmlString(QString indent = "",
Chris@30 78 QString extraAttributes = "") const;
Chris@30 79
Chris@30 80 void setProperties(const QXmlAttributes &attributes);
Chris@30 81
Chris@30 82 protected:
Chris@44 83 int getYForValue(View *v, float value) const;
Chris@44 84 float getValueForY(View *v, int y) const;
Chris@30 85
Chris@44 86 NoteModel::PointList getLocalPoints(View *v, int) const;
Chris@30 87
Chris@30 88 NoteModel *m_model;
Chris@30 89 bool m_editing;
Chris@30 90 NoteModel::Point m_originalPoint;
Chris@30 91 NoteModel::Point m_editingPoint;
Chris@30 92 NoteModel::EditCommand *m_editingCommand;
Chris@30 93 QColor m_colour;
Chris@30 94 VerticalScale m_verticalScale;
Chris@30 95 };
Chris@30 96
Chris@30 97 #endif
Chris@30 98