comparison layer/TextLayer.h @ 0:fc9323a41f5a

start base : Sonic Visualiser sv1-1.0rc1
author lbajardsilogic
date Fri, 11 May 2007 09:08:14 +0000
parents
children d8e6709e9075
comparison
equal deleted inserted replaced
-1:000000000000 0:fc9323a41f5a
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2006 Chris Cannam.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #ifndef _TEXT_LAYER_H_
17 #define _TEXT_LAYER_H_
18
19 #include "Layer.h"
20 #include "data/model/TextModel.h"
21
22 #include <QObject>
23 #include <QColor>
24
25 class View;
26 class QPainter;
27
28 class TextLayer : public Layer
29 {
30 Q_OBJECT
31
32 public:
33 TextLayer();
34
35 virtual void paint(View *v, QPainter &paint, QRect rect) const;
36
37 virtual QString getFeatureDescription(View *v, QPoint &) const;
38
39 virtual bool snapToFeatureFrame(View *v, int &frame,
40 size_t &resolution,
41 SnapType snap) const;
42
43 virtual void drawStart(View *v, QMouseEvent *);
44 virtual void drawDrag(View *v, QMouseEvent *);
45 virtual void drawEnd(View *v, QMouseEvent *);
46
47 virtual void editStart(View *v, QMouseEvent *);
48 virtual void editDrag(View *v, QMouseEvent *);
49 virtual void editEnd(View *v, QMouseEvent *);
50
51 virtual void moveSelection(Selection s, size_t newStartFrame);
52 virtual void resizeSelection(Selection s, Selection newSize);
53 virtual void deleteSelection(Selection s);
54
55 virtual void copy(Selection s, Clipboard &to);
56 virtual bool paste(const Clipboard &from, int frameOffset,
57 bool interactive);
58
59 virtual void editOpen(View *, QMouseEvent *); // on double-click
60
61 virtual const Model *getModel() const { return m_model; }
62 void setModel(TextModel *model);
63
64 virtual PropertyList getProperties() const;
65 virtual QString getPropertyLabel(const PropertyName &) const;
66 virtual PropertyType getPropertyType(const PropertyName &) const;
67 virtual int getPropertyRangeAndValue(const PropertyName &,
68 int *min, int *max, int *deflt) const;
69 virtual QString getPropertyValueLabel(const PropertyName &,
70 int value) const;
71 virtual void setProperty(const PropertyName &, int value);
72
73 void setBaseColour(QColor);
74 QColor getBaseColour() const { return m_colour; }
75
76 virtual bool isLayerScrollable(const View *v) const;
77
78 virtual bool isLayerEditable() const { return true; }
79
80 virtual int getCompletion(View *) const { return m_model->getCompletion(); }
81
82 virtual bool getValueExtents(float &min, float &max,
83 bool &logarithmic, QString &unit) const;
84
85 virtual QString toXmlString(QString indent = "",
86 QString extraAttributes = "") const;
87
88 void setProperties(const QXmlAttributes &attributes);
89
90 protected:
91 int getYForHeight(View *v, float height) const;
92 float getHeightForY(View *v, int y) const;
93
94 TextModel::PointList getLocalPoints(View *v, int x, int y) const;
95
96 TextModel *m_model;
97 bool m_editing;
98 QPoint m_editOrigin;
99 TextModel::Point m_originalPoint;
100 TextModel::Point m_editingPoint;
101 TextModel::EditCommand *m_editingCommand;
102 QColor m_colour;
103 };
104
105 #endif
106