2018-10-07 03:40:25 +00:00
|
|
|
#pragma once
|
2018-08-16 06:26:44 +00:00
|
|
|
|
2019-08-28 04:33:12 +00:00
|
|
|
#include <array>
|
2019-08-28 00:51:38 +00:00
|
|
|
#include <string>
|
|
|
|
|
2018-08-16 06:26:44 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QLayoutItem>
|
2019-08-28 00:51:38 +00:00
|
|
|
#include <QMouseEvent>
|
2018-08-16 06:26:44 +00:00
|
|
|
#include <QPropertyAnimation>
|
2019-08-28 00:51:38 +00:00
|
|
|
#include <QPushButton>
|
2018-08-16 06:26:44 +00:00
|
|
|
#include <QScrollArea>
|
|
|
|
#include <QSplitter>
|
2019-08-28 00:51:38 +00:00
|
|
|
#include <QStaticText>
|
|
|
|
#include <QTreeWidget>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
#include "EditorWidget.hpp"
|
2018-08-16 06:26:44 +00:00
|
|
|
|
2019-08-28 00:51:38 +00:00
|
|
|
namespace amuse {
|
|
|
|
class EffectBaseTypeless;
|
|
|
|
class Studio;
|
|
|
|
class Submix;
|
|
|
|
|
|
|
|
enum class EffectType;
|
|
|
|
} // namespace amuse
|
|
|
|
|
2019-08-28 05:29:00 +00:00
|
|
|
class EffectListing;
|
|
|
|
|
|
|
|
struct EffectIntrospection;
|
2018-08-16 06:26:44 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class Uint32X8Popup : public QFrame {
|
|
|
|
Q_OBJECT
|
2018-08-19 00:28:52 +00:00
|
|
|
public:
|
2019-08-28 04:33:12 +00:00
|
|
|
static constexpr int NumSliders = 8;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit Uint32X8Popup(int min, int max, QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~Uint32X8Popup() override;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
void setValue(int chanIdx, int val);
|
2019-08-28 00:51:38 +00:00
|
|
|
|
2018-08-19 00:28:52 +00:00
|
|
|
private slots:
|
2018-12-08 05:20:09 +00:00
|
|
|
void doValueChanged(int val);
|
2019-08-28 00:51:38 +00:00
|
|
|
|
2018-08-19 00:28:52 +00:00
|
|
|
signals:
|
2018-12-08 05:20:09 +00:00
|
|
|
void valueChanged(int chanIdx, int val);
|
2019-08-28 04:33:12 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::array<FieldSlider*, NumSliders> m_sliders;
|
2018-08-19 00:28:52 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class Uint32X8Button : public QPushButton {
|
|
|
|
Q_OBJECT
|
|
|
|
Uint32X8Popup* m_popup;
|
|
|
|
|
2018-08-19 00:28:52 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit Uint32X8Button(int min, int max, QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~Uint32X8Button() override;
|
|
|
|
|
2019-08-25 04:37:47 +00:00
|
|
|
void paintEvent(QPaintEvent* event) override;
|
2018-12-08 05:20:09 +00:00
|
|
|
Uint32X8Popup* popup() const { return m_popup; }
|
|
|
|
QStyleOptionComboBox comboStyleOption() const;
|
2019-08-28 00:51:38 +00:00
|
|
|
|
2018-08-19 00:28:52 +00:00
|
|
|
private slots:
|
2018-12-08 05:20:09 +00:00
|
|
|
void onPressed();
|
2018-08-19 00:28:52 +00:00
|
|
|
};
|
2018-08-16 06:26:44 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class EffectWidget : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
friend class EffectListing;
|
|
|
|
QFont m_numberFont;
|
|
|
|
QLabel m_titleLabel;
|
|
|
|
ListingDeleteButton m_deleteButton;
|
|
|
|
QStaticText m_numberText;
|
|
|
|
int m_index = -1;
|
|
|
|
amuse::EffectBaseTypeless* m_effect;
|
|
|
|
const EffectIntrospection* m_introspection;
|
|
|
|
void setIndex(int index);
|
2019-08-28 00:51:38 +00:00
|
|
|
|
2018-08-16 06:26:44 +00:00
|
|
|
private slots:
|
2018-12-08 05:20:09 +00:00
|
|
|
void numChanged(int);
|
|
|
|
void numChanged(double);
|
|
|
|
void chanNumChanged(int, int);
|
|
|
|
void deleteClicked();
|
|
|
|
|
2018-08-16 06:26:44 +00:00
|
|
|
private:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit EffectWidget(QWidget* parent, amuse::EffectBaseTypeless* effect, amuse::EffectType type);
|
2019-08-28 00:51:38 +00:00
|
|
|
~EffectWidget() override;
|
2018-12-08 05:20:09 +00:00
|
|
|
|
2018-08-16 06:26:44 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
EffectListing* getParent() const;
|
|
|
|
explicit EffectWidget(QWidget* parent, amuse::EffectBaseTypeless* effect);
|
|
|
|
explicit EffectWidget(QWidget* parent, amuse::EffectType op);
|
2019-08-25 04:37:47 +00:00
|
|
|
void paintEvent(QPaintEvent* event) override;
|
2018-12-08 05:20:09 +00:00
|
|
|
QString getText() const { return m_titleLabel.text(); }
|
2018-08-16 06:26:44 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class EffectWidgetContainer : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
friend class EffectListing;
|
|
|
|
EffectWidget* m_effectWidget;
|
|
|
|
QPropertyAnimation* m_animation = nullptr;
|
|
|
|
void animateOpen();
|
|
|
|
void animateClosed();
|
|
|
|
void snapOpen();
|
|
|
|
void snapClosed();
|
2018-08-16 06:26:44 +00:00
|
|
|
private slots:
|
2018-12-08 05:20:09 +00:00
|
|
|
void animationDestroyed();
|
|
|
|
|
2018-08-16 06:26:44 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
template <class... _Args>
|
|
|
|
EffectWidgetContainer(QWidget* parent, _Args&&... args);
|
2019-08-28 00:51:38 +00:00
|
|
|
~EffectWidgetContainer() override;
|
2018-08-16 06:26:44 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class EffectListing : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
friend class EffectWidget;
|
|
|
|
friend class StudioSetupWidget;
|
|
|
|
amuse::Submix* m_submix = nullptr;
|
|
|
|
QVBoxLayout* m_layout;
|
|
|
|
QLayoutItem* m_dragItem = nullptr;
|
|
|
|
int m_origIdx = -1;
|
|
|
|
int m_dragOpenIdx = -1;
|
|
|
|
EffectWidgetContainer* m_prevDragOpen = nullptr;
|
|
|
|
int m_autoscrollTimer = -1;
|
|
|
|
int m_autoscrollDelta = 0;
|
|
|
|
QWidget* m_autoscrollSource = nullptr;
|
2021-01-24 00:27:34 +00:00
|
|
|
QMouseEvent* m_autoscrollEvent = nullptr;
|
2018-12-08 05:20:09 +00:00
|
|
|
void startAutoscroll(QWidget* source, QMouseEvent* event, int delta);
|
|
|
|
void stopAutoscroll();
|
|
|
|
bool beginDrag(EffectWidget* widget);
|
|
|
|
void endDrag();
|
|
|
|
void cancelDrag();
|
|
|
|
void _moveDrag(int hoverIdx, const QPoint& pt, QWidget* source, QMouseEvent* event);
|
|
|
|
void moveDrag(EffectWidget* widget, const QPoint& pt, QWidget* source, QMouseEvent* event);
|
|
|
|
int moveInsertDrag(const QPoint& pt, QWidget* source, QMouseEvent* event);
|
|
|
|
void insertDragout();
|
|
|
|
void insert(amuse::EffectType type, const QString& text);
|
|
|
|
void deleteEffect(int index);
|
|
|
|
void reindex();
|
|
|
|
void clear();
|
|
|
|
|
2018-08-16 06:26:44 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit EffectListing(QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~EffectListing() override;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
bool loadData(amuse::Submix* submix);
|
|
|
|
void unloadData();
|
2019-08-25 04:37:47 +00:00
|
|
|
void timerEvent(QTimerEvent* event) override;
|
2018-08-16 06:26:44 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class EffectCatalogueItem : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
amuse::EffectType m_type;
|
|
|
|
QLabel m_iconLab;
|
|
|
|
QLabel m_label;
|
|
|
|
|
2018-08-16 06:26:44 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit EffectCatalogueItem(amuse::EffectType type, const QString& name, const QString& doc,
|
|
|
|
QWidget* parent = Q_NULLPTR);
|
|
|
|
explicit EffectCatalogueItem(const EffectCatalogueItem& other, QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~EffectCatalogueItem() override;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
amuse::EffectType getType() const { return m_type; }
|
|
|
|
QString getText() const { return m_label.text(); }
|
2018-08-16 06:26:44 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class EffectCatalogue : public QTreeWidget {
|
|
|
|
Q_OBJECT
|
2018-08-16 06:26:44 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit EffectCatalogue(QWidget* parent = Q_NULLPTR);
|
2019-08-25 04:37:47 +00:00
|
|
|
void mousePressEvent(QMouseEvent* event) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent* event) override;
|
2018-08-16 06:26:44 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class StudioSetupWidget : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
friend class EffectCatalogue;
|
|
|
|
QSplitter* m_splitter;
|
|
|
|
QTabWidget* m_tabs;
|
2019-08-28 04:33:12 +00:00
|
|
|
std::array<EffectListing*, 2> m_listing{};
|
2018-12-08 05:20:09 +00:00
|
|
|
EffectCatalogue* m_catalogue;
|
|
|
|
EffectWidget* m_draggedCmd = nullptr;
|
|
|
|
EffectCatalogueItem* m_draggedItem = nullptr;
|
|
|
|
QPoint m_draggedPt;
|
|
|
|
int m_dragInsertIdx = -1;
|
|
|
|
EffectListing* getCurrentListing() const;
|
|
|
|
void beginCommandDrag(EffectWidget* widget, const QPoint& eventPt, const QPoint& pt);
|
|
|
|
void beginCatalogueDrag(EffectCatalogueItem* item, const QPoint& eventPt, const QPoint& pt);
|
|
|
|
|
2018-08-16 06:26:44 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit StudioSetupWidget(QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~StudioSetupWidget() override;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
bool loadData(amuse::Studio* studio);
|
|
|
|
void unloadData();
|
2018-08-16 06:26:44 +00:00
|
|
|
|
2019-08-25 04:37:47 +00:00
|
|
|
void mousePressEvent(QMouseEvent* event) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent* event) override;
|
|
|
|
void keyPressEvent(QKeyEvent* event) override;
|
2018-08-16 06:26:44 +00:00
|
|
|
|
2019-08-25 04:37:47 +00:00
|
|
|
void hideEvent(QHideEvent* event) override;
|
|
|
|
void showEvent(QShowEvent* event) override;
|
2018-12-08 05:20:09 +00:00
|
|
|
void updateWindowPosition();
|
2018-08-16 06:26:44 +00:00
|
|
|
|
|
|
|
public slots:
|
2018-12-08 05:20:09 +00:00
|
|
|
void catalogueDoubleClicked(QTreeWidgetItem* item, int column);
|
2018-08-16 06:26:44 +00:00
|
|
|
|
|
|
|
signals:
|
2018-12-08 05:20:09 +00:00
|
|
|
void hidden();
|
|
|
|
void shown();
|
2018-08-16 06:26:44 +00:00
|
|
|
};
|