annotate layer/TextLayer.h @ 53:68869408f5c7

* Restore proper channel selection support for new layers * Use binary mode for SV file I/O on Windows * Commands for selection
author Chris Cannam
date Wed, 15 Mar 2006 18:11:23 +0000
parents ad214997dddb
children 01ab51f72e84
rev   line source
Chris@35 1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
Chris@35 2
Chris@35 3 /*
Chris@35 4 A waveform viewer and audio annotation editor.
Chris@35 5 Chris Cannam, Queen Mary University of London, 2005-2006
Chris@35 6
Chris@35 7 This is experimental software. Not for distribution.
Chris@35 8 */
Chris@35 9
Chris@35 10 #ifndef _TEXT_LAYER_H_
Chris@35 11 #define _TEXT_LAYER_H_
Chris@35 12
Chris@35 13 #include "base/Layer.h"
Chris@35 14 #include "model/TextModel.h"
Chris@35 15
Chris@35 16 #include <QObject>
Chris@35 17 #include <QColor>
Chris@35 18
Chris@35 19 class View;
Chris@35 20 class QPainter;
Chris@35 21
Chris@35 22 class TextLayer : public Layer
Chris@35 23 {
Chris@35 24 Q_OBJECT
Chris@35 25
Chris@35 26 public:
Chris@44 27 TextLayer();
Chris@35 28
Chris@44 29 virtual void paint(View *v, QPainter &paint, QRect rect) const;
Chris@35 30
Chris@44 31 virtual QString getFeatureDescription(View *v, QPoint &) const;
Chris@35 32
Chris@44 33 virtual bool snapToFeatureFrame(View *v, int &frame,
Chris@35 34 size_t &resolution,
Chris@35 35 SnapType snap) const;
Chris@35 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@35 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@35 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@44 48 virtual void editOpen(View *, QMouseEvent *); // on double-click
Chris@36 49
Chris@35 50 virtual const Model *getModel() const { return m_model; }
Chris@35 51 void setModel(TextModel *model);
Chris@35 52
Chris@35 53 virtual PropertyList getProperties() const;
Chris@35 54 virtual PropertyType getPropertyType(const PropertyName &) const;
Chris@35 55 virtual int getPropertyRangeAndValue(const PropertyName &,
Chris@35 56 int *min, int *max) const;
Chris@35 57 virtual QString getPropertyValueLabel(const PropertyName &,
Chris@35 58 int value) const;
Chris@35 59 virtual void setProperty(const PropertyName &, int value);
Chris@35 60
Chris@35 61 void setBaseColour(QColor);
Chris@35 62 QColor getBaseColour() const { return m_colour; }
Chris@35 63
Chris@44 64 virtual bool isLayerScrollable(const View *v) const;
Chris@35 65
Chris@35 66 virtual bool isLayerEditable() const { return true; }
Chris@35 67
Chris@35 68 virtual int getCompletion() const { return m_model->getCompletion(); }
Chris@35 69
Chris@35 70 virtual QString toXmlString(QString indent = "",
Chris@35 71 QString extraAttributes = "") const;
Chris@35 72
Chris@35 73 void setProperties(const QXmlAttributes &attributes);
Chris@35 74
Chris@35 75 protected:
Chris@44 76 int getYForHeight(View *v, float height) const;
Chris@44 77 float getHeightForY(View *v, int y) const;
Chris@35 78
Chris@44 79 TextModel::PointList getLocalPoints(View *v, int x, int y) const;
Chris@35 80
Chris@35 81 TextModel *m_model;
Chris@35 82 bool m_editing;
Chris@36 83 QPoint m_editOrigin;
Chris@35 84 TextModel::Point m_originalPoint;
Chris@35 85 TextModel::Point m_editingPoint;
Chris@35 86 TextModel::EditCommand *m_editingCommand;
Chris@35 87 QColor m_colour;
Chris@35 88 };
Chris@35 89
Chris@35 90 #endif
Chris@35 91