annotate layer/TextLayer.h @ 43:78515b1e29eb

* Rejig project file a bit to do pkg-config detection &c and change some HAVE_* symbol names accordingly * Add selection move/resize/delete * First stubs for add layer / pane commands
author Chris Cannam
date Wed, 01 Mar 2006 18:13:01 +0000
parents c28ebb4ba4de
children ad214997dddb
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@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@43 45 virtual void moveSelection(Selection s, size_t newStartFrame);
Chris@43 46 virtual void resizeSelection(Selection s, Selection newSize);
Chris@43 47
Chris@36 48 virtual void editOpen(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@35 64 virtual bool isLayerScrollable() 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@35 76 int getYForHeight(float height) const;
Chris@35 77 float getHeightForY(int y) const;
Chris@35 78
Chris@35 79 TextModel::PointList getLocalPoints(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