2018-10-07 03:40:25 +00:00
|
|
|
#pragma once
|
2018-07-09 18:05:31 +00:00
|
|
|
|
2018-07-22 03:45:47 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QMouseEvent>
|
2018-07-26 03:41:48 +00:00
|
|
|
#include <QPushButton>
|
2019-08-28 00:51:38 +00:00
|
|
|
#include <QStaticText>
|
|
|
|
#include <QTreeWidget>
|
|
|
|
|
|
|
|
#include "EditorWidget.hpp"
|
|
|
|
#include "ProjectModel.hpp"
|
|
|
|
|
|
|
|
#include <amuse/AudioGroupPool.hpp>
|
|
|
|
#include <amuse/Common.hpp>
|
2018-07-22 03:45:47 +00:00
|
|
|
|
2019-08-28 00:51:38 +00:00
|
|
|
class CatalogueItem;
|
2018-07-28 04:34:29 +00:00
|
|
|
class SoundMacroEditor;
|
2018-07-22 03:45:47 +00:00
|
|
|
class SoundMacroListing;
|
2019-08-28 00:51:38 +00:00
|
|
|
|
|
|
|
class QLayoutItem;
|
|
|
|
class QPropertyAnimation;
|
|
|
|
class QSplitter;
|
|
|
|
class QVBoxLayout;
|
2018-07-22 03:45:47 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class TargetButton : public QPushButton {
|
|
|
|
Q_OBJECT
|
2018-07-28 04:34:29 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit TargetButton(QWidget* parent = Q_NULLPTR);
|
2019-08-25 04:37:47 +00:00
|
|
|
void mouseReleaseEvent(QMouseEvent* event) override { event->ignore(); }
|
|
|
|
void mouseMoveEvent(QMouseEvent* event) override { event->ignore(); }
|
|
|
|
void focusOutEvent(QFocusEvent* event) override { event->ignore(); }
|
|
|
|
void keyPressEvent(QKeyEvent* event) override { event->ignore(); }
|
2018-07-28 04:34:29 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class FieldSoundMacroStep : public QWidget {
|
|
|
|
friend class CommandWidget;
|
|
|
|
Q_OBJECT
|
|
|
|
FieldProjectNode* m_macroField;
|
|
|
|
FieldSpinBox m_spinBox;
|
|
|
|
TargetButton m_targetButton;
|
|
|
|
SoundMacroEditor* getEditor() const;
|
|
|
|
SoundMacroListing* getListing() const;
|
2018-07-28 04:34:29 +00:00
|
|
|
signals:
|
2018-12-08 05:20:09 +00:00
|
|
|
void valueChanged(int);
|
2018-07-28 04:34:29 +00:00
|
|
|
public slots:
|
2018-12-08 05:20:09 +00:00
|
|
|
void targetPressed();
|
|
|
|
void updateMacroField();
|
|
|
|
|
2018-07-28 04:34:29 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit FieldSoundMacroStep(FieldProjectNode* macroField = Q_NULLPTR, QWidget* parent = Q_NULLPTR);
|
2019-08-25 04:37:47 +00:00
|
|
|
~FieldSoundMacroStep() override;
|
2018-12-08 05:20:09 +00:00
|
|
|
void setIndex(int index);
|
|
|
|
void cancel();
|
2018-07-28 04:34:29 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class CommandWidget : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
friend class SoundMacroListing;
|
|
|
|
QFont m_numberFont;
|
|
|
|
QLabel m_titleLabel;
|
|
|
|
ListingDeleteButton m_deleteButton;
|
|
|
|
QStaticText m_numberText;
|
|
|
|
int m_index = -1;
|
|
|
|
amuse::SoundMacro::ICmd* m_cmd;
|
|
|
|
const amuse::SoundMacro::CmdIntrospection* m_introspection;
|
|
|
|
FieldSoundMacroStep* m_stepField = nullptr;
|
|
|
|
void setIndex(int index);
|
|
|
|
SoundMacroListing* getParent() const;
|
2018-07-22 03:45:47 +00:00
|
|
|
private slots:
|
2018-12-08 05:20:09 +00:00
|
|
|
void boolChanged(int);
|
|
|
|
void numChanged(int);
|
|
|
|
void nodeChanged(int);
|
|
|
|
void deleteClicked();
|
|
|
|
|
2018-07-22 03:45:47 +00:00
|
|
|
private:
|
2018-12-08 05:20:09 +00:00
|
|
|
CommandWidget(QWidget* parent, amuse::SoundMacro::ICmd* cmd, amuse::SoundMacro::CmdOp op, SoundMacroListing* listing);
|
|
|
|
|
2018-07-20 06:38:09 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
CommandWidget(QWidget* parent, amuse::SoundMacro::ICmd* cmd, SoundMacroListing* listing);
|
|
|
|
CommandWidget(QWidget* parent, amuse::SoundMacro::CmdOp op, SoundMacroListing* listing);
|
2019-08-28 00:51:38 +00:00
|
|
|
~CommandWidget() override;
|
|
|
|
|
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-07-26 03:41:48 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class CommandWidgetContainer : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
friend class SoundMacroListing;
|
|
|
|
CommandWidget* m_commandWidget;
|
|
|
|
QPropertyAnimation* m_animation = nullptr;
|
|
|
|
void animateOpen();
|
|
|
|
void animateClosed();
|
|
|
|
void snapOpen();
|
|
|
|
void snapClosed();
|
2019-08-28 00:51:38 +00:00
|
|
|
|
2018-07-26 03:41:48 +00:00
|
|
|
private slots:
|
2018-12-08 05:20:09 +00:00
|
|
|
void animationDestroyed();
|
|
|
|
|
2018-07-26 03:41:48 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
template <class... _Args>
|
|
|
|
CommandWidgetContainer(QWidget* parent, _Args&&... args);
|
2019-08-28 00:51:38 +00:00
|
|
|
~CommandWidgetContainer() override;
|
2018-07-22 03:45:47 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class SoundMacroListing : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
friend class CommandWidget;
|
|
|
|
friend class SoundMacroEditor;
|
|
|
|
amuse::ObjToken<ProjectModel::SoundMacroNode> m_node;
|
|
|
|
QVBoxLayout* m_layout;
|
|
|
|
QLayoutItem* m_dragItem = nullptr;
|
|
|
|
int m_origIdx = -1;
|
|
|
|
int m_dragOpenIdx = -1;
|
|
|
|
CommandWidgetContainer* m_prevDragOpen = nullptr;
|
|
|
|
int m_autoscrollTimer = -1;
|
|
|
|
int m_autoscrollDelta = 0;
|
|
|
|
QWidget* m_autoscrollSource = nullptr;
|
|
|
|
QMouseEvent m_autoscrollEvent = {{}, {}, {}, {}, {}};
|
|
|
|
void startAutoscroll(QWidget* source, QMouseEvent* event, int delta);
|
|
|
|
void stopAutoscroll();
|
|
|
|
bool beginDrag(CommandWidget* widget);
|
|
|
|
void endDrag();
|
|
|
|
void cancelDrag();
|
|
|
|
void _moveDrag(int hoverIdx, const QPoint& pt, QWidget* source, QMouseEvent* event);
|
|
|
|
void moveDrag(CommandWidget* widget, const QPoint& pt, QWidget* source, QMouseEvent* event);
|
|
|
|
int moveInsertDrag(const QPoint& pt, QWidget* source, QMouseEvent* event);
|
|
|
|
void insertDragout();
|
|
|
|
void insert(amuse::SoundMacro::CmdOp op, const QString& text);
|
|
|
|
void deleteCommand(int index);
|
|
|
|
void reindex();
|
|
|
|
void clear();
|
|
|
|
|
2018-07-22 03:45:47 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit SoundMacroListing(QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~SoundMacroListing() override;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
bool loadData(ProjectModel::SoundMacroNode* node);
|
|
|
|
void unloadData();
|
|
|
|
ProjectModel::INode* currentNode() const;
|
2019-08-25 04:37:47 +00:00
|
|
|
void timerEvent(QTimerEvent* event) override;
|
2018-07-22 03:45:47 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class CatalogueItem : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
amuse::SoundMacro::CmdOp m_op;
|
|
|
|
QLabel m_iconLab;
|
|
|
|
QLabel m_label;
|
|
|
|
|
2018-07-22 03:45:47 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit CatalogueItem(amuse::SoundMacro::CmdOp op, const QString& name, const QString& doc,
|
|
|
|
QWidget* parent = Q_NULLPTR);
|
|
|
|
explicit CatalogueItem(const CatalogueItem& other, QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~CatalogueItem() override;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
amuse::SoundMacro::CmdOp getCmdOp() const { return m_op; }
|
|
|
|
QString getText() const { return m_label.text(); }
|
2018-07-22 03:45:47 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class SoundMacroCatalogue : public QTreeWidget {
|
|
|
|
Q_OBJECT
|
2018-07-22 03:45:47 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit SoundMacroCatalogue(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-07-20 06:38:09 +00:00
|
|
|
};
|
2018-07-09 18:05:31 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
class SoundMacroEditor : public EditorWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
friend class SoundMacroCatalogue;
|
|
|
|
friend class FieldSoundMacroStep;
|
|
|
|
QSplitter* m_splitter;
|
|
|
|
SoundMacroListing* m_listing;
|
|
|
|
SoundMacroCatalogue* m_catalogue;
|
|
|
|
CommandWidget* m_draggedCmd = nullptr;
|
|
|
|
CatalogueItem* m_draggedItem = nullptr;
|
|
|
|
FieldSoundMacroStep* m_targetField = nullptr;
|
|
|
|
QPoint m_draggedPt;
|
|
|
|
int m_dragInsertIdx = -1;
|
|
|
|
void beginCommandDrag(CommandWidget* widget, const QPoint& eventPt, const QPoint& pt);
|
|
|
|
void beginCatalogueDrag(CatalogueItem* item, const QPoint& eventPt, const QPoint& pt);
|
|
|
|
void beginStepTarget(FieldSoundMacroStep* stepField);
|
|
|
|
void endStepTarget();
|
|
|
|
|
2018-07-09 18:05:31 +00:00
|
|
|
public:
|
2018-12-08 05:20:09 +00:00
|
|
|
explicit SoundMacroEditor(QWidget* parent = Q_NULLPTR);
|
2019-08-28 00:51:38 +00:00
|
|
|
~SoundMacroEditor() override;
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
bool loadData(ProjectModel::SoundMacroNode* node);
|
2019-08-25 04:37:47 +00:00
|
|
|
void unloadData() override;
|
|
|
|
ProjectModel::INode* currentNode() const override;
|
2018-07-22 03:45:47 +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-07-25 06:01:01 +00:00
|
|
|
|
|
|
|
public slots:
|
2018-12-08 05:20:09 +00:00
|
|
|
void catalogueDoubleClicked(QTreeWidgetItem* item, int column);
|
2018-07-09 18:05:31 +00:00
|
|
|
};
|