From 2d13128b8698e5cd60a2a7efcd089276a8d76b70 Mon Sep 17 00:00:00 2001 From: Matthias Puchner <github@mpuchner.de> Date: Wed, 10 Nov 2021 09:18:46 +0100 Subject: [PATCH] add infrastructure to LayerOrientedSampleEditor for showing a certain item in the real space view --- .../SampleDesigner/LayerOrientedSampleEditor.cpp | 2 ++ GUI/View/SampleDesigner/LayerOrientedSampleEditor.h | 4 ++++ GUI/View/SampleDesigner/SampleEditorController.h | 4 ++++ GUI/View/SampleDesigner/SampleView.cpp | 12 ++++++++++++ GUI/View/SampleDesigner/SampleView.h | 6 ++++++ 5 files changed, 28 insertions(+) diff --git a/GUI/View/SampleDesigner/LayerOrientedSampleEditor.cpp b/GUI/View/SampleDesigner/LayerOrientedSampleEditor.cpp index 10642c3b836..89281d78c24 100644 --- a/GUI/View/SampleDesigner/LayerOrientedSampleEditor.cpp +++ b/GUI/View/SampleDesigner/LayerOrientedSampleEditor.cpp @@ -111,6 +111,8 @@ void LayerOrientedSampleEditor::setCurrentSample(MultiLayerItem* multiLayerItem) m_editControllers.insert(m_currentMultiLayerItem, new SampleEditorController(m_currentMultiLayerItem)); auto* ec = m_editControllers[m_currentMultiLayerItem]; + connect(ec, &SampleEditorController::requestViewInRealSpace, this, + &LayerOrientedSampleEditor::requestViewInRealSpace); m_undoAction = ec->undoStack()->createUndoAction(this); m_redoAction = ec->undoStack()->createRedoAction(this); diff --git a/GUI/View/SampleDesigner/LayerOrientedSampleEditor.h b/GUI/View/SampleDesigner/LayerOrientedSampleEditor.h index 0a11350d6f4..df212a80ff4 100644 --- a/GUI/View/SampleDesigner/LayerOrientedSampleEditor.h +++ b/GUI/View/SampleDesigner/LayerOrientedSampleEditor.h @@ -23,6 +23,7 @@ class QToolBar; class SampleEditorController; class MultiLayerForm; class QScrollArea; +class SessionItem; //! Sample editor with layer oriented presentation of a sample class LayerOrientedSampleEditor : public QWidget { @@ -33,6 +34,9 @@ public: void setCurrentSample(MultiLayerItem* multiLayerItem); +signals: + void requestViewInRealSpace(SessionItem* itemToShow); + private: void updateActionEnabling(); void onShowInlineEditButtonsToggled(bool checked); diff --git a/GUI/View/SampleDesigner/SampleEditorController.h b/GUI/View/SampleDesigner/SampleEditorController.h index 8134098ee10..d8ab9b2dc68 100644 --- a/GUI/View/SampleDesigner/SampleEditorController.h +++ b/GUI/View/SampleDesigner/SampleEditorController.h @@ -32,6 +32,7 @@ class ItemWithMaterial; class SelectionContainerForm; class AbstractSelectionDescriptor; class InterferenceForm; +class SessionItem; //! Class to modify a sample from the layer oriented sample editor. //! @@ -84,6 +85,9 @@ public: void onStartingToMoveLayer(); void onStoppedToMoveLayer(QWidget* widgetToMove, QWidget* moveAboveThisWidget); +signals: + void requestViewInRealSpace(SessionItem* itemToShow); + private: QUndoStack m_undoStack; MultiLayerItem* m_multiLayerItem; diff --git a/GUI/View/SampleDesigner/SampleView.cpp b/GUI/View/SampleDesigner/SampleView.cpp index 60c88ce44d9..08471145e7a 100644 --- a/GUI/View/SampleDesigner/SampleView.cpp +++ b/GUI/View/SampleDesigner/SampleView.cpp @@ -148,6 +148,9 @@ void SampleView::initLayerOrientedEditor() connect(sampleSelectionView, &SampleListView::currentSampleChanged, editor, &LayerOrientedSampleEditor::setCurrentSample); + connect(editor, &LayerOrientedSampleEditor::requestViewInRealSpace, this, + &SampleView::onRequestViewInRealSpace); + setCentralWidget(editor); resetLayout(); @@ -199,6 +202,15 @@ void SampleView::onSampleTreeViewSelectionChanged(const QItemSelection& selected m_realSpacePanel->canvas()->setCurrentItem(item); } +void SampleView::onRequestViewInRealSpace(SessionItem* itemToView) +{ + if (!itemToView) + return; + + m_docks->setDockVisible(REALSPACEPANEL); + m_realSpacePanel->canvas()->setCurrentItem(itemToView); +} + void SampleView::toggleRealSpaceView() { m_docks->toggleDock(REALSPACEPANEL); diff --git a/GUI/View/SampleDesigner/SampleView.h b/GUI/View/SampleDesigner/SampleView.h index 16e2f9851a2..41af423e7af 100644 --- a/GUI/View/SampleDesigner/SampleView.h +++ b/GUI/View/SampleDesigner/SampleView.h @@ -22,6 +22,7 @@ class ProjectDocument; class SampleToolBar; class RealSpacePanel; class QItemSelection; +class SessionItem; class SampleView : public QMainWindow { Q_OBJECT @@ -41,6 +42,11 @@ private: void updateFunctionalities(); void onSampleTreeViewSelectionChanged(const QItemSelection& selected, const QItemSelection&); + //! Show the item in the real space view + //! + //! If the real space view is not visible at the moment, it will be shown. + void onRequestViewInRealSpace(SessionItem* itemToView); + DocksController* m_docks = nullptr; ProjectDocument* m_document = nullptr; SampleToolBar* m_toolBar = nullptr; -- GitLab