1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 3 /* 4 Rosegarden 5 A MIDI and audio sequencer and musical notation editor. 6 Copyright 2000-2021 the Rosegarden development team. 7 8 Other copyrights also apply to some parts of this work. Please 9 see the AUTHORS file and individual file headers for details. 10 11 This program is free software; you can redistribute it and/or 12 modify it under the terms of the GNU General Public License as 13 published by the Free Software Foundation; either version 2 of the 14 License, or (at your option) any later version. See the file 15 COPYING included with this distribution for more information. 16 */ 17 18 #ifndef RG_TEMPORULER_H 19 #define RG_TEMPORULER_H 20 21 #include "gui/dialogs/TempoDialog.h" 22 #include "gui/general/ActionFileClient.h" 23 24 #include "base/Event.h" 25 26 #include <QFont> 27 #include <QFontMetrics> 28 #include <QPixmap> 29 #include <QSize> 30 #include <QWidget> 31 32 33 class QWheelEvent; 34 class QMenu; 35 class QPaintEvent; 36 class QMouseEvent; 37 class QEvent; 38 39 namespace Rosegarden 40 { 41 42 class EditTempoController; 43 class RulerScale; 44 class RosegardenDocument; 45 class Composition; 46 47 48 /** 49 * TempoRuler is a widget that shows a strip of tempo values at 50 * x-coordinates corresponding to tempo changes in a Composition. 51 */ 52 53 class TempoRuler : public QWidget, public ActionFileClient 54 { 55 Q_OBJECT 56 57 public: 58 /** 59 * Construct a TempoRuler that displays and allows editing of the 60 * tempo changes found in the given Composition, with positions 61 * calculated by the given RulerScale. 62 * 63 * The RulerScale will not be destroyed along with the TempoRuler. 64 */ 65 TempoRuler(RulerScale *rulerScale, 66 RosegardenDocument *doc, 67 int height = 0, 68 bool small = false, 69 bool Thorn = true); 70 71 ~TempoRuler() override; 72 73 QSize sizeHint() const override; 74 QSize minimumSizeHint() const override; 75 setMinimumWidth(int width)76 void setMinimumWidth(int width) { m_width = width; } 77 78 signals: 79 void mousePress(); 80 void mouseRelease(); 81 82 public slots: 83 void slotScrollHoriz(int x); 84 85 protected slots: 86 void slotInsertTempoHere(); 87 void slotInsertTempoAtPointer(); 88 void slotDeleteTempoChange(); 89 void slotRampToNext(); 90 void slotUnramp(); 91 void slotEditTempo(); 92 void slotEditTimeSignature(); 93 void slotEditTempos(); 94 95 protected: 96 void paintEvent(QPaintEvent *) override; 97 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) 98 void enterEvent(QEnterEvent *) override; 99 #else 100 void enterEvent(QEvent *) override; 101 #endif 102 void leaveEvent(QEvent *) override; 103 void mousePressEvent(QMouseEvent *) override; 104 void mouseReleaseEvent(QMouseEvent *) override; 105 void mouseMoveEvent(QMouseEvent *) override; 106 void wheelEvent(QWheelEvent *) override; 107 108 void createMenu(); 109 110 private: 111 int m_height; 112 int m_currentXOffset; 113 int m_width; 114 bool m_small; 115 int m_illuminate; 116 bool m_illuminatePoint; 117 bool m_illuminateTarget; 118 bool m_refreshLinesOnly; 119 120 bool m_dragVert; 121 bool m_dragTarget; 122 bool m_dragHoriz; 123 int m_dragStartY; 124 int m_dragStartX; 125 bool m_dragFine; 126 int m_clickX; 127 128 timeT m_dragStartTime; 129 timeT m_dragPreviousTime; 130 tempoT m_dragStartTempo; 131 tempoT m_dragStartTarget; 132 tempoT m_dragOriginalTempo; 133 tempoT m_dragOriginalTarget; 134 135 int getYForTempo(tempoT tempo); 136 tempoT getTempoForY(int y); 137 void showTextFloat(tempoT tempo, 138 tempoT target = -1, 139 timeT time = -1, 140 bool showTime = false); 141 142 Composition *m_composition; 143 RulerScale *m_rulerScale; 144 QMenu *m_menu; 145 EditTempoController *m_editTempoController; 146 147 QFont m_font; 148 QFont m_boldFont; 149 QFontMetrics m_fontMetrics; 150 QPixmap m_buffer; 151 152 bool m_Thorn; 153 }; 154 155 156 } 157 158 #endif 159