Make SimpleAssetPropertyHandler handle showing the edit button on component cards (#1221)

monroegm-disable-blank-issue-2
Terry Michaels 5 years ago committed by GitHub
parent 3c23f5fead
commit aa7bab1027
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1447,6 +1447,49 @@ namespace AzToolsFramework
GUI->SetBrowseButtonIcon(QIcon(iconPath.c_str())); GUI->SetBrowseButtonIcon(QIcon(iconPath.c_str()));
} }
} }
else if (attrib == AZ_CRC("EditCallback", 0xb74f2ee1))
{
PropertyAssetCtrl::EditCallbackType* func = azdynamic_cast<PropertyAssetCtrl::EditCallbackType*>(attrValue->GetAttribute());
if (func)
{
GUI->SetEditButtonVisible(true);
GUI->SetEditNotifyCallback(func);
}
else
{
GUI->SetEditNotifyCallback(nullptr);
}
}
else if (attrib == AZ_CRC("EditButton", 0x898c35dc))
{
GUI->SetEditButtonVisible(true);
AZStd::string iconPath;
attrValue->Read<AZStd::string>(iconPath);
if (!iconPath.empty())
{
QString path(iconPath.c_str());
if (!QFile::exists(path))
{
AZ::IO::FixedMaxPathString engineRoot = AZ::Utils::GetEnginePath();
QDir engineDir = !engineRoot.empty() ? QDir(QString(engineRoot.c_str())) : QDir::current();
path = engineDir.absoluteFilePath(iconPath.c_str());
}
GUI->SetEditButtonIcon(QIcon(path));
}
}
else if (attrib == AZ_CRC("EditDescription", 0x9b52634a))
{
AZStd::string buttonTooltip;
if (attrValue->Read<AZStd::string>(buttonTooltip))
{
GUI->SetEditButtonTooltip(tr(buttonTooltip.c_str()));
}
}
} }
void SimpleAssetPropertyHandlerDefault::WriteGUIValuesIntoProperty(size_t index, PropertyAssetCtrl* GUI, property_t& instance, InstanceDataNode* node) void SimpleAssetPropertyHandlerDefault::WriteGUIValuesIntoProperty(size_t index, PropertyAssetCtrl* GUI, property_t& instance, InstanceDataNode* node)
@ -1476,6 +1519,7 @@ namespace AzToolsFramework
// Set the hint in case the asset is not able to be found by assetId // Set the hint in case the asset is not able to be found by assetId
GUI->SetCurrentAssetHint(instance.GetAssetPath()); GUI->SetCurrentAssetHint(instance.GetAssetPath());
GUI->SetSelectedAssetID(assetId, instance.GetAssetType()); GUI->SetSelectedAssetID(assetId, instance.GetAssetType());
GUI->SetEditNotifyTarget(node->GetParent()->GetInstance(0));
GUI->blockSignals(false); GUI->blockSignals(false);
return false; return false;

@ -107,6 +107,7 @@ namespace LyShineEditor
void LyShineEditorSystemComponent::Activate() void LyShineEditorSystemComponent::Activate()
{ {
AzToolsFramework::EditorEventsBus::Handler::BusConnect(); AzToolsFramework::EditorEventsBus::Handler::BusConnect();
LyShine::LyShineRequestBus::Handler::BusConnect();
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
@ -119,6 +120,7 @@ namespace LyShineEditor
CUiAnimViewSequenceManager::Destroy(); CUiAnimViewSequenceManager::Destroy();
} }
LyShine::LyShineRequestBus::Handler::BusDisconnect();
AzToolsFramework::EditorEventsBus::Handler::BusDisconnect(); AzToolsFramework::EditorEventsBus::Handler::BusDisconnect();
} }
@ -191,4 +193,17 @@ namespace LyShineEditor
} }
return AzToolsFramework::AssetBrowser::SourceFileDetails(); return AzToolsFramework::AssetBrowser::SourceFileDetails();
} }
////////////////////////////////////////////////////////////////////////////////////////////////
void LyShineEditorSystemComponent::EditUICanvas([[maybe_unused]] const AZStd::string_view& canvasPath)
{
AzToolsFramework::OpenViewPane(LyViewPane::UiEditor);
AZStd::string stringPath = canvasPath;
if (!stringPath.empty())
{
QString absoluteName = stringPath.c_str();
UiEditorDLLBus::Broadcast(&UiEditorDLLInterface::OpenSourceCanvasFile, absoluteName);
}
}
} }

@ -15,6 +15,7 @@
#include <AzCore/Component/Component.h> #include <AzCore/Component/Component.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h> #include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h> #include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
#include <LyShine/LyShineBus.h>
namespace LyShineEditor namespace LyShineEditor
{ {
@ -22,6 +23,7 @@ namespace LyShineEditor
: public AZ::Component : public AZ::Component
, protected AzToolsFramework::EditorEvents::Bus::Handler , protected AzToolsFramework::EditorEvents::Bus::Handler
, protected AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler , protected AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler
, protected LyShine::LyShineRequestBus::Handler
{ {
public: public:
AZ_COMPONENT(LyShineEditorSystemComponent, "{64D08A3F-A682-4CAF-86C1-DA91638494BA}"); AZ_COMPONENT(LyShineEditorSystemComponent, "{64D08A3F-A682-4CAF-86C1-DA91638494BA}");
@ -55,5 +57,10 @@ namespace LyShineEditor
void AddSourceFileOpeners(const char* fullSourceFileName, const AZ::Uuid& /*sourceUUID*/, AzToolsFramework::AssetBrowser::SourceFileOpenerList& openers) override; void AddSourceFileOpeners(const char* fullSourceFileName, const AZ::Uuid& /*sourceUUID*/, AzToolsFramework::AssetBrowser::SourceFileOpenerList& openers) override;
AzToolsFramework::AssetBrowser::SourceFileDetails GetSourceFileDetails(const char* fullSourceFileName) override; AzToolsFramework::AssetBrowser::SourceFileDetails GetSourceFileDetails(const char* fullSourceFileName) override;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// LyShineRequestBus interface implementation
void EditUICanvas(const AZStd::string_view& canvasPath) override;
////////////////////////////////////////////////////////////////////////
}; };
} }

@ -13,6 +13,7 @@
#pragma once #pragma once
#include <AzCore/EBus/EBus.h> #include <AzCore/EBus/EBus.h>
#include <AzCore/std/string/string_view.h>
namespace LyShine namespace LyShine
{ {
@ -24,6 +25,8 @@ namespace LyShine
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single; static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
// Public functions // Public functions
virtual void EditUICanvas(const AZStd::string_view&) {};
}; };
using LyShineRequestBus = AZ::EBus<LyShineRequests>; using LyShineRequestBus = AZ::EBus<LyShineRequests>;
} // namespace LyShine } // namespace LyShine

@ -15,6 +15,7 @@
#include <AzCore/Serialization/EditContext.h> #include <AzCore/Serialization/EditContext.h>
#include <AzCore/RTTI/BehaviorContext.h> #include <AzCore/RTTI/BehaviorContext.h>
#include <LyShine/Bus/UiCanvasBus.h> #include <LyShine/Bus/UiCanvasBus.h>
#include <LyShine/LyShineBus.h>
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
//! UiCanvasAssetRefNotificationBus Behavior context handler class //! UiCanvasAssetRefNotificationBus Behavior context handler class
@ -177,7 +178,10 @@ void UiCanvasAssetRefComponent::Reflect(AZ::ReflectContext* context)
editInfo->DataElement("SimpleAssetRef", &UiCanvasAssetRefComponent::m_canvasAssetRef, editInfo->DataElement("SimpleAssetRef", &UiCanvasAssetRefComponent::m_canvasAssetRef,
"Canvas pathname", "The pathname of the canvas.") "Canvas pathname", "The pathname of the canvas.")
->Attribute("BrowseIcon", ":/stylesheet/img/UI20/browse-edit-select-files.svg"); ->Attribute("BrowseIcon", ":/stylesheet/img/UI20/browse-edit-select-files.svg")
->Attribute("EditButton", "")
->Attribute("EditDescription", "Open in UI Editor")
->Attribute("EditCallback", &UiCanvasAssetRefComponent::LaunchUIEditor);
editInfo->DataElement(AZ::Edit::UIHandlers::CheckBox, &UiCanvasAssetRefComponent::m_isAutoLoad, editInfo->DataElement(AZ::Edit::UIHandlers::CheckBox, &UiCanvasAssetRefComponent::m_isAutoLoad,
"Load automatically", "When checked, the canvas is loaded when this component is activated.") "Load automatically", "When checked, the canvas is loaded when this component is activated.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ_CRC("RefreshEntireTree", 0xefbc823c)); ->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ_CRC("RefreshEntireTree", 0xefbc823c));
@ -209,6 +213,12 @@ void UiCanvasAssetRefComponent::Reflect(AZ::ReflectContext* context)
// PROTECTED MEMBER FUNCTIONS // PROTECTED MEMBER FUNCTIONS
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
void UiCanvasAssetRefComponent::LaunchUIEditor([[maybe_unused]] const AZ::Data::AssetId& assetId, const AZ::Data::AssetType&)
{
LyShine::LyShineRequestBus::Broadcast(&LyShine::LyShineRequests::EditUICanvas, GetCanvasPathname());
}
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
void UiCanvasAssetRefComponent::Activate() void UiCanvasAssetRefComponent::Activate()
{ {

@ -69,6 +69,8 @@ public: // static member functions
protected: // member functions protected: // member functions
void LaunchUIEditor(const AZ::Data::AssetId& assetId, const AZ::Data::AssetType&);
// AZ::Component // AZ::Component
void Activate() override; void Activate() override;
void Deactivate() override; void Deactivate() override;

Loading…
Cancel
Save