/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/EditorPlugins/Scene/EditorPluginScene/Panels/LayerPanel/LayerPanel.cpp
62 строки
2 KB
Jan Krassnigg
Added Layer panel toolbar, and option to not automatically switch the layer (#1597)
06 июл 2025, 17:28
Не верифицирован
06 июл 2025, 17:28
f605d56
Код
Авторство
О чём код?
#include <EditorPluginScene/EditorPluginScenePCH.h> #include <EditorPluginScene/Objects/SceneObjectManager.h> #include <EditorPluginScene/Panels/LayerPanel/LayerAdapter.moc.h> #include <EditorPluginScene/Panels/LayerPanel/LayerPanel.moc.h> #include <EditorPluginScene/Panels/ScenegraphPanel/ScenegraphModel.moc.h> #include <EditorPluginScene/Scene/Scene2Document.h> #include <GuiFoundation/ActionViews/MenuActionMapView.moc.h> #include <GuiFoundation/ActionViews/ToolBarActionMapView.moc.h> #include <QVBoxLayout> ezQtLayerPanel::ezQtLayerPanel(ads::CDockManager* pDockManager, QWidget* pParent, ezScene2Document* pDocument) : ezQtDocumentPanel(pDockManager, pParent, pDocument) { setObjectName("LayerPanel"); setWindowTitle("Layers"); m_pSceneDocument = pDocument; m_pDelegate = new ezQtLayerDelegate(this, pDocument); std::unique_ptr<ezQtLayerModel> pModel(new ezQtLayerModel(m_pSceneDocument)); pModel->AddAdapter(new ezQtDummyAdapter(pDocument->GetSceneObjectManager(), ezGetStaticRTTI<ezSceneDocumentSettings>(), "Layers")); pModel->AddAdapter(new ezQtLayerAdapter(pDocument)); m_pTreeWidget = new ezQtDocumentTreeView(this, pDocument, std::move(pModel), m_pSceneDocument->GetLayerSelectionManager()); m_pTreeWidget->SetAllowDragDrop(true); m_pTreeWidget->SetAllowDeleteObjects(false); m_pTreeWidget->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection); m_pTreeWidget->setItemDelegate(m_pDelegate); m_pTreeWidget->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu); EZ_VERIFY(connect(m_pTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(OnRequestContextMenu(QPoint))) != nullptr, "signal/slot connection failed"); setWidget(m_pTreeWidget); { // Tool Bar ezQtToolBarActionMapView* pToolBar = new ezQtToolBarActionMapView("Toolbar", this); ezActionContext context; context.m_sMapping = "EditorPluginScene_LayerToolbar"; context.m_pDocument = pDocument; context.m_pWindow = this; pToolBar->SetActionContext(context); pToolBar->setObjectName("LayerPanel_ToolBar"); setToolBar(pToolBar); } } ezQtLayerPanel::~ezQtLayerPanel() = default; void ezQtLayerPanel::OnRequestContextMenu(QPoint pos) { ezQtMenuActionMapView menu(nullptr); ezActionContext context; context.m_sMapping = "EditorPluginScene_LayerContextMenu"; context.m_pDocument = m_pSceneDocument; context.m_pWindow = this; menu.SetActionContext(context); menu.exec(m_pTreeWidget->mapToGlobal(pos)); }