comparison layer/IntervalLayer.h @ 18:d8e6709e9075

add - EasaierSessionManager - Easaier menus - Interval model
author lbajardsilogic
date Mon, 14 May 2007 13:13:14 +0000
parents
children 0387f53242b2
comparison
equal deleted inserted replaced
17:e59b19407b6d 18:d8e6709e9075
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sound Access
5 EASAIER client application.
6 Silogic 2007. Luc Barthélémy.
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version. See the file
12 COPYING included with this distribution for more information.
13 */
14
15
16 #ifndef _INTERVAL_LAYER_H_
17 #define _INTERVAL_LAYER_H_
18
19 #include "layer/Layer.h"
20 #include "data/model/IntervalModel.h"
21
22 #include <QObject>
23 #include <QColor>
24
25 class View;
26 class QPainter;
27
28 class IntervalLayer : public Layer
29 {
30 Q_OBJECT
31
32 public:
33 IntervalLayer();
34 virtual ~IntervalLayer();
35
36
37 virtual const Model *getModel() const { return m_model; }
38 void setModel(IntervalModel *model);
39
40 virtual void paint(View *, QPainter &, QRect) const;
41
42 virtual QString toXmlString(QString indent = "",
43 QString extraAttributes = "") const;
44
45 virtual QString toEasaierXmlString(QString indent = "",
46 QString extraAttributes = "") const;
47
48 // From PropertyContainer
49 virtual PropertyList getProperties() const;
50 virtual PropertyType getPropertyType(const PropertyName &) const;
51 virtual int getPropertyRangeAndValue(const PropertyName &,
52 int *min, int *max, int *deflt) const;
53 virtual QString getPropertyValueLabel(const PropertyName &,
54 int value) const;
55
56 void setProperties(const QXmlAttributes &attributes);
57 virtual void setProperty(const PropertyName &, int value);
58
59 virtual QString getPropertyLabel(const PropertyName &) const;
60
61 void setBaseColour(QColor);
62 QColor getBaseColour() const { return m_colour; }
63
64 virtual bool getValueExtents(float &min, float &max,
65 bool &log, QString &unit) const;
66
67 virtual QString getFeatureDescription(View *v, QPoint &) const;
68
69 virtual bool isLayerEditable() const { return true; }
70
71 virtual bool snapToFeatureFrame(View *v, int &frame,
72 size_t &resolution,
73 SnapType snap) const;
74
75 // for edition
76 virtual void drawStart(View *, QMouseEvent *);
77 virtual void drawDrag(View *, QMouseEvent *);
78 virtual void drawEnd(View *, QMouseEvent *);
79
80 virtual void editStart(View *, QMouseEvent *);
81 virtual void editDrag(View *, QMouseEvent *);
82 virtual void editEnd(View *, QMouseEvent *);
83
84 virtual void editOpen(View *, QMouseEvent *); // on double-click
85
86 virtual void moveSelection(Selection s, size_t newStartFrame);
87 virtual void resizeSelection(Selection s, Selection newSize);
88 virtual void deleteSelection(Selection s);
89
90 virtual void copy(Selection s, Clipboard &to);
91 virtual void paste(const Clipboard &from, int frameOffset);
92
93 protected:
94
95 int getYForHeight(View *v, float height) const;
96 float getHeightForY(View *v, int y) const;
97
98 IntervalList getIntervalAt(View *v, int x, int y);
99 IntervalList getInterval(long start, long end);
100
101 private:
102
103 IntervalModel* m_model;
104 QColor m_colour;
105
106 int m_editing;
107 TimeIntervalPtr m_editingInterval;
108 IntervalModel::IntervalCommand* m_editingCommand;
109 };
110
111 #endif //_INTERVAL_LAYER_H_