LMMS
Loading...
Searching...
No Matches
FloatModelEditorBase.h
Go to the documentation of this file.
1/*
2 * FloatModelEditorBase.h - Base editor for float models
3 *
4 * Copyright (c) 2004-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5 * Copyright (c) 2023 Michael Gregorius
6 *
7 * This file is part of LMMS - https://lmms.io
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program (see COPYING); if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA.
23 *
24 */
25
26#ifndef LMMS_GUI_FLOAT_MODEL_EDITOR_BASE_H
27#define LMMS_GUI_FLOAT_MODEL_EDITOR_BASE_H
28
29#include <QWidget>
30#include <QPoint>
31
33
34
35namespace lmms::gui
36{
37
38class SimpleTextFloat;
39
40class LMMS_EXPORT FloatModelEditorBase : public QWidget, public FloatModelView
41{
42 Q_OBJECT
43
44 mapPropertyFromModel(float, volumeRatio, setVolumeRatio, m_volumeRatio);
45
46 void initUi(const QString & name);
47
48public:
50 {
51 Vertical,
52 Horizontal
53 };
54
55 FloatModelEditorBase(DirectionOfManipulation directionOfManipulation = DirectionOfManipulation::Vertical, QWidget * _parent = nullptr, const QString & _name = QString());
57
58 // TODO: remove
59 inline void setHintText(const QString & txt_before, const QString & txt_after)
60 {
61 setDescription(txt_before);
62 setUnit(txt_after);
63 }
64
65 bool isVolumeKnob() const
66 {
67 return m_volumeKnob;
68 }
69
70 void setVolumeKnob(const bool val)
71 {
73 }
74
75signals:
78 void sliderMoved(float value);
79
80
81protected:
82 void contextMenuEvent(QContextMenuEvent * me) override;
83 void dragEnterEvent(QDragEnterEvent * dee) override;
84 void dropEvent(QDropEvent * de) override;
85 void focusOutEvent(QFocusEvent * fe) override;
86 void mousePressEvent(QMouseEvent * me) override;
87 void mouseReleaseEvent(QMouseEvent * me) override;
88 void mouseMoveEvent(QMouseEvent * me) override;
89 void mouseDoubleClickEvent(QMouseEvent * me) override;
90 void paintEvent(QPaintEvent * me) override;
91 void wheelEvent(QWheelEvent * me) override;
92
93#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
94 void enterEvent(QEnterEvent*) override;
95#else
96 void enterEvent(QEvent*) override;
97#endif
98 void leaveEvent(QEvent *event) override;
99
100 virtual float getValue(const QPoint & p);
101 virtual QString displayValue() const;
102
103 void doConnections() override;
104
105 void showTextFloat(int msecBeforeDisplay, int msecDisplayTime);
106 void setPosition(const QPoint & p);
107
108 inline float pageSize() const
109 {
110 return (model()->maxValue() - model()->minValue()) / 100.0f;
111 }
112
114
117
121
123
124private slots:
125 virtual void enterValue();
126 void friendlyUpdate();
127 void toggleScale();
128};
129
130} // namespace lmms::gui
131
132#endif // LMMS_GUI_FLOAT_MODEL_EDITOR_BASE_H
Definition AutomatableModel.h:463
void setUnit(const QString &unit)
Definition AutomatableModelView.h:69
void setDescription(const QString &desc)
Definition AutomatableModelView.h:64
T value() const
Definition AutomatableModelView.h:59
Definition FloatModelEditorBase.h:41
float pageSize() const
Definition FloatModelEditorBase.h:108
void setPosition(const QPoint &p)
Definition FloatModelEditorBase.cpp:351
virtual QString displayValue() const
Definition FloatModelEditorBase.cpp:437
DirectionOfManipulation
Definition FloatModelEditorBase.h:50
void mousePressEvent(QMouseEvent *me) override
Definition FloatModelEditorBase.cpp:156
void enterEvent(QEnterEvent *) override
Definition FloatModelEditorBase.cpp:234
FloatModelEditorBase(DirectionOfManipulation directionOfManipulation=DirectionOfManipulation::Vertical, QWidget *_parent=nullptr, const QString &_name=QString())
default ctor
Definition FloatModelEditorBase.cpp:50
void toggleScale()
Definition FloatModelEditorBase.cpp:122
FloatModel m_volumeRatio
Definition FloatModelEditorBase.h:116
QPoint m_lastMousePos
mouse position in last mouseMoveEvent
Definition FloatModelEditorBase.h:118
void setHintText(const QString &txt_before, const QString &txt_after)
Definition FloatModelEditorBase.h:59
bool m_volumeKnob
Definition FloatModelEditorBase.h:115
void leaveEvent(QEvent *event) override
Definition FloatModelEditorBase.cpp:243
bool m_buttonPressed
Definition FloatModelEditorBase.h:120
void paintEvent(QPaintEvent *me) override
Definition FloatModelEditorBase.cpp:263
void wheelEvent(QWheelEvent *me) override
Definition FloatModelEditorBase.cpp:285
mapPropertyFromModel(float, volumeRatio, setVolumeRatio, m_volumeRatio)
bool isVolumeKnob() const
Definition FloatModelEditorBase.h:65
void initUi(const QString &name)
to be called by ctors
Definition FloatModelEditorBase.cpp:62
void setVolumeKnob(const bool val)
Definition FloatModelEditorBase.h:70
virtual void enterValue()
Definition FloatModelEditorBase.cpp:378
FloatModelEditorBase(const FloatModelEditorBase &other)=delete
void focusOutEvent(QFocusEvent *fe) override
Definition FloatModelEditorBase.cpp:249
DirectionOfManipulation m_directionOfManipulation
Definition FloatModelEditorBase.h:122
void showTextFloat(int msecBeforeDisplay, int msecDisplayTime)
Definition FloatModelEditorBase.cpp:77
void mouseDoubleClickEvent(QMouseEvent *me) override
Definition FloatModelEditorBase.cpp:257
static SimpleTextFloat * s_textFloat
Definition FloatModelEditorBase.h:113
void mouseMoveEvent(QMouseEvent *me) override
Definition FloatModelEditorBase.cpp:196
void contextMenuEvent(QContextMenuEvent *me) override
Definition FloatModelEditorBase.cpp:104
float m_leftOver
Definition FloatModelEditorBase.h:119
void friendlyUpdate()
Definition FloatModelEditorBase.cpp:422
void dropEvent(QDropEvent *de) override
Definition FloatModelEditorBase.cpp:136
void doConnections() override
Definition FloatModelEditorBase.cpp:454
virtual float getValue(const QPoint &p)
Definition FloatModelEditorBase.cpp:85
void mouseReleaseEvent(QMouseEvent *me) override
Definition FloatModelEditorBase.cpp:213
void dragEnterEvent(QDragEnterEvent *dee) override
Definition FloatModelEditorBase.cpp:129
Definition SimpleTextFloat.h:40
FloatModel * model()
Definition AutomatableModelView.h:121
static const char * name
Definition pugl.h:1582
int val
Definition jpeglib.h:956
Definition AudioPortAudio.cpp:223
TypedModelView< FloatModel > FloatModelView
Definition AutomatableModelView.h:131
uch * p
Definition crypt.c:594