annotate layer/TextLayer.h @ 1495:6bb0afa607f5

Toward trying to figure out a progress-bar problem
author Chris Cannam
date Tue, 13 Aug 2019 15:10:32 +0100
parents 696e569ff21b
children e6362cf5ff1d
rev   line source
Chris@58 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@35 2
Chris@35 3 /*
Chris@59 4 Sonic Visualiser
Chris@59 5 An audio file viewer and annotation editor.
Chris@59 6 Centre for Digital Music, Queen Mary, University of London.
Chris@59 7 This file copyright 2006 Chris Cannam.
Chris@35 8
Chris@59 9 This program is free software; you can redistribute it and/or
Chris@59 10 modify it under the terms of the GNU General Public License as
Chris@59 11 published by the Free Software Foundation; either version 2 of the
Chris@59 12 License, or (at your option) any later version. See the file
Chris@59 13 COPYING included with this distribution for more information.
Chris@35 14 */
Chris@35 15
Chris@1407 16 #ifndef SV_TEXT_LAYER_H
Chris@1407 17 #define SV_TEXT_LAYER_H
Chris@35 18
Chris@287 19 #include "SingleColourLayer.h"
Chris@128 20 #include "data/model/TextModel.h"
Chris@35 21
Chris@35 22 #include <QObject>
Chris@35 23 #include <QColor>
Chris@35 24
Chris@35 25 class View;
Chris@35 26 class QPainter;
Chris@35 27
Chris@287 28 class TextLayer : public SingleColourLayer
Chris@35 29 {
Chris@35 30 Q_OBJECT
Chris@35 31
Chris@35 32 public:
Chris@44 33 TextLayer();
Chris@35 34
Chris@1406 35 void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const override;
Chris@35 36
Chris@1406 37 QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const override;
Chris@35 38
Chris@1406 39 bool snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame,
Chris@1266 40 int &resolution,
Chris@1406 41 SnapType snap) const override;
Chris@35 42
Chris@1406 43 void drawStart(LayerGeometryProvider *v, QMouseEvent *) override;
Chris@1406 44 void drawDrag(LayerGeometryProvider *v, QMouseEvent *) override;
Chris@1406 45 void drawEnd(LayerGeometryProvider *v, QMouseEvent *) override;
Chris@35 46
Chris@1406 47 void eraseStart(LayerGeometryProvider *v, QMouseEvent *) override;
Chris@1406 48 void eraseDrag(LayerGeometryProvider *v, QMouseEvent *) override;
Chris@1406 49 void eraseEnd(LayerGeometryProvider *v, QMouseEvent *) override;
Chris@335 50
Chris@1406 51 void editStart(LayerGeometryProvider *v, QMouseEvent *) override;
Chris@1406 52 void editDrag(LayerGeometryProvider *v, QMouseEvent *) override;
Chris@1406 53 void editEnd(LayerGeometryProvider *v, QMouseEvent *) override;
Chris@35 54
Chris@1406 55 void moveSelection(Selection s, sv_frame_t newStartFrame) override;
Chris@1406 56 void resizeSelection(Selection s, Selection newSize) override;
Chris@1406 57 void deleteSelection(Selection s) override;
Chris@76 58
Chris@1406 59 void copy(LayerGeometryProvider *v, Selection s, Clipboard &to) override;
Chris@1406 60 bool paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t frameOffset,
Chris@1406 61 bool interactive) override;
Chris@43 62
Chris@1406 63 bool editOpen(LayerGeometryProvider *, QMouseEvent *) override; // on double-click
Chris@36 64
Chris@1470 65 ModelId getModel() const override { return m_model; }
Chris@1470 66 void setModel(ModelId model); // a TextModel
Chris@35 67
Chris@1406 68 PropertyList getProperties() const override;
Chris@1406 69 QString getPropertyLabel(const PropertyName &) const override;
Chris@1406 70 PropertyType getPropertyType(const PropertyName &) const override;
Chris@1406 71 int getPropertyRangeAndValue(const PropertyName &,
Chris@1406 72 int *min, int *max, int *deflt) const override;
Chris@1406 73 QString getPropertyValueLabel(const PropertyName &,
Chris@1406 74 int value) const override;
Chris@1406 75 void setProperty(const PropertyName &, int value) override;
Chris@35 76
Chris@1406 77 bool isLayerScrollable(const LayerGeometryProvider *v) const override;
Chris@35 78
Chris@1406 79 bool isLayerEditable() const override { return true; }
Chris@35 80
Chris@1470 81 int getCompletion(LayerGeometryProvider *) const override;
Chris@35 82
Chris@1406 83 bool getValueExtents(double &min, double &max,
Chris@1406 84 bool &logarithmic, QString &unit) const override;
Chris@79 85
Chris@1406 86 int getVerticalScaleWidth(LayerGeometryProvider *, bool, QPainter &) const override { return 0; }
Chris@607 87
Chris@1406 88 void toXml(QTextStream &stream, QString indent = "",
Chris@1406 89 QString extraAttributes = "") const override;
Chris@35 90
Chris@1406 91 void setProperties(const QXmlAttributes &attributes) override;
Chris@35 92
Chris@35 93 protected:
Chris@918 94 int getYForHeight(LayerGeometryProvider *v, double height) const;
Chris@918 95 double getHeightForY(LayerGeometryProvider *v, int y) const;
Chris@35 96
Chris@1406 97 int getDefaultColourHint(bool dark, bool &impose) override;
Chris@287 98
Chris@1437 99 EventVector getLocalPoints(LayerGeometryProvider *v, int x, int y) const;
Chris@35 100
Chris@1437 101 bool getPointToDrag(LayerGeometryProvider *v, int x, int y, Event &) const;
Chris@552 102
Chris@1470 103 ModelId m_model;
Chris@35 104 bool m_editing;
Chris@36 105 QPoint m_editOrigin;
Chris@1437 106 Event m_originalPoint;
Chris@1437 107 Event m_editingPoint;
Chris@1437 108 ChangeEventsCommand *m_editingCommand;
Chris@376 109
Chris@1437 110 void finish(ChangeEventsCommand *command) {
Chris@376 111 Command *c = command->finish();
Chris@376 112 if (c) CommandHistory::getInstance()->addCommand(c, false);
Chris@376 113 }
Chris@35 114 };
Chris@35 115
Chris@35 116 #endif
Chris@35 117