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 SV_TIME_RULER_H 17 #define SV_TIME_RULER_H 18 19 #include "SingleColourLayer.h" 20 21 #include <QRect> 22 #include <QColor> 23 24 class View; 25 class Model; 26 class QPainter; 27 28 class TimeRulerLayer : public SingleColourLayer 29 { 30 Q_OBJECT 31 32 public: 33 TimeRulerLayer(); 34 35 void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const override; 36 37 void setModel(ModelId); getModel()38 ModelId getModel() const override { return m_model; } 39 40 enum LabelHeight { LabelTop, LabelMiddle, LabelBottom }; setLabelHeight(LabelHeight h)41 void setLabelHeight(LabelHeight h) { m_labelHeight = h; } getLabelHeight()42 LabelHeight getLabelHeight() const { return m_labelHeight; } 43 44 bool snapToFeatureFrame(LayerGeometryProvider *, sv_frame_t &, int &, 45 SnapType, int) const override; 46 getLayerColourSignificance()47 ColourSignificance getLayerColourSignificance() const override { 48 return ColourIrrelevant; 49 } 50 getValueExtents(double &,double &,bool &,QString &)51 bool getValueExtents(double &, double &, bool &, QString &) const override { 52 return false; 53 } 54 55 QString getLayerPresentationName() const override; 56 getVerticalScaleWidth(LayerGeometryProvider *,bool,QPainter &)57 int getVerticalScaleWidth(LayerGeometryProvider *, bool, QPainter &) const override { return 0; } 58 59 void toXml(QTextStream &stream, QString indent = "", 60 QString extraAttributes = "") const override; 61 62 void setProperties(const QXmlAttributes &attributes) override; 63 canExistWithoutModel()64 bool canExistWithoutModel() const override { return true; } 65 66 protected: 67 ModelId m_model; 68 LabelHeight m_labelHeight; 69 70 int getDefaultColourHint(bool dark, bool &impose) override; 71 72 int64_t getMajorTickUSec(LayerGeometryProvider *, bool &quarterTicks) const; 73 int getXForUSec(LayerGeometryProvider *, double usec) const; 74 }; 75 76 #endif 77