Files
o3de/Gems/LyShine/Code/Source/UiLayoutCellComponent.cpp
T
Esteban Papp 1f9b284de2 Merge branch 'development' into cmake/SPEC-7179
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

# Conflicts:
#	Code/Editor/Plugins/ComponentEntityEditorPlugin/ComponentEntityEditorPlugin_precompiled.h
#	Code/Editor/Plugins/EditorCommon/EditorCommon_precompiled.h
#	Code/Editor/Plugins/EditorCommon/stdafx.cpp
#	Code/Editor/Plugins/FFMPEGPlugin/FFMPEGPlugin_precompiled.h
#	Code/Editor/Plugins/PerforcePlugin/PerforcePlugin_precompiled.h
#	Code/Editor/Plugins/ProjectSettingsTool/ProjectSettingsTool_precompiled.h
#	Code/Framework/AzToolsFramework/AzToolsFramework/AzToolsFramework_precompiled.h
#	Code/Tools/AssetProcessor/native/precompiled.h
#	Code/Tools/Standalone/StandaloneTools_precompiled.h
#	Gems/AssetMemoryAnalyzer/Code/Source/AssetMemoryAnalyzer_precompiled.h
#	Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageProcessing_precompiled.h
#	Gems/Atom/RHI/DX12/Code/Source/RHI/Atom_RHI_DX12_precompiled.h
#	Gems/Atom/RHI/Metal/Code/Include/Platform/Mac/Atom_RHI_Metal_precompiled_Platform.h
#	Gems/Atom/RHI/Metal/Code/Include/Platform/iOS/Atom_RHI_Metal_precompiled_Platform.h
#	Gems/Atom/RHI/Metal/Code/Source/Atom_RHI_Metal_precompiled.h
#	Gems/Atom/RHI/Metal/Code/atom_rhi_metal_common_files.cmake
#	Gems/Atom/RHI/Null/Code/Source/Atom_RHI_Null_precompiled.h
#	Gems/Atom/RHI/Null/Code/atom_rhi_null_common_files.cmake
#	Gems/Atom/RHI/Vulkan/Code/Include/Platform/Android/Atom_RHI_Vulkan_precompiled_Platform.h
#	Gems/Atom/RHI/Vulkan/Code/Include/Platform/Linux/Atom_RHI_Vulkan_precompiled_Platform.h
#	Gems/Atom/RHI/Vulkan/Code/Include/Platform/Mac/Atom_RHI_Vulkan_precompiled_Platform.h
#	Gems/Atom/RHI/Vulkan/Code/Include/Platform/Windows/Atom_RHI_Vulkan_precompiled_Platform.h
#	Gems/Atom/RHI/Vulkan/Code/Source/Atom_RHI_Vulkan_precompiled.h
#	Gems/Atom/RHI/Vulkan/Code/Source/RHI/SwapChain.cpp
#	Gems/Atom/RHI/Vulkan/Code/atom_rhi_vulkan_common_files.cmake
#	Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/AtomFont_precompiled.h
#	Gems/Blast/Code/Source/StdAfx.cpp
#	Gems/Camera/Code/Source/Camera_precompiled.h
#	Gems/EMotionFX/Code/Source/EMotionFX_precompiled.h
#	Gems/FastNoise/Code/Source/FastNoise_precompiled.h
#	Gems/Gestures/Code/Source/Gestures_precompiled.h
#	Gems/GradientSignal/Code/Source/GradientSignal_precompiled.h
#	Gems/GraphCanvas/Code/precompiled.h
#	Gems/ImGui/Code/Source/ImGui_precompiled.h
#	Gems/InAppPurchases/Code/Source/InAppPurchases_precompiled.h
#	Gems/LmbrCentral/Code/Source/LmbrCentral_precompiled.h
#	Gems/LmbrCentral/Code/Tests/ShapeGeometryUtilTest.cpp
#	Gems/LyShine/Code/Editor/UiCanvasEditor_precompiled.h
#	Gems/LyShine/Code/Source/Animation/LyShine_precompiled.h
#	Gems/LyShine/Code/Source/LyShine_precompiled.h
#	Gems/LyShineExamples/Code/Source/LyShineExamples_precompiled.h
#	Gems/Maestro/Code/Source/Cinematics/Maestro_precompiled.h
#	Gems/Maestro/Code/Source/Maestro_precompiled.h
#	Gems/MessagePopup/Code/Source/MessagePopup_precompiled.h
#	Gems/Metastream/Code/Source/Metastream_precompiled.h
#	Gems/Microphone/Code/Source/Microphone_precompiled.h
#	Gems/Multiplayer/Code/Source/Multiplayer_precompiled.h
#	Gems/PhysX/Code/NumericalMethods/Source/NumericalMethods_precompiled.h
#	Gems/PhysX/Code/Source/PhysXUnsupported_precompiled.h
#	Gems/PhysX/Code/Source/PhysX_precompiled.h
#	Gems/PhysX/Code/physx_unsupported_files.cmake
#	Gems/PhysXDebug/Code/Source/PhysXDebugUnsupported_precompiled.h
#	Gems/PhysXDebug/Code/Source/PhysXDebug_precompiled.h
#	Gems/ScriptCanvas/Code/Editor/precompiled.h
#	Gems/ScriptCanvas/Code/Source/precompiled.h
#	Gems/ScriptCanvasDeveloper/Code/Source/precompiled.h
#	Gems/ScriptCanvasPhysics/Code/Source/ScriptCanvasPhysics_precompiled.h
#	Gems/ScriptEvents/Code/Source/precompiled.h
#	Gems/ScriptEvents/Code/Tests/Editor/EditorTests.cpp
#	Gems/ScriptedEntityTweener/Code/Source/ScriptedEntityTweener_precompiled.h
#	Gems/SliceFavorites/Code/Source/SliceFavorites_precompiled.h
#	Gems/StartingPointCamera/Code/Source/StartingPointCamera_precompiled.h
#	Gems/StartingPointInput/Code/Source/StartingPointInput_precompiled.h
#	Gems/StartingPointMovement/Code/Source/StartingPointMovement_precompiled.h
#	Gems/SurfaceData/Code/Source/SurfaceData_precompiled.h
#	Gems/TextureAtlas/Code/Source/TextureAtlas_precompiled.h
#	Gems/TickBusOrderViewer/Code/Source/TickBusOrderViewer_precompiled.h
#	Gems/Twitch/Code/Source/Twitch_precompiled.h
#	Gems/VirtualGamepad/Code/Source/VirtualGamepad_precompiled.h
#	Gems/WhiteBox/Code/Source/WhiteBoxUnsupported_precompiled.h
#	Gems/WhiteBox/Code/Source/WhiteBox_precompiled.h
2021-07-16 15:42:37 -07:00

431 lines
20 KiB
C++

/*
* 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 "UiLayoutCellComponent.h"
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/RTTI/BehaviorContext.h>
#include <LyShine/Bus/UiElementBus.h>
#include <LyShine/Bus/UiLayoutManagerBus.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
// PUBLIC MEMBER FUNCTIONS
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
UiLayoutCellComponent::UiLayoutCellComponent()
: m_minWidthOverridden(false)
, m_minWidth(0.0f)
, m_minHeightOverridden(false)
, m_minHeight(0.0f)
, m_targetWidthOverridden(false)
, m_targetWidth(0.0f)
, m_targetHeightOverridden(false)
, m_targetHeight(0.0f)
, m_maxWidthOverridden(false)
, m_maxWidth(0.0f)
, m_maxHeightOverridden(false)
, m_maxHeight(0.0f)
, m_extraWidthRatioOverridden(false)
, m_extraWidthRatio(0.0f)
, m_extraHeightRatioOverridden(false)
, m_extraHeightRatio(0.0f)
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
UiLayoutCellComponent::~UiLayoutCellComponent()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
float UiLayoutCellComponent::GetMinWidth()
{
return m_minWidthOverridden ? m_minWidth : LyShine::UiLayoutCellUnspecifiedSize;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void UiLayoutCellComponent::SetMinWidth(float width)
{
if (LyShine::IsUiLayoutCellSizeSpecified(width))
{
m_minWidth = width;
m_minWidthOverridden = true;
}
else
{
m_minWidth = LyShine::UiLayoutCellUnspecifiedSize;
m_minWidthOverridden = false;
}
InvalidateLayout();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
float UiLayoutCellComponent::GetMinHeight()
{
return m_minHeightOverridden ? m_minHeight : LyShine::UiLayoutCellUnspecifiedSize;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void UiLayoutCellComponent::SetMinHeight(float height)
{
if (LyShine::IsUiLayoutCellSizeSpecified(height))
{
m_minHeight = height;
m_minHeightOverridden = true;
}
else
{
m_minHeight = LyShine::UiLayoutCellUnspecifiedSize;
m_minHeightOverridden = false;
}
InvalidateLayout();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
float UiLayoutCellComponent::GetTargetWidth()
{
return m_targetWidthOverridden ? m_targetWidth : LyShine::UiLayoutCellUnspecifiedSize;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void UiLayoutCellComponent::SetTargetWidth(float width)
{
if (LyShine::IsUiLayoutCellSizeSpecified(width))
{
m_targetWidth = width;
m_targetWidthOverridden = true;
}
else
{
m_targetWidth = LyShine::UiLayoutCellUnspecifiedSize;
m_targetWidthOverridden = false;
}
InvalidateLayout();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
float UiLayoutCellComponent::GetTargetHeight()
{
return m_targetHeightOverridden ? m_targetHeight : LyShine::UiLayoutCellUnspecifiedSize;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void UiLayoutCellComponent::SetTargetHeight(float height)
{
if (LyShine::IsUiLayoutCellSizeSpecified(height))
{
m_targetHeight = height;
m_targetHeightOverridden = true;
}
else
{
m_targetHeight = LyShine::UiLayoutCellUnspecifiedSize;
m_targetHeightOverridden = false;
}
InvalidateLayout();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
float UiLayoutCellComponent::GetMaxWidth()
{
return m_maxWidthOverridden ? m_maxWidth : LyShine::UiLayoutCellUnspecifiedSize;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void UiLayoutCellComponent::SetMaxWidth(float width)
{
if (LyShine::IsUiLayoutCellSizeSpecified(width))
{
m_maxWidth = width;
m_maxWidthOverridden = true;
}
else
{
m_maxWidth = LyShine::UiLayoutCellUnspecifiedSize;
m_maxWidthOverridden = false;
}
InvalidateLayout();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
float UiLayoutCellComponent::GetMaxHeight()
{
return m_maxHeightOverridden ? m_maxHeight : LyShine::UiLayoutCellUnspecifiedSize;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void UiLayoutCellComponent::SetMaxHeight(float height)
{
if (LyShine::IsUiLayoutCellSizeSpecified(height))
{
m_maxHeight = height;
m_maxHeightOverridden = true;
}
else
{
m_maxHeight = LyShine::UiLayoutCellUnspecifiedSize;
m_maxHeightOverridden = false;
}
InvalidateLayout();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
float UiLayoutCellComponent::GetExtraWidthRatio()
{
return m_extraWidthRatioOverridden ? m_extraWidthRatio : LyShine::UiLayoutCellUnspecifiedSize;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void UiLayoutCellComponent::SetExtraWidthRatio(float width)
{
if (LyShine::IsUiLayoutCellSizeSpecified(width))
{
m_extraWidthRatio = width;
m_extraWidthRatioOverridden = true;
}
else
{
m_extraWidthRatio = LyShine::UiLayoutCellUnspecifiedSize;
m_extraWidthRatioOverridden = false;
}
InvalidateLayout();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
float UiLayoutCellComponent::GetExtraHeightRatio()
{
return m_extraHeightRatioOverridden ? m_extraHeightRatio : LyShine::UiLayoutCellUnspecifiedSize;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void UiLayoutCellComponent::SetExtraHeightRatio(float height)
{
if (LyShine::IsUiLayoutCellSizeSpecified(height))
{
m_extraHeightRatio = height;
m_extraHeightRatioOverridden = true;
}
else
{
m_extraHeightRatio = LyShine::UiLayoutCellUnspecifiedSize;
m_extraHeightRatioOverridden = false;
}
InvalidateLayout();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// PUBLIC STATIC MEMBER FUNCTIONS
////////////////////////////////////////////////////////////////////////////////////////////////////
void UiLayoutCellComponent::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<UiLayoutCellComponent, AZ::Component>()
->Version(1)
->Field("MinWidthOverridden", &UiLayoutCellComponent::m_minWidthOverridden)
->Field("MinWidth", &UiLayoutCellComponent::m_minWidth)
->Field("MinHeightOverridden", &UiLayoutCellComponent::m_minHeightOverridden)
->Field("MinHeight", &UiLayoutCellComponent::m_minHeight)
->Field("TargetWidthOverridden", &UiLayoutCellComponent::m_targetWidthOverridden)
->Field("TargetWidth", &UiLayoutCellComponent::m_targetWidth)
->Field("TargetHeightOverridden", &UiLayoutCellComponent::m_targetHeightOverridden)
->Field("TargetHeight", &UiLayoutCellComponent::m_targetHeight)
->Field("MaxWidthOverridden", &UiLayoutCellComponent::m_maxWidthOverridden)
->Field("MaxWidth", &UiLayoutCellComponent::m_maxWidth)
->Field("MaxHeightOverridden", &UiLayoutCellComponent::m_maxHeightOverridden)
->Field("MaxHeight", &UiLayoutCellComponent::m_maxHeight)
->Field("ExtraWidthRatioOverridden", &UiLayoutCellComponent::m_extraWidthRatioOverridden)
->Field("ExtraWidthRatio", &UiLayoutCellComponent::m_extraWidthRatio)
->Field("ExtraHeightRatioOverridden", &UiLayoutCellComponent::m_extraHeightRatioOverridden)
->Field("ExtraHeightRatio", &UiLayoutCellComponent::m_extraHeightRatio);
AZ::EditContext* ec = serializeContext->GetEditContext();
if (ec)
{
auto editInfo = ec->Class<UiLayoutCellComponent>("LayoutCell", "Allows default layout cell properties to be overridden.");
editInfo->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "UI")
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/UiLayoutCell.png")
->Attribute(AZ::Edit::Attributes::ViewportIcon, "Editor/Icons/Components/Viewport/UiLayoutCell.png")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("UI", 0x27ff46b0))
->Attribute(AZ::Edit::Attributes::AutoExpand, true);
editInfo->DataElement(AZ::Edit::UIHandlers::CheckBox, &UiLayoutCellComponent::m_minWidthOverridden, "Min Width",
"Check this box to override the minimum width.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ_CRC("RefreshEntireTree", 0xefbc823c))
->Attribute(AZ::Edit::Attributes::ChangeNotify, &UiLayoutCellComponent::InvalidateLayout);
editInfo->DataElement(0, &UiLayoutCellComponent::m_minWidth, "Value",
"Specify minimum width.")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Visibility, &UiLayoutCellComponent::m_minWidthOverridden)
->Attribute(AZ::Edit::Attributes::ChangeNotify, &UiLayoutCellComponent::InvalidateLayout);
editInfo->DataElement(AZ::Edit::UIHandlers::CheckBox, &UiLayoutCellComponent::m_minHeightOverridden, "Min Height",
"Check this box to override the minimum height.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ_CRC("RefreshEntireTree", 0xefbc823c))
->Attribute(AZ::Edit::Attributes::ChangeNotify, &UiLayoutCellComponent::InvalidateLayout);
editInfo->DataElement(0, &UiLayoutCellComponent::m_minHeight, "Value",
"Specify minimum height.")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Visibility, &UiLayoutCellComponent::m_minHeightOverridden)
->Attribute(AZ::Edit::Attributes::ChangeNotify, &UiLayoutCellComponent::InvalidateLayout);
editInfo->DataElement(AZ::Edit::UIHandlers::CheckBox, &UiLayoutCellComponent::m_targetWidthOverridden, "Target Width",
"Check this box to override the target width.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ_CRC("RefreshEntireTree", 0xefbc823c))
->Attribute(AZ::Edit::Attributes::ChangeNotify, &UiLayoutCellComponent::InvalidateLayout);
editInfo->DataElement(0, &UiLayoutCellComponent::m_targetWidth, "Value",
"Specify target width.")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Visibility, &UiLayoutCellComponent::m_targetWidthOverridden)
->Attribute(AZ::Edit::Attributes::ChangeNotify, &UiLayoutCellComponent::InvalidateLayout);
editInfo->DataElement(AZ::Edit::UIHandlers::CheckBox, &UiLayoutCellComponent::m_targetHeightOverridden, "Target Height",
"Check this box to override the target height.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ_CRC("RefreshEntireTree", 0xefbc823c))
->Attribute(AZ::Edit::Attributes::ChangeNotify, &UiLayoutCellComponent::InvalidateLayout);
editInfo->DataElement(0, &UiLayoutCellComponent::m_targetHeight, "Value",
"Specify target height.")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Visibility, &UiLayoutCellComponent::m_targetHeightOverridden)
->Attribute(AZ::Edit::Attributes::ChangeNotify, &UiLayoutCellComponent::InvalidateLayout);
editInfo->DataElement(AZ::Edit::UIHandlers::CheckBox, &UiLayoutCellComponent::m_maxWidthOverridden, "Max Width",
"Check this box to override the max width.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ_CRC("RefreshEntireTree", 0xefbc823c))
->Attribute(AZ::Edit::Attributes::ChangeNotify, &UiLayoutCellComponent::InvalidateLayout);
editInfo->DataElement(0, &UiLayoutCellComponent::m_maxWidth, "Value",
"Specify max width.")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Visibility, &UiLayoutCellComponent::m_maxWidthOverridden)
->Attribute(AZ::Edit::Attributes::ChangeNotify, &UiLayoutCellComponent::InvalidateLayout);
editInfo->DataElement(AZ::Edit::UIHandlers::CheckBox, &UiLayoutCellComponent::m_maxHeightOverridden, "Max Height",
"Check this box to override the max height.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ_CRC("RefreshEntireTree", 0xefbc823c))
->Attribute(AZ::Edit::Attributes::ChangeNotify, &UiLayoutCellComponent::InvalidateLayout);
editInfo->DataElement(0, &UiLayoutCellComponent::m_maxHeight, "Value",
"Specify max height.")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Visibility, &UiLayoutCellComponent::m_maxHeightOverridden)
->Attribute(AZ::Edit::Attributes::ChangeNotify, &UiLayoutCellComponent::InvalidateLayout);
editInfo->DataElement(AZ::Edit::UIHandlers::CheckBox, &UiLayoutCellComponent::m_extraWidthRatioOverridden, "Extra Width Ratio",
"Check this box to override the extra width ratio.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ_CRC("RefreshEntireTree", 0xefbc823c))
->Attribute(AZ::Edit::Attributes::ChangeNotify, &UiLayoutCellComponent::InvalidateLayout);
editInfo->DataElement(0, &UiLayoutCellComponent::m_extraWidthRatio, "Value",
"Specify extra width ratio.")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Visibility, &UiLayoutCellComponent::m_extraWidthRatioOverridden)
->Attribute(AZ::Edit::Attributes::ChangeNotify, &UiLayoutCellComponent::InvalidateLayout);
editInfo->DataElement(AZ::Edit::UIHandlers::CheckBox, &UiLayoutCellComponent::m_extraHeightRatioOverridden, "Extra Height Ratio",
"Check this box to override the extra height ratio.")
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ_CRC("RefreshEntireTree", 0xefbc823c))
->Attribute(AZ::Edit::Attributes::ChangeNotify, &UiLayoutCellComponent::InvalidateLayout);
editInfo->DataElement(0, &UiLayoutCellComponent::m_extraHeightRatio, "Value",
"Specify extra height ratio.")
->Attribute(AZ::Edit::Attributes::Min, 0.0f)
->Attribute(AZ::Edit::Attributes::Visibility, &UiLayoutCellComponent::m_extraHeightRatioOverridden)
->Attribute(AZ::Edit::Attributes::ChangeNotify, &UiLayoutCellComponent::InvalidateLayout);
}
}
AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context);
if (behaviorContext)
{
behaviorContext->EBus<UiLayoutCellBus>("UiLayoutCellBus")
->Event("GetMinWidth", &UiLayoutCellBus::Events::GetMinWidth)
->Event("SetMinWidth", &UiLayoutCellBus::Events::SetMinWidth)
->Event("GetMinHeight", &UiLayoutCellBus::Events::GetMinHeight)
->Event("SetMinHeight", &UiLayoutCellBus::Events::SetMinHeight)
->Event("GetTargetWidth", &UiLayoutCellBus::Events::GetTargetWidth)
->Event("SetTargetWidth", &UiLayoutCellBus::Events::SetTargetWidth)
->Event("GetTargetHeight", &UiLayoutCellBus::Events::GetTargetHeight)
->Event("SetTargetHeight", &UiLayoutCellBus::Events::SetTargetHeight)
->Event("GetMaxWidth", &UiLayoutCellBus::Events::GetMaxWidth)
->Event("SetMaxWidth", &UiLayoutCellBus::Events::SetMaxWidth)
->Event("GetMaxHeight", &UiLayoutCellBus::Events::GetMaxHeight)
->Event("SetMaxHeight", &UiLayoutCellBus::Events::SetMaxHeight)
->Event("GetExtraWidthRatio", &UiLayoutCellBus::Events::GetExtraWidthRatio)
->Event("SetExtraWidthRatio", &UiLayoutCellBus::Events::SetExtraWidthRatio)
->Event("GetExtraHeightRatio", &UiLayoutCellBus::Events::GetExtraHeightRatio)
->Event("SetExtraHeightRatio", &UiLayoutCellBus::Events::SetExtraHeightRatio)
->VirtualProperty("MinWidth", "GetMinWidth", "SetMinWidth")
->VirtualProperty("MinHeight", "GetMinHeight", "SetMinHeight")
->VirtualProperty("TargetWidth", "GetTargetWidth", "SetTargetWidth")
->VirtualProperty("TargetHeight", "GetTargetHeight", "SetTargetHeight")
->VirtualProperty("MaxWidth", "GetMaxWidth", "SetMaxWidth")
->VirtualProperty("MaxHeight", "GetMaxHeight", "SetMaxHeight")
->VirtualProperty("ExtraWidthRatio", "GetExtraWidthRatio", "SetExtraWidthRatio")
->VirtualProperty("ExtraHeightRatio", "GetExtraHeightRatio", "SetExtraHeightRatio");
behaviorContext->Constant("UiLayoutCellUnspecifiedSize", BehaviorConstant(LyShine::UiLayoutCellUnspecifiedSize));
behaviorContext->Class<UiLayoutCellComponent>()->RequestBus("UiLayoutCellBus");
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// PROTECTED MEMBER FUNCTIONS
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
void UiLayoutCellComponent::Activate()
{
UiLayoutCellBus::Handler::BusConnect(GetEntityId());
// If this is the first time the entity has been activated this has no effect since the canvas
// is not known. But if a LayoutCell component has just been pasted onto an existing entity
// we need to invalidate the layout in case that affects things.
InvalidateLayout();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void UiLayoutCellComponent::Deactivate()
{
UiLayoutCellBus::Handler::BusDisconnect();
// We could be about to remove this component and then reactivate the entity
// which could affect the layout if there is a parent layout component
InvalidateLayout();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void UiLayoutCellComponent::InvalidateLayout()
{
// Invalidate the parent's layout
AZ::EntityId canvasEntityId;
EBUS_EVENT_ID_RESULT(canvasEntityId, GetEntityId(), UiElementBus, GetCanvasEntityId);
EBUS_EVENT_ID(canvasEntityId, UiLayoutManagerBus, MarkToRecomputeLayoutsAffectedByLayoutCellChange, GetEntityId(), false);
// Invalidate the element's layout
EBUS_EVENT_ID(canvasEntityId, UiLayoutManagerBus, MarkToRecomputeLayout, GetEntityId());
}