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@35
|
27 TextLayer(View *w);
|
Chris@35
|
28
|
Chris@35
|
29 virtual void paint(QPainter &paint, QRect rect) const;
|
Chris@35
|
30
|
Chris@35
|
31 virtual QString getFeatureDescription(QPoint &) const;
|
Chris@35
|
32
|
Chris@35
|
33 virtual bool snapToFeatureFrame(int &frame,
|
Chris@35
|
34 size_t &resolution,
|
Chris@35
|
35 SnapType snap) const;
|
Chris@35
|
36
|
Chris@35
|
37 virtual void drawStart(QMouseEvent *);
|
Chris@35
|
38 virtual void drawDrag(QMouseEvent *);
|
Chris@35
|
39 virtual void drawEnd(QMouseEvent *);
|
Chris@35
|
40
|
Chris@35
|
41 virtual void editStart(QMouseEvent *);
|
Chris@35
|
42 virtual void editDrag(QMouseEvent *);
|
Chris@35
|
43 virtual void editEnd(QMouseEvent *);
|
Chris@35
|
44
|
Chris@35
|
45 virtual const Model *getModel() const { return m_model; }
|
Chris@35
|
46 void setModel(TextModel *model);
|
Chris@35
|
47
|
Chris@35
|
48 virtual PropertyList getProperties() const;
|
Chris@35
|
49 virtual PropertyType getPropertyType(const PropertyName &) const;
|
Chris@35
|
50 virtual int getPropertyRangeAndValue(const PropertyName &,
|
Chris@35
|
51 int *min, int *max) const;
|
Chris@35
|
52 virtual QString getPropertyValueLabel(const PropertyName &,
|
Chris@35
|
53 int value) const;
|
Chris@35
|
54 virtual void setProperty(const PropertyName &, int value);
|
Chris@35
|
55
|
Chris@35
|
56 void setBaseColour(QColor);
|
Chris@35
|
57 QColor getBaseColour() const { return m_colour; }
|
Chris@35
|
58
|
Chris@35
|
59 virtual bool isLayerScrollable() const;
|
Chris@35
|
60
|
Chris@35
|
61 virtual bool isLayerEditable() const { return true; }
|
Chris@35
|
62
|
Chris@35
|
63 virtual int getCompletion() const { return m_model->getCompletion(); }
|
Chris@35
|
64
|
Chris@35
|
65 virtual QString toXmlString(QString indent = "",
|
Chris@35
|
66 QString extraAttributes = "") const;
|
Chris@35
|
67
|
Chris@35
|
68 void setProperties(const QXmlAttributes &attributes);
|
Chris@35
|
69
|
Chris@35
|
70 protected:
|
Chris@35
|
71 int getYForHeight(float height) const;
|
Chris@35
|
72 float getHeightForY(int y) const;
|
Chris@35
|
73
|
Chris@35
|
74 TextModel::PointList getLocalPoints(int x, int y) const;
|
Chris@35
|
75
|
Chris@35
|
76 TextModel *m_model;
|
Chris@35
|
77 bool m_editing;
|
Chris@35
|
78 TextModel::Point m_originalPoint;
|
Chris@35
|
79 TextModel::Point m_editingPoint;
|
Chris@35
|
80 TextModel::EditCommand *m_editingCommand;
|
Chris@35
|
81 QColor m_colour;
|
Chris@35
|
82 };
|
Chris@35
|
83
|
Chris@35
|
84 #endif
|
Chris@35
|
85
|