summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Palettes/PaletteManager.cpp
diff options
context:
space:
mode:
authorTomi Korpipaa <tomi.korpipaa@qt.io>2018-05-09 13:28:05 +0300
committerTomi Korpipää <tomi.korpipaa@qt.io>2018-05-09 10:39:19 +0000
commit420966b831116634ef2d2443191aa6d451710b4f (patch)
tree5d8b4a4c5f9b3f616327e9b6abeefebeb70be097 /src/Authoring/Studio/Palettes/PaletteManager.cpp
parentab509c2e63de9d04b5767cbb353a9a2acb96ebf0 (diff)
Re-organize folder structure to remove obsolete _Win folder
Task-number: QT3DS-1594 Change-Id: I2f4b1b5b7b38e56c38f7ed9bb7f2081924db660b Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/PaletteManager.cpp')
-rw-r--r--src/Authoring/Studio/Palettes/PaletteManager.cpp276
1 files changed, 276 insertions, 0 deletions
diff --git a/src/Authoring/Studio/Palettes/PaletteManager.cpp b/src/Authoring/Studio/Palettes/PaletteManager.cpp
new file mode 100644
index 00000000..03def618
--- /dev/null
+++ b/src/Authoring/Studio/Palettes/PaletteManager.cpp
@@ -0,0 +1,276 @@
+/****************************************************************************
+**
+** Copyright (C) 2002 NVIDIA Corporation.
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt 3D Studio.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//==============================================================================
+// Includes
+//==============================================================================
+#include "PaletteManager.h"
+#include "StudioApp.h"
+#include "MainFrm.h"
+#include "TimelineView.h"
+#include "TimelineWidget.h"
+#include "BasicObjectsView.h"
+#include "SlideView.h"
+#include "WidgetControl.h"
+#include "InspectorControlView.h"
+#include "ActionView.h"
+#include "IDragable.h"
+#include "ActionView.h"
+#include "ProjectView.h"
+#include "TabOrderHandler.h"
+#include "StudioPreferences.h"
+
+#include <QtWidgets/qdockwidget.h>
+#include <QtWidgets/qboxlayout.h>
+
+//==============================================================================
+/**
+ * Constructor
+ */
+CPaletteManager::CPaletteManager(CMainFrame *inMainFrame)
+ : m_MainFrame(inMainFrame)
+{
+ // Position tabs to the right
+ inMainFrame->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::East);
+
+ m_projectDock = new QDockWidget(QObject::tr("Project"), inMainFrame);
+ m_projectDock->setObjectName("project");
+ m_projectDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea
+ | Qt::BottomDockWidgetArea);
+ // Give the preferred size as percentages of the mainframe size
+ m_projectView = new ProjectView(QSize(inMainFrame->width() * 0.2,
+ inMainFrame->height() * 0.8),
+ m_projectDock);
+ m_projectView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ m_projectDock->setWidget(m_projectView);
+ inMainFrame->addDockWidget(Qt::RightDockWidgetArea, m_projectDock);
+ m_ControlList.insert(std::make_pair(CONTROLTYPE_PROJECT, m_projectDock));
+
+ m_inspectorDock = new QDockWidget(QObject::tr("Inspector Control"), inMainFrame);
+ m_inspectorDock->setObjectName("inspector_control");
+ m_inspectorDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea
+ | Qt::BottomDockWidgetArea);
+ // Give the preferred size as percentages of the mainframe size
+ auto inspectorView = new InspectorControlView(QSize(inMainFrame->width() * 0.2,
+ inMainFrame->height() * 0.8),
+ m_inspectorDock);
+ inspectorView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ m_inspectorDock->setWidget(inspectorView);
+ inMainFrame->addDockWidget(Qt::RightDockWidgetArea, m_inspectorDock);
+ inMainFrame->tabifyDockWidget(m_projectDock, m_inspectorDock);
+ m_ControlList.insert(std::make_pair(CONTROLTYPE_INSPECTOR, m_inspectorDock));
+
+ m_slideDock = new QDockWidget(QObject::tr("Slide"), inMainFrame);
+ m_slideDock->setObjectName("slide");
+ m_slideDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
+ // Slide palette has a fixed size hint
+ auto slideView = new SlideView(m_slideDock);
+ slideView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ m_slideDock->setWidget(slideView);
+ inMainFrame->addDockWidget(Qt::LeftDockWidgetArea, m_slideDock);
+ m_ControlList.insert(std::make_pair(CONTROLTYPE_SLIDE, m_slideDock));
+
+ m_basicObjectsDock = new QDockWidget(QObject::tr("Basic Objects"), inMainFrame);
+ m_basicObjectsDock->setObjectName("basic_objects");
+ m_basicObjectsDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea
+ | Qt::BottomDockWidgetArea);
+ // Basic objects palette has a fixed size hint
+ auto basicObjectsView = new BasicObjectsView(m_basicObjectsDock);
+ basicObjectsView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ m_basicObjectsDock->setWidget(basicObjectsView);
+ inMainFrame->addDockWidget(Qt::LeftDockWidgetArea, m_basicObjectsDock);
+ inMainFrame->tabifyDockWidget(m_basicObjectsDock, m_slideDock);
+ m_ControlList.insert(std::make_pair(CONTROLTYPE_BASICOBJECTS, m_basicObjectsDock));
+
+ m_timelineGVDock = new QDockWidget(QObject::tr("Timeline GV"));
+ m_timelineGVDock->setObjectName("timeline GV.");
+ m_timelineGVDock->setAllowedAreas(Qt::BottomDockWidgetArea);
+
+ m_timelineWidget = new TimelineWidget();
+ WidgetControl *timeLineWidgetControl = new WidgetControl(m_timelineWidget, m_timelineGVDock);
+ timeLineWidgetControl->RegisterForDnd(timeLineWidgetControl);
+ timeLineWidgetControl->AddMainFlavor(QT3DS_FLAVOR_LISTBOX);
+ timeLineWidgetControl->AddMainFlavor(QT3DS_FLAVOR_FILE);
+ timeLineWidgetControl->AddMainFlavor(QT3DS_FLAVOR_ASSET_UICFILE);
+ timeLineWidgetControl->AddMainFlavor(QT3DS_FLAVOR_ASSET_LIB);
+ timeLineWidgetControl->AddMainFlavor(QT3DS_FLAVOR_ASSET_TL);
+ timeLineWidgetControl->AddMainFlavor(QT3DS_FLAVOR_BASIC_OBJECTS);
+
+ m_timelineWidget->setParent(timeLineWidgetControl);
+
+ m_timelineGVDock->setWidget(timeLineWidgetControl);
+ inMainFrame->addDockWidget(Qt::BottomDockWidgetArea, m_timelineGVDock);
+ m_ControlList.insert(std::make_pair(CONTROLTYPE_TIMELINE, m_timelineGVDock));
+
+ m_actionDock = new QDockWidget(QObject::tr("Action"), inMainFrame);
+ m_actionDock->setObjectName("action");
+ m_actionDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea
+ | Qt::BottomDockWidgetArea);
+ // Give the preferred size as percentages of the mainframe size
+ // +25 is applied to width to compensate the action palette having no tabs by default
+ auto actionView = new ActionView(QSize(inMainFrame->width() * 0.2 + 25,
+ inMainFrame->height() * 0.2),
+ m_actionDock);
+ actionView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ m_actionDock->setWidget(actionView);
+ QObject::connect(actionView, &ActionView::actionFocused,
+ m_MainFrame, &CMainFrame::actionActive);
+ inMainFrame->addDockWidget(Qt::BottomDockWidgetArea, m_actionDock);
+ m_ControlList.insert(std::make_pair(CONTROLTYPE_ACTION, m_actionDock));
+
+ m_basicObjectsDock->setEnabled(false);
+ m_projectDock->setEnabled(false);
+ m_slideDock->setEnabled(false);
+ m_actionDock->setEnabled(false);
+ m_inspectorDock->setEnabled(false);
+ m_timelineGVDock->setEnabled(false);
+}
+
+//==============================================================================
+/**
+ * Destructor
+ */
+CPaletteManager::~CPaletteManager()
+{
+ TControlMap::iterator theIterator = m_ControlList.begin();
+ TControlMap::iterator theEndIterator = m_ControlList.end();
+ // Delete all the controls
+ for (theIterator = m_ControlList.begin(); theIterator != theEndIterator; ++theIterator)
+ delete theIterator->second;
+}
+
+//=============================================================================
+/**
+ * Force a control to become invisible
+ */
+void CPaletteManager::HideControl(long inType)
+{
+ auto dock = GetControl(inType);
+
+ if (dock) {
+ // Make sure the control is invisible
+ dock->setVisible(false);
+ }
+}
+//=============================================================================
+/**
+ * Detemine if a control is currently visible
+ */
+bool CPaletteManager::IsControlVisible(long inType) const
+{
+ auto dock = GetControl(inType);
+ return dock && dock->isVisible();
+}
+
+//=============================================================================
+/**
+ * Force a control to become visible
+ */
+void CPaletteManager::ShowControl(long inType)
+{
+ auto dock = GetControl(inType);
+
+ if (dock) {
+ // Make sure the control is visible
+ dock->setVisible(true);
+ dock->setFocus();
+ }
+}
+
+//=============================================================================
+/**
+ * Flip the visible state of a control
+ */
+void CPaletteManager::ToggleControl(long inType)
+{
+ if (IsControlVisible(inType))
+ HideControl(inType);
+ else
+ ShowControl(inType);
+}
+
+//==============================================================================
+/**
+ * Return the Control (Palette) according to its EControlTypes enum.
+ * @param inType EControlTypes
+ */
+QDockWidget *CPaletteManager::GetControl(long inType) const
+{
+ auto dock = m_ControlList.find(inType);
+ if (dock != m_ControlList.end() && dock->second)
+ return dock->second;
+ else
+ return nullptr;
+}
+
+QWidget *CPaletteManager::getFocusWidget() const
+{
+ TControlMap::const_iterator end = m_ControlList.end();
+ for (TControlMap::const_iterator iter = m_ControlList.begin(); iter != end; ++iter) {
+ if (iter->second->widget()->hasFocus())
+ return iter->second->widget();
+ }
+ return nullptr;
+}
+
+bool CPaletteManager::tabNavigateFocusedWidget(bool tabForward)
+{
+ QWidget *palette = getFocusWidget();
+ if (palette) {
+ if (auto inspector = qobject_cast<InspectorControlView *>(palette)) {
+ inspector->tabOrderHandler()->tabNavigate(tabForward);
+ return true;
+ } else if (auto actionview = qobject_cast<ActionView *>(palette)) {
+ actionview->tabOrderHandler()->tabNavigate(tabForward);
+ return true;
+ }
+ }
+ return false;
+}
+
+void CPaletteManager::onTimeChanged(long time)
+{
+ //m_timeLineToolbar->onTimeChanged(time);
+}
+
+ProjectView *CPaletteManager::projectView() const
+{
+ return m_projectView;
+}
+
+void CPaletteManager::EnablePalettes()
+{
+ m_basicObjectsDock->setEnabled(true);
+ m_projectDock->setEnabled(true);
+ m_slideDock->setEnabled(true);
+ m_timelineGVDock->setEnabled(true);
+ m_actionDock->setEnabled(true);
+ m_inspectorDock->setEnabled(true);
+}
+