Editor: Include headers where necessary

Avoids propagating dependencies through indirect inclusions, and also
gets rid of some header dependencies entirely.
This commit is contained in:
Lioncash 2019-08-27 20:51:38 -04:00
parent 107ddeb5a9
commit ef86e69421
32 changed files with 485 additions and 124 deletions

View File

@ -1,8 +1,11 @@
#include "ADSREditor.hpp"
#include "MainWindow.hpp"
#include <QVBoxLayout>
#include <QPainter>
#include <QCheckBox>
#include <QDoubleSpinBox>
#include <QMouseEvent>
#include <QPainter>
#include <QVBoxLayout>
const QColor Red = QColor(255, 127, 127);
const QColor Green = QColor(127, 255, 127);
@ -217,6 +220,8 @@ ADSRView::ADSRView(QWidget* parent) : QWidget(parent) {
m_gridFont.setPointSize(8);
}
ADSRView::~ADSRView() = default;
ADSREditor* ADSRControls::getEditor() const { return qobject_cast<ADSREditor*>(parentWidget()); }
void ADSRControls::loadData() {
@ -945,6 +950,8 @@ ADSRControls::ADSRControls(QWidget* parent) : QFrame(parent) {
setLayout(mainLayout);
}
ADSRControls::~ADSRControls() = default;
bool ADSREditor::loadData(ProjectModel::ADSRNode* node) {
m_adsrView->loadData(node);
m_controls->loadData();
@ -966,3 +973,5 @@ ADSREditor::ADSREditor(QWidget* parent) : EditorWidget(parent), m_adsrView(new A
layout->addWidget(m_controls);
setLayout(layout);
}
ADSREditor::~ADSREditor() = default;

View File

@ -1,15 +1,22 @@
#pragma once
#include "EditorWidget.hpp"
#include <cstdint>
#include <vector>
#include <QFrame>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QCheckBox>
#include <QLabel>
#include <QStaticText>
#include "EditorWidget.hpp"
#include "ProjectModel.hpp"
#include <amuse/Common.hpp>
class ADSREditor;
class QCheckBox;
class QDoubleSpinBox;
class QLabel;
class ADSRView : public QWidget {
Q_OBJECT
friend class ADSRControls;
@ -23,6 +30,8 @@ class ADSRView : public QWidget {
public:
explicit ADSRView(QWidget* parent = Q_NULLPTR);
~ADSRView() override;
void loadData(ProjectModel::ADSRNode* node);
void unloadData();
ProjectModel::INode* currentNode() const;
@ -53,8 +62,11 @@ class ADSRControls : public QFrame {
public:
explicit ADSRControls(QWidget* parent = Q_NULLPTR);
~ADSRControls() override;
void loadData();
void unloadData();
public slots:
void attackChanged(double val);
void decayChanged(double val);
@ -74,6 +86,8 @@ class ADSREditor : public EditorWidget {
public:
explicit ADSREditor(QWidget* parent = Q_NULLPTR);
~ADSREditor() override;
bool loadData(ProjectModel::ADSRNode* node);
void unloadData() override;
ProjectModel::INode* currentNode() const override;

View File

@ -1,8 +1,11 @@
#include "Common.hpp"
#include "MainWindow.hpp"
#include <QDir>
#include <QMessageBox>
#include <QObject>
#include <QProcess>
#include <QTransform>
boo::SystemString QStringToSysString(const QString& str) {
#ifdef _WIN32

View File

@ -1,13 +1,19 @@
#pragma once
#include "boo/System.hpp"
#include <QString>
#include <QDir>
#include <functional>
#include <QMessageBox>
#include <QString>
#include <boo/System.hpp>
class MainWindow;
extern MainWindow* g_MainWindow;
class QDir;
class QRectF;
class QTransform;
class UIMessenger : public QObject {
Q_OBJECT
public:

View File

@ -7,9 +7,12 @@
#include <QGridLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QJSValueIterator>
#include <QMouseEvent>
#include <QPainter>
#include <QPushButton>
class CurveEditUndoCommand : public EditorUndoCommand {
public:
@ -163,6 +166,8 @@ CurveView::CurveView(QWidget* parent) : QWidget(parent) {
m_gridFont.setPointSize(8);
}
CurveView::~CurveView() = default;
CurveEditor* CurveControls::getEditor() const { return qobject_cast<CurveEditor*>(parentWidget()); }
void CurveControls::loadData() {
@ -270,6 +275,8 @@ CurveControls::CurveControls(QWidget* parent) : QFrame(parent) {
m_lineEdit->setToolTip(docStr);
}
CurveControls::~CurveControls() = default;
bool CurveEditor::loadData(ProjectModel::CurveNode* node) {
m_curveView->loadData(node);
m_controls->loadData();
@ -292,3 +299,5 @@ CurveEditor::CurveEditor(QWidget* parent)
layout->addWidget(m_controls);
setLayout(layout);
}
CurveEditor::~CurveEditor() = default;

View File

@ -2,16 +2,21 @@
#include <array>
#include "EditorWidget.hpp"
#include <QFrame>
#include <QLabel>
#include <QStaticText>
#include <QLineEdit>
#include <QPushButton>
#include <QJSEngine>
#include <QStaticText>
#include "EditorWidget.hpp"
#include "ProjectModel.hpp"
#include <amuse/Common.hpp>
class CurveEditor;
class QLabel;
class QLineEdit;
class QPushButton;
class CurveView : public QWidget {
Q_OBJECT
friend class CurveControls;
@ -23,6 +28,8 @@ class CurveView : public QWidget {
public:
explicit CurveView(QWidget* parent = Q_NULLPTR);
~CurveView() override;
void loadData(ProjectModel::CurveNode* node);
void unloadData();
ProjectModel::INode* currentNode() const;
@ -43,9 +50,12 @@ class CurveControls : public QFrame {
public:
explicit CurveControls(QWidget* parent = Q_NULLPTR);
~CurveControls() override;
void loadData();
void unloadData();
void resizeEvent(QResizeEvent* ev) override;
public slots:
void exprCommit();
};
@ -59,6 +69,8 @@ class CurveEditor : public EditorWidget {
public:
explicit CurveEditor(QWidget* parent = Q_NULLPTR);
~CurveEditor() override;
bool loadData(ProjectModel::CurveNode* node);
void unloadData() override;
ProjectModel::INode* currentNode() const override;

View File

@ -5,6 +5,8 @@
EditorWidget::EditorWidget(QWidget* parent) : QWidget(parent) {}
EditorWidget::~EditorWidget() = default;
void EditorUndoCommand::undo() { g_MainWindow->openEditor(m_node.get()); }
void EditorUndoCommand::redo() { g_MainWindow->openEditor(m_node.get()); }
@ -92,6 +94,8 @@ FieldProjectNode::FieldProjectNode(ProjectModel::CollectionNode* collection, QWi
setCollection(collection);
}
FieldProjectNode::~FieldProjectNode() = default;
void FieldProjectNode::setCollection(ProjectModel::CollectionNode* collection) {
m_collection = collection;
@ -153,6 +157,8 @@ FieldPageObjectNode::FieldPageObjectNode(ProjectModel::GroupNode* group, QWidget
setGroup(group);
}
FieldPageObjectNode::~FieldPageObjectNode() = default;
void FieldPageObjectNode::setGroup(ProjectModel::GroupNode* group) {
m_group = group;

View File

@ -1,29 +1,34 @@
#pragma once
#include <QWidget>
#include <QUndoCommand>
#include <QApplication>
#include <QSpinBox>
#include <QComboBox>
#include <QWheelEvent>
#include <QItemEditorFactory>
#include <QToolButton>
#include <QAction>
#include <QPushButton>
#include <QComboBox>
#include <QItemEditorFactory>
#include <QLabel>
#include <QMenu>
#include <QPushButton>
#include <QSpinBox>
#include <QStyledItemDelegate>
#include <QToolButton>
#include <QUndoCommand>
#include <QWheelEvent>
#include <QWidget>
#include "ProjectModel.hpp"
#include <amuse/Common.hpp>
class EditorWidget : public QWidget {
Q_OBJECT
public:
explicit EditorWidget(QWidget* parent = Q_NULLPTR);
~EditorWidget() override;
virtual bool valid() const { return true; }
virtual void unloadData() {}
virtual ProjectModel::INode* currentNode() const { return nullptr; }
virtual void setEditorEnabled(bool en) { setEnabled(en); }
virtual AmuseItemEditFlags itemEditFlags() const { return AmuseItemNone; }
public slots:
virtual void itemCutAction() {}
virtual void itemCopyAction() {}
@ -130,6 +135,8 @@ class FieldProjectNode : public QWidget {
public:
explicit FieldProjectNode(ProjectModel::CollectionNode* collection = Q_NULLPTR, QWidget* parent = Q_NULLPTR);
~FieldProjectNode() override;
void setCollection(ProjectModel::CollectionNode* collection);
ProjectModel::CollectionNode* collection() const { return m_collection; }
int currentIndex() const { return m_comboBox.currentIndex(); }
@ -137,10 +144,13 @@ public:
void showPopup() { m_comboBox.showPopup(); }
ProjectModel::BasePoolObjectNode* currentNode() const;
bool event(QEvent* ev) override;
private slots:
void _currentIndexChanged(int);
public slots:
void openCurrent();
signals:
void currentIndexChanged(int);
};
@ -153,6 +163,8 @@ class FieldPageObjectNode : public QWidget {
public:
explicit FieldPageObjectNode(ProjectModel::GroupNode* group = Q_NULLPTR, QWidget* parent = Q_NULLPTR);
~FieldPageObjectNode() override;
void setGroup(ProjectModel::GroupNode* group);
ProjectModel::GroupNode* group() const { return m_group; }
int currentIndex() const { return m_comboBox.currentIndex(); }
@ -161,10 +173,13 @@ public:
void showPopup() { m_comboBox.showPopup(); }
ProjectModel::BasePoolObjectNode* currentNode() const;
bool event(QEvent* ev) override;
private slots:
void _currentIndexChanged(int);
public slots:
void openCurrent();
signals:
void currentIndexChanged(int);
};

View File

@ -1,10 +1,14 @@
#include "KeyboardWidget.hpp"
#include <QApplication>
#include <QHBoxLayout>
#include <QSvgRenderer>
#include <QMouseEvent>
#include <QScrollArea>
#include <QApplication>
#include <QScrollBar>
#include <QSvgRenderer>
#include "Common.hpp"
#include "StatusBarWidget.hpp"
const QString NaturalKeyNames[] = {QStringLiteral("C"), QStringLiteral("D"), QStringLiteral("E"), QStringLiteral("F"),
QStringLiteral("G"), QStringLiteral("A"), QStringLiteral("B")};
@ -70,6 +74,8 @@ KeyboardWidget::KeyboardWidget(QWidget* parent) : QWidget(parent) {
setMouseTracking(true);
}
KeyboardWidget::~KeyboardWidget() = default;
std::pair<int, int> KeyboardWidget::_getOctaveAndKey(QMouseEvent* event) const {
for (KeyboardOctave* oct : m_widgets) {
QPoint localPos = oct->mapFromParent(event->pos());
@ -144,6 +150,8 @@ void KeyboardWidget::showEvent(QShowEvent* event) {
KeyboardSlider::KeyboardSlider(QWidget* parent) : QSlider(parent) {}
KeyboardSlider::~KeyboardSlider() = default;
void KeyboardSlider::enterEvent(QEvent* event) {
if (m_statusFocus)
m_statusFocus->enter();

View File

@ -1,11 +1,10 @@
#pragma once
#include <QWidget>
#include <QSvgWidget>
#include <QSlider>
#include <QString>
#include <QSvgWidget>
#include <QWheelEvent>
#include "StatusBarWidget.hpp"
#include "Common.hpp"
#include <QWidget>
extern const QString NaturalKeyNames[7];
extern const QString SharpKeyNames[5];
@ -14,6 +13,7 @@ extern const int NaturalKeyNumbers[7];
extern const int SharpKeyNumbers[5];
class KeyboardWidget;
class StatusBarFocus;
class KeyboardOctave : public QSvgWidget {
Q_OBJECT
@ -45,6 +45,8 @@ class KeyboardWidget : public QWidget {
public:
explicit KeyboardWidget(QWidget* parent = Q_NULLPTR);
~KeyboardWidget() override;
void setStatusFocus(StatusBarFocus* statusFocus) { m_statusFocus = statusFocus; }
void mouseMoveEvent(QMouseEvent* event) override;
@ -68,6 +70,8 @@ protected:
public:
explicit KeyboardSlider(QWidget* parent = Q_NULLPTR);
~KeyboardSlider() override;
void enterEvent(QEvent* event) override;
void leaveEvent(QEvent* event) override;
void setStatusFocus(StatusBarFocus* statusFocus);

View File

@ -2,8 +2,11 @@
#include <array>
#include <QCheckBox>
#include <QPainter>
#include <QScrollArea>
#include <QScrollBar>
#include <QSpinBox>
#include <QVBoxLayout>
#include "KeyboardWidget.hpp"
@ -182,6 +185,8 @@ KeymapView::KeymapView(QWidget* parent)
m_widgetToSvg = RectToRect(QRect(0, 0, 280, 200), m_octaveRenderer.viewBoxF());
}
KeymapView::~KeymapView() = default;
KeymapEditor* KeymapControls::getEditor() const { return qobject_cast<KeymapEditor*>(parentWidget()); }
void KeymapControls::setPaintIdx(int idx) {
@ -356,6 +361,8 @@ KeymapControls::KeymapControls(QWidget* parent) : QFrame(parent) {
setLayout(mainLayout);
}
KeymapControls::~KeymapControls() = default;
void KeymapEditor::_touch() {
if (m_controlKeymap.macro.id == 0xffff)
m_controls->setPaintIdx(-1);
@ -514,3 +521,5 @@ KeymapEditor::KeymapEditor(QWidget* parent)
layout->addWidget(m_controls);
setLayout(layout);
}
KeymapEditor::~KeymapEditor() = default;

View File

@ -1,20 +1,25 @@
#pragma once
#include "EditorWidget.hpp"
#include <array>
#include <bitset>
#include <cstdint>
#include <unordered_map>
#include <QCheckBox>
#include <QFrame>
#include <QLabel>
#include <QPushButton>
#include <QScrollArea>
#include <QStaticText>
#include <QSpinBox>
#include <QSvgRenderer>
#include "EditorWidget.hpp"
#include "ProjectModel.hpp"
#include <amuse/AudioGroupPool.hpp>
#include <amuse/Common.hpp>
class KeymapEditor;
class QCheckBox;
class QScrollArea;
class QSpinBox;
class PaintButton : public QPushButton {
Q_OBJECT
@ -48,6 +53,8 @@ class KeymapView : public QWidget {
public:
explicit KeymapView(QWidget* parent = Q_NULLPTR);
~KeymapView() override;
void loadData(ProjectModel::KeymapNode* node);
void unloadData();
ProjectModel::INode* currentNode() const;
@ -75,8 +82,11 @@ class KeymapControls : public QFrame {
public:
explicit KeymapControls(QWidget* parent = Q_NULLPTR);
~KeymapControls() override;
void loadData(ProjectModel::KeymapNode* node);
void unloadData();
public slots:
void controlChanged();
void paintButtonPressed();
@ -103,6 +113,8 @@ class KeymapEditor : public EditorWidget {
public:
explicit KeymapEditor(QWidget* parent = Q_NULLPTR);
~KeymapEditor() override;
bool loadData(ProjectModel::KeymapNode* node);
void unloadData() override;
ProjectModel::INode* currentNode() const override;

View File

@ -100,6 +100,8 @@ public:
SoundMacroDelegate::SoundMacroDelegate(QObject* parent) : BaseObjectDelegate(parent) {}
SoundMacroDelegate::~SoundMacroDelegate() = default;
ProjectModel::INode* SoundMacroDelegate::getNode(const QAbstractItemModel* __model, const QModelIndex& index) const {
const LayersModel* model = static_cast<const LayersModel*>(__model);
const amuse::LayerMapping& layer = (*model->m_node->m_obj)[index.row()];
@ -507,6 +509,8 @@ amuse::LayerMapping LayersModel::_removeRow(int row) {
LayersModel::LayersModel(QObject* parent) : QAbstractTableModel(parent) {}
LayersModel::~LayersModel() = default;
void LayersTableView::deleteSelection() {
const QModelIndexList list = selectionModel()->selectedRows();
if (list.isEmpty()) {
@ -566,6 +570,8 @@ LayersTableView::LayersTableView(QWidget* parent) : QTableView(parent) {
setItemDelegateForColumn(7, &m_unsignedDelegate);
}
LayersTableView::~LayersTableView() = default;
bool LayersEditor::loadData(ProjectModel::LayersNode* node) {
m_model.loadData(node);
return true;
@ -626,3 +632,5 @@ LayersEditor::LayersEditor(QWidget* parent)
m_addRemoveButtons.removeAction()->setToolTip(tr("Remove selected layer mappings"));
connect(m_addRemoveButtons.removeAction(), &QAction::triggered, this, &LayersEditor::itemDeleteAction);
}
LayersEditor::~LayersEditor() = default;

View File

@ -1,11 +1,15 @@
#pragma once
#include "EditorWidget.hpp"
#include <QAbstractTableModel>
#include <QTableView>
#include <QAction>
#include <QToolButton>
#include <QStyledItemDelegate>
#include <QTableView>
#include "EditorWidget.hpp"
#include "ProjectModel.hpp"
#include <amuse/AudioGroupPool.hpp>
#include <amuse/Common.hpp>
class SoundMacroDelegate : public BaseObjectDelegate {
Q_OBJECT
@ -14,9 +18,12 @@ protected:
public:
explicit SoundMacroDelegate(QObject* parent = Q_NULLPTR);
~SoundMacroDelegate() override;
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
void setEditorData(QWidget* editor, const QModelIndex& index) const override;
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
private slots:
void smIndexChanged();
};
@ -30,6 +37,8 @@ class LayersModel : public QAbstractTableModel {
public:
explicit LayersModel(QObject* parent = Q_NULLPTR);
~LayersModel() override;
void loadData(ProjectModel::LayersNode* node);
void unloadData();
@ -62,6 +71,8 @@ class LayersTableView : public QTableView {
public:
explicit LayersTableView(QWidget* parent = Q_NULLPTR);
~LayersTableView() override;
void setModel(QAbstractItemModel* model) override;
void deleteSelection();
};
@ -75,11 +86,14 @@ class LayersEditor : public EditorWidget {
public:
explicit LayersEditor(QWidget* parent = Q_NULLPTR);
~LayersEditor() override;
bool loadData(ProjectModel::LayersNode* node);
void unloadData() override;
ProjectModel::INode* currentNode() const override;
void resizeEvent(QResizeEvent* ev) override;
AmuseItemEditFlags itemEditFlags() const override;
private slots:
void rowsInserted(const QModelIndex& parent, int first, int last);
void rowsMoved(const QModelIndex& parent, int start, int end, const QModelIndex& destination, int row);

View File

@ -1,6 +1,9 @@
#include "MIDIReader.hpp"
#include "MainWindow.hpp"
#include <amuse/Engine.hpp>
MIDIReader::MIDIReader(amuse::Engine& engine, bool useLock) : amuse::BooBackendMIDIReader(engine, useLock) {}
void MIDIReader::noteOff(uint8_t chan, uint8_t key, uint8_t velocity) {

View File

@ -1,10 +1,18 @@
#pragma once
#include "amuse/Voice.hpp"
#include "amuse/BooBackend.hpp"
#include "amuse/Common.hpp"
#include <cstdint>
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <amuse/BooBackend.hpp>
#include <amuse/Common.hpp>
#include <amuse/Voice.hpp>
namespace amuse {
class Engine;
}
class MIDIReader : public amuse::BooBackendMIDIReader {
std::unordered_map<uint8_t, amuse::ObjToken<amuse::Voice>> m_chanVoxs;
std::unordered_set<amuse::ObjToken<amuse::Voice>> m_keyoffVoxs;

View File

@ -1,24 +1,33 @@
#include "MainWindow.hpp"
#include <QFileDialog>
#include <QMessageBox>
#include <QLineEdit>
#include <QInputDialog>
#include <QProgressDialog>
#include <QMouseEvent>
#include <QClipboard>
#include <QFileDialog>
#include <QInputDialog>
#include <QLineEdit>
#include <QMessageBox>
#include <QMouseEvent>
#include <QProgressDialog>
#include <QtSvg/QtSvg>
#include "amuse/ContainerRegistry.hpp"
#include <QUndoStack>
#include "ADSREditor.hpp"
#include "Common.hpp"
#include "CurveEditor.hpp"
#include "KeymapEditor.hpp"
#include "LayersEditor.hpp"
#include "MIDIReader.hpp"
#include "NewSoundMacroDialog.hpp"
#include "SampleEditor.hpp"
#include "SongGroupEditor.hpp"
#include "SoundGroupEditor.hpp"
#include "SoundGroupEditor.hpp"
#include "SoundMacroEditor.hpp"
#include "ADSREditor.hpp"
#include "CurveEditor.hpp"
#include "KeymapEditor.hpp"
#include "LayersEditor.hpp"
#include "SampleEditor.hpp"
#include "NewSoundMacroDialog.hpp"
#include "StudioSetupWidget.hpp"
#include <amuse/BooBackend.hpp>
#include <amuse/ContainerRegistry.hpp>
#include <amuse/Engine.hpp>
#include <boo/audiodev/IAudioVoiceEngine.hpp>
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent)

View File

@ -1,37 +1,53 @@
#pragma once
#include <QMainWindow>
#include <QUndoStack>
#include <QProgressDialog>
#include <QThread>
#include <QStyledItemDelegate>
#include <QSortFilterProxyModel>
#include <QLinkedList>
#include <cstdint>
#include <functional>
#include <memory>
#include <QFileDialog>
#include "ui_MainWindow.h"
#include "amuse/Engine.hpp"
#include "amuse/BooBackend.hpp"
#include "boo/audiodev/IAudioVoiceEngine.hpp"
#include "ProjectModel.hpp"
#include <QLinkedList>
#include <QMainWindow>
#include <QMessageBox>
#include <QStyledItemDelegate>
#include <QThread>
#include "EditorWidget.hpp"
#include "MIDIReader.hpp"
#include "StudioSetupWidget.hpp"
#include "ProjectModel.hpp"
#include "ui_MainWindow.h"
#include <amuse/Common.hpp>
#include <amuse/Sequencer.hpp>
#include <amuse/Voice.hpp>
#define MaxRecentFiles 4
namespace amuse {
class Engine;
}
namespace boo {
struct IAudioVoiceEngine;
}
namespace Ui {
class MainWindow;
}
class MainWindow;
class SongGroupEditor;
class SoundGroupEditor;
class SoundMacroEditor;
class ADSREditor;
class CurveEditor;
class KeymapEditor;
class LayersEditor;
class MainWindow;
class SampleEditor;
class SongGroupEditor;
class SoundGroupEditor;
class SoundMacroEditor;
class StudioSetupWidget;
class VoiceAllocator;
class QProgressDialog;
class QUndoStack;
enum BackgroundTaskId { TaskOpen, TaskImport, TaskExport, TaskReloadSamples };

View File

@ -155,3 +155,5 @@ NewSoundMacroDialog::NewSoundMacroDialog(const QString& groupName, QWidget* pare
setLayout(layout);
}
NewSoundMacroDialog::~NewSoundMacroDialog() = default;

View File

@ -1,9 +1,12 @@
#pragma once
#include <QDialog>
#include <QLineEdit>
#include <cstddef>
#include <cstdint>
#include <QComboBox>
#include <QDialog>
#include <QDialogButtonBox>
#include <QLineEdit>
struct SoundMacroTemplateEntry {
const char* m_name;
@ -19,6 +22,8 @@ class NewSoundMacroDialog : public QDialog {
public:
explicit NewSoundMacroDialog(const QString& groupName, QWidget* parent = Q_NULLPTR);
~NewSoundMacroDialog() override;
QString getName() const { return m_le.text(); }
const SoundMacroTemplateEntry* getSelectedTemplate() const;
};

View File

@ -1,11 +1,15 @@
#include "SampleEditor.hpp"
#include "MainWindow.hpp"
#include "amuse/DSPCodec.hpp"
#include <QPainter>
#include <QPaintEvent>
#include <QSpinBox>
#include <QScrollBar>
#include <QCheckBox>
#include <QPaintEvent>
#include <QPainter>
#include <QScrollArea>
#include <QScrollBar>
#include <QSpinBox>
#include "MainWindow.hpp"
#include <amuse/DSPCodec.hpp>
SampleEditor* SampleView::getEditor() const {
return qobject_cast<SampleEditor*>(parentWidget()->parentWidget()->parentWidget());
@ -389,6 +393,8 @@ SampleView::SampleView(QWidget* parent) : QWidget(parent) {
m_rulerFont.setPointSize(8);
}
SampleView::~SampleView() = default;
void SampleControls::zoomSliderChanged(int val) {
SampleEditor* editor = qobject_cast<SampleEditor*>(parentWidget());
editor->m_sampleView->setZoom(val);
@ -740,6 +746,8 @@ SampleControls::SampleControls(QWidget* parent) : QFrame(parent) {
setLayout(mainLayout);
}
SampleControls::~SampleControls() = default;
bool SampleEditor::loadData(ProjectModel::SampleNode* node) {
m_controls->loadData(m_sampleView->loadData(node));
return true;
@ -770,3 +778,5 @@ SampleEditor::SampleEditor(QWidget* parent)
layout->addWidget(m_controls);
setLayout(layout);
}
SampleEditor::~SampleEditor() = default;

View File

@ -1,14 +1,25 @@
#pragma once
#include <cstdint>
#include <utility>
#include <QFont>
#include <QWidget>
#include "EditorWidget.hpp"
#include "ProjectModel.hpp"
#include <QScrollArea>
#include <QSlider>
#include <QCheckBox>
#include <QSpinBox>
#include <amuse/AudioGroupPool.hpp>
#include <amuse/AudioGroupSampleDirectory.hpp>
#include <amuse/Common.hpp>
class SampleEditor;
class QCheckBox;
class QPushButton;
class QScrollArea;
class QSlider;
class SampleView : public QWidget {
Q_OBJECT
friend class SampleControls;
@ -33,6 +44,8 @@ class SampleView : public QWidget {
public:
explicit SampleView(QWidget* parent = Q_NULLPTR);
~SampleView() override;
bool loadData(ProjectModel::SampleNode* node);
void unloadData();
ProjectModel::INode* currentNode() const;
@ -67,6 +80,8 @@ class SampleControls : public QFrame {
public:
explicit SampleControls(QWidget* parent = Q_NULLPTR);
~SampleControls() override;
void doFileWrite();
void setFileWrite(bool w);
void updateFileState();
@ -74,6 +89,7 @@ public:
void setLoopEndSample(int sample) { m_loopEnd->setValue(sample); }
void loadData(bool reset);
void unloadData();
public slots:
void zoomSliderChanged(int val);
void loopStateChanged(int state);
@ -97,6 +113,8 @@ class SampleEditor : public EditorWidget {
public:
explicit SampleEditor(QWidget* parent = Q_NULLPTR);
~SampleEditor() override;
bool loadData(ProjectModel::SampleNode* node);
void unloadData() override;
ProjectModel::INode* currentNode() const override;

View File

@ -248,6 +248,8 @@ public:
PageObjectDelegate::PageObjectDelegate(QObject* parent) : BaseObjectDelegate(parent) {}
PageObjectDelegate::~PageObjectDelegate() = default;
ProjectModel::INode* PageObjectDelegate::getNode(const QAbstractItemModel* __model, const QModelIndex& index) const {
const PageModel* model = static_cast<const PageModel*>(__model);
auto entry = model->m_sorted[index.row()];
@ -329,6 +331,8 @@ MIDIFileFieldWidget::MIDIFileFieldWidget(QWidget* parent)
m_dialog.setAcceptMode(QFileDialog::AcceptOpen);
}
MIDIFileFieldWidget::~MIDIFileFieldWidget() = default;
QWidget* MIDIFileDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option,
const QModelIndex& index) const {
MIDIFileFieldWidget* field = new MIDIFileFieldWidget(parent);
@ -507,6 +511,8 @@ MIDIFileDelegate::MIDIFileDelegate(SetupTableView* parent)
, m_fileDialogMid(parent, tr("Export MIDI"), {}, tr("MIDI(*.mid)"))
, m_fileDialogSng(parent, tr("Export Song"), {}, tr("Song(*.sng)")) {}
MIDIFileDelegate::~MIDIFileDelegate() = default;
std::unordered_map<uint8_t, amuse::SongGroupIndex::PageEntry>& PageModel::_getMap() const {
return m_drum ? m_node->m_index->m_drumPages : m_node->m_index->m_normPages;
}
@ -769,6 +775,8 @@ std::pair<uint8_t, amuse::SongGroupIndex::PageEntry> PageModel::_removeRow(uint8
PageModel::PageModel(bool drum, QObject* parent) : QAbstractTableModel(parent), m_drum(drum) {}
PageModel::~PageModel() = default;
std::unordered_map<amuse::SongId, std::array<amuse::SongGroupIndex::MIDISetup, 16>>& SetupListModel::_getMap() const {
return m_node->m_index->m_midiSetups;
}
@ -1024,6 +1032,8 @@ SetupListModel::_removeRow(amuse::SongId id) {
SetupListModel::SetupListModel(QObject* parent) : QAbstractTableModel(parent) {}
SetupListModel::~SetupListModel() = default;
void SetupModel::loadData(std::pair<const amuse::SongId, std::array<amuse::SongGroupIndex::MIDISetup, 16>>* data) {
beginResetModel();
m_data = data;
@ -1151,6 +1161,8 @@ Qt::ItemFlags SetupModel::flags(const QModelIndex& index) const { return Qt::Ite
SetupModel::SetupModel(QObject* parent) : QAbstractTableModel(parent) {}
SetupModel::~SetupModel() = default;
void PageTableView::deleteSelection() {
const QModelIndexList list = selectionModel()->selectedRows();
if (list.isEmpty()) {
@ -1196,6 +1208,8 @@ PageTableView::PageTableView(QWidget* parent) : QTableView(parent) {
setItemDelegateForColumn(3, &m_255Delegate);
}
PageTableView::~PageTableView() = default;
void SetupTableView::setModel(QAbstractItemModel* list, QAbstractItemModel* table) {
{
m_listView->setModel(list);
@ -1256,6 +1270,8 @@ SetupTableView::SetupTableView(QWidget* parent)
m_tableView->setItemDelegateForColumn(4, &m_127Delegate);
}
SetupTableView::~SetupTableView() = default;
void ColoredTabBarStyle::drawControl(QStyle::ControlElement element, const QStyleOption* option, QPainter* painter,
const QWidget* widget) const {
if (qobject_cast<const ColoredTabBar*>(widget) && element == QStyle::CE_TabBarTab) {
@ -1591,3 +1607,5 @@ SongGroupEditor::SongGroupEditor(QWidget* parent)
m_tabs.setCurrentIndex(0);
}
SongGroupEditor::~SongGroupEditor() = default;

View File

@ -1,18 +1,29 @@
#pragma once
#include "EditorWidget.hpp"
#include <array>
#include <cstdint>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#include <QFileDialog>
#include <QLineEdit>
#include <QProxyStyle>
#include <QPushButton>
#include <QSplitter>
#include <QStyledItemDelegate>
#include <QTabWidget>
#include <QAbstractTableModel>
#include <QTableView>
#include <QToolButton>
#include <QAction>
#include <QSplitter>
#include <QListView>
#include <QLineEdit>
#include <QPushButton>
#include <QFileDialog>
#include <QProxyStyle>
#include "amuse/Sequencer.hpp"
#include "EditorWidget.hpp"
#include "ProjectModel.hpp"
#include <amuse/AudioGroupProject.hpp>
#include <amuse/Common.hpp>
#include <amuse/Sequencer.hpp>
class SetupTableView;
@ -23,9 +34,12 @@ protected:
public:
explicit PageObjectDelegate(QObject* parent = Q_NULLPTR);
~PageObjectDelegate() override;
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
void setEditorData(QWidget* editor, const QModelIndex& index) const override;
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
private slots:
void objIndexChanged();
};
@ -38,11 +52,15 @@ class MIDIFileFieldWidget : public QWidget {
public:
explicit MIDIFileFieldWidget(QWidget* parent = Q_NULLPTR);
~MIDIFileFieldWidget() override;
QString path() const { return m_le.text(); }
void setPath(const QString& path) { m_le.setText(path); }
public slots:
void buttonPressed();
void fileDialogOpened(const QString& path);
signals:
void pathChanged();
};
@ -54,17 +72,21 @@ class MIDIFileDelegate : public QStyledItemDelegate {
public:
explicit MIDIFileDelegate(SetupTableView* parent = Q_NULLPTR);
~MIDIFileDelegate() override;
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
void destroyEditor(QWidget* editor, const QModelIndex& index) const override;
void setEditorData(QWidget* editor, const QModelIndex& index) const override;
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
bool editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option,
const QModelIndex& index) override;
private slots:
void doExportMIDI();
void _doExportMIDI(const QString& path);
void doExportSNG();
void _doExportSNG(const QString& path);
public slots:
void pathChanged();
};
@ -92,6 +114,8 @@ class PageModel : public QAbstractTableModel {
public:
explicit PageModel(bool drum, QObject* parent = Q_NULLPTR);
~PageModel() override;
void loadData(ProjectModel::SongGroupNode* node);
void unloadData();
@ -138,6 +162,8 @@ class SetupListModel : public QAbstractTableModel {
public:
explicit SetupListModel(QObject* parent = Q_NULLPTR);
~SetupListModel() override;
void loadData(ProjectModel::SongGroupNode* node);
void unloadData();
@ -159,6 +185,8 @@ class SetupModel : public QAbstractTableModel {
public:
explicit SetupModel(QObject* parent = Q_NULLPTR);
~SetupModel() override;
void loadData(std::pair<const amuse::SongId, std::array<amuse::SongGroupIndex::MIDISetup, 16>>* data);
void unloadData();
@ -180,6 +208,8 @@ class PageTableView : public QTableView {
public:
explicit PageTableView(QWidget* parent = Q_NULLPTR);
~PageTableView() override;
void setModel(QAbstractItemModel* model) override;
void deleteSelection();
};
@ -197,6 +227,8 @@ class SetupTableView : public QSplitter {
public:
explicit SetupTableView(QWidget* parent = Q_NULLPTR);
~SetupTableView() override;
void setModel(QAbstractItemModel* list, QAbstractItemModel* table);
void deleteSelection();
void showEvent(QShowEvent* event) override;
@ -264,6 +296,8 @@ class SongGroupEditor : public EditorWidget {
public:
explicit SongGroupEditor(QWidget* parent = Q_NULLPTR);
~SongGroupEditor() override;
bool loadData(ProjectModel::SongGroupNode* node);
void unloadData() override;
ProjectModel::INode* currentNode() const override;
@ -271,6 +305,7 @@ public:
void resizeEvent(QResizeEvent* ev) override;
QTableView* getSetupListView() const { return m_setupTable->m_listView; }
AmuseItemEditFlags itemEditFlags() const override;
private slots:
void doAdd();
void doSelectionChanged();

View File

@ -115,6 +115,8 @@ public:
SFXObjectDelegate::SFXObjectDelegate(QObject* parent) : BaseObjectDelegate(parent) {}
SFXObjectDelegate::~SFXObjectDelegate() = default;
ProjectModel::INode* SFXObjectDelegate::getNode(const QAbstractItemModel* __model, const QModelIndex& index) const {
const SFXModel* model = static_cast<const SFXModel*>(__model);
auto entry = model->m_sorted[index.row()];
@ -458,6 +460,8 @@ std::tuple<amuse::SFXId, std::string, amuse::SFXGroupIndex::SFXEntry> SFXModel::
SFXModel::SFXModel(QObject* parent) : QAbstractTableModel(parent) {}
SFXModel::~SFXModel() = default;
void SFXTableView::deleteSelection() {
QModelIndexList list = selectionModel()->selectedRows();
if (list.isEmpty())
@ -507,6 +511,8 @@ SFXTableView::SFXTableView(QWidget* parent) : QTableView(parent) {
setItemDelegateForColumn(6, &m_127Delegate);
}
SFXTableView::~SFXTableView() = default;
void SFXPlayerWidget::clicked() {
if (!m_vox) {
m_vox = g_MainWindow->startSFX(m_groupId, m_sfxId);
@ -634,3 +640,5 @@ SoundGroupEditor::SoundGroupEditor(QWidget* parent)
m_addRemoveButtons.removeAction()->setToolTip(tr("Remove selected SFX entries"));
connect(m_addRemoveButtons.removeAction(), &QAction::triggered, this, &SoundGroupEditor::itemDeleteAction);
}
SoundGroupEditor::~SoundGroupEditor() = default;

View File

@ -1,9 +1,20 @@
#pragma once
#include "EditorWidget.hpp"
#include <tuple>
#include <unordered_map>
#include <vector>
#include <QAction>
#include <QStyledItemDelegate>
#include <QTableView>
#include "amuse/Voice.hpp"
#include <QToolButton>
#include "EditorWidget.hpp"
#include "ProjectModel.hpp"
#include <amuse/AudioGroupProject.hpp>
#include <amuse/Common.hpp>
#include <amuse/Voice.hpp>
class SFXObjectDelegate : public BaseObjectDelegate {
Q_OBJECT
@ -12,9 +23,12 @@ protected:
public:
explicit SFXObjectDelegate(QObject* parent = Q_NULLPTR);
~SFXObjectDelegate() override;
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
void setEditorData(QWidget* editor, const QModelIndex& index) const override;
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
private slots:
void objIndexChanged();
};
@ -50,6 +64,8 @@ class SFXModel : public QAbstractTableModel {
public:
explicit SFXModel(QObject* parent = Q_NULLPTR);
~SFXModel() override;
void loadData(ProjectModel::SoundGroupNode* node);
void unloadData();
@ -73,6 +89,8 @@ class SFXTableView : public QTableView {
public:
explicit SFXTableView(QWidget* parent = Q_NULLPTR);
~SFXTableView() override;
void setModel