Files
o3de/Gems/LyShine/Code/Source/UiLayoutFitterComponent.h
T
2021-03-08 14:30:57 -08:00

95 lines
3.1 KiB
C++

/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <LyShine/Bus/UiLayoutFitterBus.h>
#include <LyShine/Bus/UiLayoutControllerBus.h>
#include <LyShine/UiComponentTypes.h>
#include <AzCore/Component/Component.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <UiLayoutHelpers.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
//! This component resizes its element to fit its content. It uses cell sizing information given to
//! it by other Layout components, Text component, or Image component (fixed type).
class UiLayoutFitterComponent
: public AZ::Component
, public UiLayoutControllerBus::Handler
, public UiLayoutFitterBus::Handler
{
public: // member functions
AZ_COMPONENT(UiLayoutFitterComponent, LyShine::UiLayoutFitterComponentUuid, AZ::Component);
UiLayoutFitterComponent();
~UiLayoutFitterComponent() override;
// UiLayoutControllerInterface
void ApplyLayoutWidth() override;
void ApplyLayoutHeight() override;
// ~UiLayoutControllerInterface
// UiFitToComponentInterface
bool GetHorizontalFit() override;
void SetHorizontalFit(bool horizontalFit) override;
bool GetVerticalFit() override;
void SetVerticalFit(bool verticalFit) override;
FitType GetFitType() override;
// ~UiFitToComponentInterface
public: // static member functions
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("UiFitToContentService"));
}
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC("UiFitToContentService"));
}
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
required.push_back(AZ_CRC("UiElementService", 0x3dca7ad4));
required.push_back(AZ_CRC("UiTransformService", 0x3a838e34));
}
static void Reflect(AZ::ReflectContext* context);
protected: // member functions
// AZ::Component
void Activate() override;
void Deactivate() override;
// ~AZ::Component
// UiLayoutControllerInterface
unsigned int GetPriority() const;
// ~UiLayoutControllerInterface
AZ_DISABLE_COPY_MOVE(UiLayoutFitterComponent);
//! Called on a property change that has caused this element's layout to be invalid
void CheckFitterAndInvalidateLayout();
//! Called on a property change that has caused properties on Transform2d to get modified
void RefreshEditorTransformProperties();
protected: // data
bool m_horizontalFit;
bool m_verticalFit;
};