Moved material editor document system buses and system components to atom tools framework
Renamed document related buses and components to have generic names Added a base document class with default implementation from which other application specific documents can be derived to work with the document system Added document factory function registration to the document system request bus so that each application can specify the type of document it creates Updated all comments and messaging to only refer to documents, not materials or material documents Updated material editor and shader management console to conform to the new buses This will provide a first pass of a common interface for a document management system that can be shared by multiple applications Corrected status bar message copy and paste errors Updated all test scripts to use the new buses Signed-off-by: Guthrie Adams <guthadam@amazon.com>
This commit is contained in:
@@ -6,53 +6,39 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <Atom/RPI.Reflect/Image/StreamingImageAsset.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialPropertiesLayout.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialFunctor.h>
|
||||
#include <Atom/RPI.Edit/Common/AssetUtils.h>
|
||||
#include <Atom/RPI.Edit/Common/JsonUtils.h>
|
||||
#include <Atom/RPI.Edit/Material/MaterialFunctorSourceData.h>
|
||||
#include <Atom/RPI.Edit/Material/MaterialPropertyId.h>
|
||||
#include <Atom/RPI.Edit/Material/MaterialUtils.h>
|
||||
#include <Atom/RPI.Edit/Material/MaterialFunctorSourceData.h>
|
||||
#include <Atom/RPI.Public/Material/Material.h>
|
||||
#include <Atom/RPI.Reflect/Image/Image.h>
|
||||
#include <Atom/RPI.Reflect/Image/StreamingImageAsset.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialFunctor.h>
|
||||
#include <Atom/RPI.Reflect/Material/MaterialPropertiesLayout.h>
|
||||
#include <AtomCore/Instance/Instance.h>
|
||||
#include <Document/MaterialDocument.h>
|
||||
#include <Atom/Document/MaterialDocumentNotificationBus.h>
|
||||
#include <AtomToolsFramework/Document/AtomToolsDocumentNotificationBus.h>
|
||||
#include <AtomToolsFramework/Util/MaterialPropertyUtil.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
#include <AzToolsFramework/SourceControl/SourceControlAPI.h>
|
||||
#include <Document/MaterialDocument.h>
|
||||
|
||||
namespace MaterialEditor
|
||||
{
|
||||
MaterialDocument::MaterialDocument()
|
||||
: AtomToolsFramework::AtomToolsDocument()
|
||||
{
|
||||
MaterialDocumentRequestBus::Handler::BusConnect(m_id);
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentCreated, m_id);
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentCreated, m_id);
|
||||
}
|
||||
|
||||
MaterialDocument::~MaterialDocument()
|
||||
{
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentDestroyed, m_id);
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentDestroyed, m_id);
|
||||
MaterialDocumentRequestBus::Handler::BusDisconnect();
|
||||
Clear();
|
||||
}
|
||||
|
||||
const AZ::Uuid& MaterialDocument::GetId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
AZStd::string_view MaterialDocument::GetAbsolutePath() const
|
||||
{
|
||||
return m_absolutePath;
|
||||
}
|
||||
|
||||
AZStd::string_view MaterialDocument::GetRelativePath() const
|
||||
{
|
||||
return m_relativePath;
|
||||
}
|
||||
|
||||
AZ::Data::Asset<AZ::RPI::MaterialAsset> MaterialDocument::GetAsset() const
|
||||
{
|
||||
return m_materialAsset;
|
||||
@@ -170,17 +156,17 @@ namespace MaterialEditor
|
||||
EditorMaterialFunctorResult result = RunEditorMaterialFunctors(dirtyFlags);
|
||||
for (const Name& changedPropertyGroupName : result.m_updatedPropertyGroups)
|
||||
{
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentPropertyGroupVisibilityChanged, m_id, changedPropertyGroupName, IsPropertyGroupVisible(changedPropertyGroupName));
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentPropertyGroupVisibilityChanged, m_id, changedPropertyGroupName, IsPropertyGroupVisible(changedPropertyGroupName));
|
||||
}
|
||||
for (const Name& changedPropertyName : result.m_updatedProperties)
|
||||
{
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentPropertyConfigModified, m_id, GetProperty(changedPropertyName));
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentPropertyConfigModified, m_id, GetProperty(changedPropertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentPropertyValueModified, m_id, property);
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentModified, m_id);
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentPropertyValueModified, m_id, property);
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentModified, m_id);
|
||||
}
|
||||
|
||||
bool MaterialDocument::Open(AZStd::string_view loadPath)
|
||||
@@ -192,7 +178,7 @@ namespace MaterialEditor
|
||||
return false;
|
||||
}
|
||||
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentOpened, m_id);
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentOpened, m_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -222,7 +208,7 @@ namespace MaterialEditor
|
||||
RestorePropertyValues(propertyValuesToRestore);
|
||||
AZStd::swap(undoHistoryToRestore, m_undoHistory);
|
||||
AZStd::swap(undoHistoryIndexToRestore, m_undoHistoryIndex);
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentOpened, m_id);
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentOpened, m_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -285,7 +271,7 @@ namespace MaterialEditor
|
||||
|
||||
AZ_TracePrintf("MaterialDocument", "Material document saved: '%s'.\n", m_absolutePath.data());
|
||||
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentSaved, m_id);
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentSaved, m_id);
|
||||
|
||||
m_saveTriggeredInternally = true;
|
||||
return true;
|
||||
@@ -348,7 +334,7 @@ namespace MaterialEditor
|
||||
|
||||
AZ_TracePrintf("MaterialDocument", "Material document saved: '%s'.\n", normalizedSavePath.c_str());
|
||||
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentSaved, m_id);
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentSaved, m_id);
|
||||
|
||||
// If the document is saved to a new file we need to reopen the new document to update assets, paths, property deltas.
|
||||
if (!Open(normalizedSavePath))
|
||||
@@ -424,7 +410,7 @@ namespace MaterialEditor
|
||||
|
||||
AZ_TracePrintf("MaterialDocument", "Material document saved: '%s'.\n", normalizedSavePath.c_str());
|
||||
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentSaved, m_id);
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentSaved, m_id);
|
||||
|
||||
// If the document is saved to a new file we need to reopen the new document to update assets, paths, property deltas.
|
||||
if (!Open(normalizedSavePath))
|
||||
@@ -450,7 +436,7 @@ namespace MaterialEditor
|
||||
|
||||
AZ_TracePrintf("MaterialDocument", "Material document closed: '%s'.\n", m_absolutePath.c_str());
|
||||
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentClosed, m_id);
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentClosed, m_id);
|
||||
|
||||
// Clearing after notification so paths are still available
|
||||
Clear();
|
||||
@@ -496,7 +482,7 @@ namespace MaterialEditor
|
||||
// The history index is one beyond the last executed command. Decrement the index then execute undo.
|
||||
m_undoHistory[--m_undoHistoryIndex].first();
|
||||
AZ_TracePrintf("MaterialDocument", "Material document undo: '%s'.\n", m_absolutePath.c_str());
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentUndoStateChanged, m_id);
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentUndoStateChanged, m_id);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -509,7 +495,7 @@ namespace MaterialEditor
|
||||
// Execute the current redo command then move the history index to the next position.
|
||||
m_undoHistory[m_undoHistoryIndex++].second();
|
||||
AZ_TracePrintf("MaterialDocument", "Material document redo: '%s'.\n", m_absolutePath.c_str());
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentUndoStateChanged, m_id);
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentUndoStateChanged, m_id);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -557,7 +543,7 @@ namespace MaterialEditor
|
||||
|
||||
// Assign the index to the end of history
|
||||
m_undoHistoryIndex = aznumeric_cast<int>(m_undoHistory.size());
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentUndoStateChanged, m_id);
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentUndoStateChanged, m_id);
|
||||
}
|
||||
|
||||
m_propertyValuesBeforeEdit.clear();
|
||||
@@ -584,7 +570,7 @@ namespace MaterialEditor
|
||||
if (!m_saveTriggeredInternally)
|
||||
{
|
||||
AZ_TracePrintf("MaterialDocument", "Material document changed externally: '%s'.\n", m_absolutePath.c_str());
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentExternallyModified, m_id);
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentExternallyModified, m_id);
|
||||
}
|
||||
m_saveTriggeredInternally = false;
|
||||
}
|
||||
@@ -595,7 +581,7 @@ namespace MaterialEditor
|
||||
if (m_dependentAssetIds.find(asset->GetId()) != m_dependentAssetIds.end())
|
||||
{
|
||||
AZ_TracePrintf("MaterialDocument", "Material document dependency changed: '%s'.\n", m_absolutePath.c_str());
|
||||
MaterialDocumentNotificationBus::Broadcast(&MaterialDocumentNotificationBus::Events::OnDocumentDependencyModified, m_id);
|
||||
AtomToolsFramework::AtomToolsDocumentNotificationBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentNotificationBus::Events::OnDocumentDependencyModified, m_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user