Created material editor settings dialog
Activated settings menu option Moved viewport camera controller initialization before viewport settings restoration
This commit is contained in:
@@ -30,5 +30,6 @@ namespace MaterialEditor
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
bool m_showReloadDocumentPrompt = true;
|
||||
AZStd::string m_defaultMaterialTypeName = "StandardPBR";
|
||||
};
|
||||
} // namespace MaterialEditor
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace MaterialEditor
|
||||
serializeContext->Class<MaterialDocumentSettings, AZ::UserSettings>()
|
||||
->Version(1)
|
||||
->Field("showReloadDocumentPrompt", &MaterialDocumentSettings::m_showReloadDocumentPrompt)
|
||||
->Field("defaultMaterialTypeName", &MaterialDocumentSettings::m_defaultMaterialTypeName)
|
||||
;
|
||||
|
||||
if (auto editContext = serializeContext->GetEditContext())
|
||||
@@ -32,6 +33,7 @@ namespace MaterialEditor
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialDocumentSettings::m_showReloadDocumentPrompt, "Show Reload Document Prompt", "")
|
||||
->DataElement(AZ::Edit::UIHandlers::Default, &MaterialDocumentSettings::m_defaultMaterialTypeName, "Default Material Type Name", "")
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -45,6 +47,7 @@ namespace MaterialEditor
|
||||
->Constructor()
|
||||
->Constructor<const MaterialDocumentSettings&>()
|
||||
->Property("showReloadDocumentPrompt", BehaviorValueProperty(&MaterialDocumentSettings::m_showReloadDocumentPrompt))
|
||||
->Property("defaultMaterialTypeName", BehaviorValueProperty(&MaterialDocumentSettings::m_defaultMaterialTypeName))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,6 +233,8 @@ namespace MaterialEditor
|
||||
MaterialViewportRequestBus::BroadcastResult(modelPreset, &MaterialViewportRequestBus::Events::GetModelPresetSelection);
|
||||
OnModelPresetSelected(modelPreset);
|
||||
|
||||
m_viewportController->Init(m_cameraEntity->GetId(), m_modelEntity->GetId(), m_iblEntity->GetId());
|
||||
|
||||
// Apply user settinngs restored since last run
|
||||
AZStd::intrusive_ptr<MaterialViewportSettings> viewportSettings =
|
||||
AZ::UserSettings::CreateFind<MaterialViewportSettings>(AZ::Crc32("MaterialViewportSettings"), AZ::UserSettings::CT_GLOBAL);
|
||||
@@ -248,8 +250,6 @@ namespace MaterialEditor
|
||||
AZ::TickBus::Handler::BusConnect();
|
||||
AZ::TransformNotificationBus::MultiHandler::BusConnect(m_cameraEntity->GetId());
|
||||
AzFramework::WindowSystemRequestBus::Handler::BusConnect();
|
||||
|
||||
m_viewportController->Init(m_cameraEntity->GetId(), m_modelEntity->GetId(), m_iblEntity->GetId());
|
||||
}
|
||||
|
||||
MaterialViewportRenderer::~MaterialViewportRenderer()
|
||||
|
||||
+7
-2
@@ -21,6 +21,8 @@
|
||||
#include <Atom/RPI.Edit/Material/MaterialSourceData.h>
|
||||
#include <Atom/RPI.Edit/Material/MaterialTypeSourceData.h>
|
||||
|
||||
#include <Atom/Document/MaterialDocumentSettings.h>
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
namespace MaterialEditor
|
||||
@@ -69,8 +71,11 @@ namespace MaterialEditor
|
||||
QObject::connect(m_ui->m_materialTypeComboBox, static_cast<void (QComboBox::*)(const int)>(&QComboBox::currentIndexChanged), this, [this]() { UpdateMaterialTypeSelection(); });
|
||||
QObject::connect(m_ui->m_materialTypeComboBox, &QComboBox::currentTextChanged, this, [this]() { UpdateMaterialTypeSelection(); });
|
||||
|
||||
// Select StandardPBR by default but we will later data drive this with editor settings
|
||||
const int index = m_ui->m_materialTypeComboBox->findText("StandardPBR");
|
||||
// Select the default material type from settings
|
||||
auto settings =
|
||||
AZ::UserSettings::CreateFind<MaterialDocumentSettings>(AZ::Crc32("MaterialDocumentSettings"), AZ::UserSettings::CT_GLOBAL);
|
||||
|
||||
const int index = m_ui->m_materialTypeComboBox->findText(settings->m_defaultMaterialTypeName.c_str());
|
||||
if (index >= 0)
|
||||
{
|
||||
m_ui->m_materialTypeComboBox->setCurrentIndex(index);
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <Viewport/MaterialViewportWidget.h>
|
||||
#include <Window/CreateMaterialDialog/CreateMaterialDialog.h>
|
||||
#include <Window/HelpDialog/HelpDialog.h>
|
||||
#include <Window/SettingsDialog/SettingsDialog.h>
|
||||
#include <Window/MaterialBrowserWidget.h>
|
||||
#include <Window/MaterialEditorWindow.h>
|
||||
#include <Window/MaterialInspector/MaterialInspector.h>
|
||||
@@ -314,7 +315,7 @@ namespace MaterialEditor
|
||||
|
||||
m_actionUndo->setEnabled(canUndo);
|
||||
m_actionRedo->setEnabled(canRedo);
|
||||
m_actionPreferences->setEnabled(false);
|
||||
m_actionSettings->setEnabled(true);
|
||||
|
||||
m_actionAssetBrowser->setEnabled(true);
|
||||
m_actionInspector->setEnabled(true);
|
||||
@@ -507,9 +508,11 @@ namespace MaterialEditor
|
||||
|
||||
m_menuEdit->addSeparator();
|
||||
|
||||
m_actionPreferences = m_menuEdit->addAction("&Preferences...", [this]() {
|
||||
m_actionSettings = m_menuEdit->addAction("&Settings...", [this]() {
|
||||
SettingsDialog dialog(this);
|
||||
dialog.exec();
|
||||
}, QKeySequence::Preferences);
|
||||
m_actionPreferences->setEnabled(false);
|
||||
m_actionSettings->setEnabled(true);
|
||||
|
||||
m_menuView = m_menuBar->addMenu("&View");
|
||||
|
||||
@@ -554,8 +557,8 @@ namespace MaterialEditor
|
||||
m_menuHelp = m_menuBar->addMenu("&Help");
|
||||
|
||||
m_actionHelp = m_menuHelp->addAction("&Help...", [this]() {
|
||||
HelpDialog dlg(this);
|
||||
dlg.exec();
|
||||
HelpDialog dialog(this);
|
||||
dialog.exec();
|
||||
});
|
||||
|
||||
m_actionAbout = m_menuHelp->addAction("&About...", [this]() {
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace MaterialEditor
|
||||
QMenu* m_menuEdit = {};
|
||||
QAction* m_actionUndo = {};
|
||||
QAction* m_actionRedo = {};
|
||||
QAction* m_actionPreferences = {};
|
||||
QAction* m_actionSettings = {};
|
||||
|
||||
QMenu* m_menuView = {};
|
||||
QAction* m_actionAssetBrowser = {};
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Window/SettingsDialog/SettingsDialog.h>
|
||||
#include <Window/SettingsDialog/SettingsWidget.h>
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
SettingsDialog::SettingsDialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
setWindowTitle("Material Editor Settings");
|
||||
setFixedSize(600, 300);
|
||||
setLayout(new QVBoxLayout(this));
|
||||
|
||||
auto settingsWidget = new SettingsWidget(this);
|
||||
settingsWidget->Populate();
|
||||
layout()->addWidget(settingsWidget);
|
||||
|
||||
// Create the bottom row of the dialog with action buttons
|
||||
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok, this);
|
||||
layout()->addWidget(buttonBox);
|
||||
|
||||
QObject::connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
QObject::connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
|
||||
setModal(true);
|
||||
}
|
||||
} // namespace MaterialEditor
|
||||
|
||||
//#include <Window/SettingsDialog/moc_SettingsDialog.cpp>
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
class SettingsDialog
|
||||
: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SettingsDialog(QWidget* parent = nullptr);
|
||||
~SettingsDialog() = default;
|
||||
};
|
||||
} // namespace MaterialEditor
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Window/SettingsDialog/SettingsWidget.h>
|
||||
#include <AtomToolsFramework/Inspector/InspectorPropertyGroupWidget.h>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
SettingsWidget::SettingsWidget(QWidget* parent)
|
||||
: AtomToolsFramework::InspectorWidget(parent)
|
||||
{
|
||||
m_documentSettings =
|
||||
AZ::UserSettings::CreateFind<MaterialDocumentSettings>(AZ::Crc32("MaterialDocumentSettings"), AZ::UserSettings::CT_GLOBAL);
|
||||
}
|
||||
|
||||
SettingsWidget::~SettingsWidget()
|
||||
{
|
||||
AtomToolsFramework::InspectorRequestBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void SettingsWidget::Populate()
|
||||
{
|
||||
AddGroupsBegin();
|
||||
AddDocumentGroup();
|
||||
AddGroupsEnd();
|
||||
}
|
||||
|
||||
void SettingsWidget::AddDocumentGroup()
|
||||
{
|
||||
const AZStd::string groupNameId = "documentSettings";
|
||||
const AZStd::string groupDisplayName = "Document Settings";
|
||||
const AZStd::string groupDescription = "Document Settings";
|
||||
|
||||
const AZ::Crc32 saveStateKey(AZStd::string::format("SettingsWidget::DocumentGroup"));
|
||||
AddGroup(
|
||||
groupNameId, groupDisplayName, groupDescription,
|
||||
new AtomToolsFramework::InspectorPropertyGroupWidget(
|
||||
m_documentSettings.get(), nullptr, m_documentSettings->TYPEINFO_Uuid(), this, this, saveStateKey));
|
||||
}
|
||||
|
||||
void SettingsWidget::Reset()
|
||||
{
|
||||
AtomToolsFramework::InspectorRequestBus::Handler::BusDisconnect();
|
||||
AtomToolsFramework::InspectorWidget::Reset();
|
||||
}
|
||||
|
||||
void SettingsWidget::BeforePropertyModified(AzToolsFramework::InstanceDataNode* pNode)
|
||||
{
|
||||
AZ_UNUSED(pNode);
|
||||
}
|
||||
|
||||
void SettingsWidget::AfterPropertyModified(AzToolsFramework::InstanceDataNode* pNode)
|
||||
{
|
||||
AZ_UNUSED(pNode);
|
||||
}
|
||||
|
||||
void SettingsWidget::SetPropertyEditingComplete(AzToolsFramework::InstanceDataNode* pNode)
|
||||
{
|
||||
AZ_UNUSED(pNode);
|
||||
}
|
||||
} // namespace MaterialEditor
|
||||
|
||||
//#include <Window/SettingsWidget/moc_SettingsWidget.cpp>
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <Atom/Document/MaterialDocumentSettings.h>
|
||||
#include <AtomToolsFramework/Inspector/InspectorWidget.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI_Internals.h>
|
||||
#endif
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
//! Provides controls for viewing and editing settings.
|
||||
class SettingsWidget
|
||||
: public AtomToolsFramework::InspectorWidget
|
||||
, private AzToolsFramework::IPropertyEditorNotify
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(SettingsWidget, AZ::SystemAllocator, 0);
|
||||
|
||||
explicit SettingsWidget(QWidget* parent = nullptr);
|
||||
~SettingsWidget() override;
|
||||
|
||||
void Populate();
|
||||
|
||||
private:
|
||||
void AddDocumentGroup();
|
||||
|
||||
// AtomToolsFramework::InspectorRequestBus::Handler overrides...
|
||||
void Reset() override;
|
||||
|
||||
// AzToolsFramework::IPropertyEditorNotify overrides...
|
||||
void BeforePropertyModified(AzToolsFramework::InstanceDataNode* pNode) override;
|
||||
void AfterPropertyModified(AzToolsFramework::InstanceDataNode* pNode) override;
|
||||
void SetPropertyEditingActive([[maybe_unused]] AzToolsFramework::InstanceDataNode* pNode) override {}
|
||||
void SetPropertyEditingComplete(AzToolsFramework::InstanceDataNode* pNode) override;
|
||||
void SealUndoStack() override {}
|
||||
void RequestPropertyContextMenu(AzToolsFramework::InstanceDataNode*, const QPoint&) override {}
|
||||
void PropertySelectionChanged(AzToolsFramework::InstanceDataNode*, bool) override {}
|
||||
|
||||
AZStd::intrusive_ptr<MaterialDocumentSettings> m_documentSettings;
|
||||
};
|
||||
} // namespace MaterialEditor
|
||||
+3
-3
@@ -43,7 +43,7 @@ namespace MaterialEditor
|
||||
AtomToolsFramework::InspectorRequestBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void ViewportSettingsInspector::Popuate()
|
||||
void ViewportSettingsInspector::Populate()
|
||||
{
|
||||
AddGroupsBegin();
|
||||
AddGeneralGroup();
|
||||
@@ -271,7 +271,7 @@ namespace MaterialEditor
|
||||
{
|
||||
if (m_lightingPreset != preset)
|
||||
{
|
||||
Popuate();
|
||||
Populate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ namespace MaterialEditor
|
||||
{
|
||||
if (m_modelPreset != preset)
|
||||
{
|
||||
Popuate();
|
||||
Populate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ namespace MaterialEditor
|
||||
~ViewportSettingsInspector() override;
|
||||
|
||||
private:
|
||||
void Popuate();
|
||||
void Populate();
|
||||
void AddGeneralGroup();
|
||||
|
||||
void AddModelGroup();
|
||||
|
||||
@@ -28,6 +28,10 @@ set(FILES
|
||||
Source/Window/MaterialEditor.qss
|
||||
Source/Window/MaterialEditorWindowComponent.h
|
||||
Source/Window/MaterialEditorWindowComponent.cpp
|
||||
Source/Window/SettingsDialog/SettingsDialog.cpp
|
||||
Source/Window/SettingsDialog/SettingsDialog.h
|
||||
Source/Window/SettingsDialog/SettingsWidget.cpp
|
||||
Source/Window/SettingsDialog/SettingsWidget.h
|
||||
Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp
|
||||
Source/Window/CreateMaterialDialog/CreateMaterialDialog.h
|
||||
Source/Window/CreateMaterialDialog/CreateMaterialDialog.ui
|
||||
|
||||
Reference in New Issue
Block a user