conflict fix

Signed-off-by: sphrose <82213493+sphrose@users.noreply.github.com>
This commit is contained in:
sphrose
2021-12-03 11:36:58 +00:00
579 changed files with 11102 additions and 4269 deletions
-8
View File
@@ -35,7 +35,6 @@
// CryCommon
#include <CryCommon/INavigationSystem.h>
#include <CryCommon/LyShine/ILyShine.h>
#include <CryCommon/MainThreadRenderRequestBus.h>
// Editor
@@ -595,13 +594,6 @@ void CGameEngine::SwitchToInEditor()
// Enable accelerators.
GetIEditor()->EnableAcceleratos(true);
// reset UI system
if (gEnv->pLyShine)
{
gEnv->pLyShine->Reset();
}
// [Anton] - order changed, see comments for CGameEngine::SetSimulationMode
//! Send event to switch out of game.
GetIEditor()->GetObjectManager()->SendEvent(EVENT_OUTOFGAME);
@@ -1,41 +0,0 @@
/*
* 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/EBus/EBus.h>
#include <LyShine/UiBase.h>
class UndoStack;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Interface class that the UI Editor needs to implement
class UiEditorDLLInterface
: public AZ::EBusTraits
{
public: // member functions
virtual ~UiEditorDLLInterface(){}
//! Get the selected elements in the UiEditor
virtual LyShine::EntityArray GetSelectedElements() = 0;
//! Get the id of the active Canvas the UiEditor
virtual AZ::EntityId GetActiveCanvasId() = 0;
//! Get the active undo stack for the UI Editor
virtual UndoStack* GetActiveUndoStack() = 0;
//! Soft-switch to the given file. Note that this should prompt for unsaved changes, etc.
virtual void OpenSourceCanvasFile(QString absolutePathToFile) = 0;
public: // static member functions
static const char* GetUniqueName() { return "UiEditorDLLInterface"; }
};
typedef AZ::EBus<UiEditorDLLInterface> UiEditorDLLBus;
@@ -13,7 +13,6 @@ set(FILES
EditorCommonAPI.h
ActionOutput.h
ActionOutput.cpp
UiEditorDLLBus.h
DockTitleBarWidget.cpp
DockTitleBarWidget.h
SaveUtilities/AsyncSaveRunner.h
+5 -6
View File
@@ -75,17 +75,16 @@ void CImageEx::ReverseUpDown()
}
uint32* pPixData = GetData();
uint32* pReversePix = new uint32[GetWidth() * GetHeight()];
for (int i = GetHeight() - 1, i2 = 0; i >= 0; i--, i2++)
const int height = GetHeight();
const int width = GetWidth();
for (int i = 0; i < height / 2; i++)
{
for (int k = 0; k < GetWidth(); k++)
for (int j = 0; j < width; j++)
{
pReversePix[i2 * GetWidth() + k] = pPixData[i * GetWidth() + k];
AZStd::swap(pPixData[i * width + j], pPixData[(height - 1 - i) * width + j]);
}
}
Attach(pReversePix, GetWidth(), GetHeight());
}
void CImageEx::FillAlpha(unsigned char value)
@@ -325,13 +325,13 @@ namespace AZ
T& operator*() const
{
AZ_Assert(m_assetData, "Asset is not loaded");
AZ_Assert(m_assetData, "Asset %s (%s) is not loaded", m_assetId.ToString<AZStd::string>().c_str(), m_assetHint.c_str());
return *Get();
}
T* operator->() const
{
AZ_Assert(m_assetData, "Asset is not loaded");
AZ_Assert(m_assetData, "Asset %s (%s) is not loaded", m_assetId.ToString<AZStd::string>().c_str(), m_assetHint.c_str());
return Get();
}
@@ -32,7 +32,16 @@ namespace AZ
template <typename BASE_TYPE, ThreadSafety THREAD_SAFETY>
inline void ConsoleDataWrapper<BASE_TYPE, THREAD_SAFETY>::operator =(const BASE_TYPE& rhs)
{
const BASE_TYPE currentValue = this->m_value;
// Do the value assignment outside new value check.
// Client code can supply a type for m_value that overrides the operator= function and trigger side effects
// in the operator= function body. Doing the assignment outside the value change check avoids those side
// effects not being triggered because AzCore believes the value wouldn't change.
this->m_value = rhs;
if (currentValue != rhs)
{
InvokeCallback();
}
}
template <typename BASE_TYPE, ThreadSafety THREAD_SAFETY>
+2 -1
View File
@@ -78,7 +78,8 @@ namespace AZ::IO
// native format observers
//! Returns string_view stored within the PathView
constexpr AZStd::string_view Native() const noexcept;
constexpr const AZStd::string_view& Native() const noexcept;
constexpr AZStd::string_view& Native() noexcept;
//! Conversion operator to retrieve string_view stored within the PathView
constexpr explicit operator AZStd::string_view() const noexcept;
@@ -101,7 +101,11 @@ namespace AZ::IO
}
// native format observers
constexpr auto PathView::Native() const noexcept -> AZStd::string_view
constexpr auto PathView::Native() const noexcept -> const AZStd::string_view&
{
return m_path;
}
constexpr auto PathView::Native() noexcept -> AZStd::string_view&
{
return m_path;
}
+2 -2
View File
@@ -16,7 +16,7 @@
//
// When AZ_CRC("My string") is used by default it will map to AZ::Crc32("My string").
// We do have a pro-processor program which will precompute the crc for you and
// transform that macro to AZ_CRC("My string",0xabcdef00) this will expand to just 0xabcdef00.
// transform that macro to AZ_CRC("My string", 0x18fbd270) this will expand to just 0x18fbd270.
// This will remove completely the "My string" from your executable, it will add it to a database and so on.
// WHen you want to update the string, just change the string.
// If you don't run the precompile step the code should still run fine, except it will be slower,
@@ -24,7 +24,7 @@
// a constant expression.
// For example
// switch(id) {
// case AZ_CRC("My string",0xabcdef00): {} break; // this will compile fine
// case AZ_CRC("My string",0x18fbd270): {} break; // this will compile fine
// case AZ_CRC("My string"): {} break; // this will cause "error C2051: case expression not constant"
// }
// So it's you choice what you do, depending on your needs.
@@ -9,6 +9,7 @@
#include <AzCore/Console/IConsole.h>
#include <AzCore/Console/ConsoleFunctor.h>
#include <AzCore/IO/ByteContainerStream.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Settings/SettingsRegistryConsoleUtils.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/StringFunc/StringFunc.h>
@@ -36,7 +37,7 @@ namespace AZ::SettingsRegistryConsoleUtils
combinedKeyValueCommand.c_str());
AZ::Debug::Trace::Output("SettingsRegistry", setOutput.c_str());
}
};
}
static void ConsoleRemoveSettingsRegistryValue(SettingsRegistryInterface& settingsRegistry, const ConsoleCommandContainer& commandArgs)
{
@@ -57,7 +58,7 @@ namespace AZ::SettingsRegistryConsoleUtils
AZ::Debug::Trace::Output("SettingsRegistry", removeOutput.c_str());
}
}
};
}
static void ConsoleDumpSettingsRegistryValue(SettingsRegistryInterface& settingsRegistry, const ConsoleCommandContainer& commandArgs)
{
@@ -88,13 +89,39 @@ namespace AZ::SettingsRegistryConsoleUtils
}
AZ::Debug::Trace::Output("SettingsRegistry", outputString.c_str());
};
}
static void ConsoleDumpAllSettingsRegistryValues(SettingsRegistryInterface& settingsRegistry,
[[maybe_unused]] const ConsoleCommandContainer& commandArgs)
{
ConsoleDumpSettingsRegistryValue(settingsRegistry, { "" });
};
}
static void ConsoleMergeFileToSettingsRegistry(SettingsRegistryInterface& settingsRegistry, const ConsoleCommandContainer& commandArgs)
{
if (commandArgs.empty())
{
AZ_Error("SettingsRegistryConsoleUtils", false, "Command %s requires a <file path> argument to locate json file to merge",
SettingsRegistryMergeFile);
return;
}
auto commandArgumentsIter = commandArgs.begin();
// Extract the JSON pointer path from the argument list
AZStd::string_view filePath{ *commandArgumentsIter++ };
AZ::SettingsRegistryInterface::FixedValueString jsonAnchorPath;
AZ::StringFunc::Join(jsonAnchorPath, commandArgumentsIter, commandArgs.end(), ' ');
const auto mergeFormat = AZ::IO::PathView(filePath).Extension() != ".setregpatch" ? AZ::SettingsRegistryInterface::Format::JsonMergePatch : AZ::SettingsRegistryInterface::Format::JsonPatch;
if (settingsRegistry.MergeSettingsFile(filePath, mergeFormat, jsonAnchorPath))
{
const auto mergeFileOutput = AZ::SettingsRegistryInterface::FixedValueString::format(
R"(Merged json file "%*.s" anchored to json path "%s" into the global settings registry)" "\n",
AZ_STRING_ARG(filePath), jsonAnchorPath.c_str());
AZ::Debug::Trace::Output("SettingsRegistry", mergeFileOutput.c_str());
}
}
[[nodiscard]] ConsoleFunctorHandle RegisterAzConsoleCommands(SettingsRegistryInterface& registry, AZ::IConsole& azConsole)
{
@@ -115,6 +142,11 @@ namespace AZ::SettingsRegistryConsoleUtils
resultHandle.m_consoleFunctors.emplace_back(azConsole, SettingsRegistryDumpAll,
R"(Dumps all values from the global settings registry)" "\n",
ConsoleFunctorFlags::Null, AZ::TypeId::CreateNull(), registry, &ConsoleDumpAllSettingsRegistryValues);
resultHandle.m_consoleFunctors.emplace_back(azConsole, SettingsRegistryMergeFile,
R"(Merges File into the global settings registry)" "\n"
R"(@param file-path - path to JSON formatted file to merge)" "\n"
R"(@param anchor-path - JSON path to anchor merge operation. Defaults to "")" "\n",
ConsoleFunctorFlags::Null, AZ::TypeId::CreateNull(), registry, &ConsoleMergeFileToSettingsRegistry);
return resultHandle;
}
@@ -14,15 +14,16 @@
namespace AZ::SettingsRegistryConsoleUtils
{
//! Only 4 console command are registered for the settings registry
//! "regset", "regremove", "regdump", "regdumpall"
//! The following console command are registered for the settings registry
//! "regset", "regremove", "regdump", "regdumpall", "regset-file"
//! The value should be increased if more commands are needed
inline constexpr size_t MaxSettingsRegistryConsoleFunctors = 4;
inline constexpr size_t MaxSettingsRegistryConsoleFunctors = 5;
inline constexpr const char* SettingsRegistrySet = "sr_regset";
inline constexpr const char* SettingsRegistryRemove = "sr_regremove";
inline constexpr const char* SettingsRegistryDump = "sr_regdump";
inline constexpr const char* SettingsRegistryDumpAll = "sr_regdumpall";
inline constexpr const char* SettingsRegistryMergeFile = "sr_regset_file";
// RAII structure which owns the instances of the Settings Registry Console commands
// registered with an AZ Console
@@ -51,6 +52,10 @@ namespace AZ::SettingsRegistryConsoleUtils
//!
//! "sr_regdumpall" accepts 0 arguments and dumps the entire settings registry
//! NOTE: this might result in a large amount of output to the console
//!
//! "sr_regset_file" accepts 1 or 2 arguments - <file-path> [<anchor json path>]
//! Merges the json formatted file <file path> into the settings registry underneath the root anchor ""
//! or <anchor json path> if supplied
[[nodiscard]] ConsoleFunctorHandle RegisterAzConsoleCommands(SettingsRegistryInterface& registry, AZ::IConsole& azConsole);
}
@@ -19,9 +19,6 @@
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/Settings/CommandLine.h>
#include <AzCore/std/string/conversions.h>
#include <AzCore/std/string/wildcard.h>
#include <AzCore/std/tuple.h>
#include <AzCore/std/containers/variant.h>
#include <AzCore/Utils/Utils.h>
#include <cinttypes>
@@ -983,7 +980,7 @@ namespace AZ::SettingsRegistryMergeUtils
// code in the loop makes calls that mutates the `commandLine` instance, invalidating the iterators. Making a copy
// ensures that the iterators remain valid.
// NOLINTNEXTLINE(performance-unnecessary-value-param)
void MergeSettingsToRegistry_CommandLine(SettingsRegistryInterface& registry, AZ::CommandLine commandLine, bool executeCommands)
void MergeSettingsToRegistry_CommandLine(SettingsRegistryInterface& registry, AZ::CommandLine commandLine, bool executeRegdumpCommands)
{
// Iterate over all the command line options in order to parse the --regset and --regremove
// arguments in the order they were supplied
@@ -998,18 +995,44 @@ namespace AZ::SettingsRegistryMergeUtils
continue;
}
}
else if (commandArgument.m_option == "regset-file")
{
AZStd::string_view fileArg(commandArgument.m_value);
AZStd::string_view jsonAnchorPath;
// double colons is treated as the separator for an anchor path
// single colon cannot be used as it is used in Windows paths
if (auto anchorPathIndex = AZ::StringFunc::Find(fileArg, "::");
anchorPathIndex != AZStd::string_view::npos)
{
jsonAnchorPath = fileArg.substr(anchorPathIndex + 2);
fileArg = fileArg.substr(0, anchorPathIndex);
}
if (!fileArg.empty())
{
AZ::IO::PathView filePath(fileArg);
const auto mergeFormat = filePath.Extension() != ".setregpatch"
? AZ::SettingsRegistryInterface::Format::JsonMergePatch
: AZ::SettingsRegistryInterface::Format::JsonPatch;
if (!registry.MergeSettingsFile(filePath.Native(), mergeFormat, jsonAnchorPath))
{
AZ_Warning("SettingsRegistryMergeUtils", false, R"(Merging of file "%.*s" to the Settings Registry has failed at anchor "%.*s".)",
AZ_STRING_ARG(filePath.Native()), AZ_STRING_ARG(jsonAnchorPath));
continue;
}
}
}
else if (commandArgument.m_option == "regremove")
{
if (!registry.Remove(commandArgument.m_value))
{
AZ_Warning("SettingsRegistryMergeUtils", false, "Unable to remove value at JSON Pointer %s for --regremove.",
commandArgument.m_value.data());
commandArgument.m_value.c_str());
continue;
}
}
}
if (executeCommands)
if (executeRegdumpCommands)
{
constexpr bool prettifyOutput = true;
const size_t regdumpSwitchValues = commandLine.GetNumSwitchValues("regdump");
@@ -157,6 +157,22 @@ namespace AZ::Statistics
}
}
void GetAllStatistics(AZStd::vector<NamedRunningStatistic*>& stats)
{
for (auto& iter : m_profilers)
{
iter.second.m_profiler.GetStatsManager().GetAllStatistics(stats);
}
}
void GetAllStatisticsOfUnits(AZStd::vector<NamedRunningStatistic*>& stats, const char* units)
{
for (auto& iter : m_profilers)
{
iter.second.m_profiler.GetStatsManager().GetAllStatisticsOfUnits(stats, units);
}
}
private:
struct ProfilerInfo
{
@@ -56,13 +56,25 @@ namespace AZ
void GetAllStatistics(AZStd::vector<NamedRunningStatistic*>& vector)
{
for (auto const& it : m_statistics)
for (const auto& it : m_statistics)
{
NamedRunningStatistic* stat = it.second;
vector.push_back(stat);
}
}
void GetAllStatisticsOfUnits(AZStd::vector<NamedRunningStatistic*>& vector, const char* units)
{
for (const auto& it : m_statistics)
{
NamedRunningStatistic* stat = it.second;
if (stat->GetUnits() == units)
{
vector.push_back(stat);
}
}
}
//! Helper method to apply units to statistics with empty units string.
AZ::u32 ApplyUnits(const AZStd::string& units)
{
@@ -26,6 +26,7 @@
#include <AzCore/std/functional.h>
#include <AzCore/std/parallel/condition_variable.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzCore/UnitTest/Mocks/MockFileIOBase.h>
#include <AZTestShared/Utils/Utils.h>
#include <Streamer/IStreamerMock.h>
#include <Tests/Asset/BaseAssetManagerTest.h>
@@ -131,8 +132,8 @@ namespace UnitTest
* This will test the aspect of the system where ObjectStreams and asset jobs loading dependent
* assets will do the work in their own thread.
*/
class AssetJobsFloodTest
: public BaseAssetManagerTest
class AssetJobsFloodTest : public DisklessAssetManagerBase
{
public:
TestAssetManager* m_testAssetManager{ nullptr };
@@ -183,15 +184,14 @@ namespace UnitTest
void SetUp() override
{
BaseAssetManagerTest::SetUp();
DisklessAssetManagerBase::SetUp();
SetupTest();
}
void TearDown() override
{
TearDownTest();
AssetManager::Destroy();
BaseAssetManagerTest::TearDown();
DisklessAssetManagerBase::TearDown();
}
void SetupAssets()
@@ -257,9 +257,9 @@ namespace UnitTest
AssetWithSerializedData ap2;
AssetWithSerializedData ap3;
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset4.txt", AZ::DataStream::ST_XML, &ap1, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset5.txt", AZ::DataStream::ST_XML, &ap2, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset6.txt", AZ::DataStream::ST_XML, &ap3, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset4.txt", &ap1, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset5.txt", &ap2, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset6.txt", &ap3, m_serializeContext));
AssetWithAssetReference assetWithPreload1;
AssetWithAssetReference assetWithPreload2;
@@ -273,11 +273,11 @@ namespace UnitTest
noLoadAsset.m_asset = m_testAssetManager->CreateAsset<AssetWithSerializedData>(MyAsset2Id, AssetLoadBehavior::NoLoad);
EXPECT_EQ(m_assetHandlerAndCatalog->m_numCreations, 4);
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset1.txt", AZ::DataStream::ST_XML, &assetWithPreload1, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset2.txt", AZ::DataStream::ST_XML, &assetWithPreload2, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset3.txt", AZ::DataStream::ST_XML, &assetWithPreload3, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "DelayLoadAsset.txt", AZ::DataStream::ST_XML, &delayedAsset, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "NoLoadAsset.txt", AZ::DataStream::ST_XML, &noLoadAsset, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset1.txt", &assetWithPreload1, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset2.txt", &assetWithPreload2, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset3.txt", &assetWithPreload3, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("DelayLoadAsset.txt", &delayedAsset, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("NoLoadAsset.txt", &noLoadAsset, m_serializeContext));
AssetWithQueueAndPreLoadReferences preLoadRoot;
AssetWithQueueAndPreLoadReferences preLoadA;
@@ -297,16 +297,16 @@ namespace UnitTest
preLoadBrokenA.m_preLoad = m_testAssetManager->CreateAsset<AssetWithAssetReference>(PreloadBrokenDepBId, AssetLoadBehavior::PreLoad);
preLoadBrokenB.m_preLoad = m_testAssetManager->CreateAsset<AssetWithAssetReference>(PreloadAssetNoDataId, AssetLoadBehavior::PreLoad);
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "PreLoadRoot.txt", AZ::DataStream::ST_XML, &preLoadRoot, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "PreLoadA.txt", AZ::DataStream::ST_XML, &preLoadA, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "PreLoadB.txt", AZ::DataStream::ST_XML, &noRefs, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "PreLoadC.txt", AZ::DataStream::ST_XML, &noRefs, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "QueueLoadA.txt", AZ::DataStream::ST_XML, &queueLoadA, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "QueueLoadB.txt", AZ::DataStream::ST_XML, &noRefs, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "QueueLoadC.txt", AZ::DataStream::ST_XML, &noRefs, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "PreLoadBrokenA.txt", AZ::DataStream::ST_XML, &preLoadBrokenA, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "PreLoadBrokenB.txt", AZ::DataStream::ST_XML, &preLoadBrokenB, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "PreLoadNoData.txt", AZ::DataStream::ST_XML, &noRefs, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("PreLoadRoot.txt", &preLoadRoot, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("PreLoadA.txt", &preLoadA, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("PreLoadB.txt", &noRefs, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("PreLoadC.txt", &noRefs, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("QueueLoadA.txt", &queueLoadA, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("QueueLoadB.txt", &noRefs, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("QueueLoadC.txt", &noRefs, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("PreLoadBrokenA.txt", &preLoadBrokenA, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("PreLoadBrokenB.txt", &preLoadBrokenB, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("PreLoadNoData.txt", &noRefs, m_serializeContext));
AssetWithQueueAndPreLoadReferences circularA;
AssetWithQueueAndPreLoadReferences circularB;
@@ -318,43 +318,15 @@ namespace UnitTest
circularC.m_preLoad = m_testAssetManager->CreateAsset<AssetWithAssetReference>(CircularBId, AssetLoadBehavior::PreLoad);
circularD.m_preLoad = circularC.m_preLoad;
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "CircularA.txt", AZ::DataStream::ST_XML, &circularA, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "CircularB.txt", AZ::DataStream::ST_XML, &circularB, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "CircularC.txt", AZ::DataStream::ST_XML, &circularC, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "CircularD.txt", AZ::DataStream::ST_XML, &circularD, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("CircularA.txt", &circularA, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("CircularB.txt", &circularB, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("CircularC.txt", &circularC, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("CircularD.txt", &circularD, m_serializeContext));
m_assetHandlerAndCatalog->m_numCreations = 0;
}
}
void TearDownTest()
{
DeleteAssetFromDisk(GetTestFolderPath() + "TestAsset4.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "TestAsset5.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "TestAsset6.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "TestAsset1.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "TestAsset2.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "TestAsset3.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "DelayLoadAsset.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "NoLoadAsset.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "PreLoadRoot.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "PreLoadA.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "PreLoadB.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "PreLoadC.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "QueueLoadA.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "QueueLoadB.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "QueueLoadC.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "PreLoadBrokenA.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "PreLoadBrokenB.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "PreLoadNoData.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "CircularA.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "CircularB.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "CircularC.txt");
DeleteAssetFromDisk(GetTestFolderPath() + "CircularD.txt");
}
void CheckFinishedCreationsAndDestructions()
{
// Make sure asset jobs have finished before validating the number of destroyed assets, because it's possible that the asset job
@@ -367,7 +339,7 @@ namespace UnitTest
};
static constexpr AZStd::chrono::seconds MaxDispatchTimeoutSeconds = BaseAssetManagerTest::DefaultTimeoutSeconds * 12;
template <typename Pred>
bool DispatchEventsUntilCondition(AZ::Data::AssetManager& assetManager, Pred&& conditionPredicate,
AZStd::chrono::seconds logIntervalSeconds = BaseAssetManagerTest::DefaultTimeoutSeconds,
@@ -608,7 +580,7 @@ namespace UnitTest
AZ::Data::AssetData::AssetStatus expected_base_status = AZ::Data::AssetData::AssetStatus::Ready;
EXPECT_EQ(baseStatus, expected_base_status);
}
TEST_F(AssetJobsFloodTest, RapidAcquireAndRelease)
{
auto assetUuids = {
@@ -641,7 +613,7 @@ namespace UnitTest
{
Asset<AssetWithAssetReference> asset1 =
m_testAssetManager->GetAsset(assetUuid, azrtti_typeid<AssetWithAssetReference>(), AZ::Data::AssetLoadBehavior::PreLoad);
if (checkLoaded)
{
asset1.BlockUntilLoadComplete();
@@ -714,8 +686,8 @@ namespace UnitTest
AssetWithSerializedData ap;
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "a.txt", AZ::DataStream::ST_XML, &ap, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "b.txt", AZ::DataStream::ST_XML, &ap, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("a.txt", &ap, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("b.txt", &ap, m_serializeContext));
}
auto& assetManager = AssetManager::Instance();
@@ -778,7 +750,7 @@ namespace UnitTest
* Verify that loads without using the Asset Container still work correctly
*/
class AssetContainerDisableTest
: public BaseAssetManagerTest
: public DisklessAssetManagerBase
{
public:
static inline const AZ::Uuid MyAsset1Id{ "{5B29FE2B-6B41-48C9-826A-C723951B0560}" };
@@ -797,7 +769,7 @@ namespace UnitTest
void SetUp() override
{
BaseAssetManagerTest::SetUp();
DisklessAssetManagerBase::SetUp();
SetupTest();
}
@@ -807,7 +779,7 @@ namespace UnitTest
AssetManager::Instance().UnregisterHandler(m_assetHandlerAndCatalog);
delete m_assetHandlerAndCatalog;
AssetManager::Destroy();
BaseAssetManagerTest::TearDown();
DisklessAssetManagerBase::TearDown();
}
void SetupAssets()
@@ -849,9 +821,9 @@ namespace UnitTest
AssetWithSerializedData ap2;
AssetWithSerializedData ap3;
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset4.txt", AZ::DataStream::ST_XML, &ap1, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset5.txt", AZ::DataStream::ST_XML, &ap2, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset6.txt", AZ::DataStream::ST_XML, &ap3, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset4.txt", &ap1, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset5.txt", &ap2, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset6.txt", &ap3, m_serializeContext));
AssetWithAssetReference assetWithPreload1;
AssetWithAssetReference assetWithPreload2;
@@ -862,9 +834,9 @@ namespace UnitTest
assetWithPreload3.m_asset = m_testAssetManager->CreateAsset<AssetWithSerializedData>(MyAsset6Id, AssetLoadBehavior::PreLoad);
EXPECT_EQ(m_assetHandlerAndCatalog->m_numCreations, 3);
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset1.txt", AZ::DataStream::ST_XML, &assetWithPreload1, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset2.txt", AZ::DataStream::ST_XML, &assetWithPreload2, m_serializeContext));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset3.txt", AZ::DataStream::ST_XML, &assetWithPreload3, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset1.txt", &assetWithPreload1, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset2.txt", &assetWithPreload2, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset3.txt", &assetWithPreload3, m_serializeContext));
m_assetHandlerAndCatalog->m_numCreations = 0;
}
@@ -2014,11 +1986,12 @@ namespace UnitTest
CheckFinishedCreationsAndDestructions();
m_assetHandlerAndCatalog->AssetCatalogRequestBus::Handler::BusDisconnect();
}
/**
* Run multiple threads that get and release assets simultaneously to test AssetManager's thread safety
*/
class AssetJobsMultithreadedTest
: public BaseAssetManagerTest
: public DisklessAssetManagerBase
{
public:
static inline const AZ::Uuid MyAsset1Id{ "{5B29FE2B-6B41-48C9-826A-C723951B0560}" };
@@ -2028,6 +2001,7 @@ namespace UnitTest
static inline const AZ::Uuid MyAsset5Id{ "{D9CDAB04-D206-431E-BDC0-1DD615D56197}" };
static inline const AZ::Uuid MyAsset6Id{ "{B2F139C3-5032-4B52-ADCA-D52A8F88E043}" };
// Initialize the Job Manager with 2 threads for the Asset Manager to use.
size_t GetNumJobManagerThreads() const override { return 2; }
@@ -2078,9 +2052,9 @@ namespace UnitTest
AssetWithSerializedData ap2;
AssetWithSerializedData ap3;
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset4.txt", AZ::DataStream::ST_XML, &ap1, &context));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset5.txt", AZ::DataStream::ST_XML, &ap2, &context));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset6.txt", AZ::DataStream::ST_XML, &ap3, &context));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset4.txt", &ap1, &context));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset5.txt", &ap2, &context));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset6.txt", &ap3, &context));
AssetWithAssetReference assetWithPreload1;
AssetWithAssetReference assetWithPreload2;
@@ -2089,9 +2063,9 @@ namespace UnitTest
assetWithPreload2.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(MyAsset5Id, AssetLoadBehavior::PreLoad);
assetWithPreload3.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(MyAsset6Id, AssetLoadBehavior::PreLoad);
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset1.txt", AZ::DataStream::ST_XML, &assetWithPreload1, &context));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset2.txt", AZ::DataStream::ST_XML, &assetWithPreload2, &context));
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset3.txt", AZ::DataStream::ST_XML, &assetWithPreload3, &context));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset1.txt", &assetWithPreload1, &context));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset2.txt", &assetWithPreload2, &context));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset3.txt", &assetWithPreload3, &context));
EXPECT_TRUE(assetHandlerAndCatalog->m_numCreations == 3);
assetHandlerAndCatalog->m_numCreations = 0;
@@ -2191,22 +2165,22 @@ namespace UnitTest
// A will be saved to disk with MyAsset1Id
AssetWithAssetReference a;
a.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(MyAsset2Id);
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset1.txt", AZ::DataStream::ST_XML, &a, &context));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset1.txt", &a, &context));
AssetWithAssetReference b;
b.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(MyAsset3Id);
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset2.txt", AZ::DataStream::ST_XML, &b, &context));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset2.txt", &b, &context));
AssetWithAssetReference c;
c.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(MyAsset4Id);
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset3.txt", AZ::DataStream::ST_XML, &c, &context));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset3.txt", &c, &context));
AssetWithAssetReference d;
d.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(MyAsset5Id);
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset4.txt", AZ::DataStream::ST_XML, &d, &context));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset4.txt", &d, &context));
AssetWithAssetReference e;
e.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(MyAsset6Id);
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset5.txt", AZ::DataStream::ST_XML, &e, &context));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset5.txt", &e, &context));
AssetWithAssetReference f;
f.m_asset = AssetManager::Instance().CreateAsset<AssetWithSerializedData>(MyAsset1Id); // refer back to asset1
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset6.txt", AZ::DataStream::ST_XML, &f, &context));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset6.txt", &f, &context));
EXPECT_TRUE(assetHandlerAndCatalog->m_numCreations == 6);
assetHandlerAndCatalog->m_numCreations = 0;
@@ -2347,26 +2321,26 @@ namespace UnitTest
// AssetD is MYASSETD
AssetWithSerializedData d;
d.m_data = 42;
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset4.txt", AZ::DataStream::ST_XML, &d, &context));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset4.txt", &d, &context));
// AssetC is MYASSETC
AssetWithAssetReference c;
c.m_asset = db.CreateAsset<AssetWithSerializedData>(AssetId(MyAssetDId)); // point at D
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset3.txt", AZ::DataStream::ST_XML, &c, &context));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset3.txt", &c, &context));
// AssetB is MYASSETB
AssetWithAssetReference b;
b.m_asset = db.CreateAsset<AssetWithAssetReference>(AssetId(MyAssetCId)); // point at C
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset2.txt", AZ::DataStream::ST_XML, &b, &context));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset2.txt", &b, &context));
// AssetA will be written to disk as MYASSETA
AssetWithAssetReference a;
a.m_asset = db.CreateAsset<AssetWithAssetReference>(AssetId(MyAssetBId)); // point at B
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "TestAsset1.txt", AZ::DataStream::ST_XML, &a, &context));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("TestAsset1.txt", &a, &context));
}
const size_t numThreads = 4;
AZStd::atomic_int threadCount(numThreads);
constexpr size_t NumThreads = 4;
AZStd::atomic_int threadCount(NumThreads);
AZStd::condition_variable cv;
AZStd::vector<AZStd::thread> threads;
AZStd::atomic_bool keepDispatching(true);
@@ -2381,7 +2355,7 @@ namespace UnitTest
AZStd::thread dispatchThread(dispatch);
for (size_t threadIdx = 0; threadIdx < numThreads; ++threadIdx)
for (size_t threadIdx = 0; threadIdx < NumThreads; ++threadIdx)
{
threads.emplace_back([&threadCount, &db, &cv]()
{
@@ -2569,7 +2543,6 @@ namespace UnitTest
#if AZ_TRAIT_DISABLE_FAILED_ASSET_MANAGER_TESTS
TEST_F(AssetJobsMultithreadedTest, DISABLED_ParallelDeepAssetReferences)
#else
// temporarily disabled until sporadic failures can be root caused
TEST_F(AssetJobsMultithreadedTest, ParallelDeepAssetReferences)
#endif // AZ_TRAIT_DISABLE_FAILED_ASSET_MANAGER_TESTS
{
@@ -2577,7 +2550,7 @@ namespace UnitTest
}
class AssetManagerTests
: public BaseAssetManagerTest
: public DisklessAssetManagerBase
{
protected:
static inline const AZ::Uuid MyAsset1Id{ "{5B29FE2B-6B41-48C9-826A-C723951B0560}" };
@@ -2592,7 +2565,7 @@ namespace UnitTest
void SetUp() override
{
BaseAssetManagerTest::SetUp();
DisklessAssetManagerBase::SetUp();
m_console = AZStd::make_unique<AZ::Console>();
AZ::Interface<AZ::IConsole>::Register(m_console.get());
@@ -2631,7 +2604,7 @@ namespace UnitTest
AssetManager::Destroy();
AZ::Interface<AZ::IConsole>::Unregister(m_console.get());
m_console = nullptr;
BaseAssetManagerTest::TearDown();
DisklessAssetManagerBase::TearDown();
}
};
@@ -2982,7 +2955,7 @@ namespace UnitTest
* the middle of loading. The tests help ensure that assets can't get stuck in perpetual loading states.
**/
class AssetManagerClearAssetReferenceTests
: public BaseAssetManagerTest
: public DisklessAssetManagerBase
{
protected:
static inline const AZ::Uuid RootAssetId{ "{AB13F568-C676-41FE-A7E9-341F71A78104}" };
@@ -3001,7 +2974,7 @@ namespace UnitTest
void SetUp() override
{
BaseAssetManagerTest::SetUp();
DisklessAssetManagerBase::SetUp();
// create the database
AssetManager::Descriptor desc;
@@ -3039,21 +3012,18 @@ namespace UnitTest
// Create and save the dependent asset first, so that we can get a reference to it.
AssetWithSerializedData dependentBlockingAsset;
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "DependentPreloadBlockingAsset.txt",
AZ::DataStream::ST_XML, &dependentBlockingAsset, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("DependentPreloadBlockingAsset.txt", &dependentBlockingAsset, m_serializeContext));
AssetWithAssetReference dependentAsset;
dependentAsset.m_asset = AssetManager::Instance().CreateAsset<AssetWithAssetReference>(
NestedDependentPreloadBlockingAssetId, AssetLoadBehavior::PreLoad);
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "DependentPreloadAsset.txt",
AZ::DataStream::ST_XML, &dependentAsset, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("DependentPreloadAsset.txt", &dependentAsset, m_serializeContext));
// Create and save the top-level asset.
AssetWithAssetReference rootAsset;
rootAsset.m_asset = AssetManager::Instance().CreateAsset<AssetWithAssetReference>(
DependentPreloadAssetId, AssetLoadBehavior::PreLoad);
EXPECT_TRUE(AZ::Utils::SaveObjectToFile(GetTestFolderPath() + "RootAsset.txt",
AZ::DataStream::ST_XML, &rootAsset, m_serializeContext));
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile("RootAsset.txt", &rootAsset, m_serializeContext));
}
void TearDown() override
@@ -3065,7 +3035,7 @@ namespace UnitTest
delete m_assetHandlerAndCatalog;
AssetManager::Destroy();
BaseAssetManagerTest::TearDown();
DisklessAssetManagerBase::TearDown();
}
};
@@ -165,4 +165,254 @@ namespace UnitTest
EXPECT_FALSE(AssetManager::Instance().HasActiveJobsOrStreamerRequests());
}
MemoryStreamerWrapper::MemoryStreamerWrapper()
{
using ::testing::_;
using ::testing::NiceMock;
using ::testing::Return;
ON_CALL(m_mockStreamer, SuspendProcessing()).WillByDefault([this]()
{
m_suspended = true;
});
ON_CALL(m_mockStreamer, ResumeProcessing()).WillByDefault([this]()
{
AZStd::unique_lock lock(m_mutex);
m_suspended = false;
while (!m_processingQueue.empty())
{
FileRequestHandle requestHandle = m_processingQueue.front();
m_processingQueue.pop();
const auto& onCompleteCallback = GetReadRequest(requestHandle)->m_callback;
if (onCompleteCallback)
{
onCompleteCallback(requestHandle);
}
}
});
ON_CALL(m_mockStreamer, Read(_, ::testing::An<IStreamerTypes::RequestMemoryAllocator&>(), _, _, _, _))
.WillByDefault(
[this](
[[maybe_unused]] AZStd::string_view relativePath, IStreamerTypes::RequestMemoryAllocator& allocator, size_t size,
AZStd::chrono::microseconds deadline, IStreamerTypes::Priority priority, [[maybe_unused]] size_t offset)
{
AZStd::unique_lock lock(m_mutex);
ReadRequest request;
// Save off the requested deadline and priority
request.m_deadline = deadline;
request.m_priority = priority;
request.m_data = allocator.Allocate(size, size, 8);
const auto* virtualFile = FindFile(relativePath);
AZ_Assert(
virtualFile->size() == size, "Streamer read request size did not match size of saved file: %d vs %d (%.*s)",
virtualFile->size(), size,
relativePath.size(), relativePath.data());
AZ_Assert(size > 0, "Size is zero %.*s", relativePath.size(), relativePath.data());
memcpy(request.m_data.m_address, virtualFile->data(), size);
// Create a real file request result and return it
request.m_request = m_context.GetNewExternalRequest();
m_readRequests.push_back(request);
return request.m_request;
});
ON_CALL(m_mockStreamer, SetRequestCompleteCallback(_, _))
.WillByDefault([this](FileRequestPtr& request, AZ::IO::IStreamer::OnCompleteCallback callback) -> FileRequestPtr&
{
// Save off the callback just so that we can call it when the request is "done"
AZStd::unique_lock lock(m_mutex);
ReadRequest* readRequest = GetReadRequest(request);
readRequest->m_callback = callback;
return request;
});
ON_CALL(m_mockStreamer, QueueRequest(_))
.WillByDefault([this](const auto& fileRequest)
{
if (!m_suspended)
{
decltype(ReadRequest::m_callback) onCompleteCallback;
AZStd::unique_lock lock(m_mutex);
ReadRequest* readRequest = GetReadRequest(fileRequest);
onCompleteCallback = readRequest->m_callback;
if (onCompleteCallback)
{
onCompleteCallback(fileRequest);
m_readRequests.erase(readRequest);
}
}
else
{
AZStd::unique_lock lock(m_mutex);
m_processingQueue.push(fileRequest);
}
});
ON_CALL(m_mockStreamer, GetRequestStatus(_))
.WillByDefault([]([[maybe_unused]] FileRequestHandle request)
{
// Return whatever request status has been set in this class
return IO::IStreamerTypes::RequestStatus::Completed;
});
ON_CALL(m_mockStreamer, GetReadRequestResult(_, _, _, _))
.WillByDefault([this](
[[maybe_unused]] FileRequestHandle request, void*& buffer, AZ::u64& numBytesRead,
IStreamerTypes::ClaimMemory claimMemory)
{
// Make sure the requestor plans to free the data buffer we allocated.
EXPECT_EQ(claimMemory, IStreamerTypes::ClaimMemory::Yes);
AZStd::unique_lock lock(m_mutex);
ReadRequest* readRequest = GetReadRequest(request);
// Provide valid data buffer results.
numBytesRead = readRequest->m_data.m_size;
buffer = readRequest->m_data.m_address;
return true;
});
ON_CALL(m_mockStreamer, RescheduleRequest(_, _, _))
.WillByDefault([this](IO::FileRequestPtr target, AZStd::chrono::microseconds newDeadline, IO::IStreamerTypes::Priority newPriority)
{
AZStd::unique_lock lock(m_mutex);
ReadRequest* readRequest = GetReadRequest(target);
readRequest->m_deadline = newDeadline;
readRequest->m_priority = newPriority;
return target;
});
}
ReadRequest* MemoryStreamerWrapper::GetReadRequest(FileRequestHandle request)
{
auto itr = AZStd::find_if(
m_readRequests.begin(), m_readRequests.end(),
[request](const ReadRequest& searchItem) -> bool
{
return (searchItem.m_request == request);
});
return itr;
}
AZStd::vector<char>* MemoryStreamerWrapper::FindFile(AZStd::string_view path)
{
auto itr = m_virtualFiles.find(path);
if (itr == m_virtualFiles.end())
{
// Path didn't work as-is, does it have the test folder prefixed? If so try removing it
if (AZ::StringFunc::StartsWith(path, GetTestFolderPath()))
{
AZStd::string_view pathWithoutFolder = path;
pathWithoutFolder = AZ::StringFunc::LStrip(pathWithoutFolder, GetTestFolderPath().c_str());
itr = m_virtualFiles.find(pathWithoutFolder);
}
else // Path isn't prefixed, so try adding it
{
itr = m_virtualFiles.find(GetTestFolderPath().append(path));
}
}
if (itr != m_virtualFiles.end())
{
return &itr->second;
}
// Currently no test expects a file not to exist so we assert to make it easy to quickly find where something went wrong
// If we ever need to test for a non-existent file this assert should just be conditionally disabled for that specific test
AZ_Assert(false, "Failed to find virtual file %*.s", path.size(), path.data())
return nullptr;
}
void DisklessAssetManagerBase::SetUp()
{
using ::testing::_;
using ::testing::NiceMock;
using ::testing::Return;
BaseAssetManagerTest::SetUp();
ON_CALL(m_fileIO, Size(::testing::Matcher<const char*>(::testing::_), _))
.WillByDefault(
[this](const char* path, u64& size)
{
AZStd::scoped_lock lock(m_streamerWrapper->m_mutex);
const auto* file = m_streamerWrapper->FindFile(path);
if (file)
{
size = file->size();
return ResultCode::Success;
}
AZ_Error("DisklessAssetManagerBase", false, "Failed to find virtual file %.*s", path);
return ResultCode::Error;
});
m_prevFileIO = IO::FileIOBase::GetInstance();
IO::FileIOBase::SetInstance(nullptr);
IO::FileIOBase::SetInstance(&m_fileIO);
}
void DisklessAssetManagerBase::TearDown()
{
IO::FileIOBase::SetInstance(nullptr);
IO::FileIOBase::SetInstance(m_prevFileIO);
BaseAssetManagerTest::TearDown();
}
IO::IStreamer* DisklessAssetManagerBase::CreateStreamer()
{
m_streamerWrapper = AZStd::make_unique<MemoryStreamerWrapper>();
return &(m_streamerWrapper->m_mockStreamer);
}
void DisklessAssetManagerBase::DestroyStreamer(IO::IStreamer*)
{
m_streamerWrapper = nullptr;
}
void DisklessAssetManagerBase::WriteAssetToDisk(const AZStd::string& assetName, const AZStd::string&)
{
AZStd::string assetFileName = GetTestFolderPath() + assetName;
AssetWithCustomData asset;
EXPECT_TRUE(m_streamerWrapper->WriteMemoryFile(assetFileName, &asset, m_serializeContext));
}
void DisklessAssetManagerBase::DeleteAssetFromDisk(const AZStd::string&)
{
}
}
@@ -20,7 +20,8 @@
#include <Tests/Asset/TestAssetTypes.h>
#include <Tests/SerializeContextFixture.h>
#include <Tests/TestCatalog.h>
#include <AzCore/UnitTest/Mocks/MockFileIOBase.h>
#include <Streamer/IStreamerMock.h>
namespace UnitTest
{
@@ -58,7 +59,11 @@ namespace UnitTest
// Subclasses can optionally override the streamer creation and destruction
virtual IO::IStreamer* CreateStreamer() { return aznew IO::Streamer(AZStd::thread_desc{}, StreamerComponent::CreateStreamerStack()); }
virtual void DestroyStreamer(IO::IStreamer* streamer) { delete streamer; }
virtual void DestroyStreamer(IO::IStreamer* streamer)
{
delete streamer;
streamer = nullptr;
}
void SetUp() override;
void TearDown() override;
@@ -66,8 +71,8 @@ namespace UnitTest
static void SuppressTraceOutput(bool suppress);
// Helper methods to create and destroy actual assets on the disk for true end-to-end asset loading.
void WriteAssetToDisk(const AZStd::string& assetName, const AZStd::string& assetIdGuid);
void DeleteAssetFromDisk(const AZStd::string& assetName);
virtual void WriteAssetToDisk(const AZStd::string& assetName, const AZStd::string& assetIdGuid);
virtual void DeleteAssetFromDisk(const AZStd::string& assetName);
void BlockUntilAssetJobsAreComplete();
@@ -82,4 +87,57 @@ namespace UnitTest
AZStd::vector<AZStd::string> m_assetsWritten;
};
struct ReadRequest
{
AZStd::chrono::milliseconds m_deadline{};
AZ::IO::IStreamerTypes::Priority m_priority{};
IO::IStreamerTypes::RequestMemoryAllocatorResult m_data{ nullptr, 0, IO::IStreamerTypes::MemoryType::ReadWrite };
AZ::IO::IStreamer::OnCompleteCallback m_callback;
IO::FileRequestPtr m_request;
};
struct MemoryStreamerWrapper
{
MemoryStreamerWrapper();
~MemoryStreamerWrapper() = default;
ReadRequest* GetReadRequest(IO::FileRequestHandle request);
template<typename TObject>
bool WriteMemoryFile(const AZStd::string& filePath, TObject* object, AZ::SerializeContext* context)
{
auto& buffer = m_virtualFiles[filePath];
ByteContainerStream stream(&buffer);
return AZ::Utils::SaveObjectToStream(stream, DataStream::StreamType::ST_XML, object, context);
}
AZStd::vector<char>* FindFile(AZStd::string_view path);
::testing::NiceMock<StreamerMock> m_mockStreamer;
IO::StreamerContext m_context;
AZStd::atomic_bool m_suspended{ false };
AZStd::recursive_mutex m_mutex;
AZStd::queue<FileRequestHandle> m_processingQueue; // Keeps tracks of requests that have been queued while processing is suspended
AZStd::vector<ReadRequest> m_readRequests;
AZStd::unordered_map<AZStd::string, AZStd::vector<char>> m_virtualFiles;
};
struct DisklessAssetManagerBase : BaseAssetManagerTest
{
void SetUp() override;
void TearDown() override;
IO::IStreamer* CreateStreamer() override;
void DestroyStreamer(IO::IStreamer*) override;
void WriteAssetToDisk(const AZStd::string& assetName, const AZStd::string& assetIdGuid) override;
void DeleteAssetFromDisk(const AZStd::string& assetName) override;
AZStd::unique_ptr<MemoryStreamerWrapper> m_streamerWrapper;
::testing::NiceMock<MockFileIOBase> m_fileIO;
IO::FileIOBase* m_prevFileIO{};
};
}
@@ -539,6 +539,22 @@ tags=tools,renderer,metal)"
EXPECT_STREQ("Bat", commandLine.GetMiscValue(2).c_str());
}
TEST_F(SettingsRegistryMergeUtilsCommandLineFixture, RegsetFileArgument_DoesNotMergeNUL)
{
AZStd::string regsetFile = AZ::IO::SystemFile::GetNullFilename();
AZ::CommandLine commandLine;
commandLine.Parse({ "--regset-file", regsetFile });
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(*m_registry, commandLine, false);
// Add a settings path to anchor loaded settings underneath
regsetFile = AZStd::string::format("%s::/AnchorPath/Of/Settings", AZ::IO::SystemFile::GetNullFilename());
commandLine.Parse({ "--regset-file", regsetFile });
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(*m_registry, commandLine, false);
EXPECT_EQ(AZ::SettingsRegistryInterface::Type::NoType, m_registry->GetType("/AnchorPath/Of/Settings"));
}
using SettingsRegistryAncestorDescendantOrEqualPathFixture = SettingsRegistryMergeUtilsCommandLineFixture;
TEST_F(SettingsRegistryAncestorDescendantOrEqualPathFixture, ValidateThatAncestorOrDescendantOrPathWithTheSameValue_Succeeds)
+6 -2
View File
@@ -167,7 +167,8 @@ namespace UnitTest
if (!info.m_streamName.empty())
{
AZStd::string fullName = GetTestFolderPath() + info.m_streamName;
info.m_dataLen = static_cast<size_t>(IO::SystemFile::Length(fullName.c_str()));
IO::FileIOBase* io = IO::FileIOBase::GetInstance();
io->Size(fullName.c_str(), info.m_dataLen);
}
else
{
@@ -187,8 +188,11 @@ namespace UnitTest
if (!info.m_streamName.empty())
{
IO::FileIOBase* io = AZ::IO::FileIOBase::GetInstance();
AZStd::string fullName = GetTestFolderPath() + info.m_streamName;
info.m_dataLen = static_cast<size_t>(IO::SystemFile::Length(fullName.c_str()));
io->Size(fullName.c_str(), info.m_dataLen);
}
else
{
@@ -6,16 +6,17 @@
*
*/
#include "CommunicatorTracePrinter.h"
#include "ProcessCommunicatorTracePrinter.h"
CommunicatorTracePrinter::CommunicatorTracePrinter(AzFramework::ProcessCommunicator* communicator, const char* window) :
ProcessCommunicatorTracePrinter::ProcessCommunicatorTracePrinter(AzFramework::ProcessCommunicator* communicator, const char* window) :
m_communicator(communicator),
m_window(window)
{
m_stringBeingConcatenated.reserve(1024);
}
CommunicatorTracePrinter::~CommunicatorTracePrinter()
ProcessCommunicatorTracePrinter::~ProcessCommunicatorTracePrinter()
{
// flush stdout
WriteCurrentString(false);
@@ -24,7 +25,7 @@ CommunicatorTracePrinter::~CommunicatorTracePrinter()
WriteCurrentString(true);
}
void CommunicatorTracePrinter::Pump()
void ProcessCommunicatorTracePrinter::Pump()
{
if (m_communicator->IsValid())
{
@@ -42,7 +43,7 @@ void CommunicatorTracePrinter::Pump()
}
}
void CommunicatorTracePrinter::ParseDataBuffer(AZ::u32 readSize, bool isFromStdErr)
void ProcessCommunicatorTracePrinter::ParseDataBuffer(AZ::u32 readSize, bool isFromStdErr)
{
if (readSize > AZ_ARRAY_SIZE(m_streamBuffer))
{
@@ -67,7 +68,7 @@ void CommunicatorTracePrinter::ParseDataBuffer(AZ::u32 readSize, bool isFromStdE
}
}
void CommunicatorTracePrinter::WriteCurrentString(bool isFromStdErr)
void ProcessCommunicatorTracePrinter::WriteCurrentString(bool isFromStdErr)
{
AZStd::string& bufferToUse = isFromStdErr ? m_errorStringBeingConcatenated : m_stringBeingConcatenated;
@@ -10,20 +10,21 @@
#include <AzFramework/Process/ProcessCommunicator.h>
//! CommunicatorTracePrinter listens to stderr and stdout of a running process and writes its output to the AZ_Trace system
//! ProcessCommunicatorTracePrinter listens to stderr and stdout of a running process and writes its output to the AZ_Trace system
//! Importantly, it does not do any blocking operations.
class CommunicatorTracePrinter
class ProcessCommunicatorTracePrinter
{
public:
CommunicatorTracePrinter(AzFramework::ProcessCommunicator* communicator, const char* window);
~CommunicatorTracePrinter();
ProcessCommunicatorTracePrinter(AzFramework::ProcessCommunicator* communicator, const char* window);
~ProcessCommunicatorTracePrinter();
// call this periodically to drain the buffers and write them.
//! Call this periodically to drain the buffers and write them.
void Pump();
// drains the buffer into the string thats being built, then traces the string when it hits a newline.
//! Drains the buffer into the string that's being built, then traces the string when it hits a newline.
void ParseDataBuffer(AZ::u32 readSize, bool isFromStdErr);
//! Prints the current buffer to AZ_Error or AZ_TracePrintf so that it can be picked up by AZ::Debug::Trace
void WriteCurrentString(bool isFromStdError);
private:
@@ -71,10 +71,11 @@ namespace AzFramework::Terrain
->Event("GetSurfaceWeights", &AzFramework::Terrain::TerrainDataRequestBus::Events::GetSurfaceWeights)
->Event("GetSurfaceWeightsFromVector2",
&AzFramework::Terrain::TerrainDataRequestBus::Events::GetSurfaceWeightsFromVector2)
->Event("GetIsHole", &AzFramework::Terrain::TerrainDataRequestBus::Events::GetIsHole)
->Event("GetIsHoleFromFloats", &AzFramework::Terrain::TerrainDataRequestBus::Events::GetIsHoleFromFloats)
->Event("GetSurfacePoint", &AzFramework::Terrain::TerrainDataRequestBus::Events::GetSurfacePoint)
->Event("GetSurfacePoint", &AzFramework::Terrain::TerrainDataRequestBus::Events::BehaviorContextGetSurfacePoint)
->Event("GetSurfacePointFromVector2",
&AzFramework::Terrain::TerrainDataRequestBus::Events::GetSurfacePointFromVector2)
&AzFramework::Terrain::TerrainDataRequestBus::Events::BehaviorContextGetSurfacePointFromVector2)
->Event("GetTerrainAabb", &AzFramework::Terrain::TerrainDataRequestBus::Events::GetTerrainAabb)
->Event("GetTerrainHeightQueryResolution",
&AzFramework::Terrain::TerrainDataRequestBus::Events::GetTerrainHeightQueryResolution)
@@ -52,8 +52,8 @@ namespace AzFramework
virtual void SetTerrainAabb(const AZ::Aabb& worldBounds) = 0;
//! Returns terrains height in meters at location x,y.
//! @terrainExistsPtr: Can be nullptr. If != nullptr then, if there's no terrain at location x,y or location x,y is inside a terrain HOLE then *terrainExistsPtr will become false,
//! otherwise *terrainExistsPtr will become true.
//! @terrainExistsPtr: Can be nullptr. If != nullptr then, if there's no terrain at location x,y or location x,y is inside
//! a terrain HOLE then *terrainExistsPtr will become false, otherwise *terrainExistsPtr will become true.
virtual float GetHeight(const AZ::Vector3& position, Sampler sampler = Sampler::BILINEAR, bool* terrainExistsPtr = nullptr) const = 0;
virtual float GetHeightFromVector2(
const AZ::Vector2& position, Sampler sampler = Sampler::BILINEAR, bool* terrainExistsPtr = nullptr) const = 0;
@@ -68,8 +68,7 @@ namespace AzFramework
// Given an XY coordinate, return the surface normal.
//! @terrainExists: Can be nullptr. If != nullptr then, if there's no terrain at location x,y or location x,y is inside a
//! terrain HOLE then *terrainExistsPtr will be set to false,
//! otherwise *terrainExistsPtr will be set to true.
//! terrain HOLE then *terrainExistsPtr will be set to false, otherwise *terrainExistsPtr will be set to true.
virtual AZ::Vector3 GetNormal(
const AZ::Vector3& position, Sampler sampleFilter = Sampler::BILINEAR, bool* terrainExistsPtr = nullptr) const = 0;
virtual AZ::Vector3 GetNormalFromVector2(
@@ -78,8 +77,8 @@ namespace AzFramework
float x, float y, Sampler sampleFilter = Sampler::BILINEAR, bool* terrainExistsPtr = nullptr) const = 0;
//! Given an XY coordinate, return the max surface type and weight.
//! @terrainExists: Can be nullptr. If != nullptr then, if there's no terrain at location x,y or location x,y is inside a terrain HOLE then *terrainExistsPtr will be set to false,
//! otherwise *terrainExistsPtr will be set to true.
//! @terrainExists: Can be nullptr. If != nullptr then, if there's no terrain at location x,y or location x,y is inside
//! a terrain HOLE then *terrainExistsPtr will be set to false, otherwise *terrainExistsPtr will be set to true.
virtual SurfaceData::SurfaceTagWeight GetMaxSurfaceWeight(
const AZ::Vector3& position, Sampler sampleFilter = Sampler::BILINEAR, bool* terrainExistsPtr = nullptr) const = 0;
virtual SurfaceData::SurfaceTagWeight GetMaxSurfaceWeightFromVector2(
@@ -87,8 +86,8 @@ namespace AzFramework
virtual SurfaceData::SurfaceTagWeight GetMaxSurfaceWeightFromFloats(
float x, float y, Sampler sampleFilter = Sampler::BILINEAR, bool* terrainExistsPtr = nullptr) const = 0;
//! Given an XY coordinate, return the set of surface types and weights. The Vector3 input position version is defined to ignore
//! the input Z value.
//! Given an XY coordinate, return the set of surface types and weights. The Vector3 input position version is defined to
//! ignore the input Z value.
virtual void GetSurfaceWeights(
const AZ::Vector3& inPosition,
SurfaceData::SurfaceTagWeightList& outSurfaceWeights,
@@ -106,13 +105,14 @@ namespace AzFramework
Sampler sampleFilter = Sampler::DEFAULT,
bool* terrainExistsPtr = nullptr) const = 0;
//! Convenience function for low level systems that can't do a reverse lookup from Crc to string. Everyone else should use GetMaxSurfaceWeight or GetMaxSurfaceWeightFromFloats.
//! Convenience function for low level systems that can't do a reverse lookup from Crc to string. Everyone else should use
//! GetMaxSurfaceWeight or GetMaxSurfaceWeightFromFloats.
//! Not available in the behavior context.
//! Returns nullptr if the position is inside a hole or outside of the terrain boundaries.
virtual const char* GetMaxSurfaceName(
const AZ::Vector3& position, Sampler sampleFilter = Sampler::BILINEAR, bool* terrainExistsPtr = nullptr) const = 0;
//! Given an XY coordinate, return all terrain information at that location. The Vector3 input position version is defined
//! Given an XY coordinate, return all terrain information at that location. The Vector3 input position version is defined
//! to ignore the input Z value.
virtual void GetSurfacePoint(
const AZ::Vector3& inPosition,
@@ -132,6 +132,25 @@ namespace AzFramework
bool* terrainExistsPtr = nullptr) const = 0;
private:
// Private variations of the GetSurfacePoint API exposed to BehaviorContext that returns a value instead of
// using an "out" parameter. The "out" parameter is useful for reusing memory allocated in SurfacePoint when
// using the public API, but can't easily be used from Script Canvas.
SurfaceData::SurfacePoint BehaviorContextGetSurfacePoint(
const AZ::Vector3& inPosition,
Sampler sampleFilter = Sampler::DEFAULT) const
{
SurfaceData::SurfacePoint result;
GetSurfacePoint(inPosition, result, sampleFilter);
return result;
}
SurfaceData::SurfacePoint BehaviorContextGetSurfacePointFromVector2(
const AZ::Vector2& inPosition,
Sampler sampleFilter = Sampler::DEFAULT) const
{
SurfaceData::SurfacePoint result;
GetSurfacePointFromVector2(inPosition, result, sampleFilter);
return result;
// Functions without the optional bool* parameter that can be used from Python tests.
float GetHeightVal(AZ::Vector3 position, Sampler sampler = Sampler::BILINEAR) const
{
@@ -143,6 +143,13 @@ namespace AzFramework
return vsync_interval;
}
bool NativeWindow::SetSyncInterval(uint32_t newSyncInterval)
{
vsync_interval = newSyncInterval;
return true;
}
/*static*/ bool NativeWindow::GetFullScreenStateOfDefaultWindow()
{
NativeWindowHandle defaultWindowHandle = nullptr;
@@ -132,6 +132,7 @@ namespace AzFramework
void ToggleFullScreenState() override;
float GetDpiScaleFactor() const override;
uint32_t GetSyncInterval() const override;
bool SetSyncInterval(uint32_t newSyncInterval) override;
uint32_t GetDisplayRefreshRate() const override;
//! Get the full screen state of the default window.
@@ -78,6 +78,10 @@ namespace AzFramework
//! Returns the sync interval which tells the drivers the number of v-blanks to synchronize with
virtual uint32_t GetSyncInterval() const = 0;
//! Sets the sync interval which tells the drivers the number of v-blanks to synchronize with
//! Returns if the sync interval was succesfully set
virtual bool SetSyncInterval(uint32_t newSyncInterval) = 0;
//! Returns the refresh rate of the main display
virtual uint32_t GetDisplayRefreshRate() const = 0;
};
@@ -277,6 +277,8 @@ set(FILES
Process/ProcessWatcher.cpp
Process/ProcessWatcher.h
Process/ProcessCommon_fwd.h
Process/ProcessCommunicatorTracePrinter.cpp
Process/ProcessCommunicatorTracePrinter.h
ProjectManager/ProjectManager.h
ProjectManager/ProjectManager.cpp
Render/GameIntersectorComponent.h
+127 -48
View File
@@ -29,6 +29,13 @@ namespace InputUnitTests
////////////////////////////////////////////////////////////////////////////////////////////////
class InputTest : public ScopedAllocatorSetupFixture
{
public:
InputTest() : ScopedAllocatorSetupFixture()
{
// Many input tests are only valid if the GamePad device is supported on this platform.
m_gamepadSupported = InputDeviceGamepad::GetMaxSupportedGamepads() > 0;
}
protected:
////////////////////////////////////////////////////////////////////////////////////////////
void SetUp() override
@@ -46,6 +53,7 @@ namespace InputUnitTests
////////////////////////////////////////////////////////////////////////////////////////////
AZStd::unique_ptr<InputSystemComponent> m_inputSystemComponent;
bool m_gamepadSupported;
};
////////////////////////////////////////////////////////////////////////////////////////////////
@@ -78,12 +86,17 @@ namespace InputUnitTests
}
////////////////////////////////////////////////////////////////////////////////////////////////
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
TEST_F(InputTest, DISABLED_InputContext_ActivateDeactivate_Successfull)
#else
TEST_F(InputTest, InputContext_ActivateDeactivate_Successfull)
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
{
if (!m_gamepadSupported)
{
#if defined(GTEST_SKIP)
GTEST_SKIP() << "Skipping test InputContext_ActivateDeactivate_Successfull";
#else
SUCCEED() << "Skipping test InputContext_ActivateDeactivate_Successfull";
#endif
return;
}
// Create an input context (they are inactive by default).
InputContext inputContext("TestInputContext");
@@ -148,12 +161,18 @@ namespace InputUnitTests
}
////////////////////////////////////////////////////////////////////////////////////////////////
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
TEST_F(InputTest, DISABLED_InputContext_AddRemoveInputMapping_Successfull)
#else
TEST_F(InputTest, InputContext_AddRemoveInputMapping_Successfull)
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
{
if (!m_gamepadSupported)
{
#if defined(GTEST_SKIP)
GTEST_SKIP() << "Skipping test InputContext_AddRemoveInputMapping_Successfull";
#else
SUCCEED() << "Skipping test InputContext_AddRemoveInputMapping_Successfull";
#endif
return;
}
// Create an input context and activate it.
InputContext inputContext("TestInputContext");
inputContext.Activate();
@@ -256,12 +275,18 @@ namespace InputUnitTests
}
////////////////////////////////////////////////////////////////////////////////////////////////
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
TEST_F(InputTest, DISABLED_InputContext_ConsumeProcessedInput_Consumed)
#else
TEST_F(InputTest, InputContext_ConsumeProcessedInput_Consumed)
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
{
if (!m_gamepadSupported)
{
#if defined(GTEST_SKIP)
GTEST_SKIP() << "Skipping test InputContext_ConsumeProcessedInput_Consumed";
#else
SUCCEED() << "Skipping test InputContext_ConsumeProcessedInput_Consumed";
#endif
return;
}
InputContext::InitData initData;
// Create a high priority input context that consumes input processed by any of its mappings.
@@ -340,12 +365,18 @@ namespace InputUnitTests
}
////////////////////////////////////////////////////////////////////////////////////////////////
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
TEST_F(InputTest, DISABLED_InputContext_FilteredInput_Mapped)
#else
TEST_F(InputTest, InputContext_FilteredInput_Mapped)
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
{
if (!m_gamepadSupported)
{
#if defined(GTEST_SKIP)
GTEST_SKIP() << "Skipping test InputContext_FilteredInput_Mapped";
#else
SUCCEED() << "Skipping test InputContext_FilteredInput_Mapped";
#endif
return;
}
// Create an input context that initially only listens for keyboard input.
InputContext::InitData initData;
initData.autoActivate = true;
@@ -413,12 +444,18 @@ namespace InputUnitTests
}
////////////////////////////////////////////////////////////////////////////////////////////////
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
TEST_F(InputTest, DISABLED_InputMappingOr_AddRemoveSourceInput_Successful)
#else
TEST_F(InputTest, InputMappingOr_AddRemoveSourceInput_Successful)
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
{
if (!m_gamepadSupported)
{
#if defined(GTEST_SKIP)
GTEST_SKIP() << "Skipping test InputMappingOr_AddRemoveSourceInput_Successful";
#else
SUCCEED() << "Skipping test InputMappingOr_AddRemoveSourceInput_Successful";
#endif
return;
}
// Create an input context and activate it.
InputContext inputContext("TestInputContext");
inputContext.Activate();
@@ -491,12 +528,18 @@ namespace InputUnitTests
}
////////////////////////////////////////////////////////////////////////////////////////////////
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
TEST_F(InputTest, DISABLED_InputMappingOr_SingleSourceInput_Mapped)
#else
TEST_F(InputTest, InputMappingOr_SingleSourceInput_Mapped)
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
{
if (!m_gamepadSupported)
{
#if defined(GTEST_SKIP)
GTEST_SKIP() << "Skipping test InputMappingOr_SingleSourceInput_Mapped";
#else
SUCCEED() << "Skipping test InputMappingOr_SingleSourceInput_Mapped";
#endif
return;
}
// Create an input context and activate it.
InputContext inputContext("TestInputContext");
inputContext.Activate();
@@ -558,12 +601,18 @@ namespace InputUnitTests
}
////////////////////////////////////////////////////////////////////////////////////////////////
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
TEST_F(InputTest, DISABLED_InputMappingOr_MultipleSourceInputs_Mapped)
#else
TEST_F(InputTest, InputMappingOr_MultipleSourceInputs_Mapped)
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
{
if (!m_gamepadSupported)
{
#if defined(GTEST_SKIP)
GTEST_SKIP() << "Skipping test InputMappingOr_MultipleSourceInputs_Mapped";
#else
SUCCEED() << "Skipping test InputMappingOr_MultipleSourceInputs_Mapped";
#endif
return;
}
// Create an input context and activate it.
InputContext inputContext("TestInputContext");
inputContext.Activate();
@@ -650,12 +699,18 @@ namespace InputUnitTests
}
////////////////////////////////////////////////////////////////////////////////////////////////
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
TEST_F(InputTest, DISABLED_InputMappingAnd_AddRemoveSourceInput_Successful)
#else
TEST_F(InputTest, InputMappingAnd_AddRemoveSourceInput_Successful)
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
{
if (!m_gamepadSupported)
{
#if defined(GTEST_SKIP)
GTEST_SKIP() << "Skipping test InputMappingAnd_AddRemoveSourceInput_Successful";
#else
SUCCEED() << "Skipping test InputMappingAnd_AddRemoveSourceInput_Successful";
#endif
return;
}
// Create an input context and activate it.
InputContext inputContext("TestInputContext");
inputContext.Activate();
@@ -728,12 +783,18 @@ namespace InputUnitTests
}
////////////////////////////////////////////////////////////////////////////////////////////////
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
TEST_F(InputTest, DISABLED_InputMappingAnd_SingleSourceInput_Mapped)
#else
TEST_F(InputTest, InputMappingAnd_SingleSourceInput_Mapped)
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
{
if (!m_gamepadSupported)
{
#if defined(GTEST_SKIP)
GTEST_SKIP() << "Skipping test InputMappingAnd_SingleSourceInput_Mapped";
#else
SUCCEED() << "Skipping test InputMappingAnd_SingleSourceInput_Mapped";
#endif
return;
}
// Create an input context and activate it.
InputContext inputContext("TestInputContext");
inputContext.Activate();
@@ -795,12 +856,18 @@ namespace InputUnitTests
}
////////////////////////////////////////////////////////////////////////////////////////////////
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
TEST_F(InputTest, DISABLED_InputMappingAnd_MultipleSourceInputs_Mapped)
#else
TEST_F(InputTest, InputMappingAnd_MultipleSourceInputs_Mapped)
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
{
if (!m_gamepadSupported)
{
#if defined(GTEST_SKIP)
GTEST_SKIP() << "Skipping test InputMappingAnd_MultipleSourceInputs_Mapped";
#else
SUCCEED() << "Skipping test InputMappingAnd_MultipleSourceInputs_Mapped";
#endif
return;
}
// Create an input context and activate it.
InputContext inputContext("TestInputContext");
inputContext.Activate();
@@ -909,12 +976,18 @@ namespace InputUnitTests
}
////////////////////////////////////////////////////////////////////////////////////////////////
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
TEST_F(InputTest, DISABLED_InputMappingAnd_MultipleSourceInputsWithDifferentValues_ValuesAveraged)
#else
TEST_F(InputTest, InputMappingAnd_MultipleSourceInputsWithDifferentValues_ValuesAveraged)
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
{
if (!m_gamepadSupported)
{
#if defined(GTEST_SKIP)
GTEST_SKIP() << "Skipping test InputMappingAnd_MultipleSourceInputsWithDifferentValues_ValuesAveraged";
#else
SUCCEED() << "Skipping test InputMappingAnd_MultipleSourceInputsWithDifferentValues_ValuesAveraged";
#endif
return;
}
// Create an input context and activate it.
InputContext inputContext("TestInputContext");
inputContext.Activate();
@@ -969,12 +1042,18 @@ namespace InputUnitTests
}
////////////////////////////////////////////////////////////////////////////////////////////////
#if AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
TEST_F(InputTest, DISABLED_InputMappingAnd_MultipleSourceInputsFromTheSameInputDeviceTypeWithDifferentIndicies_NotMapped)
#else
TEST_F(InputTest, InputMappingAnd_MultipleSourceInputsFromTheSameInputDeviceTypeWithDifferentIndicies_NotMapped)
#endif // AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS
{
if (!m_gamepadSupported)
{
#if defined(GTEST_SKIP)
GTEST_SKIP() << "Skipping test InputMappingAnd_MultipleSourceInputsFromTheSameInputDeviceTypeWithDifferentIndicies_NotMapped";
#else
SUCCEED() << "Skipping test InputMappingAnd_MultipleSourceInputsFromTheSameInputDeviceTypeWithDifferentIndicies_NotMapped";
#endif
return;
}
// Create an input context and activate it.
InputContext inputContext("TestInputContext");
inputContext.Activate();
@@ -36,6 +36,7 @@ namespace UnitTest
MOCK_METHOD0(ToggleFullScreenState, void());
MOCK_CONST_METHOD0(GetDpiScaleFactor, float());
MOCK_CONST_METHOD0(GetSyncInterval, uint32_t());
MOCK_METHOD1(SetSyncInterval, bool(uint32_t));
MOCK_CONST_METHOD0(GetDisplayRefreshRate, uint32_t());
};
} // namespace UnitTest
@@ -53,7 +53,6 @@ static void OptimizedSetParent(QWidget* widget, QWidget* parent)
namespace AzQtComponents
{
static const FancyDockingDropZoneConstants g_FancyDockingConstants;
// Constant for the threshold in pixels for snapping to edges while dragging for docking
static const int g_snapThresholdInPixels = 15;
@@ -155,7 +154,7 @@ namespace AzQtComponents
// Timer for updating our hovered drop zone opacity
QObject::connect(m_dropZoneHoverFadeInTimer, &QTimer::timeout, this, &FancyDocking::onDropZoneHoverFadeInUpdate);
m_dropZoneHoverFadeInTimer->setInterval(g_FancyDockingConstants.dropZoneHoverFadeUpdateIntervalMS);
m_dropZoneHoverFadeInTimer->setInterval(FancyDockingDropZoneConstants::dropZoneHoverFadeUpdateIntervalMS);
QIcon dragIcon = QIcon(QStringLiteral(":/Cursors/Grabbing.svg"));
m_dragCursor = QCursor(dragIcon.pixmap(16), 5, 2);
}
@@ -333,13 +332,13 @@ namespace AzQtComponents
*/
void FancyDocking::onDropZoneHoverFadeInUpdate()
{
const qreal dropZoneHoverOpacity = g_FancyDockingConstants.dropZoneHoverFadeIncrement + m_dropZoneState.dropZoneHoverOpacity();
const qreal dropZoneHoverOpacity = FancyDockingDropZoneConstants::dropZoneHoverFadeIncrement + m_dropZoneState.dropZoneHoverOpacity();
// Once we've reached the full drop zone opacity, cut it off in case we
// went over and stop the timer
if (dropZoneHoverOpacity >= g_FancyDockingConstants.dropZoneOpacity)
if (dropZoneHoverOpacity >= FancyDockingDropZoneConstants::dropZoneOpacity)
{
m_dropZoneState.setDropZoneHoverOpacity(g_FancyDockingConstants.dropZoneOpacity);
m_dropZoneState.setDropZoneHoverOpacity(FancyDockingDropZoneConstants::dropZoneOpacity);
m_dropZoneHoverFadeInTimer->stop();
}
else
@@ -792,12 +791,12 @@ namespace AzQtComponents
QPoint mainWindowTopLeft = multiscreenMapFromGlobal(mainWindow->mapToGlobal(mainWindowRect.topLeft()));
QPoint mainWindowTopRight = multiscreenMapFromGlobal(mainWindow->mapToGlobal(mainWindowRect.topRight()));
QPoint mainWindowBottomLeft = multiscreenMapFromGlobal(mainWindow->mapToGlobal(mainWindowRect.bottomLeft()));
QSize absoluteLeftRightSize(g_FancyDockingConstants.absoluteDropZoneSizeInPixels, mainWindowRect.height());
QSize absoluteLeftRightSize(FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels, mainWindowRect.height());
QRect absoluteLeftDropZone(mainWindowTopLeft, absoluteLeftRightSize);
QRect absoluteRightDropZone(mainWindowTopRight - QPoint(g_FancyDockingConstants.absoluteDropZoneSizeInPixels, 0), absoluteLeftRightSize);
QSize absoluteTopBottomSize(mainWindowRect.width(), g_FancyDockingConstants.absoluteDropZoneSizeInPixels);
QRect absoluteRightDropZone(mainWindowTopRight - QPoint(FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels, 0), absoluteLeftRightSize);
QSize absoluteTopBottomSize(mainWindowRect.width(), FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels);
QRect absoluteTopDropZone(mainWindowTopLeft, absoluteTopBottomSize);
QRect absoluteBottomDropZone(mainWindowBottomLeft - QPoint(0, g_FancyDockingConstants.absoluteDropZoneSizeInPixels), absoluteTopBottomSize);
QRect absoluteBottomDropZone(mainWindowBottomLeft - QPoint(0, FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels), absoluteTopBottomSize);
// If the drop target is a main window, then we will only show the absolute
// drop zone if the cursor is in that zone already
@@ -986,16 +985,16 @@ namespace AzQtComponents
switch (m_dropZoneState.absoluteDropZoneArea())
{
case Qt::LeftDockWidgetArea:
dockRect.setX(dockRect.x() + g_FancyDockingConstants.absoluteDropZoneSizeInPixels);
dockRect.setX(dockRect.x() + FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels);
break;
case Qt::RightDockWidgetArea:
dockRect.setWidth(dockRect.width() - g_FancyDockingConstants.absoluteDropZoneSizeInPixels);
dockRect.setWidth(dockRect.width() - FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels);
break;
case Qt::TopDockWidgetArea:
dockRect.setY(dockRect.y() + g_FancyDockingConstants.absoluteDropZoneSizeInPixels);
dockRect.setY(dockRect.y() + FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels);
break;
case Qt::BottomDockWidgetArea:
dockRect.setHeight(dockRect.height() - g_FancyDockingConstants.absoluteDropZoneSizeInPixels);
dockRect.setHeight(dockRect.height() - FancyDockingDropZoneConstants::absoluteDropZoneSizeInPixels);
break;
}
@@ -1034,15 +1033,15 @@ namespace AzQtComponents
// Set the drop zone width/height to the default, but if the dock widget
// width and/or height is below the threshold, then switch to scaling them
// down accordingly
int dropZoneWidth = g_FancyDockingConstants.dropZoneSizeInPixels;
if (dockWidth < g_FancyDockingConstants.minDockSizeBeforeDropZoneScalingInPixels)
int dropZoneWidth = FancyDockingDropZoneConstants::dropZoneSizeInPixels;
if (dockWidth < FancyDockingDropZoneConstants::minDockSizeBeforeDropZoneScalingInPixels)
{
dropZoneWidth = aznumeric_cast<int>(dockWidth * g_FancyDockingConstants.dropZoneScaleFactor);
dropZoneWidth = aznumeric_cast<int>(dockWidth * FancyDockingDropZoneConstants::dropZoneScaleFactor);
}
int dropZoneHeight = g_FancyDockingConstants.dropZoneSizeInPixels;
if (dockHeight < g_FancyDockingConstants.minDockSizeBeforeDropZoneScalingInPixels)
int dropZoneHeight = FancyDockingDropZoneConstants::dropZoneSizeInPixels;
if (dockHeight < FancyDockingDropZoneConstants::minDockSizeBeforeDropZoneScalingInPixels)
{
dropZoneHeight = aznumeric_cast<int>(dockHeight * g_FancyDockingConstants.dropZoneScaleFactor);
dropZoneHeight = aznumeric_cast<int>(dockHeight * FancyDockingDropZoneConstants::dropZoneScaleFactor);
}
// Calculate the inner corners to be used when constructing the drop zone polygons
@@ -1078,7 +1077,7 @@ namespace AzQtComponents
int innerDropZoneWidth = m_dropZoneState.innerDropZoneRect().width();
int innerDropZoneHeight = m_dropZoneState.innerDropZoneRect().height();
int centerDropZoneDiameter = (innerDropZoneWidth < innerDropZoneHeight) ? innerDropZoneWidth : innerDropZoneHeight;
centerDropZoneDiameter = aznumeric_cast<int>(centerDropZoneDiameter * g_FancyDockingConstants.centerTabDropZoneScale);
centerDropZoneDiameter = aznumeric_cast<int>(centerDropZoneDiameter * FancyDockingDropZoneConstants::centerTabDropZoneScale);
// Setup our center tab drop zone
const QSize centerDropZoneSize(centerDropZoneDiameter, centerDropZoneDiameter);
@@ -1986,7 +1985,7 @@ namespace AzQtComponents
// hasn't faded in all the way yet, then ignore the drop zone area
// which will make the widget floating
bool modifiedKeyPressed = FancyDockingDropZoneWidget::CheckModifierKey();
if (modifiedKeyPressed || m_dropZoneState.dropZoneHoverOpacity() != g_FancyDockingConstants.dropZoneOpacity)
if (modifiedKeyPressed || m_dropZoneState.dropZoneHoverOpacity() != FancyDockingDropZoneConstants::dropZoneOpacity)
{
area = Qt::NoDockWidgetArea;
}
@@ -3026,7 +3025,7 @@ namespace AzQtComponents
{
bool modifiedKeyPressed = FancyDockingDropZoneWidget::CheckModifierKey();
m_ghostWidget->setWindowOpacity(modifiedKeyPressed ? 1.0f : g_FancyDockingConstants.draggingDockWidgetOpacity);
m_ghostWidget->setWindowOpacity(modifiedKeyPressed ? 1.0f : FancyDockingDropZoneConstants::draggingDockWidgetOpacity);
m_ghostWidget->setPixmap(m_state.dockWidgetScreenGrab.screenGrab, m_state.placeholder(), m_state.placeholderScreen());
}
}
@@ -19,26 +19,6 @@
namespace AzQtComponents
{
static const FancyDockingDropZoneConstants g_Constants;
FancyDockingDropZoneConstants::FancyDockingDropZoneConstants()
{
draggingDockWidgetOpacity = 0.6;
dropZoneOpacity = 0.4;
dropZoneSizeInPixels = 40;
minDockSizeBeforeDropZoneScalingInPixels = dropZoneSizeInPixels * 3;
dropZoneScaleFactor = 0.25;
centerTabDropZoneScale = 0.5;
centerTabIconScale = 0.5;
dropZoneColor = QColor(155, 155, 155);
dropZoneBorderColor = Qt::black;
dropZoneBorderInPixels = 1;
absoluteDropZoneSizeInPixels = 25;
dockingTargetDelayMS = 110;
dropZoneHoverFadeUpdateIntervalMS = 20;
dropZoneHoverFadeIncrement = dropZoneOpacity / (dockingTargetDelayMS / dropZoneHoverFadeUpdateIntervalMS);
centerDropZoneIconPath = QString(":/stylesheet/img/UI20/docking/tabs_icon.svg");
}
FancyDockingDropZoneWidget::FancyDockingDropZoneWidget(QMainWindow* mainWindow, QWidget* coordinatesRelativeTo, QScreen* screen, FancyDockingDropZoneState* dropZoneState)
// NOTE: this will not work with multiple monitors if this widget has a parent. The floating drop zone
@@ -154,7 +134,7 @@ namespace AzQtComponents
// Draw all of the normal drop zones if they exist (if a dock widget is hovered over)
painter.setPen(Qt::NoPen);
painter.setOpacity(g_Constants.dropZoneOpacity);
painter.setOpacity(FancyDockingDropZoneConstants::dropZoneOpacity);
auto dropZones = m_dropZoneState->dropZones();
for (auto it = dropZones.cbegin(); it != dropZones.cend(); ++it)
{
@@ -189,7 +169,7 @@ namespace AzQtComponents
// Otherwise, set the normal color
else
{
painter.setBrush(g_Constants.dropZoneColor);
painter.setBrush(FancyDockingDropZoneConstants::dropZoneColor);
}
// negate the window position to offset everything by that much
@@ -214,8 +194,8 @@ namespace AzQtComponents
// Scale the tabs icon based on the drop zone size and our specified offset
// Doing this through QIcon to make sure that SVG is rendered already in desired resolution
const QSize& dropZoneSize = dropZoneRect.size();
const QSize requestedIconSize = dropZoneSize * g_Constants.centerTabIconScale;
const QIcon dropZoneIcon = QIcon(g_Constants.centerDropZoneIconPath);
const QSize requestedIconSize = dropZoneSize * FancyDockingDropZoneConstants::centerTabIconScale;
const QIcon dropZoneIcon = QIcon(FancyDockingDropZoneConstants::centerDropZoneIconPath);
const QPixmap dropZonePixmap = dropZoneIcon.pixmap(requestedIconSize);
const QSize receivedIconSize = dropZoneIcon.actualSize(requestedIconSize);
@@ -264,7 +244,7 @@ namespace AzQtComponents
}
else
{
painter.setBrush(g_Constants.dropZoneColor);
painter.setBrush(FancyDockingDropZoneConstants::dropZoneColor);
}
painter.drawRect(absoluteDropZoneRect);
@@ -313,8 +293,8 @@ namespace AzQtComponents
const QPoint innerBottomRight = innerDropZoneRect.bottomRight();
// Draw the lines using the appropriate pen
QPen dropZoneBorderPen(g_Constants.dropZoneBorderColor);
dropZoneBorderPen.setWidth(g_Constants.dropZoneBorderInPixels);
QPen dropZoneBorderPen(FancyDockingDropZoneConstants::dropZoneBorderColor);
dropZoneBorderPen.setWidth(FancyDockingDropZoneConstants::dropZoneBorderInPixels);
painter.setPen(dropZoneBorderPen);
painter.setOpacity(1);
painter.drawLine(topLeft, innerTopLeft);
@@ -28,63 +28,58 @@ class QPainter;
namespace AzQtComponents
{
struct AZ_QT_COMPONENTS_API FancyDockingDropZoneConstants
namespace FancyDockingDropZoneConstants
{
// Constant for the opacity of the screen grab for the dock widget being dragged
qreal draggingDockWidgetOpacity;
static constexpr qreal draggingDockWidgetOpacity = 0.6;
// Constant for the opacity of the normal drop zones
qreal dropZoneOpacity;
static constexpr qreal dropZoneOpacity = 0.4;
// Constant for the default drop zone size (in pixels)
int dropZoneSizeInPixels;
static constexpr int dropZoneSizeInPixels = 40;
// Constant for the dock width/height size (in pixels) before we need to start
// scaling down the drop zone sizes, or else they will overlap with the center
// tab icon or each other
int minDockSizeBeforeDropZoneScalingInPixels;
static constexpr int minDockSizeBeforeDropZoneScalingInPixels = dropZoneSizeInPixels * 3;
// Constant for the factor by which we must scale down the drop zone sizes once
// the dock width/height size is too small
qreal dropZoneScaleFactor;
static constexpr qreal dropZoneScaleFactor = 0.25;
// Constant for the percentage to scale down the inner drop zone rectangle for the center tab drop zone
qreal centerTabDropZoneScale;
static constexpr qreal centerTabDropZoneScale = 0.5;
// Constant for the percentage to scale down the center tab drop zone for the center tab icon
qreal centerTabIconScale;
static constexpr qreal centerTabIconScale = 0.5;
// Constant for the drop zone hotspot default color
QColor dropZoneColor;
static const QColor dropZoneColor = QColor(155, 155, 155);
// Constant for the drop zone border color
QColor dropZoneBorderColor;
static const QColor dropZoneBorderColor = Qt::black;
// Constant for the border width in pixels separating the drop zones
int dropZoneBorderInPixels;
static constexpr int dropZoneBorderInPixels = 1;
// Constant for the border width in pixels separating the drop zones
int absoluteDropZoneSizeInPixels;
static constexpr int absoluteDropZoneSizeInPixels = 25;
// Constant for the delay (in milliseconds) before a drop zone becomes active
// once it is hovered over
int dockingTargetDelayMS;
static constexpr int dockingTargetDelayMS = 110;
// Constant for the rate at which we will update (fade in) the drop zone opacity
// when hovered over (in milliseconds)
int dropZoneHoverFadeUpdateIntervalMS;
static constexpr int dropZoneHoverFadeUpdateIntervalMS = 20;
// Constant for the incremental opacity increase for the hovered drop zone
// that will fade in to the full drop zone opacity in the desired time
qreal dropZoneHoverFadeIncrement;
static constexpr qreal dropZoneHoverFadeIncrement = dropZoneOpacity / (dockingTargetDelayMS / dropZoneHoverFadeUpdateIntervalMS);
// Constant for the path to the center drop zone tabs icon
QString centerDropZoneIconPath;
FancyDockingDropZoneConstants();
FancyDockingDropZoneConstants(const FancyDockingDropZoneConstants&) = delete;
FancyDockingDropZoneConstants& operator=(const FancyDockingDropZoneConstants&) = delete;
static const QString centerDropZoneIconPath = QStringLiteral(":/stylesheet/img/UI20/docking/tabs_icon.svg");
};
class FancyDockingDropZoneState
@@ -323,7 +323,7 @@ namespace AzQtComponents
saturation *= 2.0 - lightness;
}
double value = (lightness + saturation) / 2.0;
saturation = (2.0 * saturation) / (lightness + saturation);
saturation = qFuzzyIsNull(lightness + saturation) ? 0 : (2.0 * saturation) / (lightness + saturation);
m_hsv.saturation = AZ::GetClamp(saturation, 0.0, 1.0);
m_hsv.value = AZ::GetClamp(value, 0.0, 12.5);
@@ -341,11 +341,12 @@ namespace AzQtComponents
double saturation = m_hsv.saturation * m_hsv.value;
if (lightness <= 1.0)
{
saturation /= lightness;
saturation = (qFuzzyIsNull(lightness)) ? 0.0 : saturation / lightness;
}
else
{
saturation /= 2.0 - lightness;
double two_minus_lightness = 2.0 - lightness;
saturation = (qFuzzyIsNull(two_minus_lightness)) ? 0.0 : saturation / two_minus_lightness;
}
lightness /= 2.0;
@@ -164,11 +164,7 @@ namespace
}
}
#if AZ_TRAIT_DISABLE_FAILED_ZERO_COLOR_CONVERSION_TEST
TEST(AzQtComponents, DISABLED_ColorConversionsTestAllZeros)
#else
TEST(AzQtComponents, ColorConversionsTestAllZeros)
#endif // AZ_TRAIT_DISABLE_FAILED_ZERO_COLOR_CONVERSION_TEST
{
TestConversions({ 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 });
}
@@ -13,19 +13,16 @@
#define AZ_TRAIT_UNIT_TEST_ENTITY_ID_GEN_TEST_COUNT 10000
#define AZ_TRAIT_UNIT_TEST_DILLER_TRIGGER_EVENT_COUNT 100000
#define AZ_TRAIT_DISABLE_ALL_SAVE_DATA_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_AP_CONNECTION_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_ASSET_LOAD_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_ATOM_RPI_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_ARCHIVE_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_ZERO_COLOR_CONVERSION_TEST true
#define AZ_TRAIT_DISABLE_FAILED_FRAMEPROFILER_TEST true
#define AZ_TRAIT_DISABLE_FAILED_FRAMEWORK_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_GRADIENT_SIGNAL_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_MULTIPLAYER_GRIDMATE_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_INPUT_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_NATIVE_WINDOWS_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS true
#define AZ_TRAIT_DISABLE_FAILED_EMOTION_FX_TESTS true
@@ -30,6 +30,7 @@
#include <AzToolsFramework/ContainerEntity/ContainerEntitySystemComponent.h>
#include <AzToolsFramework/Entity/EditorEntityContextComponent.h>
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntitySystemComponent.h>
#include <AzToolsFramework/FocusMode/FocusModeSystemComponent.h>
#include <AzToolsFramework/Slice/SliceMetadataEntityContextComponent.h>
#include <AzToolsFramework/Prefab/PrefabSystemComponent.h>
@@ -268,6 +269,7 @@ namespace AzToolsFramework
azrtti_typeid<Components::EditorEntityUiSystemComponent>(),
azrtti_typeid<FocusModeSystemComponent>(),
azrtti_typeid<ContainerEntitySystemComponent>(),
azrtti_typeid<ReadOnlyEntitySystemComponent>(),
azrtti_typeid<SliceMetadataEntityContextComponent>(),
azrtti_typeid<Prefab::PrefabSystemComponent>(),
azrtti_typeid<EditorEntityFixupComponent>(),
@@ -23,6 +23,7 @@
#include <AzToolsFramework/Entity/EditorEntityModelComponent.h>
#include <AzToolsFramework/Entity/EditorEntitySearchComponent.h>
#include <AzToolsFramework/Entity/EditorEntitySortComponent.h>
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntitySystemComponent.h>
#include <AzToolsFramework/FocusMode/FocusModeSystemComponent.h>
#include <AzToolsFramework/PropertyTreeEditor/PropertyTreeEditorComponent.h>
#include <AzToolsFramework/Render/EditorIntersectorComponent.h>
@@ -75,6 +76,7 @@ namespace AzToolsFramework
EditorEntityFixupComponent::CreateDescriptor(),
EntityUtilityComponent::CreateDescriptor(),
ContainerEntitySystemComponent::CreateDescriptor(),
ReadOnlyEntitySystemComponent::CreateDescriptor(),
FocusModeSystemComponent::CreateDescriptor(),
SliceMetadataEntityContextComponent::CreateDescriptor(),
SliceRequestComponent::CreateDescriptor(),
@@ -0,0 +1,63 @@
/*
* 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/EntityId.h>
#include <AzCore/EBus/EBus.h>
#include <AzFramework/Entity/EntityContext.h>
namespace AzToolsFramework
{
//! Used to notify changes of state for read-only entities.
class ReadOnlyEntityPublicNotifications
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
using BusIdType = AzFramework::EntityContextId;
//////////////////////////////////////////////////////////////////////////
//! Triggered when an entity's read-only status changes.
//! @param entityId The entity whose status has changed.
//! @param readOnly The read-only state the container was changed to.
virtual void OnReadOnlyEntityStatusChanged([[maybe_unused]] const AZ::EntityId& entityId, [[maybe_unused]] bool readOnly) {}
protected:
~ReadOnlyEntityPublicNotifications() = default;
};
using ReadOnlyEntityPublicNotificationBus = AZ::EBus<ReadOnlyEntityPublicNotifications>;
//! Used by the ReadOnlyEntitySystemComponent to query the read-only state of entities as set by systems using the API.
class ReadOnlyEntityQueryRequests
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
using BusIdType = AzFramework::EntityContextId;
//////////////////////////////////////////////////////////////////////////
//! Triggered when an entity's read-only status is queried.
//! Allows multiple systems to weigh in on the read-only status of an entity.
//! @param entityId The entity whose status has changed.
//! @param[out] isReadOnly The output of the query. Should only be changed to true, and left untouched if false.
virtual void IsReadOnly(const AZ::EntityId& entityId, bool& isReadOnly) = 0;
protected:
~ReadOnlyEntityQueryRequests() = default;
};
using ReadOnlyEntityQueryRequestBus = AZ::EBus<ReadOnlyEntityQueryRequests>;
} // namespace AzToolsFramework
@@ -0,0 +1,43 @@
/*
* 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/Interface/Interface.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzFramework/Entity/EntityContextBus.h>
namespace AzToolsFramework
{
//! An entity registered as read-only cannot be altered in the editor.
class ReadOnlyEntityPublicInterface
{
public:
AZ_RTTI(ReadOnlyEntityPublicInterface, "{921FE15B-6EBD-47F0-8238-BC63318DEDEA}");
//! Returns whether the entity id provided is registered as read-only.
virtual bool IsReadOnly(const AZ::EntityId& entityId) = 0;
};
//! An entity registered as read-only cannot be altered in the editor.
class ReadOnlyEntityQueryInterface
{
public:
AZ_RTTI(ReadOnlyEntityQueryInterface, "{2ACD63C5-1F3E-4DE8-880E-8115F857D329}");
//! Refreshes the cached read-only status for the entities provided.
//! @param entityIds The entityIds whose read-only state will be queried again.
virtual void RefreshReadOnlyState(const EntityIdList& entityIds) = 0;
//! Refreshes the cached read-only status for all entities.
//! Useful when disconnecting a handler at runtime.
virtual void RefreshReadOnlyStateForAllEntities() = 0;
};
} // namespace AzToolsFramework
@@ -0,0 +1,99 @@
/*
* 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/Entity/ReadOnly/ReadOnlyEntitySystemComponent.h>
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityBus.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
namespace AzToolsFramework
{
void ReadOnlyEntitySystemComponent::Activate()
{
AZ::Interface<ReadOnlyEntityQueryInterface>::Register(this);
AZ::Interface<ReadOnlyEntityPublicInterface>::Register(this);
EditorEntityContextNotificationBus::Handler::BusConnect();
}
void ReadOnlyEntitySystemComponent::Deactivate()
{
EditorEntityContextNotificationBus::Handler::BusDisconnect();
AZ::Interface<ReadOnlyEntityPublicInterface>::Unregister(this);
AZ::Interface<ReadOnlyEntityQueryInterface>::Unregister(this);
}
void ReadOnlyEntitySystemComponent::Reflect(AZ::ReflectContext* context)
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<ReadOnlyEntitySystemComponent, AZ::Component>()->Version(1);
}
}
void ReadOnlyEntitySystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC_CE("ReadOnlyEntityService"));
}
bool ReadOnlyEntitySystemComponent::IsReadOnly(const AZ::EntityId& entityId)
{
if (!m_readOnlystates.contains(entityId))
{
QueryReadOnlyStateForEntity(entityId);
}
return m_readOnlystates[entityId];
}
void ReadOnlyEntitySystemComponent::RefreshReadOnlyState(const EntityIdList& entityIds)
{
for (const AZ::EntityId entityId : entityIds)
{
bool wasReadOnly = m_readOnlystates[entityId];
QueryReadOnlyStateForEntity(entityId);
if (bool isReadOnly = m_readOnlystates[entityId]; wasReadOnly != isReadOnly)
{
ReadOnlyEntityPublicNotificationBus::Broadcast(
&ReadOnlyEntityPublicNotificationBus::Events::OnReadOnlyEntityStatusChanged, entityId, isReadOnly);
}
}
}
void ReadOnlyEntitySystemComponent::RefreshReadOnlyStateForAllEntities()
{
for (auto elem : m_readOnlystates)
{
AZ::EntityId entityId = elem.first;
bool wasReadOnly = m_readOnlystates[entityId];
QueryReadOnlyStateForEntity(entityId);
if (bool isReadOnly = m_readOnlystates[entityId]; wasReadOnly != isReadOnly)
{
ReadOnlyEntityPublicNotificationBus::Broadcast(
&ReadOnlyEntityPublicNotificationBus::Events::OnReadOnlyEntityStatusChanged, entityId, isReadOnly);
}
}
}
void ReadOnlyEntitySystemComponent::OnContextReset()
{
m_readOnlystates.clear();
}
void ReadOnlyEntitySystemComponent::QueryReadOnlyStateForEntity(const AZ::EntityId& entityId)
{
bool isReadOnly = false;
ReadOnlyEntityQueryRequestBus::Broadcast(
&ReadOnlyEntityQueryRequestBus::Events::IsReadOnly, entityId, isReadOnly);
m_readOnlystates[entityId] = isReadOnly;
}
} // namespace AzToolsFramework
@@ -0,0 +1,56 @@
/*
* 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 <AzCore/Memory/SystemAllocator.h>
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityInterface.h>
namespace AzToolsFramework
{
//! System Component to track read-only entity registration.
//! An entity registered as ReadOnly cannot be altered in the Editor.
class ReadOnlyEntitySystemComponent final
: public AZ::Component
, private ReadOnlyEntityPublicInterface
, private ReadOnlyEntityQueryInterface
, private EditorEntityContextNotificationBus::Handler
{
public:
AZ_COMPONENT(ReadOnlyEntitySystemComponent, "{B32EB03F-D88F-4B3A-9C16-071AF04DA646}");
ReadOnlyEntitySystemComponent() = default;
virtual ~ReadOnlyEntitySystemComponent() = default;
// AZ::Component overrides ...
void Activate() override;
void Deactivate() override;
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
// ReadOnlyEntityPublicNotifications overrides ...
bool IsReadOnly(const AZ::EntityId& entityId) override;
// ReadOnlyEntityQueryInterface overrides ...
void RefreshReadOnlyState(const EntityIdList& entityIds) override;
void RefreshReadOnlyStateForAllEntities() override;
// EditorEntityContextNotificationBus overrides ...
void OnContextReset() override;
private:
void QueryReadOnlyStateForEntity(const AZ::EntityId& entityId);
AZStd::unordered_map<AZ::EntityId, bool> m_readOnlystates;
};
} // namespace AzToolsFramework
@@ -34,10 +34,12 @@ namespace AzToolsFramework::Prefab
PrefabPublicNotificationBus::Handler::BusConnect();
AZ::Interface<PrefabFocusInterface>::Register(this);
AZ::Interface<PrefabFocusPublicInterface>::Register(this);
PrefabFocusPublicRequestBus::Handler::BusConnect();
}
PrefabFocusHandler::~PrefabFocusHandler()
{
PrefabFocusPublicRequestBus::Handler::BusDisconnect();
AZ::Interface<PrefabFocusPublicInterface>::Unregister(this);
AZ::Interface<PrefabFocusInterface>::Unregister(this);
PrefabPublicNotificationBus::Handler::BusDisconnect();
@@ -45,6 +47,18 @@ namespace AzToolsFramework::Prefab
EditorEntityInfoNotificationBus::Handler::BusDisconnect();
}
void PrefabFocusHandler::Reflect(AZ::ReflectContext* context)
{
if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context); behaviorContext)
{
behaviorContext->EBus<PrefabFocusPublicRequestBus>("PrefabFocusPublicRequestBus")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
->Attribute(AZ::Script::Attributes::Category, "Prefab")
->Attribute(AZ::Script::Attributes::Module, "prefab")
->Event("FocusOnOwningPrefab", &PrefabFocusPublicInterface::FocusOnOwningPrefab);
}
}
void PrefabFocusHandler::InitializeEditorInterfaces()
{
m_containerEntityInterface = AZ::Interface<ContainerEntityInterface>::Get();
@@ -30,8 +30,8 @@ namespace AzToolsFramework::Prefab
//! Handles Prefab Focus mode, determining which prefab file entity changes will target.
class PrefabFocusHandler final
: private PrefabFocusInterface
, private PrefabFocusPublicInterface
: public PrefabFocusPublicRequestBus::Handler
, private PrefabFocusInterface
, private PrefabPublicNotificationBus::Handler
, private EditorEntityContextNotificationBus::Handler
, private EditorEntityInfoNotificationBus::Handler
@@ -42,13 +42,15 @@ namespace AzToolsFramework::Prefab
PrefabFocusHandler();
~PrefabFocusHandler();
static void Reflect(AZ::ReflectContext* context);
// PrefabFocusInterface overrides ...
void InitializeEditorInterfaces() override;
PrefabFocusOperationResult FocusOnPrefabInstanceOwningEntityId(AZ::EntityId entityId) override;
TemplateId GetFocusedPrefabTemplateId(AzFramework::EntityContextId entityContextId) const override;
InstanceOptionalReference GetFocusedPrefabInstance(AzFramework::EntityContextId entityContextId) const override;
// PrefabFocusPublicInterface overrides ...
// PrefabFocusPublicInterface and PrefabFocusPublicRequestBus overrides ...
PrefabFocusOperationResult FocusOnOwningPrefab(AZ::EntityId entityId) override;
PrefabFocusOperationResult FocusOnParentOfFocusedPrefab(AzFramework::EntityContextId entityContextId) override;
PrefabFocusOperationResult FocusOnPathIndex(AzFramework::EntityContextId entityContextId, int index) override;
@@ -58,4 +58,18 @@ namespace AzToolsFramework::Prefab
virtual const int GetPrefabFocusPathLength(AzFramework::EntityContextId entityContextId) const = 0;
};
/**
* The primary purpose of this bus is to facilitate writing automated tests for prefab focus mode.
* If you would like to integrate prefabs focus mode into your system, please call PrefabFocusPublicInterface
* for better performance.
*/
class PrefabFocusPublicRequests
: public AZ::EBusTraits
{
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
using PrefabFocusPublicRequestBus = AZ::EBus<PrefabFocusPublicInterface, PrefabFocusPublicRequests>;
} // namespace AzToolsFramework::Prefab
@@ -521,21 +521,18 @@ namespace AzToolsFramework
nestedInstanceLink.has_value(),
"A valid link was not found for one of the instances provided as input for the CreatePrefab operation.");
PrefabDomReference nestedInstanceLinkDom = nestedInstanceLink->get().GetLinkDom();
AZ_Assert(
nestedInstanceLinkDom.has_value(),
"A valid DOM was not found for the link corresponding to one of the instances provided as input for the "
"CreatePrefab operation.");
PrefabDomValueReference nestedInstanceLinkPatches =
PrefabDomUtils::FindPrefabDomValue(nestedInstanceLinkDom->get(), PrefabDomUtils::PatchesName);
AZ_Assert(
nestedInstanceLinkPatches.has_value(),
"A valid DOM for patches was not found for the link corresponding to one of the instances provided as input for the "
"CreatePrefab operation.");
PrefabDom patchesCopyForUndoSupport;
patchesCopyForUndoSupport.CopyFrom(nestedInstanceLinkPatches->get(), patchesCopyForUndoSupport.GetAllocator());
PrefabDomReference nestedInstanceLinkDom = nestedInstanceLink->get().GetLinkDom();
if (nestedInstanceLinkDom.has_value())
{
PrefabDomValueReference nestedInstanceLinkPatches =
PrefabDomUtils::FindPrefabDomValue(nestedInstanceLinkDom->get(), PrefabDomUtils::PatchesName);
if (nestedInstanceLinkPatches.has_value())
{
patchesCopyForUndoSupport.CopyFrom(nestedInstanceLinkPatches->get(), patchesCopyForUndoSupport.GetAllocator());
}
}
PrefabUndoHelpers::RemoveLink(
sourceInstance->GetTemplateId(), targetTemplateId, sourceInstance->GetInstanceAlias(), sourceInstance->GetLinkId(),
AZStd::move(patchesCopyForUndoSupport), undoBatch);
@@ -60,6 +60,7 @@ namespace AzToolsFramework
AzToolsFramework::Prefab::PrefabConversionUtils::PrefabCatchmentProcessor::Reflect(context);
AzToolsFramework::Prefab::PrefabConversionUtils::EditorInfoRemover::Reflect(context);
PrefabPublicRequestHandler::Reflect(context);
PrefabFocusHandler::Reflect(context);
PrefabLoader::Reflect(context);
PrefabSystemScriptingHandler::Reflect(context);
@@ -23,11 +23,11 @@ namespace AzToolsFramework
/// @name Reverse URLs.
/// Used to identify common actions and override them when necessary.
//@{
static const AZ::Crc32 s_backAction = AZ_CRC("com.o3de.action.common.back", 0xd772a2af);
static const AZ::Crc32 s_deleteAction = AZ_CRC("com.o3de.action.common.delete", 0x5731f6cb);
static const AZ::Crc32 s_duplicateAction = AZ_CRC("com.o3de.action.common.duplicate", 0x08ccf461);
static const AZ::Crc32 s_nextComponentMode = AZ_CRC("com.o3de.action.common.nextComponentMode", 0xcc26094f);
static const AZ::Crc32 s_previousComponentMode = AZ_CRC("com.o3de.action.common.previousComponentMode", 0x0d18ff39);
static const AZ::Crc32 s_backAction = AZ_CRC("com.o3de.action.common.back", 0x80c3030f);
static const AZ::Crc32 s_deleteAction = AZ_CRC("com.o3de.action.common.delete", 0x58e78eed);
static const AZ::Crc32 s_duplicateAction = AZ_CRC("com.o3de.action.common.duplicate", 0xbc5a4a23);
static const AZ::Crc32 s_nextComponentMode = AZ_CRC("com.o3de.action.common.nextComponentMode", 0xf9aca3a8);
static const AZ::Crc32 s_previousComponentMode = AZ_CRC("com.o3de.action.common.previousComponentMode", 0x0580eaec);
//@}
/// Specific Action properties to be sent to a type implementing
@@ -159,6 +159,10 @@ set(FILES
Entity/SliceEditorEntityOwnershipServiceBus.h
Entity/EntityUtilityComponent.h
Entity/EntityUtilityComponent.cpp
Entity/ReadOnly/ReadOnlyEntityInterface.h
Entity/ReadOnly/ReadOnlyEntityBus.h
Entity/ReadOnly/ReadOnlyEntitySystemComponent.cpp
Entity/ReadOnly/ReadOnlyEntitySystemComponent.h
Fingerprinting/TypeFingerprinter.h
Fingerprinting/TypeFingerprinter.cpp
FocusMode/FocusModeInterface.h
@@ -0,0 +1,125 @@
/*
* 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 <Tests/Entity/ReadOnly/ReadOnlyEntityFixture.h>
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
namespace AzToolsFramework
{
void ReadOnlyEntityFixture::SetUpEditorFixtureImpl()
{
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
// in the unit tests.
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
m_readOnlyEntityPublicInterface = AZ::Interface<ReadOnlyEntityPublicInterface>::Get();
ASSERT_TRUE(m_readOnlyEntityPublicInterface != nullptr);
GenerateTestHierarchy();
}
void ReadOnlyEntityFixture::TearDownEditorFixtureImpl()
{
}
void ReadOnlyEntityFixture::GenerateTestHierarchy()
{
/*
* Root
* |_ Child
* |_ GrandChild1
* |_ GrandChild2
*/
m_entityMap[RootEntityName] = CreateEditorEntity(RootEntityName, AZ::EntityId());
m_entityMap[ChildEntityName] = CreateEditorEntity(ChildEntityName, m_entityMap[RootEntityName]);
m_entityMap[GrandChild1EntityName] = CreateEditorEntity(GrandChild1EntityName, m_entityMap[ChildEntityName]);
m_entityMap[GrandChild2EntityName] = CreateEditorEntity(GrandChild2EntityName, m_entityMap[ChildEntityName]);
}
AZ::EntityId ReadOnlyEntityFixture::CreateEditorEntity(const char* name, AZ::EntityId parentId)
{
AZ::Entity* entity = nullptr;
UnitTest::CreateDefaultEditorEntity(name, &entity);
// Parent
AZ::TransformBus::Event(entity->GetId(), &AZ::TransformInterface::SetParent, parentId);
return entity->GetId();
}
ReadOnlyHandlerAlwaysTrue::ReadOnlyHandlerAlwaysTrue()
{
auto editorEntityContextId = AzFramework::EntityContextId::CreateNull();
EditorEntityContextRequestBus::BroadcastResult(editorEntityContextId, &EditorEntityContextRequests::GetEditorEntityContextId);
ReadOnlyEntityQueryRequestBus::Handler::BusConnect(editorEntityContextId);
}
ReadOnlyHandlerAlwaysTrue::~ReadOnlyHandlerAlwaysTrue()
{
ReadOnlyEntityQueryRequestBus::Handler::BusDisconnect();
if (auto readOnlyEntityQueryInterface = AZ::Interface<ReadOnlyEntityQueryInterface>::Get())
{
readOnlyEntityQueryInterface->RefreshReadOnlyStateForAllEntities();
}
}
void ReadOnlyHandlerAlwaysTrue::IsReadOnly([[maybe_unused]] const AZ::EntityId& entityId, bool& isReadOnly)
{
isReadOnly = true;
}
ReadOnlyHandlerAlwaysFalse::ReadOnlyHandlerAlwaysFalse()
{
auto editorEntityContextId = AzFramework::EntityContextId::CreateNull();
EditorEntityContextRequestBus::BroadcastResult(editorEntityContextId, &EditorEntityContextRequests::GetEditorEntityContextId);
ReadOnlyEntityQueryRequestBus::Handler::BusConnect(editorEntityContextId);
}
ReadOnlyHandlerAlwaysFalse::~ReadOnlyHandlerAlwaysFalse()
{
ReadOnlyEntityQueryRequestBus::Handler::BusDisconnect();
if (auto readOnlyEntityQueryInterface = AZ::Interface<ReadOnlyEntityQueryInterface>::Get())
{
readOnlyEntityQueryInterface->RefreshReadOnlyStateForAllEntities();
}
}
ReadOnlyHandlerEntityId::ReadOnlyHandlerEntityId(AZ::EntityId entityId)
: m_entityId(entityId)
{
auto editorEntityContextId = AzFramework::EntityContextId::CreateNull();
EditorEntityContextRequestBus::BroadcastResult(editorEntityContextId, &EditorEntityContextRequests::GetEditorEntityContextId);
ReadOnlyEntityQueryRequestBus::Handler::BusConnect(editorEntityContextId);
}
ReadOnlyHandlerEntityId::~ReadOnlyHandlerEntityId()
{
ReadOnlyEntityQueryRequestBus::Handler::BusDisconnect();
if (auto readOnlyEntityQueryInterface = AZ::Interface<ReadOnlyEntityQueryInterface>::Get())
{
readOnlyEntityQueryInterface->RefreshReadOnlyStateForAllEntities();
}
}
void ReadOnlyHandlerEntityId::IsReadOnly(const AZ::EntityId& entityId, bool& isReadOnly)
{
if (entityId == m_entityId)
{
isReadOnly = true;
}
}
}
@@ -0,0 +1,78 @@
/*
* 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/TransformBus.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzTest/AzTest.h>
#include <AzToolsFramework/UnitTest/AzToolsFrameworkTestHelpers.h>
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityBus.h>
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityInterface.h>
namespace AzToolsFramework
{
class ReadOnlyEntityFixture
: public UnitTest::ToolsApplicationFixture
{
protected:
void SetUpEditorFixtureImpl() override;
void TearDownEditorFixtureImpl() override;
void GenerateTestHierarchy();
AZ::EntityId CreateEditorEntity(const char* name, AZ::EntityId parentId);
AZStd::unordered_map<AZStd::string, AZ::EntityId> m_entityMap;
ReadOnlyEntityPublicInterface* m_readOnlyEntityPublicInterface = nullptr;
public:
inline static const char* RootEntityName = "Root";
inline static const char* ChildEntityName = "Child";
inline static const char* GrandChild1EntityName = "GrandChild1";
inline static const char* GrandChild2EntityName = "GrandChild2";
};
class ReadOnlyHandlerAlwaysTrue
: public ReadOnlyEntityQueryRequestBus::Handler
{
public:
ReadOnlyHandlerAlwaysTrue();
~ReadOnlyHandlerAlwaysTrue();
// ReadOnlyEntityQueryNotificationBus overrides ...
void IsReadOnly(const AZ::EntityId& entityId, bool& isReadOnly) override;
};
class ReadOnlyHandlerAlwaysFalse
: public ReadOnlyEntityQueryRequestBus::Handler
{
public:
ReadOnlyHandlerAlwaysFalse();
~ReadOnlyHandlerAlwaysFalse();
// ReadOnlyEntityQueryNotificationBus overrides ...
void IsReadOnly([[maybe_unused]] const AZ::EntityId& entityId, [[maybe_unused]] bool& isReadOnly) override {}
};
class ReadOnlyHandlerEntityId
: public ReadOnlyEntityQueryRequestBus::Handler
{
public:
ReadOnlyHandlerEntityId(AZ::EntityId entityId);
~ReadOnlyHandlerEntityId();
// ReadOnlyEntityQueryNotificationBus overrides ...
void IsReadOnly(const AZ::EntityId& entityId, bool& isReadOnly) override;
private:
AZ::EntityId m_entityId;
};
}
@@ -0,0 +1,99 @@
/*
* 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 <Tests/Entity/ReadOnly/ReadOnlyEntityFixture.h>
namespace AzToolsFramework
{
TEST_F(ReadOnlyEntityFixture, NoHandlerEntityIsNotReadOnlyByDefault)
{
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
}
TEST_F(ReadOnlyEntityFixture, SingleHandlerEntityIsReadOnly)
{
// Create a handler that sets all entities to read-only.
ReadOnlyHandlerAlwaysTrue alwaysTrueHandler;
// All entities should be marked read-only now.
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[RootEntityName]));
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[GrandChild1EntityName]));
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[GrandChild2EntityName]));
}
TEST_F(ReadOnlyEntityFixture, SingleHandlerEntityIsNotReadOnly)
{
// Create a handler that sets all entities to read-only.
ReadOnlyHandlerAlwaysFalse alwaysFalseHandler;
// All entities should not be marked read-only now.
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[RootEntityName]));
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[GrandChild1EntityName]));
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[GrandChild2EntityName]));
}
TEST_F(ReadOnlyEntityFixture, SingleHandlerWithLogic)
{
// Create a handler that sets just the child entity to read-only.
ReadOnlyHandlerEntityId entityIdHandler(m_entityMap[ChildEntityName]);
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[RootEntityName]));
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[GrandChild1EntityName]));
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[GrandChild2EntityName]));
}
TEST_F(ReadOnlyEntityFixture, TwoHandlersCanOverlap)
{
// Create two handlers that set different entities to read-only.
ReadOnlyHandlerEntityId entityIdHandler1(m_entityMap[ChildEntityName]);
ReadOnlyHandlerEntityId entityIdHandler2(m_entityMap[GrandChild2EntityName]);
// Both entities should be marked as read-only, while others aren't.
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[RootEntityName]));
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[GrandChild1EntityName]));
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[GrandChild2EntityName]));
}
TEST_F(ReadOnlyEntityFixture, EnsureCacheIsRefreshedCorrectly)
{
// Verify the child entity is not marked as read-only
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
// Create a handler that sets the child entity to read-only.
ReadOnlyHandlerEntityId entityIdHandler(m_entityMap[ChildEntityName]);
// Communicate to the ReadOnlyEntitySystemComponent that the read-only state for the child entity may have changed.
// Note that this operation would usually be executed by the handler, hence the Query interface call.
if (auto readOnlyEntityQueryInterface = AZ::Interface<ReadOnlyEntityQueryInterface>::Get())
{
readOnlyEntityQueryInterface->RefreshReadOnlyState({ m_entityMap[ChildEntityName] });
}
// Verify the child entity is marked as read-only
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
}
TEST_F(ReadOnlyEntityFixture, EnsureCacheIsClearedCorrectly)
{
{
// Create a handler that sets the child entity to read-only.
ReadOnlyHandlerEntityId entityIdHandler(m_entityMap[ChildEntityName]);
// Verify the child entity is marked as read-only
EXPECT_TRUE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
}
// When the handler goes out of scope, it calls RefreshReadOnlyStateForAllEntities and refreshes the cache.
// Verify the child entity is no longer marked as read-only
EXPECT_FALSE(m_readOnlyEntityPublicInterface->IsReadOnly(m_entityMap[ChildEntityName]));
}
}
@@ -0,0 +1,150 @@
/*
* 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 <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
#include <Prefab/PrefabTestComponent.h>
#include <Prefab/PrefabTestDomUtils.h>
#include <Prefab/PrefabTestFixture.h>
namespace UnitTest
{
using PrefabDeleteTest = PrefabTestFixture;
TEST_F(PrefabDeleteTest, DeleteEntitiesInInstance_DeleteSingleEntitySucceeds)
{
PrefabEntityResult createEntityResult = m_prefabPublicInterface->CreateEntity(AZ::EntityId(), AZ::Vector3());
// Verify that a valid entity is created.
AZ::EntityId testEntityId = createEntityResult.GetValue();
ASSERT_TRUE(testEntityId.IsValid());
AZ::Entity* testEntity = AzToolsFramework::GetEntityById(testEntityId);
ASSERT_TRUE(testEntity != nullptr);
m_prefabPublicInterface->DeleteEntitiesInInstance(AzToolsFramework::EntityIdList{ testEntityId });
// Verify that entity can't be found after deletion.
testEntity = AzToolsFramework::GetEntityById(testEntityId);
EXPECT_TRUE(testEntity == nullptr);
}
TEST_F(PrefabDeleteTest, DeleteEntitiesInInstance_DeleteSinglePrefabSucceeds)
{
PrefabEntityResult createEntityResult = m_prefabPublicInterface->CreateEntity(AZ::EntityId(), AZ::Vector3());
// Verify that a valid entity is created.
AZ::EntityId createdEntityId = createEntityResult.GetValue();
ASSERT_TRUE(createdEntityId.IsValid());
AZ::Entity* createdEntity = AzToolsFramework::GetEntityById(createdEntityId);
ASSERT_TRUE(createdEntity != nullptr);
// Rather than hardcode a path, use a path from settings registry since that will work on all platforms.
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
AZ::IO::FixedMaxPath path;
registry->Get(path.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
CreatePrefabResult createPrefabResult =
m_prefabPublicInterface->CreatePrefabInMemory(AzToolsFramework::EntityIdList{ createdEntityId }, path);
AZ::EntityId createdPrefabContainerId = createPrefabResult.GetValue();
ASSERT_TRUE(createdPrefabContainerId.IsValid());
AZ::Entity* prefabContainerEntity = AzToolsFramework::GetEntityById(createdPrefabContainerId);
ASSERT_TRUE(prefabContainerEntity != nullptr);
// Verify that the prefab container entity and the entity within are deleted.
m_prefabPublicInterface->DeleteEntitiesInInstance(AzToolsFramework::EntityIdList{ createdPrefabContainerId });
prefabContainerEntity = AzToolsFramework::GetEntityById(createdPrefabContainerId);
EXPECT_TRUE(prefabContainerEntity == nullptr);
createdEntity = AzToolsFramework::GetEntityById(createdEntityId);
EXPECT_TRUE(createdEntity == nullptr);
}
TEST_F(PrefabDeleteTest, DeleteEntitiesAndAllDescendantsInInstance_DeletingEntityDeletesChildEntityToo)
{
PrefabEntityResult parentEntityCreationResult = m_prefabPublicInterface->CreateEntity(AZ::EntityId(), AZ::Vector3());
// Verify that valid parent entity is created.
AZ::EntityId parentEntityId = parentEntityCreationResult.GetValue();
ASSERT_TRUE(parentEntityId.IsValid());
AZ::Entity* parentEntity = AzToolsFramework::GetEntityById(parentEntityId);
ASSERT_TRUE(parentEntity != nullptr);
// Verify that valid child entity is created.
PrefabEntityResult childEntityCreationResult = m_prefabPublicInterface->CreateEntity(parentEntityId, AZ::Vector3());
AZ::EntityId childEntityId = childEntityCreationResult.GetValue();
ASSERT_TRUE(childEntityId.IsValid());
AZ::Entity* childEntity = AzToolsFramework::GetEntityById(childEntityId);
ASSERT_TRUE(childEntity != nullptr);
// PrefabTestFixture won't add required editor components by default. Hence we add them here.
AddRequiredEditorComponents(childEntity);
AddRequiredEditorComponents(parentEntity);
// Parent the child entity under the parent entity.
AZ::TransformBus::Event(childEntityId, &AZ::TransformBus::Events::SetParent, parentEntityId);
// Delete parent entity and its children.
m_prefabPublicInterface->DeleteEntitiesAndAllDescendantsInInstance(AzToolsFramework::EntityIdList{ parentEntityId });
// Verify that both the parent and child entities are deleted.
parentEntity = AzToolsFramework::GetEntityById(parentEntityId);
EXPECT_TRUE(parentEntity == nullptr);
childEntity = AzToolsFramework::GetEntityById(childEntityId);
EXPECT_TRUE(childEntity == nullptr);
}
TEST_F(PrefabDeleteTest, DeleteEntitiesAndAllDescendantsInInstance_DeletingEntityDeletesChildPrefabToo)
{
PrefabEntityResult entityToBePutUnderPrefabResult = m_prefabPublicInterface->CreateEntity(AZ::EntityId(), AZ::Vector3());
// Verify that a valid entity is created that will be put in a prefab later.
AZ::EntityId entityToBePutUnderPrefabId = entityToBePutUnderPrefabResult.GetValue();
ASSERT_TRUE(entityToBePutUnderPrefabId.IsValid());
AZ::Entity* entityToBePutUnderPrefab = AzToolsFramework::GetEntityById(entityToBePutUnderPrefabId);
ASSERT_TRUE(entityToBePutUnderPrefab != nullptr);
// Verify that a valid parent entity is created.
PrefabEntityResult parentEntityCreationResult = m_prefabPublicInterface->CreateEntity(AZ::EntityId(), AZ::Vector3());
AZ::EntityId parentEntityId = parentEntityCreationResult.GetValue();
ASSERT_TRUE(parentEntityId.IsValid());
AZ::Entity* parentEntity = AzToolsFramework::GetEntityById(parentEntityId);
ASSERT_TRUE(parentEntity != nullptr);
// Rather than hardcode a path, use a path from settings registry since that will work on all platforms.
AZ::SettingsRegistryInterface* registry = AZ::SettingsRegistry::Get();
AZ::IO::FixedMaxPath path;
registry->Get(path.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
CreatePrefabResult createPrefabResult =
m_prefabPublicInterface->CreatePrefabInMemory(AzToolsFramework::EntityIdList{ entityToBePutUnderPrefabId }, path);
// Verify that a valid prefab container entity is created.
AZ::EntityId createdPrefabContainerId = createPrefabResult.GetValue();
ASSERT_TRUE(createdPrefabContainerId.IsValid());
AZ::Entity* prefabContainerEntity = AzToolsFramework::GetEntityById(createdPrefabContainerId);
ASSERT_TRUE(prefabContainerEntity != nullptr);
// PrefabTestFixture won't add required editor components by default. Hence we add them here.
AddRequiredEditorComponents(parentEntity);
AddRequiredEditorComponents(prefabContainerEntity);
// Parent the prefab under the parent entity.
AZ::TransformBus::Event(createdPrefabContainerId, &AZ::TransformBus::Events::SetParent, parentEntityId);
// Delete the parent entity.
m_prefabPublicInterface->DeleteEntitiesAndAllDescendantsInInstance(AzToolsFramework::EntityIdList{ parentEntityId });
// Validate that the parent and the prefab under it and the entity inside the prefab are all deleted.
parentEntity = AzToolsFramework::GetEntityById(parentEntityId);
ASSERT_TRUE(parentEntity == nullptr);
entityToBePutUnderPrefab = AzToolsFramework::GetEntityById(entityToBePutUnderPrefabId);
ASSERT_TRUE(entityToBePutUnderPrefab == nullptr);
prefabContainerEntity = AzToolsFramework::GetEntityById(createdPrefabContainerId);
EXPECT_TRUE(prefabContainerEntity == nullptr);
}
} // namespace UnitTest
@@ -57,6 +57,11 @@ namespace UnitTest
return AZStd::make_unique<PrefabTestToolsApplication>("PrefabTestApplication");
}
void PrefabTestFixture::PropagateAllTemplateChanges()
{
m_prefabSystemComponent->OnSystemTick();
}
AZ::Entity* PrefabTestFixture::CreateEntity(const char* entityName, const bool shouldActivate)
{
// Circumvent the EntityContext system and generate a new entity with a transformcomponent
@@ -125,4 +130,13 @@ namespace UnitTest
EXPECT_EQ(entityInInstance->GetState(), AZ::Entity::State::Active);
}
}
void PrefabTestFixture::AddRequiredEditorComponents(AZ::Entity* entity)
{
ASSERT_TRUE(entity != nullptr);
entity->Deactivate();
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(
&AzToolsFramework::EditorEntityContextRequests::AddRequiredComponents, *entity);
entity->Activate();
}
}
@@ -52,6 +52,8 @@ namespace UnitTest
AZStd::unique_ptr<ToolsTestApplication> CreateTestApplication() override;
void PropagateAllTemplateChanges();
AZ::Entity* CreateEntity(const char* entityName, const bool shouldActivate = true);
void CompareInstances(const Instance& instanceA, const Instance& instanceB, bool shouldCompareLinkIds = true,
@@ -62,6 +64,8 @@ namespace UnitTest
//! Validates that all entities within a prefab instance are in 'Active' state.
void ValidateInstanceEntitiesActive(Instance& instance);
void AddRequiredEditorComponents(AZ::Entity* entity);
PrefabSystemComponent* m_prefabSystemComponent = nullptr;
PrefabLoaderInterface* m_prefabLoaderInterface = nullptr;
PrefabPublicInterface* m_prefabPublicInterface = nullptr;
@@ -128,7 +128,7 @@ namespace UnitTest
void ProcessDeferredUpdates()
{
// Force a prefab propagation for updates that are deferred to the next tick.
m_prefabSystemComponent->OnSystemTick();
PropagateAllTemplateChanges();
// Ensure the model process its entity update queue
m_model->ProcessEntityUpdates();
@@ -28,6 +28,9 @@ set(FILES
Entity/EditorEntitySearchComponentTests.cpp
Entity/EditorEntitySelectionTests.cpp
Entity/EntityUtilityComponentTests.cpp
Entity/ReadOnly/ReadOnlyEntityFixture.cpp
Entity/ReadOnly/ReadOnlyEntityFixture.h
Entity/ReadOnly/ReadOnlyEntityTests.cpp
EntityIdQLabelTests.cpp
EntityInspectorTests.cpp
EntityOwnershipService/EntityOwnershipServiceTestFixture.cpp
@@ -66,6 +69,7 @@ set(FILES
Prefab/PrefabFocus/PrefabFocusTests.cpp
Prefab/MockPrefabFileIOActionValidator.cpp
Prefab/MockPrefabFileIOActionValidator.h
Prefab/PrefabDeleteTests.cpp
Prefab/PrefabDuplicateTests.cpp
Prefab/PrefabEntityAliasTests.cpp
Prefab/PrefabInstanceToTemplatePropagatorTests.cpp
+8
View File
@@ -71,6 +71,14 @@ public:
// The value of the argument as integer number.
virtual const int GetIValue() const = 0;
// </interfuscator:shuffle>
// Description:
// Retrieve the value of the argument.
// Arguments:
// cmdLineValue. The cmdline value will be filled out if a valid boolean is found.
// Return Value:
// Returns true if the cmdline arg is actually a boolean string matching "true" or "false"; otherwise return false.
virtual const bool GetBoolValue(bool& cmdLineValue) const = 0;
};
// Command line interface
File diff suppressed because it is too large Load Diff
@@ -1,58 +0,0 @@
/*
* 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/EBus/EBus.h>
// Forward declarations
class ISprite;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Interface class that listeners need to implement to be notified of changes to the sprite settings
class UiSpriteSettingsChangeNotification
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
/**
* Overrides the default AZ::EBusTraits address policy so that the bus
* has multiple addresses at which to receive messages. This bus is
* identified by Sprite pointer. Messages addressed to an ID are received by
* handlers connected to that ID.
*/
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
/**
* Overrides the default AZ::EBusTraits ID type so that Sprite pointers are
* used to access the addresses of the bus.
*/
typedef ISprite* BusIdType;
//////////////////////////////////////////////////////////////////////////
virtual ~UiSpriteSettingsChangeNotification() {}
//! Called when the sprite settings such as number of cells etc change
virtual void OnSpriteSettingsChanged() = 0;
};
typedef AZ::EBus<UiSpriteSettingsChangeNotification> UiSpriteSettingsChangeNotificationBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Notify listeners when sprite image sources change.
class UiSpriteSourceNotificationInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiSpriteSourceNotificationInterface() {}
//! A sprite image (or sequence of images) has changed file sources.
virtual void OnSpriteSourceChanged() = 0;
};
typedef AZ::EBus<UiSpriteSourceNotificationInterface> UiSpriteSourceNotificationBus;
@@ -1,75 +0,0 @@
/*
* 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/EBus/EBus.h>
#include <AzCore/Component/Component.h>
#include <AzCore/Slice/SliceComponent.h>
#include <AzCore/Serialization/ObjectStream.h>
namespace AZ
{
namespace IO
{
class FileIOStream;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Bus interface for tools to talk to the LyShine system
//! It is valid to use this bus from resource compilers or the UI Editor
class UiSystemToolsInterface
: public AZ::EBusTraits
{
public: // types
class CanvasAssetHandle
{
public:
virtual ~CanvasAssetHandle() {};
};
public:
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
using MutexType = AZStd::recursive_mutex;
// Public functions
//! Load a canvas but do not init or activate the entities
//! The CanvasAssetHandle is an opaque pointer only valid to be passed to the
//! methods below.
virtual CanvasAssetHandle* LoadCanvasFromStream(AZ::IO::GenericStream& stream, const AZ::ObjectStream::FilterDescriptor& filterDesc) = 0;
//! Save a canvas to a stream
virtual void SaveCanvasToStream(CanvasAssetHandle* canvas, AZ::IO::FileIOStream& stream) = 0;
//! Get the slice component for a loaded canvas
virtual AZ::SliceComponent* GetRootSliceSliceComponent(CanvasAssetHandle* canvas) = 0;
//! Get the slice entity for a loaded canvas
virtual AZ::Entity* GetRootSliceEntity(CanvasAssetHandle* canvas) = 0;
//! Get the canvas entity for a loaded canvas
virtual AZ::Entity* GetCanvasEntity(CanvasAssetHandle* canvas) = 0;
//! Replace the slice component with a new one. The old slice component is not deleted.
//! The client is responsible for that.
virtual void ReplaceRootSliceSliceComponent(CanvasAssetHandle* canvas, AZ::SliceComponent* newSliceComponent) = 0;
//! Replace the canvas entity with a new one. The old canvas entity is not deleted.
//! The client is responsible for that.
virtual void ReplaceCanvasEntity(CanvasAssetHandle* canvas, AZ::Entity* newCanvasEntity) = 0;
//! Delete the canvas file object and its canvas entity and slice entity.
virtual void DestroyCanvas(CanvasAssetHandle* canvas) = 0;
};
using UiSystemToolsBus = AZ::EBus<UiSystemToolsInterface>;
@@ -1,32 +0,0 @@
/*
* 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/ComponentBus.h>
// Forward declarations
class ISprite;
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiAnimateEntityInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiAnimateEntityInterface() {}
//! Called when the animation system has updated the data members of an entity's components
virtual void PropertyValuesChanged() = 0;
public: // static member data
//! More than one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
};
typedef AZ::EBus<UiAnimateEntityInterface> UiAnimateEntityBus;
@@ -1,122 +0,0 @@
/*
* 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/EBus/EBus.h>
#include <LyShine/Animation/IUiAnimation.h>
struct IUiAnimNode;
namespace AZ
{
class Entity;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiAnimNodeInterface
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
typedef IUiAnimNode* BusIdType;
//! Only one implementation for an IAnimNode* can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
//////////////////////////////////////////////////////////////////////////
public: // member functions
virtual ~UiAnimNodeInterface() {}
virtual AZ::EntityId GetAzEntityId() = 0;
virtual void SetAzEntity(AZ::Entity* entity) = 0;
};
typedef AZ::EBus<UiAnimNodeInterface> UiAnimNodeBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiAnimationInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiAnimationInterface() {}
//! Start a sequence
virtual void StartSequence(const AZStd::string& sequenceName) = 0;
//! Play a sequence from startTime to endTime
virtual void PlaySequenceRange(const AZStd::string& sequenceName, float startTime, float endTime) = 0;
//! Stop a sequence
virtual void StopSequence(const AZStd::string& sequenceName) = 0;
//! Abort a sequence
virtual void AbortSequence(const AZStd::string& sequenceName) = 0;
//! Pause a sequence
virtual void PauseSequence(const AZStd::string& sequenceName) = 0;
//! Resume a sequence
virtual void ResumeSequence(const AZStd::string& sequenceName) = 0;
//! Reset a sequence
virtual void ResetSequence(const AZStd::string& sequenceName) = 0;
//! Get the speed of a sequence
virtual float GetSequencePlayingSpeed(const AZStd::string& sequenceName) = 0;
//! Set the speed of a sequence
virtual void SetSequencePlayingSpeed(const AZStd::string& sequenceName, float speed) = 0;
//! Get the current time of a sequence
virtual float GetSequencePlayingTime(const AZStd::string& sequenceName) = 0;
//! Get whether a sequence is currently playing
virtual bool IsSequencePlaying(const AZStd::string& sequenceName) = 0;
//! Get the length of a sequence in seconds
virtual float GetSequenceLength(const AZStd::string& sequenceName) = 0;
//! Set the behavior a sequence will exhibit when it stops playing
virtual void SetSequenceStopBehavior(IUiAnimationSystem::ESequenceStopBehavior stopBehavior) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiAnimationInterface> UiAnimationBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiAnimationNotifications
: public AZ::ComponentBus
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const bool EnableEventQueue = true;
//////////////////////////////////////////////////////////////////////////
public: // member functions
virtual ~UiAnimationNotifications(){}
//! Called on an animation event
virtual void OnUiAnimationEvent(IUiAnimationListener::EUiAnimationEvent uiAnimationEvent, AZStd::string animSequenceName) = 0;
//! Called on animation track event triggered
virtual void OnUiTrackEvent(AZStd::string eventName, AZStd::string valueName, AZStd::string animSequenceName) {}
};
typedef AZ::EBus<UiAnimationNotifications> UiAnimationNotificationBus;
@@ -1,67 +0,0 @@
/*
* 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/ComponentBus.h>
#include <AzCore/Math/Vector2.h>
#include <LyShine/UiBase.h>
class ISprite;
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiButtonInterface
: public AZ::ComponentBus
{
public: // types
typedef AZStd::function<void(AZ::EntityId, AZ::Vector2)> OnClickCallback;
public: // member functions
virtual ~UiButtonInterface() {}
//! Get the on-click callback
virtual OnClickCallback GetOnClickCallback() = 0;
//! Set the on-click callback
virtual void SetOnClickCallback(OnClickCallback onClick) = 0;
//! Get the action name
virtual const LyShine::ActionName& GetOnClickActionName() = 0;
//! Set the action name
virtual void SetOnClickActionName(const LyShine::ActionName& actionName) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiButtonInterface> UiButtonBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiButtonNotifications
: public AZ::ComponentBus
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const bool EnableEventQueue = true;
//////////////////////////////////////////////////////////////////////////
public: // member functions
virtual ~UiButtonNotifications() {}
//! Notify listeners that the button was clicked
virtual void OnButtonClick() {}
};
typedef AZ::EBus<UiButtonNotifications> UiButtonNotificationBus;
@@ -1,483 +0,0 @@
/*
* 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/ComponentBus.h>
#include <AzCore/Math/Vector2.h>
#include <AzCore/Math/Matrix4x4.h>
#include <AzFramework/Input/Channels/InputChannelDigitalWithSharedModifierKeyStates.h>
#include <AzFramework/Input/User/LocalUserId.h>
#include <LyShine/UiBase.h>
// Forward declarations
struct IUiAnimationSystem;
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiCanvasInterface
: public AZ::ComponentBus
{
public: // member functions
//! Deleting a canvas will delete all its child elements recursively and all of their components
virtual ~UiCanvasInterface() {}
//! Get the asset ID path name of this canvas. If not loaded or saved yet this will be ""
virtual const AZStd::string& GetPathname() = 0;
//! Get the ID of this canvas. This will remain the same while this canvas is loaded.
virtual LyShine::CanvasId GetCanvasId() = 0;
//! Get the unique ID of this canvas
virtual AZ::u64 GetUniqueCanvasId() = 0;
//! Get the draw order of this canvas. Rendering is back-to-front, so higher numbers render in front of lower numbers.
virtual int GetDrawOrder() = 0;
//! Set the draw order of this canvas. Rendering is back-to-front, so higher numbers render in front of lower numbers.
virtual void SetDrawOrder(int drawOrder) = 0;
//! Get the flag indicating if this canvas will stay loaded through a level unload.
virtual bool GetKeepLoadedOnLevelUnload() = 0;
//! Set the flag indicating if this canvas will stay loaded through a level unload.
virtual void SetKeepLoadedOnLevelUnload(bool keepLoaded) = 0;
//! Force a layout recompute. Layouts marked for a recompute are handled on the canvas update,
//! so this can be used if an immediate recompute is desired
virtual void RecomputeChangedLayouts() = 0;
//! Get the number child elements of this canvas
virtual int GetNumChildElements() = 0;
//! Get the specified child element, index must be less than GetNumChildElements()
virtual AZ::Entity* GetChildElement(int index) = 0;
//! Get the specified child entity Id, index must be less than GetNumChildElements()
virtual AZ::EntityId GetChildElementEntityId(int index) = 0;
//! Get the child elements of this canvas
virtual LyShine::EntityArray GetChildElements() = 0;
//! Get the child entity Ids of this canvas
virtual AZStd::vector<AZ::EntityId> GetChildElementEntityIds() = 0;
//! Create a new element that is a child of the canvas, the canvas has ownership of the child
virtual AZ::Entity* CreateChildElement(const LyShine::NameType& name) = 0;
//! Return the element on this canvas with the given id or nullptr if no match
virtual AZ::Entity* FindElementById(LyShine::ElementId id) = 0;
//! Return the first element on this canvas with the given name or nullptr if no match
virtual AZ::Entity* FindElementByName(const LyShine::NameType& name) = 0;
//! Return the first element on this canvas with the given name or nullptr if no match
virtual AZ::EntityId FindElementEntityIdByName(const LyShine::NameType& name) = 0;
//! Find all elements on this canvas with the given name
virtual void FindElementsByName(const LyShine::NameType& name, LyShine::EntityArray& result) = 0;
//! Return the element with the given hierarchical name or nullptr if no match
//! \param name, a hierarchical name relative to the root with '/' as the separator
virtual AZ::Entity* FindElementByHierarchicalName(const LyShine::NameType& name) = 0;
//! Find all elements on this canvas matching the predicate
virtual void FindElements(AZStd::function<bool(const AZ::Entity*)> predicate, LyShine::EntityArray& result) = 0;
//! Get the front-most element whose bounds include the given point in canvas space
//! \return nullptr if no match
virtual AZ::Entity* PickElement(AZ::Vector2 point) = 0;
//! Get all element whose bounds intersect with the given box in canvas space
//! \return empty EntityArray if no match
virtual LyShine::EntityArray PickElements(const AZ::Vector2& bound0, const AZ::Vector2& bound1) = 0;
//! Look for an entity with interactable component to handle an event at given point
virtual AZ::EntityId FindInteractableToHandleEvent(AZ::Vector2 point) = 0;
//! Save this canvas to the given path in XML
//! \return true if no error
virtual bool SaveToXml(const AZStd::string& assetIdPathname, const AZStd::string& sourceAssetPathname) = 0;
//! Initialize a set of entities that have been added to the canvas
//! Used when instantiating a slice or for undo/redo, copy/paste
//! \param topLevelEntities - The elements that were created
//! \param makeUniqueNamesAndIds If false the entity names and ElementIds in the string are kept, else unique ones are generated
//! \param insertionPoint The parent element for the created elements, if nullptr the root element is the parent
virtual void FixupCreatedEntities(LyShine::EntityArray topLevelEntities, bool makeUniqueNamesAndIds, AZ::Entity* optionalInsertionPoint) = 0;
//! Add an existing entity to the canvas (only for internal use from editor)
//! \param element The newly created element to add to the canvas
//! \param parent The parent element for the created element, if nullptr the root element is the parent
//! \param insertBefore The sibling element to place this element before, if nullptr then add as last child
virtual void AddElement(AZ::Entity* element, AZ::Entity* parent, AZ::Entity* insertBefore) = 0;
//! Go through all elements in the canvas and reinitialize them
//! This is done whenever a slice asset changes and the entity context is rebuilt from the root slice asset
virtual void ReinitializeElements() = 0;
//! Save this canvas to an XML string
//! \return the resulting string
virtual AZStd::string SaveToXmlString() = 0;
//! Get an element name that is unique to the children of the specified parent and to an optional array of elements
//! \param parentEntityId The entityId of the parent who's children's names must not match the returned name
//! \param baseName The name to append a unique identifier to
//! \param includedChildren An array of any other elements who's names must not match the returned name
//! \return Unique name that does not match the specified parent's children or the optional array of children
virtual AZStd::string GetUniqueChildName(AZ::EntityId parentEntityId, AZStd::string baseName, const LyShine::EntityArray* includeChildren) = 0;
//! Clone an element and add it to this canvas as a child of the given parent element
//! The entity and all its components/children are cloned and new IDs are generated
//! NOTE: Only state that is persistent/reflected is cloned
//! \param sourceEntity The entity to clone
//! \param parentEntity The parent element for the created elements, if nullptr the root element is the parent
//! \return The new entity
virtual AZ::Entity* CloneElement(AZ::Entity* sourceEntity, AZ::Entity* parentEntity) = 0;
//! Clone an element and add it to this canvas as a child of the given parent element
//! The entity and all its components/children are cloned and new IDs are generated
//! NOTE: Only state that is persistent/reflected is cloned
//! \param sourceEntity The entity to clone (may be from a different canvas)
//! \param parentEntity The parent element for the created elements, if invalid the root element is the parent
//! \param insertBefore The child of the parent element that the new element should be inserted before, if invalid the new element is the last child element
//! \return The new entity
virtual AZ::EntityId CloneElementEntityId(AZ::EntityId sourceEntity, AZ::EntityId parentEntity, AZ::EntityId insertBefore) = 0;
//! Create a clone of this canvas entity
//! \param canvasSize The resolution to display the canvas at
virtual AZ::Entity* CloneCanvas(const AZ::Vector2& canvasSize) = 0;
//! Set the transformation from canvas space to viewport space
virtual void SetCanvasToViewportMatrix(const AZ::Matrix4x4& matrix) = 0;
//! Get the transformation from canvas space to viewport space
virtual const AZ::Matrix4x4& GetCanvasToViewportMatrix() = 0;
//! Get the transformation from viewport space to canvas space
virtual void GetViewportToCanvasMatrix(AZ::Matrix4x4& matrix) = 0;
//! Returns the "target" size of the canvas (in pixels)
//
//! The target canvas size changes depending on whether you're running in
//! the UI Editor or in-game. While in-game, we assume that the canvas size
//! fills the screen, so the target canvas size is the size of the viewport.
//
//! When using the editor, however, the target size is the "authored" size of
//! the canvas. The canvas is authored in one resolution, but it may be
//! displayed by the game at whatever the game resolution is set to.
virtual AZ::Vector2 GetCanvasSize() = 0;
//! Set the authored size of the canvas (in pixels)
virtual void SetCanvasSize(const AZ::Vector2& canvasSize) = 0;
//! Set the target size of the canvas (in pixels)
//!
//! This should be called before the UpdateCanvas and RenderCanvas methods.
//! When running in game in full screen mode the target canvas size should be set to the viewport size
virtual void SetTargetCanvasSize(bool isInGame, const AZ::Vector2& targetCanvasSize) = 0;
//! Get scale to adjust for the difference between canvas size (authored size)
//! and the viewport size (target canvas size) when running on current device
virtual AZ::Vector2 GetDeviceScale() = 0;
//! Get flag that indicates whether visual element's vertices should snap to the nearest pixel
virtual bool GetIsPixelAligned() = 0;
//! Set flag that indicates whether visual element's vertices should snap to the nearest pixel
virtual void SetIsPixelAligned(bool isPixelAligned) = 0;
//! Get flag that indicates whether text should snap to the nearest pixel
virtual bool GetIsTextPixelAligned() = 0;
//! Set flag that indicates whether text should snap to the nearest pixel
virtual void SetIsTextPixelAligned(bool isTextPixelAligned) = 0;
//! Get the animation system for this canvas
virtual IUiAnimationSystem* GetAnimationSystem() = 0;
//! Get flag that governs whether the canvas is enabled
//
//! A canvas that's enabled will be updated and rendered each frame.
virtual bool GetEnabled() = 0;
//! Set flag that governs whether the canvas is enabled
//
//! A canvas that's enabled will be updated and rendered each frame.
virtual void SetEnabled(bool enabled) = 0;
//! Get flag that controls whether the canvas is rendering to a texture
virtual bool GetIsRenderToTexture() = 0;
//! Set flag that controls whether the canvas is rendering to a texture
virtual void SetIsRenderToTexture(bool isRenderToTexture) = 0;
//! Get the render target name that this canvas will render to
virtual AZStd::string GetRenderTargetName() = 0;
//! Set the render target name that this canvas will render to
virtual void SetRenderTargetName(const AZStd::string& name) = 0;
//! Get flag that controls whether this canvas automatically handles positional input (mouse/touch)
virtual bool GetIsPositionalInputSupported() = 0;
//! Set flag that controls whether this canvas automatically handles positional input (mouse/touch)
virtual void SetIsPositionalInputSupported(bool isSupported) = 0;
//! Get flag that controls whether this canvas consumes all input events while it is enabled
virtual bool GetIsConsumingAllInputEvents() = 0;
//! Set flag that controls whether this canvas consumes all input events while it is enabled
virtual void SetIsConsumingAllInputEvents(bool isConsuming) = 0;
//! Get flag that controls whether this canvas automatically handles multi-touch input
virtual bool GetIsMultiTouchSupported() = 0;
//! Set flag that controls whether this canvas automatically handles multi-touch input
virtual void SetIsMultiTouchSupported(bool isSupported) = 0;
//! Get flag that controls whether this canvas automatically handles navigation input (via keyboard/gamepad)
virtual bool GetIsNavigationSupported() = 0;
//! Set flag that controls whether this canvas automatically handles navigation input (via keyboard/gamepad)
virtual void SetIsNavigationSupported(bool isSupported) = 0;
//! Get the analog (eg. thumb-stick) input value that must be exceeded before a navigation command will be processed
virtual float GetNavigationThreshold() = 0;
//! Set the analog (eg. thumb-stick) input value that must be exceeded before a navigation command will be processed
virtual void SetNavigationThreshold(float navigationThreshold) = 0;
//! Get the delay (milliseconds) before a held navigation command will begin repeating
virtual AZ::u64 GetNavigationRepeatDelay() = 0;
//! Set the delay (milliseconds) before a held navigation command will begin repeating
virtual void SetNavigationRepeatDelay(AZ::u64 navigationRepeatDelay) = 0;
//! Get the delay (milliseconds) before a held navigation command will continue repeating
virtual AZ::u64 GetNavigationRepeatPeriod() = 0;
//! Set the delay (milliseconds) before a held navigation command will continue repeating
virtual void SetNavigationRepeatPeriod(AZ::u64 navigationRepeatPeriod) = 0;
//! Get the local user id that is being used to filter incoming input events
virtual AzFramework::LocalUserId GetLocalUserIdInputFilter() = 0;
//! Set the local user id that will be used to filter incoming input events
virtual void SetLocalUserIdInputFilter(AzFramework::LocalUserId localUserId) = 0;
//! Handle an input event for the canvas
virtual bool HandleInputEvent(const AzFramework::InputChannel::Snapshot& inputSnapshot,
const AZ::Vector2* viewportPos = nullptr,
AzFramework::ModifierKeyMask activeModifierKeys = AzFramework::ModifierKeyMask::None) = 0;
//! Handle a unicode text event for the canvas
virtual bool HandleTextEvent(const AZStd::string& textUTF8) = 0;
//! Handle a positional input event for the canvas, this could come from
//! a ray cast intersection for example
virtual bool HandleInputPositionalEvent(const AzFramework::InputChannel::Snapshot& inputSnapshot, AZ::Vector2 viewportPos) = 0;
//! Get the mouse position of the last input event
virtual AZ::Vector2 GetMousePosition() = 0;
//! Get the element to be displayed when hovering over an interactable
virtual AZ::EntityId GetTooltipDisplayElement() = 0;
//! Set the element to be displayed when hovering over an interactable
virtual void SetTooltipDisplayElement(AZ::EntityId entityId) = 0;
//! Force the active interactable for the canvas to be the given one,
//! also force AutoActivation of interactable,
//! intended for internal use by UI components
virtual void ForceFocusInteractable(AZ::EntityId interactableId) = 0;
//! Force the active interactable for the canvas to be the given one,
//! also set last mouse pos to point,
//! intended for internal use by UI components
virtual void ForceActiveInteractable(AZ::EntityId interactableId, bool shouldStayActive, AZ::Vector2 point) = 0;
//! Get the hover interactable
virtual AZ::EntityId GetHoverInteractable() = 0;
//! Force the hover interactable for the canvas to be the given one, this can be useful when using
//! keyboard/gamepad navigation and the current hover interactable is deleted by a script and the script
//! wants to specify the new hover interactable
virtual void ForceHoverInteractable(AZ::EntityId interactableId) = 0;
//! Clear all active interactables, and all hover interactables if last input was positional (mouse/touch).
//! This is intended for internal use by UI components
virtual void ClearAllInteractables() = 0;
//! Generate Enter pressed/released input events on an interactable.
//! Useful for automated testing to simulate button clicks
virtual void ForceEnterInputEventOnInteractable(AZ::EntityId interactableId) = 0;
public: // static member data
//! Only one component on an entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiCanvasInterface> UiCanvasBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! The canvas component implements this bus and it is provided for C++ implementations of
//! UI components to use to talk to the canvas
class UiCanvasComponentImplementationInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiCanvasComponentImplementationInterface() {}
//! Mark the render graph for the canvas as dirty. This will cause the render graph to get
//! cleared and rebuilt on the next render.
virtual void MarkRenderGraphDirty() = 0;
public: // static member data
//! Only one component on an entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiCanvasComponentImplementationInterface> UiCanvasComponentImplementationBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Interface class that listeners need to implement to be notified of canvas actions
class UiCanvasActionNotification
: public AZ::ComponentBus
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const bool EnableEventQueue = true;
//////////////////////////////////////////////////////////////////////////
public: // member functions
virtual ~UiCanvasActionNotification(){}
//! Called when the canvas sends an action to the listener
virtual void OnAction(AZ::EntityId entityId, const LyShine::ActionName& actionName) = 0;
};
typedef AZ::EBus<UiCanvasActionNotification> UiCanvasNotificationBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Interface class that listeners need to implement to be notified when the draw order of any
//! canvas changes
class UiCanvasOrderNotification
: public AZ::EBusTraits
{
public: // member functions
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
virtual ~UiCanvasOrderNotification(){}
//! Called when the draw order setting for a canvas changes
//! Note this is used to update the order in the UiCanvasManager so that
//! order has not been updated when this fires.
virtual void OnCanvasDrawOrderChanged(AZ::EntityId canvasEntityId) = 0;
};
typedef AZ::EBus<UiCanvasOrderNotification> UiCanvasOrderNotificationBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Interface class that listeners need to implement to be notified when any canvas has been
//! enabled or disabled
class UiCanvasEnabledStateNotification
: public AZ::EBusTraits
{
public: // member functions
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
virtual ~UiCanvasEnabledStateNotification() {}
//! Called when the canvas was enabled or disabled
virtual void OnCanvasEnabledStateChanged(AZ::EntityId canvasEntityId, bool enabled) = 0;
};
typedef AZ::EBus<UiCanvasEnabledStateNotification> UiCanvasEnabledStateNotificationBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Interface class that listeners need to implement to be notified of canvas size or scale changes
class UiCanvasSizeNotification
: public AZ::EBusTraits
{
public:
virtual ~UiCanvasSizeNotification() {}
//! Called when the target canvas size or uniform device scale changes.
virtual void OnCanvasSizeOrScaleChange(AZ::EntityId canvasEntityId) = 0;
};
typedef AZ::EBus<UiCanvasSizeNotification> UiCanvasSizeNotificationBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Interface class that listeners need to implement to be notified of changes to the canvas
//! pixel alignment settings
class UiCanvasPixelAlignmentNotification
: public AZ::ComponentBus
{
public:
virtual ~UiCanvasPixelAlignmentNotification() {}
//! Called when the pixel alignment setting for the canvas changes
virtual void OnCanvasPixelAlignmentChange() {}
//! Called when the text pixel alignment setting for the canvas changes
virtual void OnCanvasTextPixelAlignmentChange() {}
};
typedef AZ::EBus<UiCanvasPixelAlignmentNotification> UiCanvasPixelAlignmentNotificationBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Interface class that listeners need to implement to be notified of canvas input.
//! Note that interactables already get methods called on them when they themselves are interacted
//! with. This notification bus is intended for other entities or Lua to know when some other
//! entities are interacted with.
class UiCanvasInputNotifications
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiCanvasInputNotifications() {}
//! Called when an element is pressed. Will return an invalid entity id if no interactable was
//! pressed.
virtual void OnCanvasPrimaryPressed([[maybe_unused]] AZ::EntityId entityId) {};
//! Called when an element is released. The released entity that is sent is the entity that was
//! active (if any).
virtual void OnCanvasPrimaryReleased([[maybe_unused]] AZ::EntityId entityId) {};
//! Called when an element is pressed. Will be an invalid entity id if no interactable was
//! pressed.
virtual void OnCanvasMultiTouchPressed([[maybe_unused]] AZ::EntityId entityId, [[maybe_unused]] int multiTouchIndex) {};
//! Called when an element is released. The released entity that is sent is the entity that was
//! active (if any).
virtual void OnCanvasMultiTouchReleased([[maybe_unused]] AZ::EntityId entityId, [[maybe_unused]] int multiTouchIndex) {};
//! Called when an element starts being hovered
virtual void OnCanvasHoverStart([[maybe_unused]] AZ::EntityId entityId) {};
//! Called when an element ends being hovered
virtual void OnCanvasHoverEnd([[maybe_unused]] AZ::EntityId entityId) {};
//! Called when the enter key is pressed
virtual void OnCanvasEnterPressed([[maybe_unused]] AZ::EntityId entityId) {};
//! Called when the enter key is released
virtual void OnCanvasEnterReleased([[maybe_unused]] AZ::EntityId entityId) {};
};
typedef AZ::EBus<UiCanvasInputNotifications> UiCanvasInputNotificationBus;
@@ -1,67 +0,0 @@
/*
* 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/ComponentBus.h>
#include <AzFramework/Input/User/LocalUserId.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiCanvasManagerInterface
: public AZ::EBusTraits
{
public: // types
typedef std::vector<AZ::EntityId> CanvasEntityList;
public:
//! Create a canvas
virtual AZ::EntityId CreateCanvas() = 0;
//! Load a canvas
virtual AZ::EntityId LoadCanvas(const AZStd::string& canvasPathname) = 0;
//! Unload a canvas
virtual void UnloadCanvas(AZ::EntityId canvasEntityId) = 0;
//! Find a canvas by path, optionally load the canvas if it was not found
virtual AZ::EntityId FindLoadedCanvasByPathName(const AZStd::string& canvasPathname, bool loadIfNotFound = false) = 0;
//! Get a list of canvases that are loaded in game, this is sorted by draw order
virtual CanvasEntityList GetLoadedCanvases() = 0;
//! Set the local user id that will be used to filter incoming input events for all canvases.
//! Can be overriden for an individual canvas using UiCanvasInterface::SetLocalUserIdInputFilter.
virtual void SetLocalUserIdInputFilterForAllCanvases(AzFramework::LocalUserId localUserId) = 0;
};
typedef AZ::EBus<UiCanvasManagerInterface> UiCanvasManagerBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Interface class that listeners need to implement to be notified of canvas manager changes
class UiCanvasManagerNotification
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
//////////////////////////////////////////////////////////////////////////
virtual ~UiCanvasManagerNotification() {}
//! Called when a canvas has been loaded
virtual void OnCanvasLoaded([[maybe_unused]] AZ::EntityId canvasEntityId) {}
//! Called when a canvas has been unloaded/destroyed
virtual void OnCanvasUnloaded([[maybe_unused]] AZ::EntityId canvasEntityId) {}
//! Called when a canvas has been reloaded (due to hot-loading)
//! For a hot-load, the OnCanvasLoaded/OnCanvasUnloaded notifications are not sent - only this one is
virtual void OnCanvasReloaded([[maybe_unused]] AZ::EntityId canvasEntityId) {}
};
typedef AZ::EBus<UiCanvasManagerNotification> UiCanvasManagerNotificationBus;
@@ -1,37 +0,0 @@
/*
* 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/ComponentBus.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Elements that require update notifications should connect to this bus using the entity id of their
//! containing canvas.
class UiCanvasUpdateNotification
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiCanvasUpdateNotification() {}
//! Update the component. This is called when the game is running.
//! It is different from the TickBus in that it is called only when the canvas is updated.
//! So it is not called if the canvas is disabled.
virtual void Update(float deltaTime) = 0;
//! Update the component while in the editor.
//! This is called every frame when in the editor and the game is NOT running.
virtual void UpdateInEditor(float /*deltaTime*/) {}
public: // static member data
//! Multiple components on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
};
typedef AZ::EBus<UiCanvasUpdateNotification> UiCanvasUpdateNotificationBus;
@@ -1,95 +0,0 @@
/*
* 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/ComponentBus.h>
#include <AzCore/Math/Vector2.h>
#include <LyShine/UiBase.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiCheckboxInterface
: public AZ::ComponentBus
{
public: // types
//! params: sending entity id, new state
typedef AZStd::function<void(AZ::EntityId, AZ::Vector2, bool)> StateChangeCallback;
public: // member functions
virtual ~UiCheckboxInterface() {}
//! Query the state of the checkbox
//! \return The current state for the checkbox.
virtual bool GetState() = 0;
//! Manually override the state of the checkbox
//! \param isOn The new desired state of the checkbox.
virtual void SetState(bool checked) = 0;
//! Toggle the state of the checkbox
//! \return The new state of the checkbox.
virtual bool ToggleState() = 0;
//! Get the state change callback
virtual StateChangeCallback GetStateChangeCallback() = 0;
//! Set the state change callback
virtual void SetStateChangeCallback(StateChangeCallback onChange) = 0;
//! Set the optional checked (ON) entity
virtual void SetCheckedEntity(AZ::EntityId entityId) = 0;
//! Get the optional checked (ON) entity
virtual AZ::EntityId GetCheckedEntity() = 0;
//! Set the optional unchecked (OFF) entity
virtual void SetUncheckedEntity(AZ::EntityId entityId) = 0;
//! Get the optional unchecked (OFF) entity
virtual AZ::EntityId GetUncheckedEntity() = 0;
//! Get the action triggered when turned on
virtual const LyShine::ActionName& GetTurnOnActionName() = 0;
//! Set the action triggered when turned on
virtual void SetTurnOnActionName(const LyShine::ActionName& actionName) = 0;
//! Get the action triggered when turned off
virtual const LyShine::ActionName& GetTurnOffActionName() = 0;
//! Set the action triggered when turned off
virtual void SetTurnOffActionName(const LyShine::ActionName& actionName) = 0;
//! Get the action triggered when changed
virtual const LyShine::ActionName& GetChangedActionName() = 0;
//! Set the action triggered when changed
virtual void SetChangedActionName(const LyShine::ActionName& actionName) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiCheckboxInterface> UiCheckboxBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiCheckboxNotifications
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiCheckboxNotifications() {}
//! Notify listeners that the checkbox state has changed
virtual void OnCheckboxStateChange([[maybe_unused]] bool checked) {}
};
typedef AZ::EBus<UiCheckboxNotifications> UiCheckboxNotificationBus;
@@ -1,99 +0,0 @@
/*
* 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/ComponentBus.h>
#include <AzCore/Math/Vector2.h>
#include <LyShine/UiBase.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiDraggableInterface
: public AZ::ComponentBus
{
public: // types
//! States that the component can be in during a drag. Lua scripts can switch the state to alert the user
enum class DragState
{
Normal,
Valid,
Invalid
};
public: // member functions
virtual ~UiDraggableInterface() {}
//! Get the state of the drag
virtual DragState GetDragState() = 0;
//! Set the state of the drag. This is only relevant during a drag.
//! The state affects the visual state of the draggable and can be used to indicate when it is
//! over a valid drop target.
virtual void SetDragState(DragState dragState) = 0;
//! Redo the drag, this is not usually needed but if a UiDraggableNotificationBus handler causes
//! drop targets to move, and keyboard or console navigation is being used, it can be needed.
//! In that case the handler should call this method after moving drop targets.
virtual void RedoDrag(AZ::Vector2 point) = 0;
//! Set this draggable element to be a proxy for another draggable element and start a drag on
//! this draggable element at the specified point
virtual void SetAsProxy(AZ::EntityId originalDraggableId, AZ::Vector2 point) = 0;
//! Conclude the drag of a proxy. This should be called from the OnDragEnd callback of the proxy and
//! will result in calling OnDragEnd on the draggable element that this is a proxy for
virtual void ProxyDragEnd(AZ::Vector2 point) = 0;
//! Check if this draggable element is a proxy
virtual bool IsProxy() = 0;
//! Get the original draggable element that this element is a proxy for
//! Returns an invalid entity id if this is not a proxy
virtual AZ::EntityId GetOriginalFromProxy() = 0;
//! Get the flag that indicates if this draggable can be dropped on any canvas
virtual bool GetCanDropOnAnyCanvas() = 0;
//! Set the flag that indicates if this draggable can be dropped on any canvas
virtual void SetCanDropOnAnyCanvas(bool anyCanvas) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiDraggableInterface> UiDraggableBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiDraggableNotifications
: public AZ::ComponentBus
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const bool EnableEventQueue = true;
//////////////////////////////////////////////////////////////////////////
public: // member functions
virtual ~UiDraggableNotifications() {}
//! Called on drag start
virtual void OnDragStart(AZ::Vector2 position) = 0;
//! Called on position change during drag
virtual void OnDrag(AZ::Vector2 position) = 0;
//! Called on drag end
virtual void OnDragEnd(AZ::Vector2 position) = 0;
};
typedef AZ::EBus<UiDraggableNotifications> UiDraggableNotificationBus;
@@ -1,89 +0,0 @@
/*
* 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/ComponentBus.h>
#include <LyShine/UiBase.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiDropTargetInterface
: public AZ::ComponentBus
{
public: // types
using DropState = int;
enum
{
DropStateNormal = 0,
DropStateValid,
DropStateInvalid,
NumDropStates
};
public: // member functions
virtual ~UiDropTargetInterface() {}
//! Get the OnDrop action name
virtual const LyShine::ActionName& GetOnDropActionName() = 0;
//! Set the OnDrop action name
virtual void SetOnDropActionName(const LyShine::ActionName& actionName) = 0;
//! Called when mouse/touch enters the bounds of this drop target while dragging a UiDraggableComponent
virtual void HandleDropHoverStart(AZ::EntityId draggable) = 0;
//! Called on the currently drop hovered drop target component when mouse/touch moves outside of bounds
virtual void HandleDropHoverEnd(AZ::EntityId draggable) = 0;
//! Called when a draggable is dropped on this drop target
virtual void HandleDrop(AZ::EntityId draggable) = 0;
//! Get the state of the drop
virtual DropState GetDropState() = 0;
//! Set the state of the drop target.
//! The state affects the visual state of the drop target and can be used to indicate when it has
//! a valid draggable hovering over it.
virtual void SetDropState(DropState dropState) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiDropTargetInterface> UiDropTargetBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiDropTargetNotifications
: public AZ::ComponentBus
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const bool EnableEventQueue = true;
//////////////////////////////////////////////////////////////////////////
public: // member functions
virtual ~UiDropTargetNotifications() {}
//! Called on starting hovering over a drop target
virtual void OnDropHoverStart(AZ::EntityId draggable) = 0;
//! Called on ending hovering over a drop target
virtual void OnDropHoverEnd(AZ::EntityId draggable) = 0;
//! Called on drop
virtual void OnDrop(AZ::EntityId draggable) = 0;
};
typedef AZ::EBus<UiDropTargetNotifications> UiDropTargetNotificationBus;
@@ -1,123 +0,0 @@
/*
* 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/ComponentBus.h>
#include <LyShine/UiBase.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
//! The UI Dropdown Component is an interactable component which displays a list of options when clicked.
//! In its default state, the dropdown display a simple button, next to an arrow indicating the dropdown
//! functionality. When the arrow / option is clicked, the dropdown list appears, displaying the options available.
//! If the list is too long to be displayed, a scrollbar can be added to scroll up and down the list of options.
class UiDropdownInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiDropdownInterface() {}
//! Get the currently selected option
virtual AZ::EntityId GetValue() = 0;
//! Set the currently selected option manually
virtual void SetValue(AZ::EntityId value) = 0;
//! Get the content element this dropdown will expand
virtual AZ::EntityId GetContent() = 0;
//! Set the content element this dropdown will expand
virtual void SetContent(AZ::EntityId content) = 0;
//! Get whether this dropdown should expand automatically on hover
virtual bool GetExpandOnHover() = 0;
//! Set whether this dropdown should expand automatically on hover
virtual void SetExpandOnHover(bool expandOnHover) = 0;
//! Get how long to wait before expanding upon hover / collapsing upon exit
virtual float GetWaitTime() = 0;
//! Set how long to wait before expanding upon hover / collapsing upon exit
virtual void SetWaitTime(float waitTime) = 0;
//! Get whether this dropdown should collapse when the user clicks outside
virtual bool GetCollapseOnOutsideClick() = 0;
//! Set whether this dropdown should collapse when the user clicks outside
virtual void SetCollapseOnOutsideClick(bool collapseOnOutsideClick) = 0;
//! Get the element the dropdown content will parent to when expanded (the canvas by default)
virtual AZ::EntityId GetExpandedParentId() = 0;
//! Set the element the dropdown content will parent to when expanded
virtual void SetExpandedParentId(AZ::EntityId expandedParentId) = 0;
//! Get the text element to display to show the currently selected option
virtual AZ::EntityId GetTextElement() = 0;
//! Set the text element to display to show the currently selected option
virtual void SetTextElement(AZ::EntityId textElement) = 0;
//! Get the icon element to display to show the currently selected option
virtual AZ::EntityId GetIconElement() = 0;
//! Set the icon element to display to show the currently selected option
virtual void SetIconElement(AZ::EntityId iconElement) = 0;
//! Expand the dropdown
virtual void Expand() = 0;
//! Collapse the dropdown
virtual void Collapse() = 0;
//! Get the name of the action that is sent when the dropdown is expanded
virtual const LyShine::ActionName& GetExpandedActionName() = 0;
//! Set the name of the action that is sent when the dropdown is expanded
virtual void SetExpandedActionName(const LyShine::ActionName& actionName) = 0;
//! Get the name of the action that is sent when the dropdown is collapsed
virtual const LyShine::ActionName& GetCollapsedActionName() = 0;
//! Set the name of the action that is sent when the dropdown is collapsed
virtual void SetCollapsedActionName(const LyShine::ActionName& actionName) = 0;
//! Get the name of the action that is sent when the dropdown value is changed
virtual const LyShine::ActionName& GetOptionSelectedActionName() = 0;
//! Set the name of the action that is sent when the dropdown value is changed
virtual void SetOptionSelectedActionName(const LyShine::ActionName& actionName) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiDropdownInterface> UiDropdownBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiDropdownNotifications
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiDropdownNotifications() {}
//! Notify listeners that the dropdown was expanded
virtual void OnDropdownExpanded() {}
//! Notify listeners that the dropdown was collapsed
virtual void OnDropdownCollapsed() {}
//! Notify listeners that an option was selected
virtual void OnDropdownValueChanged([[maybe_unused]] AZ::EntityId option) {}
};
typedef AZ::EBus<UiDropdownNotifications> UiDropdownNotificationBus;
@@ -1,62 +0,0 @@
/*
* 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/ComponentBus.h>
#include <LyShine/UiBase.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
//! The UiDropdownOptionComponent is a component that is designed to work in conjunction with the
//! UiDropdownComponent. It represents any option of that dropdown that the user should be able to
//! select to update the value of the dropdown.
class UiDropdownOptionInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiDropdownOptionInterface() {}
//! Get the owning dropdown of this option
virtual AZ::EntityId GetOwningDropdown() = 0;
//! Set the owning dropdown of this option
virtual void SetOwningDropdown(AZ::EntityId owningDropdown) = 0;
//! Get the text element of this option
virtual AZ::EntityId GetTextElement() = 0;
//! Set the text element of this option
virtual void SetTextElement(AZ::EntityId textElement) = 0;
//! Get the icon element of this option
virtual AZ::EntityId GetIconElement() = 0;
//! Set the icon element of this option
virtual void SetIconElement(AZ::EntityId iconElement) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiDropdownOptionInterface> UiDropdownOptionBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiDropdownOptionNotifications
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiDropdownOptionNotifications() {}
//! Notify listeners that the dropdown option was selected
virtual void OnDropdownOptionSelected() {}
};
typedef AZ::EBus<UiDropdownOptionNotifications> UiDropdownOptionNotificationBus;
@@ -1,32 +0,0 @@
/*
* 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/ComponentBus.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Interface class that a dynamic layout component needs to implement. A dynamic layout component
//! clones a prototype element to achieve the desired number of children. The parent is resized
//! accordingly
class UiDynamicLayoutInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiDynamicLayoutInterface() {}
//! Clone a prototype element or remove cloned elements to end up with the specified number of children
virtual void SetNumChildElements(int numChildren) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiDynamicLayoutInterface> UiDynamicLayoutBus;
@@ -1,233 +0,0 @@
/*
* 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/ComponentBus.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Interface class that a dynamic scrollbox component needs to implement. A dynamic scrollbox
//! component sets up scrollbox content as a horizontal or vertical list of elements that are
//! cloned from prototype entities. Only the minimum number of entities are created for efficient
//! scrolling
class UiDynamicScrollBoxInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiDynamicScrollBoxInterface() {}
//! Refresh the content. Should be called when list size or element content has changed.
//! This will reset any cached information such as element sizes, so it is recommended
//! to use AddElementsToEnd and RemoveElementsFromFront if possible when elements vary
//! in size. AddElementsToEnd and RemoveElementsFromFront will also ensure that the
//! scroll offset is adjusted to keep the visible elements in place
virtual void RefreshContent() = 0;
//! Add elements to the end of the list.
//! Used with lists that are not divided into sections
virtual void AddElementsToEnd(int numElementsToAdd, bool scrollToEndIfWasAtEnd) = 0;
//! Remove elements from the front of the list.
//! Used with lists that are not divided into sections
virtual void RemoveElementsFromFront(int numElementsToRemove) = 0;
//! Scroll to the end of the list
virtual void ScrollToEnd() = 0;
//! Get the element index of the specified child element. Returns -1 if not found.
//! If the list is divided into sections, the index is local to the section
virtual int GetElementIndexOfChild(AZ::EntityId childElement) = 0;
//! Get the section index of the specified child element. Returns -1 if not found.
//! Used with lists that are divided into sections
virtual int GetSectionIndexOfChild(AZ::EntityId childElement) = 0;
//! Get the child element at the specified element index.
//! Used with lists that are not divided into sections
virtual AZ::EntityId GetChildAtElementIndex(int index) = 0;
//! Get the child element at the specified section index and element index.
//! Used with lists that are divided into sections
virtual AZ::EntityId GetChildAtSectionAndElementIndex(int sectionIndex, int index) = 0;
//! Get whether the list should automatically prepare and refresh its content post activation
virtual bool GetAutoRefreshOnPostActivate() = 0;
//! Set whether the list should automatically prepare and refresh its content post activation
virtual void SetAutoRefreshOnPostActivate(bool autoRefresh) = 0;
//! Get the prototype entity used for the elements
virtual AZ::EntityId GetPrototypeElement() = 0;
//! Set the prototype entity used for the elements
virtual void SetPrototypeElement(AZ::EntityId prototypeElement) = 0;
//! Get whether the elements vary in size
virtual bool GetElementsVaryInSize() = 0;
//! Set whether the elements vary in size
virtual void SetElementsVaryInSize(bool varyInSize) = 0;
//! Get whether to auto calculate the elements when they vary in size
virtual bool GetAutoCalculateVariableElementSize() = 0;
//! Set whether to auto calculate the elements when they vary in size
virtual void SetAutoCalculateVariableElementSize(bool autoCalculateSize) = 0;
//! Get the estimated size for the variable elements. If set to 0, then element sizes
//! are calculated up front rather than when becoming visible
virtual float GetEstimatedVariableElementSize() = 0;
//! Set the estimated size for the variable elements. If set to 0, then element sizes
//! are calculated up front rather than when becoming visible
virtual void SetEstimatedVariableElementSize(float estimatedSize) = 0;
//! Get whether the list is divided into sections with headers
virtual bool GetSectionsEnabled() = 0;
//! Set whether the list is divided into sections with headers
virtual void SetSectionsEnabled(bool enabled) = 0;
//! Get the prototype entity used for the headers
virtual AZ::EntityId GetPrototypeHeader() = 0;
//! Set the prototype entity used for the headers
virtual void SetPrototypeHeader(AZ::EntityId prototypeHeader) = 0;
//! Get whether headers stick to the beginning of the visible list area
virtual bool GetHeadersSticky() = 0;
//! Set whether headers stick to the beginning of the visible list area
virtual void SetHeadersSticky(bool stickyHeaders) = 0;
//! Get whether the headers vary in size
virtual bool GetHeadersVaryInSize() = 0;
//! Set whether the headers vary in size
virtual void SetHeadersVaryInSize(bool varyInSize) = 0;
//! Get whether to auto calculate the headers when they vary in size
virtual bool GetAutoCalculateVariableHeaderSize() = 0;
//! Set whether to auto calculate the headers when they vary in size
virtual void SetAutoCalculateVariableHeaderSize(bool autoCalculateSize) = 0;
//! Get the estimated size for the variable headers. If set to 0, then header sizes
//! are calculated up front rather than when becoming visible
virtual float GetEstimatedVariableHeaderSize() = 0;
//! Set the estimated size for the variable headers. If set to 0, then header sizes
//! are calculated up front rather than when becoming visible
virtual void SetEstimatedVariableHeaderSize(float estimatedSize) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiDynamicScrollBoxInterface> UiDynamicScrollBoxBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Interface class that provides data needed to display a list of elements
class UiDynamicScrollBoxDataInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiDynamicScrollBoxDataInterface() {}
//! Returns the number of elements in the list.
//! Called when the list is being constructed (in the component's InGamePostActivate or when RefreshContent is being called explicitely).
//! Used with lists that are not divided into sections
virtual int GetNumElements() { return 0; }
//! Returns the width of an element at the specified index.
//! Called when a horizontal list contains elements of varying size, and the element's "auto calculate size" option is disabled.
//! Used with lists that are not divided into sections
virtual float GetElementWidth([[maybe_unused]] int index) { return 0.0f; }
//! Returns the height of an element at the specified index.
//! Called when a vertical list contains elements of varying size, and the element's "auto calculate size" option is disabled.
//! Used with lists that are not divided into sections
virtual float GetElementHeight([[maybe_unused]] int index) { return 0.0f; }
//! Returns the number of sections in the list.
//! Called when the list is being constructed (in the component's InGamePostActivate or when RefreshContent is being called explicitely).
//! Used with lists that are divided into sections
virtual int GetNumSections() { return 0; }
//! Returns the number of elements in the specified section.
//! Called when the list is being constructed (in the component's InGamePostActivate or when RefreshContent is being called explicitely).
//! Used with lists that are divided into sections
virtual int GetNumElementsInSection([[maybe_unused]] int sectionIndex) { return 0; }
//! Returns the width of an element at the specified section.
//! Called when a horizontal list contains elements of varying size, and the element's "auto calculate size" option is disabled.
//! Used with lists that are divided into sections
virtual float GetElementInSectionWidth([[maybe_unused]] int sectionIndex, [[maybe_unused]] int elementindex) { return 0.0f; }
//! Returns the height of an element at the specified section.
//! Called when a vertical list contains elements of varying size, and the element's "auto calculate size" option is disabled.
//! Used with lists that are divided into sections
virtual float GetElementInSectionHeight([[maybe_unused]] int sectionIndex, [[maybe_unused]] int elementindex) { return 0.0f; }
//! Returns the width of a header at the specified section.
//! Called when a horizontal list contains headers of varying size, and the header's "auto calculate size" option is disabled.
//! Used with lists that are divided into sections
virtual float GetSectionHeaderWidth([[maybe_unused]] int sectionIndex) { return 0.0f; }
//! Returns the height of a header at the specified section.
//! Called when a vertical list contains elements of varying size, and the header's "auto calculate size" option is disabled.
//! Used with lists that are divided into sections
virtual float GetSectionHeaderHeight([[maybe_unused]] int sectionIndex) { return 0.0f; }
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiDynamicScrollBoxDataInterface> UiDynamicScrollBoxDataBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Interface class that listeners need to implement to receive notifications of element state
//! changes, such as when an element is about to scroll into view
class UiDynamicScrollBoxElementNotifications
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiDynamicScrollBoxElementNotifications(){}
//! Called when an element is about to become visible. Used to populate the element with data for display.
//! Used with lists that are not divided into sections
virtual void OnElementBecomingVisible([[maybe_unused]] AZ::EntityId entityId, [[maybe_unused]] int index) {}
//! Called when elements have variable sizes and are set to auto calculate.
//! Used with lists that are not divided into sections
virtual void OnPrepareElementForSizeCalculation([[maybe_unused]] AZ::EntityId entityId, [[maybe_unused]] int index) {}
//! Called when an element in a section is about to become visible. Used to populate the element with data for display
//! Used with lists that are divided into sections
virtual void OnElementInSectionBecomingVisible([[maybe_unused]] AZ::EntityId entityId, [[maybe_unused]] int sectionIndex, [[maybe_unused]] int index) {}
//! Called when elements in sections have variable sizes and are set to auto calculate
//! Used with lists that are divided into sections
virtual void OnPrepareElementInSectionForSizeCalculation([[maybe_unused]] AZ::EntityId entityId, [[maybe_unused]] int sectionIndex, [[maybe_unused]] int index) {}
//! Called when a header is about to become visible. Used to populate the header with data for display.
//! Used with lists that are divided into sections
virtual void OnSectionHeaderBecomingVisible([[maybe_unused]] AZ::EntityId entityId, [[maybe_unused]] int sectionIndex) {}
//! Called when headers have variable sizes and are set to auto calculate.
//! Used with lists that are divided into sections
virtual void OnPrepareSectionHeaderForSizeCalculation([[maybe_unused]] AZ::EntityId entityId, [[maybe_unused]] int sectionIndex) {}
};
typedef AZ::EBus<UiDynamicScrollBoxElementNotifications> UiDynamicScrollBoxElementNotificationBus;
@@ -1,53 +0,0 @@
/*
* 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/ComponentBus.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiEditorInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiEditorInterface() {}
//! Test if this entity should be visible in the Ui Canvas Editor
virtual bool GetIsVisible() = 0;
//! Set whether this entity should be visible in the Ui Canvas Editor
virtual void SetIsVisible(bool isVisible) = 0;
//! Test if this entity is selectable in the UI Canvas Editor
virtual bool GetIsSelectable() = 0;
//! Set whether this entity is selectable in the UI Canvas Editor
virtual void SetIsSelectable(bool isSelectable) = 0;
//! Test if this entity is currently selected in the UI Canvas Editor
virtual bool GetIsSelected() = 0;
//! Set whether this entity is currently selected in the UI Canvas Editor
virtual void SetIsSelected(bool isSelected) = 0;
//! Test if this entity is currently expanded in the UI Canvas Editor
virtual bool GetIsExpanded() = 0;
//! Set whether this entity is currently expanded in the UI Canvas Editor
virtual void SetIsExpanded(bool isExpanded) = 0;
//! Test if all the parents of this UI element are visible in the editor
virtual bool AreAllAncestorsVisible() = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiEditorInterface> UiEditorBus;
@@ -1,102 +0,0 @@
/*
* 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/ComponentBus.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiEditorCanvasInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiEditorCanvasInterface() {}
//! Get the snap state.
virtual bool GetIsSnapEnabled() = 0;
//! Set the snap state.
virtual void SetIsSnapEnabled(bool enabled) = 0;
//! Get the translation distance to snap to
virtual float GetSnapDistance() = 0;
//! Set the translation distance to snap to
virtual void SetSnapDistance(float distance) = 0;
//! Get the degrees of rotation to snap to
virtual float GetSnapRotationDegrees() = 0;
//! Set the degrees of rotation to snap to
virtual void SetSnapRotationDegrees(float degrees) = 0;
//! Get the positions of the horizontal guide lines (along y-axis in canvas pixels)
virtual AZStd::vector<float> GetHorizontalGuidePositions() = 0;
//! Add a horizontal guide line
virtual void AddHorizontalGuide(float position) = 0;
//! Remove the horizontal guide line at the given index
virtual void RemoveHorizontalGuide(int index) = 0;
//! Set the position of the horizontal guide line at the given index
virtual void SetHorizontalGuidePosition(int index, float position) = 0;
//! Get the positions of the vertical guide lines (along x-axis in canvas pixels)
virtual AZStd::vector<float> GetVerticalGuidePositions() = 0;
//! Add a vertical guide line
virtual void AddVerticalGuide(float position) = 0;
//! Remove the vertical guide line at the given index
virtual void RemoveVerticalGuide(int index) = 0;
//! Set the position of the vertical guide line at the given index
virtual void SetVerticalGuidePosition(int index, float position) = 0;
//! Remove all of the guides
virtual void RemoveAllGuides() = 0;
//! Get the color to draw the guide lines on this canvas
virtual AZ::Color GetGuideColor() = 0;
//! Set the color to draw the guide lines on this canvas
virtual void SetGuideColor(const AZ::Color& color) = 0;
//! Get whether the guides on this canvas are locked
virtual bool GetGuidesAreLocked() = 0;
//! Set whether the guides on this canvas are locked
virtual void SetGuidesAreLocked(bool areLocked) = 0;
//! Check the canvas for any orphaned elements. These are elements not referenced as a child by the canvas or any of its descendant elements.
virtual bool CheckForOrphanedElements() = 0;
//! Recover any orphaned elements in the canvas by placing them under a special top-level element.
virtual void RecoverOrphanedElements() = 0;
//! Remove any orphaned elements in the canvas.
virtual void RemoveOrphanedElements() = 0;
//! Update the canvas from the UI Editor
//! \param deltaTime the amount of time in seconds since the last call to this function
//! \param isInGame, true if canvas being updated in preview mode, false if being updated in edit mode
virtual void UpdateCanvasInEditorViewport(float deltaTime, bool isInGame) = 0;
//! Render the canvas in the UI Editor
//! \param isInGame, true if canvas being rendered in preview mode, false if being rendered in edit mode
//! \param viewportSize, this is the size of the viewport that the canvas is being rendered to
virtual void RenderCanvasInEditorViewport(bool isInGame, AZ::Vector2 viewportSize) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiEditorCanvasInterface> UiEditorCanvasBus;
@@ -1,43 +0,0 @@
/*
* 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/EBus/EBus.h>
#include <AzCore/Component/EntityId.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiEditorChangeNotificationInterface
: public AZ::EBusTraits
{
public: // member functions
virtual ~UiEditorChangeNotificationInterface() {}
//! Called when the transform properties in the UI editor need to be refreshed
virtual void OnEditorTransformPropertiesNeedRefresh() = 0;
//! Forces a refresh of the entire properties tree in the UI Editor.
virtual void OnEditorPropertiesRefreshEntireTree() = 0;
};
typedef AZ::EBus<UiEditorChangeNotificationInterface> UiEditorChangeNotificationBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Notify components who store directories as properties when directory contents change.
class UiEditorRefreshDirectoryNotificationInterface
: public AZ::EBusTraits
{
public: // member functions
virtual ~UiEditorRefreshDirectoryNotificationInterface() {}
//! Notify directory properties that they should refresh their contents
virtual void OnRefreshDirectory() = 0;
};
typedef AZ::EBus<UiEditorRefreshDirectoryNotificationInterface> UiEditorRefreshDirectoryNotificationBus;
@@ -1,199 +0,0 @@
/*
* 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/ComponentBus.h>
#include <AzCore/Math/Vector2.h>
#include <LyShine/UiBase.h>
namespace LyShine
{
class IRenderGraph;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiElementInterface
: public AZ::ComponentBus
{
public: // member functions
//! Deleting an element will remove it from its parent and delete its child elements and components
virtual ~UiElementInterface() {}
//! Render the element and its child elements and components, this is done by adding primitives to the render graph
//! \param renderGraph, the render graph being added to
//! \param isInGame, true if element being rendered in game (or preview), false if being render in edit mode
virtual void RenderElement(LyShine::IRenderGraph* renderGraph, bool isInGame) = 0;
//! Retrieves the identifier of this element.
virtual LyShine::ElementId GetElementId() = 0;
//! Get the name of this element
virtual LyShine::NameType GetName() = 0;
//! Get the canvas that contains this element (returns AZ::InvalidEntityId if element has no canvas)
virtual AZ::EntityId GetCanvasEntityId() = 0;
//! Get the parent element of this element (returns nullptr if element has no parent)
virtual AZ::Entity* GetParent() = 0;
//! Get the parent entity Id of this element (returns invalid Id if element has no parent)
virtual AZ::EntityId GetParentEntityId() = 0;
//! Get the number child elements of this element
virtual int GetNumChildElements() = 0;
//! Get the specified child element, index must be less than GetNumChildElements()
virtual AZ::Entity* GetChildElement(int index) = 0;
//! Get the specified child entity Id, index must be less than GetNumChildElements()
virtual AZ::EntityId GetChildEntityId(int index) = 0;
//! Get the specified child's UiElementInterface, index must be less than GetNumChildElements()
//! and the element must be fully initialized
virtual UiElementInterface* GetChildElementInterface(int index) = 0;
//! Get the index of the specified child element
virtual int GetIndexOfChild(const AZ::Entity* child) = 0;
//! Get the index of the specified child element
virtual int GetIndexOfChildByEntityId(AZ::EntityId childId) = 0;
//! Get the child elements of this element
virtual LyShine::EntityArray GetChildElements() = 0;
//! Get the child entity Ids of this element
virtual AZStd::vector<AZ::EntityId> GetChildEntityIds() = 0;
//! Create a new element that is a child of this element, this element (the parent) has ownership of the child
//! The new entity will have a UiElementComponent added but will not yet be initialized or activated
virtual AZ::Entity* CreateChildElement(const LyShine::NameType& name) = 0;
//! Destroy this element
virtual void DestroyElement() = 0;
//! Queue up element for destruction at end of frame
virtual void DestroyElementOnFrameEnd() = 0;
//! Re-parent this element to move it in the hierarchy
//! \param newParent New parent element. If null then the canvas is the parent
//! \param nextElement Element to insert this element before. If null element is put at end of child list
virtual void Reparent(AZ::Entity* newParent, AZ::Entity* insertBefore = nullptr) = 0;
//! Re-parent this element to move it in the hierarchy
//! \param newParent New parent element. If InvalidEntityId then the canvas is the parent
//! \param nextElement Element to insert this element before. If InvalidEntityId then element is put at end of child list
virtual void ReparentByEntityId(AZ::EntityId newParent, AZ::EntityId insertBefore) = 0;
//! Add this element as a child of the specified parent
//! \param newParent New parent element. If null then the canvas is the parent
//! \param index Child index where element is inserted. If -1 element is put at end of child list
virtual void AddToParentAtIndex(AZ::Entity* newParent, int index = -1) = 0;
//! Remove this element from its parent
virtual void RemoveFromParent() = 0;
//! Get the front-most child element whose bounds include the given point in canvas space
//! \return nullptr if no match
virtual AZ::Entity* FindFrontmostChildContainingPoint(AZ::Vector2 point, bool isInGame) = 0;
//! Get all the children whose bounds intersect with the given rect in canvas space
//! \return Empty EntityArray if no match
virtual LyShine::EntityArray FindAllChildrenIntersectingRect(const AZ::Vector2& bound0, const AZ::Vector2& bound1, bool isInGame) = 0;
//! Look for an entity with interactable component to handle an event at given point
virtual AZ::EntityId FindInteractableToHandleEvent(AZ::Vector2 point) = 0;
//! Look for a parent (ancestor) entity with interactable component to handle dragging starting at given point
virtual AZ::EntityId FindParentInteractableSupportingDrag(AZ::Vector2 point) = 0;
//! Return the first immediate child element with the given name or nullptr if no match
virtual AZ::Entity* FindChildByName(const LyShine::NameType& name) = 0;
//! Return the first descendant element with the given name or nullptr if no match
virtual AZ::Entity* FindDescendantByName(const LyShine::NameType& name) = 0;
//! Return the first immediate child entity Id with the given name or invalid Id if no match
virtual AZ::EntityId FindChildEntityIdByName(const LyShine::NameType& name) = 0;
//! Return the first descendant entity Id with the given name or invalid Id if no match
virtual AZ::EntityId FindDescendantEntityIdByName(const LyShine::NameType& name) = 0;
//! Return the first immediate child element with the given id or nullptr if no match
virtual AZ::Entity* FindChildByEntityId(AZ::EntityId id) = 0;
//! Return the descendant element with the given id or nullptr if no match
virtual AZ::Entity* FindDescendantById(LyShine::ElementId id) = 0;
//! recursively find descendant elements matching a predicate
//! \param result, any matching elements will be added to this array
virtual void FindDescendantElements(AZStd::function<bool(const AZ::Entity*)> predicate, LyShine::EntityArray& result) = 0;
//! recursively visit descendant elements and call the given function on them
//! The function is called first on the element and then on its children
virtual void CallOnDescendantElements(AZStd::function<void(const AZ::EntityId)> callFunction) = 0;
//! Return whether a given element is an ancestor of this element
virtual bool IsAncestor(AZ::EntityId id) = 0;
//! Enabled/disabled
virtual bool IsEnabled() = 0;
virtual void SetIsEnabled(bool isEnabled) = 0;
virtual bool GetAreElementAndAncestorsEnabled() = 0;
//! This can be used to disable the render without disabling the update/interaction.
//! This is used internally by components that temporarily disable rendering of other elements (though they preserve the existing value).
virtual bool IsRenderEnabled() = 0;
virtual void SetIsRenderEnabled(bool isRenderEnabled) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiElementInterface> UiElementBus;
// UI_ANIMATION_REVISIT This may be a temporary location
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiElementChangeNotification
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiElementChangeNotification() {}
//! Notify listeners that a property has change on this entity
virtual void UiElementPropertyChanged() {}
};
typedef AZ::EBus<UiElementChangeNotification> UiElementChangeNotificationBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiElementNotifications
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiElementNotifications() {}
//! Notify listeners that the element is being destroyed
virtual void OnUiElementBeingDestroyed() {}
//! Notify listeners that the element has been fixed up (canvas and parent for the element have been set)
virtual void OnUiElementFixup(AZ::EntityId /*canvasEntityId*/, AZ::EntityId /*parentEntityId*/) {}
//! Notify listeners that the element has been enabled or disabled (the flag on this element was changed)
virtual void OnUiElementEnabledChanged(bool /*isEnabled*/) {}
//! Notify listeners that the element has been enabled or disabled either directly or to a change to an ancestors enabled flag
virtual void OnUiElementAndAncestorsEnabledChanged(bool /*areElementAndAncestorsEnabled*/) {}
};
typedef AZ::EBus<UiElementNotifications> UiElementNotificationBus;
@@ -1,90 +0,0 @@
/*
* 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/EBus/EBus.h>
#include <AzCore/Math/Uuid.h>
#include <AzCore/Asset/AssetCommon.h>
#include <AzCore/Serialization/ObjectStream.h>
#include <AzCore/Slice/SliceComponent.h>
#include <AzCore/Math/Vector3.h>
#include <AzFramework/Entity/EntityContextBus.h>
#include <AzFramework/Entity/EntityContext.h>
// Forward declarations
namespace AZ
{
class Entity;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Bus for making requests to the UI entity context.
//! There is one UiEntityContext per UI canvas.
class UiEntityContextRequests
: public AZ::EBusTraits
{
public:
virtual ~UiEntityContextRequests() {}
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides. Accessed by EntityContextId
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
typedef AzFramework::EntityContextId BusIdType;
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
//////////////////////////////////////////////////////////////////////////
//! Creates an entity in a UI context.
//! \return a new entity
virtual AZ::Entity* CreateUiEntity(const char* name) = 0;
//! Registers an existing entity with a UI context.
virtual void AddUiEntity(AZ::Entity* entity) = 0;
//! Registers an existing set of entities with a UI context.
virtual void AddUiEntities(const AzFramework::EntityList& entities) = 0;
//! Destroys an entity in a UI context.
//! \return whether or not the entity was destroyed. A false return value signifies the entity did not belong to the UI context.
virtual bool DestroyUiEntity(AZ::EntityId entityId) = 0;
//! Clones a set of entities.
//! \param sourceEntities - the source set of entities to clone
//! \param resultEntities - the set of entities cloned from the source
virtual bool CloneUiEntities(const AZStd::vector<AZ::EntityId>& sourceEntities, AzFramework::EntityList& resultEntities) = 0;
};
using UiEntityContextRequestBus = AZ::EBus<UiEntityContextRequests>;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Bus for receiving events/notifications from the UI entity context
class UiEntityContextNotification
: public AZ::EBusTraits
{
public:
virtual ~UiEntityContextNotification() {};
//! Fired when the context is being reset.
virtual void OnContextReset() {}
//! Fired when a slice has been successfully instantiated.
virtual void OnSliceInstantiated(const AZ::Data::AssetId& /*sliceAssetId*/, const AZ::SliceComponent::SliceInstanceAddress& /*sliceAddress*/, const AzFramework::SliceInstantiationTicket& /*ticket*/) {}
//! Fired when a slice has failed to instantiate.
virtual void OnSliceInstantiationFailed(const AZ::Data::AssetId& /*sliceAssetId*/, const AzFramework::SliceInstantiationTicket& /*ticket*/) {}
//! Fired when the entity stream has been successfully loaded.
virtual void OnEntityStreamLoadSuccess() {}
//! Fired when the entity stream load has failed
virtual void OnEntityStreamLoadFailed() {}
};
using UiEntityContextNotificationBus = AZ::EBus<UiEntityContextNotification>;
@@ -1,78 +0,0 @@
/*
* 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/ComponentBus.h>
#include <AzCore/Math/Color.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiFaderInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiFaderInterface() {}
//! Get the fade value. This is a float between 0 and 1. 1 means no fade. 0 means complete fade to invisible.
virtual float GetFadeValue() = 0;
//! Set the fade value
virtual void SetFadeValue(float fade) = 0;
//! Trigger a fade animation.
//! \param targetValue The value to end the fade at [0,1]
//! \param speed Speed measured in full fade amount per second; 0 means instant
//! \param listener The listener to notify when the fade is completed or interrupted
virtual void Fade(float targetValue, float speed) = 0;
//! Get whether a fade animation is taking place
virtual bool IsFading() = 0;
//! Get the flag that indicates whether the fader should use render to texture
virtual bool GetUseRenderToTexture() = 0;
//! Set the flag that indicates whether the fader should use render to texture
virtual void SetUseRenderToTexture(bool useRenderToTexture) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiFaderInterface> UiFaderBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Interface class that listeners need to implement
class UiFaderNotifications
: public AZ::ComponentBus
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const bool EnableEventQueue = true;
//////////////////////////////////////////////////////////////////////////
public: // member functions
virtual ~UiFaderNotifications(){}
//! Called when the animation triggered by UiFaderInterface::Fade() is done.
//! The listener is automatically removed from the fader component after this is called.
virtual void OnFadeComplete() = 0;
//! Called when the animation triggered by UiFaderInterface::Fade() is interrupted.
//! The listener is automatically removed from the fader component after this is called.
virtual void OnFadeInterrupted() = 0;
//! Called when the fader component is destroyed
virtual void OnFaderDestroyed() = 0;
};
typedef AZ::EBus<UiFaderNotifications> UiFaderNotificationBus;
@@ -1,172 +0,0 @@
/*
* 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/ComponentBus.h>
#include <AzCore/Math/Vector2.h>
#include <AzFramework/Entity/EntityContextBus.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Bus that defines the interface for flipbook animations.
//!
//! A flipbook animation component exists on an entity that has an image component
//! and interacts with the image bus to achieve its functionality (such as by
//! manipulating sprite-sheet indices).
class UiFlipbookAnimationInterface
: public AZ::ComponentBus
{
public: // Types
//! Defines the looping behavior when playing back a flipbook animation.
enum class LoopType
{
None, //!< No looping behavior
Linear, //!< When end frame is reached, next frame will be the loop start frame
PingPong //!< When end frame is reached, next frame will be the previous frame,
//!< continuing in reverse until the start frame is reached.
};
//! Units of speed for framerate
enum class FramerateUnits
{
FPS, //!< Framerate of animation
SecondsPerFrame, //!< Number of seconds to wait before playing next frame
};
public:
virtual ~UiFlipbookAnimationInterface() {}
//! Start the animation sequence, beginning at the start frame.
//!
//! If a LoopType other than None has been set, the animation won't stop
//! unless explicitly done so (or the image is unloaded/destroyed).
virtual void Start() = 0;
//! Stops animation playback.
virtual void Stop() = 0;
//! \return True if the flipbook animation is currently playing, false otherwise.
virtual bool IsPlaying() = 0;
//! \return The starting frame of the animation.
virtual AZ::u32 GetStartFrame() = 0;
//! Sets the starting frame of the animation.
virtual void SetStartFrame(AZ::u32 startFrame) = 0;
//! \return End frame of the animation.
virtual AZ::u32 GetEndFrame() = 0;
//! Sets the ending frame of the animation.
virtual void SetEndFrame(AZ::u32 endFrame) = 0;
//! \return The current frame of the animation that's being rendered.
virtual AZ::u32 GetCurrentFrame() = 0;
//! Sets the current frame of the animation to render.
//!
//! If the animation is currently playing, this will effectively "skip"
//! to the given frame.
virtual void SetCurrentFrame(AZ::u32 currentFrame) = 0;
//! This frame is distinct from the start frame and allows a "lead in"
//! seqence of frames to play leading up to the looping animation. The
//! frames that occur prior to the loop start frame will only play once.
//!
//! \return The frame to start the loop from.
virtual AZ::u32 GetLoopStartFrame() = 0;
//! Sets the starting frame for looping sequences.
virtual void SetLoopStartFrame(AZ::u32 loopStartFrame) = 0;
//! \return The LoopType of the flipbook animation.
virtual LoopType GetLoopType() = 0;
//! Sets the LoopType of the flipbook animation.
virtual void SetLoopType(LoopType loopType) = 0;
//! Gets the speed used to determine when to transition to the next frame.
//!
//! Framerate is defined relative to unit of time, specified by FramerateUnits.
//!
//! See GetFramerateUnit, SetFramerateUnit.
virtual float GetFramerate() = 0;
//! Sets the speed used to determine when to transition to the next frame.
//!
//! Framerate is defined relative to unit of time, specified by FramerateUnits.
//!
//! See GetFramerateUnit, SetFramerateUnit.
virtual void SetFramerate(float framerate) = 0;
//! Gets the framerate unit.
virtual FramerateUnits GetFramerateUnit() = 0;
//! Sets the framerate unit.
virtual void SetFramerateUnit(FramerateUnits framerateUnit) = 0;
//! Gets the delay (in seconds) before playing the flipbook (applied only once during playback).
virtual float GetStartDelay() = 0;
//! Sets the delay (in seconds) before playing the flipbook (applied only once during playback).
virtual void SetStartDelay(float startDelay) = 0;
//! Gets the delay (in seconds) before playing the loop sequence.
virtual float GetLoopDelay() = 0;
//! Sets the delay (in seconds) before playing the loop sequence.
virtual void SetLoopDelay(float loopDelay) = 0;
//! Gets the delay (in seconds) before playing the reverse loop sequence (PingPong loop types only).
virtual float GetReverseDelay() = 0;
//! Sets the delay (in seconds) before playing the reverse loop sequence (PingPong loop types only).
virtual void SetReverseDelay(float reverseDelay) = 0;
//! Returns true if the animation will begin playing when the component activates, false otherwise.
virtual bool GetIsAutoPlay() = 0;
//! Sets whether the animation will automatically begin playing.
//!
//! This flag is ignored after the component has activated.
virtual void SetIsAutoPlay(bool isAutoPlay) = 0;
};
using UiFlipbookAnimationBus = AZ::EBus<UiFlipbookAnimationInterface>;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Allows listeners to be aware of events, like loop completion, occurring.
class UiFlipbookAnimationNotifications
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiFlipbookAnimationNotifications() {}
//! Notify listeners when the animation starts
virtual void OnAnimationStarted() {}
//! Notify listeners when the animation stops
virtual void OnAnimationStopped() {}
//! Notify listeners when the current loop sequence has completed
//!
//! This will only trigger for LoopType sequences other than None.
//!
//! For Linear LoopType, this will trigger on the last frame of the last
//! frame of the loop.
//!
//! For PingPong LoopType, this will trigger on the last frame of the
//! loop sequence before reversing the loop direction.
virtual void OnLoopSequenceCompleted() {}
};
typedef AZ::EBus<UiFlipbookAnimationNotifications> UiFlipbookAnimationNotificationsBus;
@@ -1,106 +0,0 @@
/*
* 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/EBus/EBus.h>
#include <AzCore/Math/Uuid.h>
#include <AzCore/Asset/AssetCommon.h>
#include <AzCore/Serialization/ObjectStream.h>
#include <AzCore/Serialization/IdUtils.h>
#include <AzCore/Slice/SliceComponent.h>
#include <AzCore/Math/Vector2.h>
#include <AzFramework/Entity/EntityContextBus.h>
#include <AzFramework/Entity/EntityContext.h>
// Forward declarations
namespace AZ
{
class Entity;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Bus for making requests to the UI game entity context.
class UiGameEntityContextRequests
: public AZ::EBusTraits
{
public:
virtual ~UiGameEntityContextRequests() {}
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides. Accessed by EntityContextId
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
typedef AzFramework::EntityContextId BusIdType;
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
//////////////////////////////////////////////////////////////////////////
//! Instantiates a dynamic slice asynchronously.
//! \return a ticket identifying the spawn request.
//! Callers can immediately subscribe to the SliceInstantiationResultBus for this ticket
//! to receive result for this specific request.
virtual AzFramework::SliceInstantiationTicket InstantiateDynamicSlice(
const AZ::Data::Asset<AZ::Data::AssetData>& /*sliceAsset*/,
const AZ::Vector2& /*position*/,
bool /*isViewportPosition*/,
AZ::Entity* /*parent*/,
const AZ::IdUtils::Remapper<AZ::EntityId>::IdMapper& /*customIdMapper*/)
{ return AzFramework::SliceInstantiationTicket(); }
};
using UiGameEntityContextBus = AZ::EBus<UiGameEntityContextRequests>;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Bus for receiving notifications from the UI game entity context component.
class UiGameEntityContextNotifications
: public AZ::EBusTraits
{
public:
virtual ~UiGameEntityContextNotifications() = default;
/// Fired when a slice has been successfully instantiated.
virtual void OnSliceInstantiated(const AZ::Data::AssetId& /*sliceAssetId*/,
const AZ::SliceComponent::SliceInstanceAddress& /*instance*/,
const AzFramework::SliceInstantiationTicket& /*ticket*/) {}
/// Fired when a slice asset could not be instantiated.
virtual void OnSliceInstantiationFailed(const AZ::Data::AssetId& /*sliceAssetId*/,
const AzFramework::SliceInstantiationTicket& /*ticket*/) {}
};
using UiGameEntityContextNotificationBus = AZ::EBus<UiGameEntityContextNotifications>;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Bus for receiving notifications from the UI game entity context component. This bus is used
//! by the UiSpawnerComponent that depends on the UiGameEntityContext fixing entities up before
//! it sends out notifications to listeners on the UiSpawnerNotificationBus
class UiGameEntityContextSliceInstantiationResults
: public AZ::EBusTraits
{
public:
virtual ~UiGameEntityContextSliceInstantiationResults() = default;
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides. Addressed by SliceInstantiationTicket
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
typedef AzFramework::SliceInstantiationTicket BusIdType;
//////////////////////////////////////////////////////////////////////////
//! Signals that a slice was successfully instantiated prior to entity registration.
virtual void OnEntityContextSlicePreInstantiate(const AZ::Data::AssetId& /*sliceAssetId*/, const AZ::SliceComponent::SliceInstanceAddress& /*sliceAddress*/) {}
//! Signals that a slice was successfully instantiated after entity registration.
virtual void OnEntityContextSliceInstantiated(const AZ::Data::AssetId& /*sliceAssetId*/, const AZ::SliceComponent::SliceInstanceAddress& /*sliceAddress*/) {}
//! Signals that a slice could not be instantiated.
virtual void OnEntityContextSliceInstantiationFailed(const AZ::Data::AssetId& /*sliceAssetId*/) {}
};
using UiGameEntityContextSliceInstantiationResultsBus = AZ::EBus<UiGameEntityContextSliceInstantiationResults>;
@@ -1,168 +0,0 @@
/*
* 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/ComponentBus.h>
#include <AzCore/Math/Color.h>
class ISprite;
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiImageInterface
: public AZ::ComponentBus
{
public: // types
enum class ImageType : int32_t
{
Stretched, //!< the texture is stretched to fit the rect without maintaining aspect ratio
Sliced, //!< the texture is sliced such that center stretches and the edges do not
Fixed, //!< the texture is not stretched at all
Tiled, //!< the texture is tiled (repeated)
StretchedToFit, //!< the texture is scaled to fit the rect while maintaining aspect ratio
StretchedToFill //!< the texture is scaled to fill the rect while maintaining aspect ratio
};
enum class SpriteType : int32_t
{
SpriteAsset,
RenderTarget,
};
enum class FillType : int32_t
{
None, //!< the image is displayed fully filled
Linear, //!< the image is filled linearly from one edge to the opposing edge
Radial, //!< the image is filled radially around the center
RadialCorner, //!< the image is filled radially around a corner
RadialEdge, //!< the image is filled radially around the midpoint of an edge
};
enum class FillCornerOrigin : int32_t
{
TopLeft,
TopRight,
BottomRight,
BottomLeft,
};
enum class FillEdgeOrigin : int32_t
{
Left,
Top,
Right,
Bottom,
};
public: // member functions
virtual ~UiImageInterface() {}
//! Gets the image color tint
virtual AZ::Color GetColor() = 0;
//! Sets the image color tint
virtual void SetColor(const AZ::Color& color) = 0;
//! Gets the image color alpha
virtual float GetAlpha() = 0;
//! Sets the image color alpha
virtual void SetAlpha(float color) = 0;
//! Gets the sprite for this element
virtual ISprite* GetSprite() = 0;
//! Sets the sprite for this element
virtual void SetSprite(ISprite* sprite) = 0;
//! Gets the source location of the image to be displayed by the element
virtual AZStd::string GetSpritePathname() = 0;
//! Sets the source location of the image to be displayed by the element
virtual void SetSpritePathname(AZStd::string spritePath) = 0;
//! Sets the source location of the image to be displayed by the element only
//! if the sprite asset exists. Otherwise, the current sprite remains unchanged.
//! Returns whether the sprite changed
virtual bool SetSpritePathnameIfExists(AZStd::string spritePath) = 0;
//! Gets the name of the render target
virtual AZStd::string GetRenderTargetName() = 0;
//! Sets the name of the render target
virtual void SetRenderTargetName(AZStd::string renderTargetName) = 0;
//! Gets whether the render target is in sRGB color space
virtual bool GetIsRenderTargetSRGB() = 0;
//! Sets whether the render target is in sRGB color space
virtual void SetIsRenderTargetSRGB(bool isSRGB) = 0;
//! Gets the type of the sprite
virtual SpriteType GetSpriteType() = 0;
//! Sets the type of the sprite
virtual void SetSpriteType(SpriteType spriteType) = 0;
//! Gets the type of the image
virtual ImageType GetImageType() = 0;
//! Sets the type of the image
virtual void SetImageType(ImageType imageType) = 0;
//! Gets the fill type for the image
virtual FillType GetFillType() = 0;
//! Sets the fill type for the image
virtual void SetFillType(FillType fillType) = 0;
//! Gets the fill amount for the image in the range [0,1]
virtual float GetFillAmount() = 0;
//! Sets the fill amount for the image in the range [0,1]
virtual void SetFillAmount(float fillAmount) = 0;
//! Gets the start angle for radial fill, measured clockwise in degrees from straight up
virtual float GetRadialFillStartAngle() = 0;
//! Sets the start angle for radial fill, measured clockwise in degrees from straight up
virtual void SetRadialFillStartAngle(float radialFillStartAngle) = 0;
//! Gets the corner fill origin
virtual FillCornerOrigin GetCornerFillOrigin() = 0;
//! Sets the corner fill origin
virtual void SetCornerFillOrigin(FillCornerOrigin cornerOrigin) = 0;
//! Gets the edge fill origin
virtual FillEdgeOrigin GetEdgeFillOrigin() = 0;
//! Sets the edge fill origin
virtual void SetEdgeFillOrigin(FillEdgeOrigin edgeOrigin) = 0;
//! Gets whether the image is filled clockwise
virtual bool GetFillClockwise() = 0;
//! Sets whether the image is filled clockwise
virtual void SetFillClockwise(bool fillClockwise) = 0;
//! Gets whether the center of a sliced image is filled
virtual bool GetFillCenter() = 0;
//! Sets whether the center of a sliced image is filled
virtual void SetFillCenter(bool fillCenter) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiImageInterface> UiImageBus;
@@ -1,42 +0,0 @@
/*
* 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/ComponentBus.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiImageSequenceInterface
: public AZ::ComponentBus
{
public: // types
enum class ImageType : int32_t
{
Stretched, //!< the texture is stretched to fit the rect without maintaining aspect ratio
Fixed, //!< the texture is not stretched at all
StretchedToFit, //!< the texture is scaled to fit the rect while maintaining aspect ratio
StretchedToFill //!< the texture is scaled to fill the rect while maintaining aspect ratio
};
public: // member functions
virtual ~UiImageSequenceInterface() {}
//! Gets the type of the image
virtual ImageType GetImageType() = 0;
//! Sets the type of the image
virtual void SetImageType(ImageType imageType) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiImageSequenceInterface> UiImageSequenceBus;
@@ -1,45 +0,0 @@
/*
* 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/ComponentBus.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Defines an interface for working with indexable image types, such as sprite-sheets or image sequences.
class UiIndexableImageInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiIndexableImageInterface() {}
//! Sets the index of the image to display
virtual void SetImageIndex(AZ::u32 index) = 0;
//! Gets the index of the image to display
virtual const AZ::u32 GetImageIndex() = 0;
//! Gets the number of indices for this image.
virtual const AZ::u32 GetImageIndexCount() = 0;
//! Given an index, return its alias (if defined)
virtual AZStd::string GetImageIndexAlias(AZ::u32 index) = 0;
//! Given an index, set an alias for it
virtual void SetImageIndexAlias(AZ::u32 index, const AZStd::string& alias) = 0;
//! Given an alias, return the index that corresponds to it
virtual AZ::u32 GetImageIndexFromAlias(const AZStd::string& alias) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiIndexableImageInterface> UiIndexableImageBus;
@@ -1,37 +0,0 @@
/*
* 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/ComponentBus.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiInitializationInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiInitializationInterface() {}
//! Initialize the component after it has been created as part of a set of entities.
//! I.e. After a group of entities has been created and activated from a load or clone operation
//! in the game (not in the UI Editor) this is called on each created element.
//! This allows the component to perform operations that rely on related entities being
//! activated.
virtual void InGamePostActivate() = 0;
public: // static member functions
static const char* GetUniqueName() { return "UiInitializationInterface"; }
public: // static member data
//! Multiple components on an entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
};
typedef AZ::EBus<UiInitializationInterface> UiInitializationBus;
@@ -1,85 +0,0 @@
/*
* 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/ComponentBus.h>
#include <LyShine/UiBase.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
// This bus allows the get/set of properties for a group of actions that many interactable components
// implement.
// It is separate from UiInteractableBus because UiInteractableBus is part of a core system for how
// the UI canvas communincates with any UI element that wants user input. Sometimes UI components
// want input because they are part of a 2D puzzle for example but they do not always want to have
// to support the standard action changes.
class UiInteractableActionsInterface
: public AZ::ComponentBus
{
public: // types
typedef AZStd::function<void(AZ::EntityId)> OnActionCallback;
public: // member functions
virtual ~UiInteractableActionsInterface() {}
//! Get the hover start action name
virtual const LyShine::ActionName& GetHoverStartActionName() = 0;
//! Set the hover start action name
virtual void SetHoverStartActionName(const LyShine::ActionName& actionName) = 0;
//! Get the hover end action name
virtual const LyShine::ActionName& GetHoverEndActionName() = 0;
//! Set the hover end action name
virtual void SetHoverEndActionName(const LyShine::ActionName& actionName) = 0;
//! Get the pressed action name
virtual const LyShine::ActionName& GetPressedActionName() = 0;
//! Set the pressed action name
virtual void SetPressedActionName(const LyShine::ActionName& actionName) = 0;
//! Get the released action name
virtual const LyShine::ActionName& GetReleasedActionName() = 0;
//! Set the released action name
virtual void SetReleasedActionName(const LyShine::ActionName& actionName) = 0;
//! Get the hover start callback
virtual OnActionCallback GetHoverStartActionCallback() = 0;
//! Set the hover start callback
virtual void SetHoverStartActionCallback(OnActionCallback onActionCallback) = 0;
//! Get the hover end callback
virtual OnActionCallback GetHoverEndActionCallback() = 0;
//! Set the hover end callback
virtual void SetHoverEndActionCallback(OnActionCallback onActionCallback) = 0;
//! Get the pressed callback
virtual OnActionCallback GetPressedActionCallback() = 0;
//! Set the pressed callback
virtual void SetPressedActionCallback(OnActionCallback onActionCallback) = 0;
//! Get the release callback
virtual OnActionCallback GetReleasedActionCallback() = 0;
//! Set the release callback
virtual void SetReleasedActionCallback(OnActionCallback onActionCallback) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiInteractableActionsInterface> UiInteractableActionsBus;
@@ -1,180 +0,0 @@
/*
* 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/ComponentBus.h>
#include <AzCore/Math/Vector2.h>
#include <AzFramework/Input/Channels/InputChannelDigitalWithSharedModifierKeyStates.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiInteractableInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiInteractableInterface() {}
//! Check whether this component can handle the event at the given location
virtual bool CanHandleEvent(AZ::Vector2 point) = 0;
//! Called on an interactable component when a pressed event is received over it
//! \param point, the point at which the event occurred (viewport space)
//! \param shouldStayActive, output - true if the interactable wants to become the active element for the canvas
//! \return true if the interactable handled the event
virtual bool HandlePressed(AZ::Vector2 point, bool& shouldStayActive) = 0;
//! Called on the currently pressed interactable component when a release event is received
//! \param point, the point at which the event occurred (viewport space)
//! \return true if the interactable handled the event
virtual bool HandleReleased(AZ::Vector2 point) = 0;
//! Called on an interactable component when a multi-touch pressed event is received over it
//! \param point, the point at which the event occurred (viewport space)
//! \param multiTouchIndex, the index of the multi-touch (the 'primary' touch with index 0 is sent to HandlePressed)
//! \return true if the interactable handled the event
virtual bool HandleMultiTouchPressed(AZ::Vector2 point, int multiTouchIndex) = 0;
//! Called on the currently pressed interactable component when a multi-touch release event is received
//! \param point, the point at which the event occurred (viewport space)
//! \param multiTouchIndex, the index of the multi-touch (the 'primary' touch with index 0 is sent to HandlePressed)
//! \return true if the interactable handled the event
virtual bool HandleMultiTouchReleased(AZ::Vector2 point, int multiTouchIndex) = 0;
//! Called on an interactable component when an enter pressed event is received
//! \param shouldStayActive, output - true if the interactable wants to become the active element for the canvas
//! \return true if the interactable handled the event
virtual bool HandleEnterPressed([[maybe_unused]] bool& shouldStayActive) { return false; }
//! Called on the currently pressed interactable component when an enter released event is received
//! \return true if the interactable handled the event
virtual bool HandleEnterReleased() { return false; }
//! Called when the interactable was navigated to via gamepad/keyboard, and auto activation is enabled on the interactable
//! \return true if the interactable handled the event
virtual bool HandleAutoActivation() { return false; }
//! Called on the currently active interactable component when text input is received
//! \return true if the interactable handled the event
virtual bool HandleTextInput([[maybe_unused]] const AZStd::string& textUTF8) { return false; };
//! Called on the currently active interactable component when input is received
//! \return true if the interactable handled the event
virtual bool HandleKeyInputBegan([[maybe_unused]] const AzFramework::InputChannel::Snapshot& inputSnapshot, [[maybe_unused]] AzFramework::ModifierKeyMask activeModifierKeys) { return false; }
//! Called on the currently active interactable component when a mouse/touch position event is received
//! \param point, the current mouse/touch position (viewport space)
virtual void InputPositionUpdate([[maybe_unused]] AZ::Vector2 point) {};
//! Called on the currently pressed interactable component when a multi-touch position event is received
//! \param point, the current mouse/touch position (viewport space)
//! \param multiTouchIndex, the index of the multi-touch (the 'primary' touch with index 0 is sent to HandlePressed)
virtual void MultiTouchPositionUpdate([[maybe_unused]] AZ::Vector2 point, [[maybe_unused]] int multiTouchIndex) {};
//! Returns true if this interactable supports taking active status when a drag is started on a child
//! interactble AND the given drag startPoint would be a valid drag start point
//! \param point, the start point of the drag (which would be on a child interactable) (viewport space)
virtual bool DoesSupportDragHandOff([[maybe_unused]] AZ::Vector2 startPoint) { return false; }
//! Called on a parent of the currently active interactable element to allow interactables that
//! contain other interactables to support drags that start on the child.
//! If this return true the hand-off occured and the caller will no longer be considered the
//! active interactable by the canvas.
//! \param currentActiveInteractable, the child element that is the currently active interactable
//! \param startPoint, the start point of the potential drag (viewport space)
//! \param currentPoint, the current points of the potential drag (viewport space)
virtual bool OfferDragHandOff([[maybe_unused]] AZ::EntityId currentActiveInteractable, [[maybe_unused]] AZ::Vector2 startPoint, [[maybe_unused]] AZ::Vector2 currentPoint, [[maybe_unused]] float dragThreshold) { return false; };
//! Called on the currently active interactable component when the active interactable changes
virtual void LostActiveStatus() {};
//! Called when mouse/touch enters the bounds of this interactable
virtual void HandleHoverStart() = 0;
//! Called on the currently hovered interactable component when mouse/touch moves outside of bounds
virtual void HandleHoverEnd() = 0;
//! Called when a descendant of the interactable becomes the hover interactable by being navigated to
virtual void HandleDescendantReceivedHoverByNavigation([[maybe_unused]] AZ::EntityId descendantEntityId) {};
//! Called when the interactable becomes the hover interactable by being navigated to from one of its descendants
virtual void HandleReceivedHoverByNavigatingFromDescendant([[maybe_unused]] AZ::EntityId descendantEntityId) {};
//! Query whether the interactable is currently pressed
virtual bool IsPressed() { return false; }
//! Enable/disable event handling
virtual bool IsHandlingEvents() { return true; }
virtual void SetIsHandlingEvents([[maybe_unused]] bool isHandlingEvents) {}
//! Enable/disable multi-touch event handling
virtual bool IsHandlingMultiTouchEvents() { return true; }
virtual void SetIsHandlingMultiTouchEvents([[maybe_unused]] bool isHandlingMultiTouchEvents) {}
//! Get/set whether the interactable automatically becomes active when navigated to via gamepad/keyboard
virtual bool GetIsAutoActivationEnabled() = 0;
virtual void SetIsAutoActivationEnabled(bool isEnabled) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiInteractableInterface> UiInteractableBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiInteractableActiveNotifications
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiInteractableActiveNotifications() {}
//! Notify listener that this interactable is no longer active
virtual void ActiveCancelled() {}
//! Notify listener that this interactable has given up active status to a new interactable
virtual void ActiveChanged([[maybe_unused]] AZ::EntityId m_newActiveInteractable, [[maybe_unused]] bool shouldStayActive) {}
};
typedef AZ::EBus<UiInteractableActiveNotifications> UiInteractableActiveNotificationBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
//! Interface class that listeners need to implement in order to get notifications when actions are
//! triggered
class UiInteractableNotifications
: public AZ::ComponentBus
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const bool EnableEventQueue = true;
//////////////////////////////////////////////////////////////////////////
public: // member functions
virtual ~UiInteractableNotifications(){}
//! Called on hover start
virtual void OnHoverStart() {};
//! Called on hover end
virtual void OnHoverEnd() {};
//! Called on pressed
virtual void OnPressed() {};
//! Called on released
virtual void OnReleased() {};
//! Called on receiving hover by being navigated to from a descendant
virtual void OnReceivedHoverByNavigatingFromDescendant([[maybe_unused]] AZ::EntityId descendantEntityId) {};
};
typedef AZ::EBus<UiInteractableNotifications> UiInteractableNotificationBus;
@@ -1,111 +0,0 @@
/*
* 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/ComponentBus.h>
#include <LyShine/UiBase.h>
#include <AzCore/Math/Color.h>
class ISprite;
////////////////////////////////////////////////////////////////////////////////////////////////////
// This bus allows the get/set of properties for a group of states that many interactable components
// implement.
// It is separate from UiInteractableBus because UiInteractableBus is part of a core system for how
// the UI canvas communincates with any UI element that wants user input. Sometimes UI components
// want input because they are part of a 2D puzzle for example but they do not always want to have
// to support the standard state changes.
class UiInteractableStatesInterface
: public AZ::ComponentBus
{
public: // types
//! The different visual states that an interactable can be in. An enum class is avoided so that
//! derived components of UiInteractableComponent can extend with additional states.
using State = int;
enum
{
StateNormal = 0,
StateHover,
StatePressed,
StateDisabled,
NumStates
};
public: // member functions
virtual ~UiInteractableStatesInterface() {}
//! Set the color to be used for the given target when the interactable is in the given state
//! If the interactable already has a color action for this state/target combination then replaces it
virtual void SetStateColor(State state, AZ::EntityId target, const AZ::Color& color) = 0;
//! Get the color to be used for the given target when the interactable is in the given state
//! \return the color to be used for the given target when the interactable is in the given state
virtual AZ::Color GetStateColor(State state, AZ::EntityId target) = 0;
//! Get whether the interactable has a color action for this state/target combination
//! \return true if the interactable has a color action for this state/target combination
virtual bool HasStateColor(State state, AZ::EntityId target) = 0;
//! Set the alpha to be used for the given target when the interactable is in the given state
//! If the interactable already has an alpha action for this state/target combination then replaces it
virtual void SetStateAlpha(State state, AZ::EntityId target, float alpha) = 0;
//! Get the alpha to be used for the given target when the interactable is in the given state
//! \return the alpha to be used for the given target when the interactable is in the given state
virtual float GetStateAlpha(State state, AZ::EntityId target) = 0;
//! Get whether the interactable has an alpha action for this state/target combination
//! \return true if the interactable has an alpha action for this state/target combination
virtual bool HasStateAlpha(State state, AZ::EntityId target) = 0;
//! Set the sprite to be used for the given target when the interactable is in the given state
//! If the interactable already has a sprite action for this state/target combination then replaces it
virtual void SetStateSprite(State state, AZ::EntityId target, ISprite* sprite) = 0;
//! Get the sprite to be used for the given target when the interactable is in the given state
//! \return the sprite to be used for the given target when the interactable is in the given state
virtual ISprite* GetStateSprite(State state, AZ::EntityId target) = 0;
//! Set the sprite path to be used for the given target when the interactable is in the given state
//! If the interactable already has a sprite action for this state/target combination then replaces it
virtual void SetStateSpritePathname(State state, AZ::EntityId target, const AZStd::string& spritePath) = 0;
//! Get the sprite path to be used for the given target when the interactable is in the given state
//! \return the sprite path to be used for the given target when the interactable is in the given state
virtual AZStd::string GetStateSpritePathname(State state, AZ::EntityId target) = 0;
//! Get whether the interactable has a sprite action for this state/target combination
//! \return true if the interactable has a sprite action for this state/target combination
virtual bool HasStateSprite(State state, AZ::EntityId target) = 0;
//! Set the font to be used for the given target when the interactable is in the given state
//! If the interactable already has a font action for this state/target combination then replaces it
virtual void SetStateFont(State state, AZ::EntityId target, const AZStd::string& fontPathname, unsigned int fontEffectIndex) = 0;
//! Get the font path to be used for the given target when the interactable is in the given state
//! \return the font path to be used for the given target when the interactable is in the given state
virtual AZStd::string GetStateFontPathname(State state, AZ::EntityId target) = 0;
//! Get the font effect to be used for the given target when the interactable is in the given state
//! \return the font effect to be used for the given target when the interactable is in the given state
virtual unsigned int GetStateFontEffectIndex(State state, AZ::EntityId target) = 0;
//! Get whether the interactable has a font action for this state/target combination
//! \return true if the interactable has a font action for this state/target combination
virtual bool HasStateFont(State state, AZ::EntityId target) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiInteractableStatesInterface> UiInteractableStatesBus;
@@ -1,34 +0,0 @@
/*
* 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/ComponentBus.h>
#include <AzCore/Math/Vector2.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiInteractionMaskInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiInteractionMaskInterface() {}
//! Check whether this element is masking the given point
virtual bool IsPointMasked(AZ::Vector2 point) = 0;
public: // static member functions
static const char* GetUniqueName() { return "UIInteractionMaskInterface"; }
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiInteractionMaskInterface> UiInteractionMaskBus;
@@ -1,89 +0,0 @@
/*
* 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/ComponentBus.h>
#include <AzCore/Math/Vector2.h>
#include <LyShine/Bus/UiTransformBus.h>
#include <LyShine/IDraw2d.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiLayoutInterface
: public AZ::ComponentBus
{
public: // types
//! Horizontal order used by layout components
enum class HorizontalOrder
{
LeftToRight,
RightToLeft
};
//! Vertical order used by layout components
enum class VerticalOrder
{
TopToBottom,
BottomToTop
};
//! Padding (in pixels) inside the edges of an element
struct Padding
{
AZ_TYPE_INFO(Padding, "{DE5C18B0-4214-4A37-B590-8D45CC450A96}")
Padding()
: m_left(0)
, m_top(0)
, m_right(0)
, m_bottom(0) {}
int m_left;
int m_right;
int m_top;
int m_bottom;
};
public: // member functions
virtual ~UiLayoutInterface() {}
//! Get whether this layout component uses layout cells to calculate its layout
virtual bool IsUsingLayoutCellsToCalculateLayout() = 0;
//! Get whether this layout component should bypass the default layout cell values calculated by its children
virtual bool GetIgnoreDefaultLayoutCells() = 0;
//! Set whether this layout component should bypass the default layout cell values calculated by its children
virtual void SetIgnoreDefaultLayoutCells(bool ignoreDefaultLayoutCells) = 0;
//! Get the horizontal child alignment
virtual IDraw2d::HAlign GetHorizontalChildAlignment() = 0;
//! Set the horizontal child alignment
virtual void SetHorizontalChildAlignment(IDraw2d::HAlign alignment) = 0;
//! Get the vertical child alignment
virtual IDraw2d::VAlign GetVerticalChildAlignment() = 0;
//! Set the vertical child alignment
virtual void SetVerticalChildAlignment(IDraw2d::VAlign alignment) = 0;
//! Find out whether this layout component is currently overriding the transform of the specified element.
virtual bool IsControllingChild(AZ::EntityId childId) = 0;
//! Get the size the element needs to be to fit a specified number of child elements of a certain size
virtual AZ::Vector2 GetSizeToFitChildElements(const AZ::Vector2& childElementSize, int numChildElements) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiLayoutInterface> UiLayoutBus;
@@ -1,75 +0,0 @@
/*
* 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/ComponentBus.h>
#include <LyShine/UiLayoutCellBase.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiLayoutCellInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiLayoutCellInterface() {}
//! Get the overridden min width. LyShine::UiLayoutCellUnspecifiedSize means it has not been overridden
virtual float GetMinWidth() = 0;
//! Set the overridden min width. LyShine::UiLayoutCellUnspecifiedSize means don't override
virtual void SetMinWidth(float width) = 0;
//! Get the overridden min height. LyShine::UiLayoutCellUnspecifiedSize means it has not been overridden
virtual float GetMinHeight() = 0;
//! Set the overridden min height. LyShine::UiLayoutCellUnspecifiedSize means don't override
virtual void SetMinHeight(float height) = 0;
//! Get the overridden target width. LyShine::UiLayoutCellUnspecifiedSize means it has not been overridden
virtual float GetTargetWidth() = 0;
//! Set the overridden target width. LyShine::UiLayoutCellUnspecifiedSize means don't override
virtual void SetTargetWidth(float width) = 0;
//! Get the overridden target height. LyShine::UiLayoutCellUnspecifiedSize means it has not been overridden
virtual float GetTargetHeight() = 0;
//! Set the overridden target height. LyShine::UiLayoutCellUnspecifiedSize means don't override
virtual void SetTargetHeight(float height) = 0;
//! Get the overridden max width. LyShine::UiLayoutCellUnspecifiedSize means it has not been overridden
virtual float GetMaxWidth() = 0;
//! Set the overridden max width. LyShine::UiLayoutCellUnspecifiedSize means don't override
virtual void SetMaxWidth(float width) = 0;
//! Get the overridden max height. LyShine::UiLayoutCellUnspecifiedSize means it has not been overridden
virtual float GetMaxHeight() = 0;
//! Set the overridden max height. LyShine::UiLayoutCellUnspecifiedSize means don't override
virtual void SetMaxHeight(float height) = 0;
//! Get the overridden extra width ratio. LyShine::UiLayoutCellUnspecifiedSize means it has not been overridden
virtual float GetExtraWidthRatio() = 0;
//! Set the overridden extra width ratio. LyShine::UiLayoutCellUnspecifiedSize means don't override
virtual void SetExtraWidthRatio(float width) = 0;
//! Get the overridden extra height ratio. LyShine::UiLayoutCellUnspecifiedSize means it has not been overridden
virtual float GetExtraHeightRatio() = 0;
//! Set the overridden extra height ratio. LyShine::UiLayoutCellUnspecifiedSize means don't override
virtual void SetExtraHeightRatio(float height) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiLayoutCellInterface> UiLayoutCellBus;
@@ -1,47 +0,0 @@
/*
* 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/ComponentBus.h>
#include <LyShine/UiLayoutCellBase.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiLayoutCellDefaultInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiLayoutCellDefaultInterface() {}
//! Get the minimum width
virtual float GetMinWidth() = 0;
//! Get the minimum height
virtual float GetMinHeight() = 0;
//! Get the target width
//! \param maxWidth A width that the element will not surpass. LyShine::UiLayoutCellUnspecifiedSize means no max
virtual float GetTargetWidth(float maxWidth) = 0;
//! Get the target height
//! \param maxHeight A height that the element will not surpass. LyShine::UiLayoutCellUnspecifiedSize means no max
virtual float GetTargetHeight(float maxHeight) = 0;
//! Get the extra width ratio
virtual float GetExtraWidthRatio() = 0;
//! Get the extra height ratio
virtual float GetExtraHeightRatio() = 0;
public: // static member data
//! Multiple components on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
};
typedef AZ::EBus<UiLayoutCellDefaultInterface> UiLayoutCellDefaultBus;
@@ -1,46 +0,0 @@
/*
* 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/ComponentBus.h>
#include <LyShine/Bus/UiLayoutBus.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiLayoutColumnInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiLayoutColumnInterface() {}
//! Get the padding (in pixels) inside the edges of the element
virtual UiLayoutInterface::Padding GetPadding() = 0;
//! Set the padding (in pixels) inside the edges of the element
virtual void SetPadding(UiLayoutInterface::Padding padding) = 0;
//! Get the spacing (in pixels) between child elements
virtual float GetSpacing() = 0;
//! Set the spacing (in pixels) between child elements
virtual void SetSpacing(float spacing) = 0;
//! Get the vertical order for this layout
virtual UiLayoutInterface::VerticalOrder GetOrder() = 0;
//! Set the vertical order for this layout
virtual void SetOrder(UiLayoutInterface::VerticalOrder order) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiLayoutColumnInterface> UiLayoutColumnBus;
@@ -1,49 +0,0 @@
/*
* 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/ComponentBus.h>
#include <LyShine/UiBase.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
//! This interface can to be implemented by any component that wants to modify transform properties
//! of elements are runtime using the Layout system. The methods in this interface will be called
//! by the LayoutManager whenever the element is told to recompute its layout. Because an element
//! might have multiple components that implement this interface, the handlers will be sorted by
//! priority (lower priority number gets called earlier).
class UiLayoutControllerInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiLayoutControllerInterface() {}
//! Set elements' width transform properties
virtual void ApplyLayoutWidth() = 0;
//! Set elements' height transform properties
virtual void ApplyLayoutHeight() = 0;
public: // static member data
//! Events are ordered, each handler may set its priority
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::MultipleAndOrdered;
//! Priority will be used for ordering, lower priority number means it gets called earlier
struct BusHandlerOrderCompare
{
AZ_FORCE_INLINE bool operator()(const UiLayoutControllerInterface* left, const UiLayoutControllerInterface* right) const { return left->GetPriority() < right->GetPriority(); }
};
protected: // member data
static const unsigned int k_defaultPriority = 100; // Default is 100, make it lower to get called earlier, higher to get called later
virtual unsigned int GetPriority() const { return k_defaultPriority; }
};
typedef AZ::EBus<UiLayoutControllerInterface> UiLayoutControllerBus;
@@ -1,55 +0,0 @@
/*
* 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/ComponentBus.h>
#include <LyShine/UiBase.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 UiLayoutFitterInterface
: public AZ::ComponentBus
{
public: // types
//! Fit type indicating enabled fits
enum class FitType
{
None,
HorizontalOnly,
VerticalOnly,
HorizontalAndVertical
};
public: // member functions
virtual ~UiLayoutFitterInterface() {}
//! Get whether to resize the element horizontally
virtual bool GetHorizontalFit() = 0;
//! Set whether to resize the element horizontally
virtual void SetHorizontalFit(bool horizontalFit) = 0;
//! Get whether to resize the element vertically
virtual bool GetVerticalFit() = 0;
//! Set whether to resize the element vertically
virtual void SetVerticalFit(bool verticalFit) = 0;
//! Get the fit type
virtual FitType GetFitType() = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiLayoutFitterInterface> UiLayoutFitterBus;
@@ -1,74 +0,0 @@
/*
* 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/ComponentBus.h>
#include <AzCore/Math/Vector2.h>
#include <LyShine/Bus/UiLayoutBus.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiLayoutGridInterface
: public AZ::ComponentBus
{
public: // types
//! Used to determine which direction to start the layout with
enum class StartingDirection
{
HorizontalOrder,
VerticalOrder
};
public: // member functions
virtual ~UiLayoutGridInterface() {}
//! Get the padding (in pixels) inside the edges of the element
virtual UiLayoutInterface::Padding GetPadding() = 0;
//! Set the padding (in pixels) inside the edges of the element
virtual void SetPadding(UiLayoutInterface::Padding padding) = 0;
//! Get the spacing (in pixels) between child elements
virtual AZ::Vector2 GetSpacing() = 0;
//! Set the spacing (in pixels) between child elements
virtual void SetSpacing(AZ::Vector2 spacing) = 0;
//! Get the size (in pixels) of a child element in this layout
virtual AZ::Vector2 GetCellSize() = 0;
//! Set the size (in pixels) of a child element in this layout
virtual void SetCellSize(AZ::Vector2 size) = 0;
//! Get the horizontal order for this layout
virtual UiLayoutInterface::HorizontalOrder GetHorizontalOrder() = 0;
//! Set the horizontal order for this layout
virtual void SetHorizontalOrder(UiLayoutInterface::HorizontalOrder order) = 0;
//! Get the vertical order for this layout
virtual UiLayoutInterface::VerticalOrder GetVerticalOrder() = 0;
//! Set the vertical order for this layout
virtual void SetVerticalOrder(UiLayoutInterface::VerticalOrder order) = 0;
//! Get the starting direction for this layout
virtual StartingDirection GetStartingDirection() = 0;
//! Set the starting direction for this layout
virtual void SetStartingDirection(StartingDirection direction) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiLayoutGridInterface> UiLayoutGridBus;
@@ -1,47 +0,0 @@
/*
* 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/ComponentBus.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiLayoutManagerInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiLayoutManagerInterface() {}
public: // static member data
//! Mark an element to recompute its layout. This is called when something that affects the layout
//! has been modified. (ex. layout element size changed, layout element property changed, layout
//! element child count changed.)
virtual void MarkToRecomputeLayout(AZ::EntityId entityId) = 0;
//! Mark the specified element's parent to recompute its layout. The parent uses its child's layout
//! cell values to calculate its layout, so this is called when something that affects the
//! child's layout cell values has been modified. (ex. child's layout cell property changed.)
//! Since a child's layout cell values may affect its parent's layout cell values, the top level parent
//! is marked
virtual void MarkToRecomputeLayoutsAffectedByLayoutCellChange(AZ::EntityId entityId, bool isDefaultLayoutCell) = 0;
//! Unmark all elements from needing to recompute their layouts
virtual void UnmarkAllLayouts() = 0;
//! Recompute layouts of marked elements and clear the marked layout list
virtual void RecomputeMarkedLayouts() = 0;
//! Compute the layout for the specified element and its descendants
virtual void ComputeLayoutForElementAndDescendants(AZ::EntityId entityId) = 0;
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiLayoutManagerInterface> UiLayoutManagerBus;
@@ -1,46 +0,0 @@
/*
* 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/ComponentBus.h>
#include <LyShine/Bus/UiLayoutBus.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiLayoutRowInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiLayoutRowInterface() {}
//! Get the padding (in pixels) inside the edges of the element
virtual UiLayoutInterface::Padding GetPadding() = 0;
//! Set the padding (in pixels) inside the edges of the element
virtual void SetPadding(UiLayoutInterface::Padding padding) = 0;
//! Get the spacing (in pixels) between child elements
virtual float GetSpacing() = 0;
//! Set the spacing (in pixels) between child elements
virtual void SetSpacing(float spacing) = 0;
//! Get the horizontal order for this layout
virtual UiLayoutInterface::HorizontalOrder GetOrder() = 0;
//! Set the horizontal order for this layout
virtual void SetOrder(UiLayoutInterface::HorizontalOrder order) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiLayoutRowInterface> UiLayoutRowBus;
@@ -1,71 +0,0 @@
/*
* 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/ComponentBus.h>
#include <AzCore/Math/Color.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
//! A markup button allows for button-like behavior on markup text.
//!
//! The markup itself is contained within a text component. The markup button
//! handles interaction with the text, and can also apply styling (such as
//! coloring for button/clickable text).
//!
//! Markup button behavior is only intended for mouse interactions.
class UiMarkupButtonInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiMarkupButtonInterface() {}
//! Get the link color
virtual AZ::Color GetLinkColor() = 0;
//! Set the link color
virtual void SetLinkColor(const AZ::Color& linkColor) = 0;
//! Get the link hover color
virtual AZ::Color GetLinkHoverColor() = 0;
//! Set the link hover color
virtual void SetLinkHoverColor(const AZ::Color& linkHoverColor) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiMarkupButtonInterface> UiMarkupButtonBus;
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiMarkupButtonNotifications
: public AZ::ComponentBus
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const bool EnableEventQueue = true;
//////////////////////////////////////////////////////////////////////////
public: // member functions
virtual ~UiMarkupButtonNotifications() {}
virtual void OnHoverStart(int id, const AZStd::string& action, const AZStd::string& data) = 0;
virtual void OnHoverEnd(int id, const AZStd::string& action, const AZStd::string& data) = 0;
virtual void OnPressed(int id, const AZStd::string& action, const AZStd::string& data) = 0;
virtual void OnReleased(int id, const AZStd::string& action, const AZStd::string& data) = 0;
virtual void OnClick(int id, const AZStd::string& action, const AZStd::string& data) = 0;
};
typedef AZ::EBus<UiMarkupButtonNotifications> UiMarkupButtonNotificationsBus;
@@ -1,62 +0,0 @@
/*
* 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/ComponentBus.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
class UiMaskInterface
: public AZ::ComponentBus
{
public: // member functions
virtual ~UiMaskInterface() {}
//! Get whether masking is enabled
virtual bool GetIsMaskingEnabled() = 0;
//! Set whether masking is enabled
virtual void SetIsMaskingEnabled(bool enableMasking) = 0;
//! Get whether interaction masking is enabled
virtual bool GetIsInteractionMaskingEnabled() = 0;
//! Set whether interaction masking is enabled
virtual void SetIsInteractionMaskingEnabled(bool enableInteractionMasking) = 0;
//! Get whether mask visual is drawn to color buffer behind child elements
virtual bool GetDrawBehind() = 0;
//! Set whether mask visual is drawn to color buffer behind child elements
virtual void SetDrawBehind(bool drawMaskVisualBehindChildren) = 0;
//! Get whether mask visual is drawn to color buffer in front of child elements
virtual bool GetDrawInFront() = 0;
//! Set whether mask visual is drawn to color buffer in front of child elements
virtual void SetDrawInFront(bool drawMaskVisualInFrontOfChildren) = 0;
//! Get whether to use alpha test when drawing mask visual to stencil
virtual bool GetUseAlphaTest() = 0;
//! Set whether to use alpha test when drawing mask visual to stencil
virtual void SetUseAlphaTest(bool useAlphaTest) = 0;
//! Get the flag that indicates whether the mask should use render to texture
virtual bool GetUseRenderToTexture() = 0;
//! Set the flag that indicates whether the mask should use render to texture
virtual void SetUseRenderToTexture(bool useRenderToTexture) = 0;
public: // static member data
//! Only one component on a entity can implement the events
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
};
typedef AZ::EBus<UiMaskInterface> UiMaskBus;

Some files were not shown because too many files have changed in this diff Show More