2018-10-07 03:40:25 +00:00
|
|
|
#pragma once
|
2018-07-18 07:39:26 +00:00
|
|
|
|
2019-08-30 06:24:39 +00:00
|
|
|
#include <array>
|
2019-08-28 00:51:38 +00:00
|
|
|
#include <cstdint>
|
|
|
|
#include <vector>
|
|
|
|
|
2018-08-04 02:07:34 +00:00
|
|
|
#include <QFrame>
|
|
|
|
#include <QStaticText>
|
|
|
|
|
2019-08-28 00:51:38 +00:00
|
|
|
#include "EditorWidget.hpp"
|
|
|
|
#include "ProjectModel.hpp"
|
|
|
|
|
|
|
|
#include <amuse/Common.hpp>
|
|
|
|
|
2018-08-04 02:07:34 +00:00
|
|
|
class ADSREditor;
|
|
|
|
|
2019-08-28 00:51:38 +00:00
|
|
|
class QCheckBox;
|
|
|
|
class QDoubleSpinBox;
|
|
|
|
class QLabel;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class ADSRView : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
friend class ADSRControls;
|
|
|
|
amuse::ObjToken<ProjectModel::ADSRNode> m_node;
|
|
|
|
QFont m_gridFont;
|
2019-08-30 06:24:39 +00:00
|
|
|
std::array<QStaticText, 11> m_percentTexts;
|
2018-12-08 05:20:09 +00:00
|
|
|
std::vector<QStaticText> m_timeTexts;
|
|
|
|
int m_dragPoint = -1;
|
|
|
|
uint64_t m_cycleIdx = 0;
|
|
|
|
ADSREditor* getEditor() const;
|
|
|
|
|
2018-08-04 02:07:34 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit ADSRView(QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~ADSRView() override;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
void loadData(ProjectModel::ADSRNode* node);
|
|
|
|
void unloadData();
|
|
|
|
ProjectModel::INode* currentNode() const;
|
2018-08-04 02:07:34 +00:00
|
|
|
|
2019-08-25 04:37:47 +00:00
|
|
|
void paintEvent(QPaintEvent* ev) override;
|
|
|
|
void mousePressEvent(QMouseEvent* ev) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent* ev) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent* ev) override;
|
2018-08-04 02:07:34 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class ADSRControls : public QFrame {
|
|
|
|
Q_OBJECT
|
|
|
|
friend class ADSRView;
|
|
|
|
QDoubleSpinBox* m_attack;
|
|
|
|
QDoubleSpinBox* m_decay;
|
|
|
|
QDoubleSpinBox* m_sustain;
|
|
|
|
QDoubleSpinBox* m_release;
|
|
|
|
QCheckBox* m_dls;
|
|
|
|
QLabel* m_velToAttackLab;
|
|
|
|
QDoubleSpinBox* m_velToAttack;
|
|
|
|
QLabel* m_keyToDecayLab;
|
|
|
|
QDoubleSpinBox* m_keyToDecay;
|
|
|
|
bool m_enableUpdate = true;
|
|
|
|
ADSREditor* getEditor() const;
|
|
|
|
void setAttackAndDecay(double attack, double decay, uint64_t cycleCount);
|
|
|
|
void setDecayAndSustain(double decay, double sustain, uint64_t cycleCount);
|
|
|
|
void setRelease(double release, uint64_t cycleCount);
|
|
|
|
|
2018-08-04 02:07:34 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit ADSRControls(QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~ADSRControls() override;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
void loadData();
|
|
|
|
void unloadData();
|
2019-08-28 00:51:38 +00:00
|
|
|
|
2018-08-04 02:07:34 +00:00
|
|
|
public slots:
|
2018-12-08 05:20:09 +00:00
|
|
|
void attackChanged(double val);
|
|
|
|
void decayChanged(double val);
|
|
|
|
void sustainChanged(double val);
|
|
|
|
void releaseChanged(double val);
|
|
|
|
void dlsStateChanged(int state);
|
|
|
|
void velToAttackChanged(double val);
|
|
|
|
void keyToDecayChanged(double val);
|
2018-08-04 02:07:34 +00:00
|
|
|
};
|
2018-07-18 07:39:26 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class ADSREditor : public EditorWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
friend class ADSRView;
|
|
|
|
friend class ADSRControls;
|
|
|
|
ADSRView* m_adsrView;
|
|
|
|
ADSRControls* m_controls;
|
|
|
|
|
2018-07-18 07:39:26 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit ADSREditor(QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~ADSREditor() override;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
bool loadData(ProjectModel::ADSRNode* node);
|
2019-08-25 04:37:47 +00:00
|
|
|
void unloadData() override;
|
|
|
|
ProjectModel::INode* currentNode() const override;
|
2018-07-18 07:39:26 +00:00
|
|
|
};
|