2018-07-09 18:05:31 +00:00
|
|
|
#ifndef AMUSE_SOUND_MACRO_EDITOR_HPP
|
|
|
|
#define AMUSE_SOUND_MACRO_EDITOR_HPP
|
|
|
|
|
2018-07-14 06:06:33 +00:00
|
|
|
#include "EditorWidget.hpp"
|
2018-07-20 06:38:09 +00:00
|
|
|
#include <QStaticText>
|
2018-07-22 03:45:47 +00:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QPropertyAnimation>
|
|
|
|
#include <QSplitter>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <QSpinBox>
|
2018-07-25 06:01:01 +00:00
|
|
|
#include <QComboBox>
|
|
|
|
#include <QTreeWidget>
|
2018-07-26 03:41:48 +00:00
|
|
|
#include <QPushButton>
|
2018-07-22 03:45:47 +00:00
|
|
|
|
2018-07-28 04:34:29 +00:00
|
|
|
class SoundMacroEditor;
|
2018-07-22 03:45:47 +00:00
|
|
|
class SoundMacroListing;
|
|
|
|
class CatalogueItem;
|
|
|
|
|
2018-07-28 04:34:29 +00:00
|
|
|
class TargetButton : public QPushButton
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit TargetButton(QWidget* parent = Q_NULLPTR);
|
|
|
|
void mouseReleaseEvent(QMouseEvent* event) { event->ignore(); }
|
|
|
|
void mouseMoveEvent(QMouseEvent* event) { event->ignore(); }
|
2018-08-16 06:26:44 +00:00
|
|
|
void focusOutEvent(QFocusEvent* event) { event->ignore(); }
|
|
|
|
void keyPressEvent(QKeyEvent* event) { event->ignore(); }
|
2018-07-28 04:34:29 +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;
|
|
|
|
signals:
|
|
|
|
void valueChanged(int);
|
|
|
|
public slots:
|
|
|
|
void targetPressed();
|
|
|
|
void updateMacroField();
|
|
|
|
public:
|
|
|
|
explicit FieldSoundMacroStep(FieldProjectNode* macroField = Q_NULLPTR, QWidget* parent = Q_NULLPTR);
|
|
|
|
~FieldSoundMacroStep();
|
|
|
|
void setIndex(int index);
|
|
|
|
void cancel();
|
|
|
|
};
|
|
|
|
|
2018-07-20 06:38:09 +00:00
|
|
|
class CommandWidget : public QWidget
|
|
|
|
{
|
2018-07-22 03:45:47 +00:00
|
|
|
Q_OBJECT
|
|
|
|
friend class SoundMacroListing;
|
2018-07-20 06:38:09 +00:00
|
|
|
QFont m_numberFont;
|
2018-07-26 03:41:48 +00:00
|
|
|
QLabel m_titleLabel;
|
2018-08-16 06:26:44 +00:00
|
|
|
ListingDeleteButton m_deleteButton;
|
2018-07-20 06:38:09 +00:00
|
|
|
QStaticText m_numberText;
|
2018-07-26 03:41:48 +00:00
|
|
|
int m_index = -1;
|
2018-07-22 03:45:47 +00:00
|
|
|
amuse::SoundMacro::ICmd* m_cmd;
|
|
|
|
const amuse::SoundMacro::CmdIntrospection* m_introspection;
|
2018-07-28 04:34:29 +00:00
|
|
|
FieldSoundMacroStep* m_stepField = nullptr;
|
2018-07-22 03:45:47 +00:00
|
|
|
void setIndex(int index);
|
2018-07-26 03:41:48 +00:00
|
|
|
SoundMacroListing* getParent() const;
|
2018-07-22 03:45:47 +00:00
|
|
|
private slots:
|
|
|
|
void boolChanged(int);
|
|
|
|
void numChanged(int);
|
2018-07-28 04:34:29 +00:00
|
|
|
void nodeChanged(int);
|
2018-07-26 03:41:48 +00:00
|
|
|
void deleteClicked();
|
2018-07-22 03:45:47 +00:00
|
|
|
private:
|
2018-08-19 20:05:39 +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-08-19 20:05:39 +00:00
|
|
|
CommandWidget(QWidget* parent, amuse::SoundMacro::ICmd* cmd, SoundMacroListing* listing);
|
|
|
|
CommandWidget(QWidget* parent, amuse::SoundMacro::CmdOp op, SoundMacroListing* listing);
|
2018-07-20 06:38:09 +00:00
|
|
|
void paintEvent(QPaintEvent* event);
|
2018-07-26 03:41:48 +00:00
|
|
|
QString getText() const { return m_titleLabel.text(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
class CommandWidgetContainer : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
friend class SoundMacroListing;
|
|
|
|
CommandWidget* m_commandWidget;
|
|
|
|
QPropertyAnimation* m_animation = nullptr;
|
|
|
|
void animateOpen();
|
|
|
|
void animateClosed();
|
|
|
|
void snapOpen();
|
|
|
|
void snapClosed();
|
|
|
|
private slots:
|
|
|
|
void animationDestroyed();
|
|
|
|
public:
|
2018-08-19 20:05:39 +00:00
|
|
|
template <class..._Args>
|
|
|
|
CommandWidgetContainer(QWidget* parent, _Args&&... args);
|
2018-07-22 03:45:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SoundMacroListing : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
friend class CommandWidget;
|
|
|
|
friend class SoundMacroEditor;
|
2018-07-30 06:20:03 +00:00
|
|
|
amuse::ObjToken<ProjectModel::SoundMacroNode> m_node;
|
2018-07-22 03:45:47 +00:00
|
|
|
QVBoxLayout* m_layout;
|
|
|
|
QLayoutItem* m_dragItem = nullptr;
|
|
|
|
int m_origIdx = -1;
|
|
|
|
int m_dragOpenIdx = -1;
|
2018-07-26 03:41:48 +00:00
|
|
|
CommandWidgetContainer* m_prevDragOpen = nullptr;
|
2018-07-22 03:45:47 +00:00
|
|
|
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);
|
2018-07-26 03:41:48 +00:00
|
|
|
void endDrag();
|
2018-07-22 03:45:47 +00:00
|
|
|
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();
|
2018-07-26 03:41:48 +00:00
|
|
|
void insert(amuse::SoundMacro::CmdOp op, const QString& text);
|
|
|
|
void deleteCommand(int index);
|
2018-07-22 03:45:47 +00:00
|
|
|
void reindex();
|
2018-07-26 03:41:48 +00:00
|
|
|
void clear();
|
2018-07-22 03:45:47 +00:00
|
|
|
public:
|
2018-07-26 03:41:48 +00:00
|
|
|
explicit SoundMacroListing(QWidget* parent = Q_NULLPTR);
|
|
|
|
bool loadData(ProjectModel::SoundMacroNode* node);
|
|
|
|
void unloadData();
|
2018-07-28 04:34:29 +00:00
|
|
|
ProjectModel::INode* currentNode() const;
|
2018-07-22 03:45:47 +00:00
|
|
|
void timerEvent(QTimerEvent* event);
|
|
|
|
};
|
|
|
|
|
|
|
|
class CatalogueItem : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
amuse::SoundMacro::CmdOp m_op;
|
2018-07-26 03:41:48 +00:00
|
|
|
QLabel m_iconLab;
|
|
|
|
QLabel m_label;
|
2018-07-22 03:45:47 +00:00
|
|
|
public:
|
|
|
|
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);
|
|
|
|
amuse::SoundMacro::CmdOp getCmdOp() const { return m_op; }
|
2018-07-26 03:41:48 +00:00
|
|
|
QString getText() const { return m_label.text(); }
|
2018-07-22 03:45:47 +00:00
|
|
|
};
|
|
|
|
|
2018-07-25 06:01:01 +00:00
|
|
|
class SoundMacroCatalogue : public QTreeWidget
|
2018-07-22 03:45:47 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit SoundMacroCatalogue(QWidget* parent = Q_NULLPTR);
|
2018-07-25 06:01:01 +00:00
|
|
|
void mousePressEvent(QMouseEvent* event);
|
|
|
|
void mouseReleaseEvent(QMouseEvent* event);
|
|
|
|
void mouseMoveEvent(QMouseEvent* event);
|
2018-07-20 06:38:09 +00:00
|
|
|
};
|
2018-07-09 18:05:31 +00:00
|
|
|
|
2018-07-14 06:06:33 +00:00
|
|
|
class SoundMacroEditor : public EditorWidget
|
2018-07-09 18:05:31 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2018-07-25 06:01:01 +00:00
|
|
|
friend class SoundMacroCatalogue;
|
2018-07-28 04:34:29 +00:00
|
|
|
friend class FieldSoundMacroStep;
|
2018-07-22 03:45:47 +00:00
|
|
|
QSplitter* m_splitter;
|
|
|
|
SoundMacroListing* m_listing;
|
|
|
|
SoundMacroCatalogue* m_catalogue;
|
|
|
|
CommandWidget* m_draggedCmd = nullptr;
|
|
|
|
CatalogueItem* m_draggedItem = nullptr;
|
2018-07-28 04:34:29 +00:00
|
|
|
FieldSoundMacroStep* m_targetField = nullptr;
|
2018-07-22 03:45:47 +00:00
|
|
|
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);
|
2018-07-28 04:34:29 +00:00
|
|
|
void beginStepTarget(FieldSoundMacroStep* stepField);
|
|
|
|
void endStepTarget();
|
2018-07-09 18:05:31 +00:00
|
|
|
public:
|
2018-07-26 03:41:48 +00:00
|
|
|
explicit SoundMacroEditor(QWidget* parent = Q_NULLPTR);
|
|
|
|
bool loadData(ProjectModel::SoundMacroNode* node);
|
|
|
|
void unloadData();
|
2018-07-28 04:34:29 +00:00
|
|
|
ProjectModel::INode* currentNode() const;
|
2018-07-22 03:45:47 +00:00
|
|
|
|
|
|
|
void mousePressEvent(QMouseEvent* event);
|
|
|
|
void mouseReleaseEvent(QMouseEvent* event);
|
|
|
|
void mouseMoveEvent(QMouseEvent* event);
|
|
|
|
void keyPressEvent(QKeyEvent* event);
|
2018-07-25 06:01:01 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void catalogueDoubleClicked(QTreeWidgetItem* item, int column);
|
2018-07-09 18:05:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //AMUSE_SOUND_MACRO_EDITOR_HPP
|