diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.cpp index 169a90497b..a0b3762123 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.cpp @@ -1447,6 +1447,49 @@ namespace AzToolsFramework GUI->SetBrowseButtonIcon(QIcon(iconPath.c_str())); } } + else if (attrib == AZ_CRC("EditCallback", 0xb74f2ee1)) + { + PropertyAssetCtrl::EditCallbackType* func = azdynamic_cast(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(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(buttonTooltip)) + { + GUI->SetEditButtonTooltip(tr(buttonTooltip.c_str())); + } + } } 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 GUI->SetCurrentAssetHint(instance.GetAssetPath()); GUI->SetSelectedAssetID(assetId, instance.GetAssetType()); + GUI->SetEditNotifyTarget(node->GetParent()->GetInstance(0)); GUI->blockSignals(false); return false; diff --git a/Gems/LyShine/Code/Editor/LyShineEditorSystemComponent.cpp b/Gems/LyShine/Code/Editor/LyShineEditorSystemComponent.cpp index c0e9b7aaac..d1c7ce96a4 100644 --- a/Gems/LyShine/Code/Editor/LyShineEditorSystemComponent.cpp +++ b/Gems/LyShine/Code/Editor/LyShineEditorSystemComponent.cpp @@ -107,6 +107,7 @@ namespace LyShineEditor void LyShineEditorSystemComponent::Activate() { AzToolsFramework::EditorEventsBus::Handler::BusConnect(); + LyShine::LyShineRequestBus::Handler::BusConnect(); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -119,6 +120,7 @@ namespace LyShineEditor CUiAnimViewSequenceManager::Destroy(); } + LyShine::LyShineRequestBus::Handler::BusDisconnect(); AzToolsFramework::EditorEventsBus::Handler::BusDisconnect(); } @@ -191,4 +193,17 @@ namespace LyShineEditor } 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); + } + } } diff --git a/Gems/LyShine/Code/Editor/LyShineEditorSystemComponent.h b/Gems/LyShine/Code/Editor/LyShineEditorSystemComponent.h index d37fc83735..f389c4c2f5 100644 --- a/Gems/LyShine/Code/Editor/LyShineEditorSystemComponent.h +++ b/Gems/LyShine/Code/Editor/LyShineEditorSystemComponent.h @@ -15,6 +15,7 @@ #include #include #include +#include namespace LyShineEditor { @@ -22,6 +23,7 @@ namespace LyShineEditor : public AZ::Component , protected AzToolsFramework::EditorEvents::Bus::Handler , protected AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler + , protected LyShine::LyShineRequestBus::Handler { public: 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; AzToolsFramework::AssetBrowser::SourceFileDetails GetSourceFileDetails(const char* fullSourceFileName) override; //////////////////////////////////////////////////////////////////////// + + //////////////////////////////////////////////////////////////////////// + // LyShineRequestBus interface implementation + void EditUICanvas(const AZStd::string_view& canvasPath) override; + //////////////////////////////////////////////////////////////////////// }; } diff --git a/Gems/LyShine/Code/Include/LyShine/LyShineBus.h b/Gems/LyShine/Code/Include/LyShine/LyShineBus.h index 1b7b81f32d..5b8fc4889d 100644 --- a/Gems/LyShine/Code/Include/LyShine/LyShineBus.h +++ b/Gems/LyShine/Code/Include/LyShine/LyShineBus.h @@ -13,6 +13,7 @@ #pragma once #include +#include namespace LyShine { @@ -24,6 +25,8 @@ namespace LyShine static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single; static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; // Public functions + + virtual void EditUICanvas(const AZStd::string_view&) {}; }; using LyShineRequestBus = AZ::EBus; } // namespace LyShine diff --git a/Gems/LyShine/Code/Source/World/UiCanvasAssetRefComponent.cpp b/Gems/LyShine/Code/Source/World/UiCanvasAssetRefComponent.cpp index 9d436f8a57..07212cad29 100644 --- a/Gems/LyShine/Code/Source/World/UiCanvasAssetRefComponent.cpp +++ b/Gems/LyShine/Code/Source/World/UiCanvasAssetRefComponent.cpp @@ -15,6 +15,7 @@ #include #include #include +#include //////////////////////////////////////////////////////////////////////////////////////////////////// //! UiCanvasAssetRefNotificationBus Behavior context handler class @@ -177,7 +178,10 @@ void UiCanvasAssetRefComponent::Reflect(AZ::ReflectContext* context) editInfo->DataElement("SimpleAssetRef", &UiCanvasAssetRefComponent::m_canvasAssetRef, "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, "Load automatically", "When checked, the canvas is loaded when this component is activated.") ->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ_CRC("RefreshEntireTree", 0xefbc823c)); @@ -209,6 +213,12 @@ void UiCanvasAssetRefComponent::Reflect(AZ::ReflectContext* context) // 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() { diff --git a/Gems/LyShine/Code/Source/World/UiCanvasAssetRefComponent.h b/Gems/LyShine/Code/Source/World/UiCanvasAssetRefComponent.h index 9d441975b4..9d0e5c405e 100644 --- a/Gems/LyShine/Code/Source/World/UiCanvasAssetRefComponent.h +++ b/Gems/LyShine/Code/Source/World/UiCanvasAssetRefComponent.h @@ -69,6 +69,8 @@ public: // static member functions protected: // member functions + void LaunchUIEditor(const AZ::Data::AssetId& assetId, const AZ::Data::AssetType&); + // AZ::Component void Activate() override; void Deactivate() override;