lmms
Cross-platform music production software
Loading...
Searching...
No Matches
SlicerTWaveform.h
Go to the documentation of this file.
1/*
2 * SlicerTWaveform.h - declaration of class SlicerTWaveform
3 *
4 * Copyright (c) 2023 Daniel Kauss Serna <daniel.kauss.serna@gmail.com>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25#ifndef LMMS_GUI_SLICERT_WAVEFORM_H
26#define LMMS_GUI_SLICERT_WAVEFORM_H
27
28#include <QElapsedTimer>
29#include <QWidget>
30
31namespace lmms {
32
33class SlicerT;
34
35namespace gui {
36
37class SlicerTWaveform : public QWidget
38{
39 Q_OBJECT
40
41public slots:
42 void updateUI();
43 void isPlaying(float current, float start, float end);
44
45public:
46 SlicerTWaveform(int totalWidth, int totalHeight, SlicerT* instrument, QWidget* parent);
47
48 // predefined sizes
49 static constexpr int s_seekerHorMargin = 5;
50 static constexpr int s_seekerVerMargin = 6;
51 static constexpr int s_middleMargin = 6;
52 static constexpr int s_arrowHeight = 5;
53
54 // interaction behavior values
55 static constexpr float s_distanceForClick = 0.02f;
56 static constexpr float s_minSeekerDistance = 0.13f;
57 static constexpr float s_zoomSensitivity = 0.5f;
58 static constexpr int s_minMilisPassed = 10;
59
60 enum class UIObjects
61 {
62 Nothing,
63 SeekerStart,
64 SeekerEnd,
65 SeekerMiddle,
66 SlicePoint,
67 };
68
69protected:
70 void mousePressEvent(QMouseEvent* me) override;
71 void mouseReleaseEvent(QMouseEvent* me) override;
72 void mouseMoveEvent(QMouseEvent* me) override;
73 void mouseDoubleClickEvent(QMouseEvent* me) override;
74 void wheelEvent(QWheelEvent* we) override;
75
76 void paintEvent(QPaintEvent* pe) override;
77 void resizeEvent(QResizeEvent* event) override;
78
79private:
82
83 int m_seekerHeight; // used to calcualte all vertical sizes
87
90
91 float m_seekerStart = 0;
92 float m_seekerEnd = 1;
93 float m_seekerMiddle = 0.5f;
94
97 float m_noteEnd;
98
99 float m_zoomLevel = 1.0f;
100
102 QPixmap m_seeker;
107
109
110 QElapsedTimer m_updateTimer;
111 void drawSeekerWaveform();
112 void drawSeeker();
113 void drawEditorWaveform();
114 void drawEditor();
115
116 void updateClosest(QMouseEvent* me);
117 void updateCursor();
118};
119} // namespace gui
120} // namespace lmms
121#endif // LMMS_GUI_SLICERT_WAVEFORM_H
Definition SlicerT.h:40
int m_closestSlice
Definition SlicerTWaveform.h:89
void wheelEvent(QWheelEvent *we) override
Definition SlicerTWaveform.cpp:468
void updateUI()
Definition SlicerTWaveform.cpp:285
void updateClosest(QMouseEvent *me)
Definition SlicerTWaveform.cpp:295
int m_editorHeight
Definition SlicerTWaveform.h:85
int m_seekerWidth
Definition SlicerTWaveform.h:84
void updateCursor()
Definition SlicerTWaveform.cpp:343
static constexpr int s_seekerVerMargin
Definition SlicerTWaveform.h:50
void mousePressEvent(QMouseEvent *me) override
Definition SlicerTWaveform.cpp:358
float m_seekerMiddle
Definition SlicerTWaveform.h:93
int m_seekerHeight
Definition SlicerTWaveform.h:83
static constexpr int s_minMilisPassed
Definition SlicerTWaveform.h:58
QPixmap m_editorWaveform
Definition SlicerTWaveform.h:104
QElapsedTimer m_updateTimer
Definition SlicerTWaveform.h:110
static constexpr float s_minSeekerDistance
Definition SlicerTWaveform.h:56
float m_zoomLevel
Definition SlicerTWaveform.h:99
SlicerTWaveform(int totalWidth, int totalHeight, SlicerT *instrument, QWidget *parent)
Definition SlicerTWaveform.cpp:68
UIObjects m_closestObject
Definition SlicerTWaveform.h:88
int m_height
Definition SlicerTWaveform.h:81
void mouseDoubleClickEvent(QMouseEvent *me) override
Definition SlicerTWaveform.cpp:453
static constexpr float s_zoomSensitivity
Definition SlicerTWaveform.h:57
void resizeEvent(QResizeEvent *event) override
Definition SlicerTWaveform.cpp:98
void mouseReleaseEvent(QMouseEvent *me) override
Definition SlicerTWaveform.cpp:387
int m_width
Definition SlicerTWaveform.h:80
void drawEditorWaveform()
Definition SlicerTWaveform.cpp:173
void paintEvent(QPaintEvent *pe) override
Definition SlicerTWaveform.cpp:476
static constexpr float s_distanceForClick
Definition SlicerTWaveform.h:55
void drawSeekerWaveform()
Definition SlicerTWaveform.cpp:113
void drawSeeker()
Definition SlicerTWaveform.cpp:138
UIObjects
Definition SlicerTWaveform.h:61
QPixmap m_sliceEditor
Definition SlicerTWaveform.h:105
float m_noteCurrent
Definition SlicerTWaveform.h:95
QPixmap m_seeker
Definition SlicerTWaveform.h:102
float m_seekerStart
Definition SlicerTWaveform.h:91
float m_seekerEnd
Definition SlicerTWaveform.h:92
void drawEditor()
Definition SlicerTWaveform.cpp:204
int m_editorWidth
Definition SlicerTWaveform.h:86
static constexpr int s_seekerHorMargin
Definition SlicerTWaveform.h:49
static constexpr int s_middleMargin
Definition SlicerTWaveform.h:51
SlicerT * m_slicerTParent
Definition SlicerTWaveform.h:108
QPixmap m_seekerWaveform
Definition SlicerTWaveform.h:103
void mouseMoveEvent(QMouseEvent *me) override
Definition SlicerTWaveform.cpp:395
QPixmap m_emptySampleIcon
Definition SlicerTWaveform.h:106
static constexpr int s_arrowHeight
Definition SlicerTWaveform.h:52
void isPlaying(float current, float start, float end)
Definition SlicerTWaveform.cpp:272
float m_noteEnd
Definition SlicerTWaveform.h:97
QPixmap m_sliceArrow
Definition SlicerTWaveform.h:101
float m_noteStart
Definition SlicerTWaveform.h:96
Definition AudioPortAudio.cpp:209
Definition RemotePluginBase.cpp:34