comparison layer/TextLayer.h @ 35:10ba9276a315

* Add TextModel and TextLayer types * Make View refresh work better when editing a model (previously edits might not be refreshed if their visible changed area extended beyond the strict frame range that was being modified in the model) * Add phase-adjusted instantaneous frequency display to spectrogram layer (still a work in progress) * Pull maths aliases out into a separate header in dsp/maths so MathUtilities can be included without introducing them
author Chris Cannam
date Mon, 20 Feb 2006 13:33:36 +0000
parents
children c28ebb4ba4de
comparison
equal deleted inserted replaced
34:c43f2c4f66f2 35:10ba9276a315
1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 A waveform viewer and audio annotation editor.
5 Chris Cannam, Queen Mary University of London, 2005-2006
6
7 This is experimental software. Not for distribution.
8 */
9
10 #ifndef _TEXT_LAYER_H_
11 #define _TEXT_LAYER_H_
12
13 #include "base/Layer.h"
14 #include "model/TextModel.h"
15
16 #include <QObject>
17 #include <QColor>
18
19 class View;
20 class QPainter;
21
22 class TextLayer : public Layer
23 {
24 Q_OBJECT
25
26 public:
27 TextLayer(View *w);
28
29 virtual void paint(QPainter &paint, QRect rect) const;
30
31 virtual QString getFeatureDescription(QPoint &) const;
32
33 virtual bool snapToFeatureFrame(int &frame,
34 size_t &resolution,
35 SnapType snap) const;
36
37 virtual void drawStart(QMouseEvent *);
38 virtual void drawDrag(QMouseEvent *);
39 virtual void drawEnd(QMouseEvent *);
40
41 virtual void editStart(QMouseEvent *);
42 virtual void editDrag(QMouseEvent *);
43 virtual void editEnd(QMouseEvent *);
44
45 virtual const Model *getModel() const { return m_model; }
46 void setModel(TextModel *model);
47
48 virtual PropertyList getProperties() const;
49 virtual PropertyType getPropertyType(const PropertyName &) const;
50 virtual int getPropertyRangeAndValue(const PropertyName &,
51 int *min, int *max) const;
52 virtual QString getPropertyValueLabel(const PropertyName &,
53 int value) const;
54 virtual void setProperty(const PropertyName &, int value);
55
56 void setBaseColour(QColor);
57 QColor getBaseColour() const { return m_colour; }
58
59 virtual bool isLayerScrollable() const;
60
61 virtual bool isLayerEditable() const { return true; }
62
63 virtual int getCompletion() const { return m_model->getCompletion(); }
64
65 virtual QString toXmlString(QString indent = "",
66 QString extraAttributes = "") const;
67
68 void setProperties(const QXmlAttributes &attributes);
69
70 protected:
71 int getYForHeight(float height) const;
72 float getHeightForY(int y) const;
73
74 TextModel::PointList getLocalPoints(int x, int y) const;
75
76 TextModel *m_model;
77 bool m_editing;
78 TextModel::Point m_originalPoint;
79 TextModel::Point m_editingPoint;
80 TextModel::EditCommand *m_editingCommand;
81 QColor m_colour;
82 };
83
84 #endif
85