Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Replace Qt docking system with ADS #118

Merged
merged 6 commits into from
Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

VST is a trademark of Steinberg Media Technologies GmbH

Code in the editor/widgets/dock folder is based on the "Qt Advanced Docking System" (https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System), and so is licensed under LGPL v2.1. See the LICENSE file in that folder for details.
7 changes: 4 additions & 3 deletions editor/model/LibraryEntry.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "LibraryEntry.h"

#include "PoolOperators.h"
#include "objects/RootSurface.h"
#include "objects/ModuleSurface.h"

using namespace AxiomModel;

Expand All @@ -12,8 +12,9 @@ LibraryEntry::LibraryEntry(QString name, const QUuid &baseUuid, const QUuid &mod
_modificationDateTime(modificationDateTime), _tags(std::move(tags)), _root(std::move(root)) {
auto rootSurfaces = findChildren(_root->nodeSurfaces().sequence(), QUuid());
assert(rootSurfaces.size() == 1);
_rootSurface = dynamic_cast<RootSurface *>(*AxiomCommon::takeAt(std::move(rootSurfaces), 0));
_rootSurface = dynamic_cast<ModuleSurface *>(*AxiomCommon::takeAt(rootSurfaces, 0));
assert(_rootSurface);
_rootSurface->setEntry(this);

_root->history().stackChanged.connect(this, &LibraryEntry::modified);
}
Expand All @@ -27,7 +28,7 @@ std::unique_ptr<LibraryEntry> LibraryEntry::create(QString name, const QUuid &ba

std::unique_ptr<LibraryEntry> LibraryEntry::create(QString name, std::set<QString> tags) {
auto newRoot = std::make_unique<ModelRoot>();
newRoot->pool().registerObj(std::make_unique<RootSurface>(QUuid::createUuid(), QPointF(0, 0), 0, 0, newRoot.get()));
newRoot->pool().registerObj(std::make_unique<ModuleSurface>(QUuid::createUuid(), QPointF(0, 0), 0, newRoot.get()));
return create(std::move(name), QUuid::createUuid(), QUuid::createUuid(), QDateTime::currentDateTimeUtc(),
std::move(tags), std::move(newRoot));
}
Expand Down
6 changes: 3 additions & 3 deletions editor/model/LibraryEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace AxiomModel {

class Library;

class RootSurface;
class ModuleSurface;

class LibraryEntry : public AxiomCommon::TrackedObject {
public:
Expand Down Expand Up @@ -51,7 +51,7 @@ namespace AxiomModel {

ModelRoot *root() const { return _root.get(); }

RootSurface *rootSurface() const { return _rootSurface; }
ModuleSurface *rootSurface() const { return _rootSurface; }

void modified();

Expand All @@ -64,6 +64,6 @@ namespace AxiomModel {
QDateTime _modificationDateTime;
std::set<QString> _tags;
std::unique_ptr<ModelRoot> _root;
RootSurface *_rootSurface;
ModuleSurface *_rootSurface;
};
}
2 changes: 1 addition & 1 deletion editor/model/actions/DeleteObjectAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void DeleteObjectAction::backward() {
QDataStream stream(&_buffer, QIODevice::ReadOnly);
IdentityReferenceMapper ref;
auto addedObjects =
ModelObjectSerializer::deserializeChunk(stream, ProjectSerializer::schemaVersion, root(), QUuid(), &ref);
ModelObjectSerializer::deserializeChunk(stream, ProjectSerializer::schemaVersion, root(), QUuid(), &ref, false);
_buffer.clear();
}

Expand Down
4 changes: 2 additions & 2 deletions editor/model/actions/PasteBufferAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ void PasteBufferAction::forward(bool) {
if (_isBufferFormatted) {
IdentityReferenceMapper ref;
used = ModelObjectSerializer::deserializeChunk(stream, ProjectSerializer::schemaVersion, root(), _surfaceUuid,
&ref);
&ref, false);
} else {
CloneReferenceMapper ref;
ref.setUuid(_surfaceUuid, _surfaceUuid);
ref.setPos(_surfaceUuid, _center - objectCenter);
used = ModelObjectSerializer::deserializeChunk(stream, ProjectSerializer::schemaVersion, root(), _surfaceUuid,
&ref);
&ref, false);
}

_isBufferFormatted = true;
Expand Down
1 change: 1 addition & 0 deletions editor/model/objects/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(SOURCE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/Control.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ControlSurface.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/MidiControl.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ModuleSurface.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Node.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/CustomNode.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/ExtractControl.cpp"
Expand Down
22 changes: 22 additions & 0 deletions editor/model/objects/ModuleSurface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "ModuleSurface.h"

#include "../LibraryEntry.h"

using namespace AxiomModel;

ModuleSurface::ModuleSurface(const QUuid &uuid, QPointF pan, float zoom, AxiomModel::ModelRoot *root)
: NodeSurface(uuid, QUuid(), pan, zoom, root) {}

QString ModuleSurface::name() {
return _entry->name();
}

QString ModuleSurface::debugName() {
return "ModuleSurface";
}

void ModuleSurface::setEntry(AxiomModel::LibraryEntry *entry) {
assert(!_entry);
_entry = entry;
_entry->nameChanged.forward(&nameChanged);
}
30 changes: 30 additions & 0 deletions editor/model/objects/ModuleSurface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include "NodeSurface.h"

namespace AxiomModel {

class LibraryEntry;

class ModuleSurface : public NodeSurface {
public:
ModuleSurface(const QUuid &uuid, QPointF pan, float zoom, AxiomModel::ModelRoot *root);

QString name() override;

QString debugName() override;

bool canExposeControl() const override { return false; }

bool canHavePortals() const override { return false; }

uint64_t getRuntimeId() override { return 0; }

void setEntry(AxiomModel::LibraryEntry *entry);

AxiomModel::LibraryEntry *entry() const { return _entry; }

private:
AxiomModel::LibraryEntry *_entry = nullptr;
};
}
2 changes: 1 addition & 1 deletion editor/model/serialize/LibrarySerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ std::unique_ptr<LibraryEntry> LibrarySerializer::deserializeEntry(QDataStream &s
// 0.4.0 (schema version 5) removed history from being serialized in the library
auto deserializeHistory = version < 5;

auto root = ModelObjectSerializer::deserializeRoot(stream, deserializeHistory, version);
auto root = ModelObjectSerializer::deserializeRoot(stream, deserializeHistory, true, version);
return LibraryEntry::create(std::move(name), baseUuid, modificationUuid, modificationDateTime, std::move(tags),
std::move(root));
}
16 changes: 8 additions & 8 deletions editor/model/serialize/ModelObjectSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void ModelObjectSerializer::serializeRoot(AxiomModel::ModelRoot *root, bool incl

std::vector<ModelObject *> ModelObjectSerializer::deserializeChunk(QDataStream &stream, uint32_t version,
ModelRoot *root, const QUuid &parent,
AxiomModel::ReferenceMapper *ref) {
AxiomModel::ReferenceMapper *ref, bool isLibrary) {
std::vector<ModelObject *> usedObjects;

uint32_t objectCount;
Expand All @@ -37,7 +37,7 @@ std::vector<ModelObject *> ModelObjectSerializer::deserializeChunk(QDataStream &
stream >> objectBuffer;
QDataStream objectStream(&objectBuffer, QIODevice::ReadOnly);

auto newObject = deserialize(objectStream, version, root, parent, ref);
auto newObject = deserialize(objectStream, version, root, parent, ref, isLibrary);
usedObjects.push_back(newObject.get());
root->pool().registerObj(std::move(newObject));
}
Expand All @@ -46,10 +46,10 @@ std::vector<ModelObject *> ModelObjectSerializer::deserializeChunk(QDataStream &
}

std::unique_ptr<ModelRoot> ModelObjectSerializer::deserializeRoot(QDataStream &stream, bool includeHistory,
uint32_t version) {
bool isLibrary, uint32_t version) {
auto modelRoot = std::make_unique<ModelRoot>();
IdentityReferenceMapper ref;
deserializeChunk(stream, version, modelRoot.get(), QUuid(), &ref);
deserializeChunk(stream, version, modelRoot.get(), QUuid(), &ref, isLibrary);
if (includeHistory) {
modelRoot->setHistory(HistorySerializer::deserialize(stream, version, modelRoot.get()));
}
Expand All @@ -65,7 +65,7 @@ void ModelObjectSerializer::serialize(AxiomModel::ModelObject *obj, QDataStream

std::unique_ptr<ModelObject> ModelObjectSerializer::deserialize(QDataStream &stream, uint32_t version,
AxiomModel::ModelRoot *root, const QUuid &parent,
AxiomModel::ReferenceMapper *ref) {
AxiomModel::ReferenceMapper *ref, bool isLibrary) {
QUuid uuid;
stream >> uuid;
uuid = ref->mapUuid(uuid);
Expand All @@ -80,7 +80,7 @@ std::unique_ptr<ModelObject> ModelObjectSerializer::deserialize(QDataStream &str
uint8_t typeInt;
stream >> typeInt;

return deserializeInner(stream, version, root, (ModelObject::ModelType) typeInt, uuid, parentUuid, ref);
return deserializeInner(stream, version, root, (ModelObject::ModelType) typeInt, uuid, parentUuid, ref, isLibrary);
}

void ModelObjectSerializer::serializeInner(AxiomModel::ModelObject *obj, QDataStream &stream) {
Expand All @@ -98,10 +98,10 @@ std::unique_ptr<ModelObject> ModelObjectSerializer::deserializeInner(QDataStream
AxiomModel::ModelRoot *root,
AxiomModel::ModelObject::ModelType type,
const QUuid &uuid, const QUuid &parent,
AxiomModel::ReferenceMapper *ref) {
AxiomModel::ReferenceMapper *ref, bool isLibrary) {
switch (type) {
case ModelObject::ModelType::NODE_SURFACE:
return NodeSurfaceSerializer::deserialize(stream, version, uuid, parent, ref, root);
return NodeSurfaceSerializer::deserialize(stream, version, uuid, parent, ref, root, isLibrary);
case ModelObject::ModelType::NODE:
return NodeSerializer::deserialize(stream, version, uuid, parent, ref, root);
case ModelObject::ModelType::CONTROL_SURFACE:
Expand Down
9 changes: 5 additions & 4 deletions editor/model/serialize/ModelObjectSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,23 @@ namespace AxiomModel {

namespace ModelObjectSerializer {
std::vector<ModelObject *> deserializeChunk(QDataStream &stream, uint32_t version, ModelRoot *root,
const QUuid &parent, ReferenceMapper *ref);
const QUuid &parent, ReferenceMapper *ref, bool isLibrary);

void serializeRoot(ModelRoot *root, bool includeHistory, QDataStream &stream);

std::unique_ptr<ModelRoot> deserializeRoot(QDataStream &stream, bool includeHistory, uint32_t version);
std::unique_ptr<ModelRoot> deserializeRoot(QDataStream &stream, bool includeHistory, bool isLibrary,
uint32_t version);

void serialize(ModelObject *obj, QDataStream &stream, const QUuid &parent);

std::unique_ptr<ModelObject> deserialize(QDataStream &stream, uint32_t version, ModelRoot *root,
const QUuid &parent, ReferenceMapper *ref);
const QUuid &parent, ReferenceMapper *ref, bool isLibrary);

void serializeInner(ModelObject *obj, QDataStream &stream);

std::unique_ptr<ModelObject> deserializeInner(QDataStream &stream, uint32_t version, ModelRoot *root,
ModelObject::ModelType type, const QUuid &uuid,
const QUuid &parent, ReferenceMapper *ref);
const QUuid &parent, ReferenceMapper *ref, bool isLibrary);

template<class T>
void serializeChunk(QDataStream &stream, const QUuid &parent, T objects) {
Expand Down
9 changes: 7 additions & 2 deletions editor/model/serialize/NodeSurfaceSerializer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "NodeSurfaceSerializer.h"

#include "../objects/GroupSurface.h"
#include "../objects/ModuleSurface.h"
#include "../objects/NodeSurface.h"
#include "../objects/RootSurface.h"

Expand All @@ -11,20 +12,24 @@ void NodeSurfaceSerializer::serialize(AxiomModel::NodeSurface *surface, QDataStr
stream << surface->zoom();

if (auto rootSurface = dynamic_cast<RootSurface *>(surface)) {
stream << (quint64)rootSurface->nextPortalId();
stream << (quint64) rootSurface->nextPortalId();
}
}

std::unique_ptr<NodeSurface> NodeSurfaceSerializer::deserialize(QDataStream &stream, uint32_t version,
const QUuid &uuid, const QUuid &parentUuid,
AxiomModel::ReferenceMapper *ref,
AxiomModel::ModelRoot *root) {
AxiomModel::ModelRoot *root, bool isLibrary) {
QPointF pan;
stream >> pan;
float zoom;
stream >> zoom;

if (parentUuid.isNull()) {
if (isLibrary) {
return std::make_unique<ModuleSurface>(uuid, pan, zoom, root);
}

// unique portal IDs were added in 0.4.0, corresponding to schema version 5
quint64 nextPortalId = 0;
if (version >= 5) {
Expand Down
3 changes: 2 additions & 1 deletion editor/model/serialize/NodeSurfaceSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace AxiomModel {
void serialize(NodeSurface *surface, QDataStream &stream);

std::unique_ptr<NodeSurface> deserialize(QDataStream &stream, uint32_t version, const QUuid &uuid,
const QUuid &parentUuid, ReferenceMapper *ref, ModelRoot *root);
const QUuid &parentUuid, ReferenceMapper *ref, ModelRoot *root,
bool isLibrary);
}
}
2 changes: 1 addition & 1 deletion editor/model/serialize/ProjectSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ std::unique_ptr<Project> ProjectSerializer::deserialize(QDataStream &stream, uin
if (versionOut) *versionOut = version;

auto linkedFile = getLinkedFile(stream, version);
auto modelRoot = ModelObjectSerializer::deserializeRoot(stream, true, version);
auto modelRoot = ModelObjectSerializer::deserializeRoot(stream, true, false, version);
auto project = std::make_unique<Project>(linkedFile, std::move(modelRoot));

// Before schema version 5, the module library was included in the project file. To ensure modules aren't lost,
Expand Down
Binary file added editor/resources/icons/dock-close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added editor/resources/icons/dock-menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions editor/resources/res.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<file>logo.png</file>

<file>styles/MainStyles.qss</file>
<file>styles/Dock.qss</file>
<file>styles/ModuleBrowserPanel.qss</file>
<file>styles/ModulePreviewList.qss</file>
<file>styles/SchematicPanel.qss</file>
Expand All @@ -19,6 +20,8 @@
<file>icons/output-midi-portal.png</file>
<file>icons/output-num-portal.png</file>
<file>icons/automation-portal.png</file>
<file>icons/dock-close.png</file>
<file>icons/dock-menu.png</file>

<file>default.axl</file>
</qresource>
Expand Down
53 changes: 53 additions & 0 deletions editor/resources/styles/Dock.qss
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
ads--CDockContainerWidget {
background: #292929;
}

ads--CDockContainerWidget QSplitter::handle {
border-right: 2px solid #292929;
border-bottom: 2px solid #292929;
}

ads--CDockAreaWidget {
background: #292929;
}

ads--CDockAreaWidget #tabsContainerWidget, ads--CDockAreaWidget #dockAreaTitleBar {
background: #292929;
}

ads--CDockAreaWidget #tabsMenuButton::menu-indicator {
image: none;
}

ads--CDockWidgetTitleBar {
background: transparent;
padding: 8px 10px;
}

ads--CDockWidgetTitleBar:hover, ads--CDockWidgetTitleBar[activeTab="true"] {
background: #444;
}

ads--CDockWidgetTitleBar QLabel {
background: transparent;
}

ads--CDockWidget {
border-color: #444;
border-style: solid;
border-width: 2px 0 0 0;
}

QPushButton#closeButton, QPushButton#tabsMenuButton {
padding: 2px;
background: transparent;
border: none;
}

QPushButton#closeButton:hover, QPushButton#tabsMenuButton:hover {
background: #444;
}

QPushButton#closeButton:pressed, QPushButton#tabsMenuButton:pressed {
background: #444;
}
2 changes: 1 addition & 1 deletion editor/resources/styles/MainStyles.qss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
* {
color: #EEEEEE;
background-color: #111;/*#0A0A0A;*/
background-color: #111;
}

/* form control styling */
Expand Down
14 changes: 11 additions & 3 deletions editor/widgets/dock/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
cmake_minimum_required(VERSION 3.4.3)

set(SOURCE_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/DockPanel.cpp")
set(SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/ads_globals.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/DockAreaWidget.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/DockContainerWidget.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/DockManager.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/DockOverlay.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/DockSplitter.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/DockStateSerialization.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/DockWidget.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/DockWidgetTitleBar.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/FloatingDockContainer.cpp")

target_sources(axiom_widgets PRIVATE ${SOURCE_FILES})
target_sources(axiom_widgets PRIVATE ${SOURCE_FILES})
Loading