forked from o3de/o3de
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* valueHashed attribute to identify property changes in pointer/opaque types Signed-off-by: Daniel Tamkin <[email protected]> * Removed external refresh logic Signed-off-by: Daniel Tamkin <[email protected]> * ComponentAdapter Signed-off-by: Daniel Tamkin <[email protected]> * Fixed Refresh Attributes and bus disconnects Signed-off-by: Daniel Tamkin <[email protected]> * Address comments, renamed file Signed-off-by: Daniel Tamkin <[email protected]> * Default value for m_valueSize Signed-off-by: Daniel Tamkin <[email protected]> Signed-off-by: Daniel Tamkin <[email protected]>
- Loading branch information
Showing
9 changed files
with
153 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...ework/AzToolsFramework/AzToolsFramework/UI/DocumentPropertyEditor/DPEComponentAdapter.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright (c) Contributors to the Open 3D Engine Project. | ||
* For complete copyright and license terms please see the LICENSE at the root of this distribution. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 OR MIT | ||
* | ||
*/ | ||
|
||
#include <AzToolsFramework/UI/DocumentPropertyEditor/DPEComponentAdapter.h> | ||
#include <QtCore/QTimer> | ||
|
||
namespace AZ::DocumentPropertyEditor | ||
{ | ||
ComponentAdapter::ComponentAdapter() = default; | ||
|
||
ComponentAdapter::ComponentAdapter(AZ::Component* componentInstace) | ||
{ | ||
SetComponent(componentInstace); | ||
} | ||
|
||
ComponentAdapter::~ComponentAdapter() | ||
{ | ||
AzToolsFramework::ToolsApplicationEvents::Bus::Handler::BusDisconnect(); | ||
AzToolsFramework::PropertyEditorEntityChangeNotificationBus::MultiHandler::BusDisconnect(m_componentInstance->GetEntityId()); | ||
delete m_componentInstance; | ||
} | ||
|
||
void ComponentAdapter::OnEntityComponentPropertyChanged(AZ::ComponentId componentId) | ||
{ | ||
if (m_componentInstance->GetId() == componentId) | ||
{ | ||
m_queuedRefreshLevel = AzToolsFramework::PropertyModificationRefreshLevel::Refresh_Values; | ||
QTimer::singleShot( | ||
0, | ||
[this]() | ||
{ | ||
DoRefresh(); | ||
}); | ||
} | ||
} | ||
|
||
void ComponentAdapter::InvalidatePropertyDisplay(AzToolsFramework::PropertyModificationRefreshLevel level) | ||
{ | ||
if (level > m_queuedRefreshLevel) | ||
{ | ||
m_queuedRefreshLevel = level; | ||
QTimer::singleShot( | ||
0, | ||
[this]() | ||
{ | ||
DoRefresh(); | ||
}); | ||
} | ||
} | ||
|
||
void ComponentAdapter::SetComponent(AZ::Component* componentInstance) | ||
{ | ||
m_componentInstance = componentInstance; | ||
AzToolsFramework::PropertyEditorEntityChangeNotificationBus::MultiHandler::BusConnect(m_componentInstance->GetEntityId()); | ||
AzToolsFramework::ToolsApplicationEvents::Bus::Handler::BusConnect(); | ||
AZ::Uuid instanceTypeId = azrtti_typeid(m_componentInstance); | ||
SetValue(m_componentInstance, instanceTypeId); | ||
} | ||
|
||
void ComponentAdapter::DoRefresh() | ||
{ | ||
if (m_queuedRefreshLevel == AzToolsFramework::PropertyModificationRefreshLevel::Refresh_None) | ||
{ | ||
return; | ||
} | ||
m_queuedRefreshLevel = AzToolsFramework::PropertyModificationRefreshLevel::Refresh_None; | ||
NotifyResetDocument(); | ||
} | ||
|
||
} // namespace AZ::DocumentPropertyEditor |
47 changes: 47 additions & 0 deletions
47
...amework/AzToolsFramework/AzToolsFramework/UI/DocumentPropertyEditor/DPEComponentAdapter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) Contributors to the Open 3D Engine Project. | ||
* For complete copyright and license terms please see the LICENSE at the root of this distribution. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 OR MIT | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <AzCore/Component/Component.h> | ||
#include <AzFramework/DocumentPropertyEditor/ReflectionAdapter.h> | ||
#include <AzToolsFramework/API/ToolsApplicationAPI.h> | ||
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h> | ||
|
||
namespace AZ::DocumentPropertyEditor | ||
{ | ||
//! ComponentAdapter is responsible to listening for signals that affect each component in the Entity Inspector | ||
class ComponentAdapter | ||
: public ReflectionAdapter | ||
, private AzToolsFramework::PropertyEditorEntityChangeNotificationBus::MultiHandler | ||
, private AzToolsFramework::ToolsApplicationEvents::Bus::Handler | ||
{ | ||
public: | ||
//! Creates an uninitialized (empty) ComponentAdapter. | ||
ComponentAdapter(); | ||
//! Creates a ComponentAdapter with a specific component instance, see SetComponent | ||
ComponentAdapter(AZ::Component* componentInstance); | ||
~ComponentAdapter(); | ||
|
||
void OnEntityComponentPropertyChanged(AZ::ComponentId componentId) override; | ||
|
||
void InvalidatePropertyDisplay(AzToolsFramework::PropertyModificationRefreshLevel level) override; | ||
|
||
//! Sets the component, connects the appropriate Bus Handlers and sets the reflect data for this instance | ||
void SetComponent(AZ::Component* componentInstance); | ||
|
||
//! Trigger a refresh based on messages from the listeners | ||
void DoRefresh(); | ||
|
||
protected: | ||
AZ::Component* m_componentInstance = nullptr; | ||
enum AzToolsFramework::PropertyModificationRefreshLevel m_queuedRefreshLevel = | ||
AzToolsFramework::PropertyModificationRefreshLevel::Refresh_None; | ||
}; | ||
|
||
} // namespace AZ::DocumentPropertyEditor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters