Merge branch 'development' into UsingCommaAsDecimalSeperator
Signed-off-by: John Jones-Steele <jjjoness@amazon.com>
This commit is contained in:
@@ -44,6 +44,22 @@ namespace AZ
|
||||
return &out;
|
||||
}
|
||||
|
||||
void SetPerspectiveMatrixFOV(Matrix4x4& out, float fovY, float aspectRatio)
|
||||
{
|
||||
float sinFov, cosFov;
|
||||
SinCos(0.5f * fovY, sinFov, cosFov);
|
||||
float yScale = cosFov / sinFov; //cot(fovY/2)
|
||||
float xScale = yScale / aspectRatio;
|
||||
|
||||
out.SetElement(0, 0, xScale);
|
||||
out.SetElement(1, 1, yScale);
|
||||
}
|
||||
|
||||
float GetPerspectiveMatrixFOV(const Matrix4x4& m)
|
||||
{
|
||||
return 2.0 * AZStd::atan(1.0f / m.GetElement(1, 1));
|
||||
}
|
||||
|
||||
Matrix4x4* MakeFrustumMatrixRH(Matrix4x4& out, float left, float right, float bottom, float top, float nearDist, float farDist, bool reverseDepth)
|
||||
{
|
||||
AZ_Assert(right > left, "right should be greater than left");
|
||||
|
||||
@@ -64,4 +64,8 @@ namespace AZ
|
||||
//! Transforms a position by a matrix. This function can be used with any generic cases which include projection matrices.
|
||||
Vector3 MatrixTransformPosition(const Matrix4x4& matrix, const Vector3& inPosition);
|
||||
|
||||
|
||||
void SetPerspectiveMatrixFOV(Matrix4x4& out, float fovY, float aspectRatio);
|
||||
float GetPerspectiveMatrixFOV(const Matrix4x4& m);
|
||||
|
||||
} // namespace AZ
|
||||
|
||||
@@ -27,11 +27,10 @@ namespace AZ
|
||||
struct AllocationInfo
|
||||
{
|
||||
size_t m_byteSize{};
|
||||
unsigned int m_alignment{};
|
||||
const char* m_name{};
|
||||
|
||||
const char* m_fileName{};
|
||||
int m_lineNum{};
|
||||
unsigned int m_alignment{};
|
||||
void* m_namesBlock{}; ///< Memory block if m_name and m_fileName have been allocated specifically for this allocation record
|
||||
size_t m_namesBlockSize{};
|
||||
|
||||
@@ -41,7 +40,7 @@ namespace AZ
|
||||
};
|
||||
|
||||
// We use OSAllocator which uses system calls to allocate memory, they are not recorded or tracked!
|
||||
typedef AZStd::unordered_map<void*, AllocationInfo, AZStd::hash<void*>, AZStd::equal_to<void*>, OSStdAllocator> AllocationRecordsType;
|
||||
using AllocationRecordsType = AZStd::unordered_map<void*, AllocationInfo, AZStd::hash<void*>, AZStd::equal_to<void*>, OSStdAllocator>;
|
||||
|
||||
/**
|
||||
* Records enumeration callback
|
||||
@@ -50,7 +49,7 @@ namespace AZ
|
||||
* \param unsigned char number of stack records/levels, if AllocationInfo::m_stackFrames != NULL.
|
||||
* \returns true if you want to continue traverse of the records and false if you want to stop.
|
||||
*/
|
||||
typedef AZStd::function<bool (void*, const AllocationInfo&, unsigned char)> AllocationInfoCBType;
|
||||
using AllocationInfoCBType = AZStd::function<bool (void*, const AllocationInfo&, unsigned char)>;
|
||||
/**
|
||||
* Example of records enumeration callback.
|
||||
*/
|
||||
|
||||
@@ -114,6 +114,9 @@ namespace Camera
|
||||
//! Makes the camera the active view
|
||||
virtual void MakeActiveView() = 0;
|
||||
|
||||
//! Check if this camera is the active render camera
|
||||
virtual bool IsActiveView() = 0;
|
||||
|
||||
//! Get the camera frustum's aggregate configuration
|
||||
virtual Configuration GetCameraConfiguration()
|
||||
{
|
||||
|
||||
+18
-4
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <../Common/WinAPI/AzFramework/Input/Devices/Keyboard/InputDeviceKeyboard_WinAPI.h>
|
||||
#include <AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Platform.h>
|
||||
#include <AzCore/Module/Environment.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
namespace
|
||||
@@ -29,7 +30,7 @@ namespace AzFramework
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//! Count of the number instances of this class that have been created
|
||||
static int s_instanceCount;
|
||||
static AZ::EnvironmentVariable<int> s_instanceCount;
|
||||
|
||||
public:
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -106,7 +107,7 @@ namespace AzFramework
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int InputDeviceKeyboardWindows::s_instanceCount = 0;
|
||||
AZ::EnvironmentVariable<int> InputDeviceKeyboardWindows::s_instanceCount = nullptr;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
InputDeviceKeyboardWindows::InputDeviceKeyboardWindows(InputDeviceKeyboard& inputDevice)
|
||||
@@ -116,8 +117,10 @@ namespace AzFramework
|
||||
, m_hasFocus(false)
|
||||
, m_hasTextEntryStarted(false)
|
||||
{
|
||||
if (s_instanceCount++ == 0)
|
||||
if (!s_instanceCount)
|
||||
{
|
||||
s_instanceCount = AZ::Environment::CreateVariable<int>("InputDeviceKeyboardInstanceCount", 1);
|
||||
|
||||
// Register for raw keyboard input
|
||||
RAWINPUTDEVICE rawInputDevice;
|
||||
rawInputDevice.usUsagePage = RAW_INPUT_KEYBOARD_USAGE_PAGE;
|
||||
@@ -128,6 +131,10 @@ namespace AzFramework
|
||||
AZ_Assert(result, "Failed to register raw input device: keyboard");
|
||||
AZ_UNUSED(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_instanceCount.Set(s_instanceCount.Get() + 1);
|
||||
}
|
||||
|
||||
RawInputNotificationBusWindows::Handler::BusConnect();
|
||||
}
|
||||
@@ -137,7 +144,8 @@ namespace AzFramework
|
||||
{
|
||||
RawInputNotificationBusWindows::Handler::BusDisconnect();
|
||||
|
||||
if (--s_instanceCount == 0)
|
||||
int instanceCount = s_instanceCount.Get();
|
||||
if (--instanceCount == 0)
|
||||
{
|
||||
// Deregister from raw keyboard input
|
||||
RAWINPUTDEVICE rawInputDevice;
|
||||
@@ -148,7 +156,13 @@ namespace AzFramework
|
||||
const BOOL result = RegisterRawInputDevices(&rawInputDevice, 1, sizeof(rawInputDevice));
|
||||
AZ_Assert(result, "Failed to deregister raw input device: keyboard");
|
||||
AZ_UNUSED(result);
|
||||
|
||||
s_instanceCount.Reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
s_instanceCount.Set(instanceCount);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+21
-7
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <AzCore/Module/Environment.h>
|
||||
#include <AzFramework/Input/Devices/Mouse/InputDeviceMouse.h>
|
||||
#include <AzFramework/Input/Buses/Notifications/RawInputNotificationBus_Platform.h>
|
||||
#include <AzFramework/Input/Buses/Requests/InputSystemCursorRequestBus.h>
|
||||
@@ -43,7 +44,7 @@ namespace AzFramework
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//! Count of the number instances of this class that have been created
|
||||
static int s_instanceCount;
|
||||
static AZ::EnvironmentVariable<int> s_instanceCount;
|
||||
|
||||
public:
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -125,7 +126,7 @@ namespace AzFramework
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int InputDeviceMouseWindows::s_instanceCount = 0;
|
||||
AZ::EnvironmentVariable<int> InputDeviceMouseWindows::s_instanceCount = nullptr;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
InputDeviceMouseWindows::InputDeviceMouseWindows(InputDeviceMouse& inputDevice)
|
||||
@@ -137,18 +138,24 @@ namespace AzFramework
|
||||
{
|
||||
memset(&m_lastClientRect, 0, sizeof(m_lastClientRect));
|
||||
|
||||
if (s_instanceCount++ == 0)
|
||||
if (!s_instanceCount)
|
||||
{
|
||||
s_instanceCount = AZ::Environment::CreateVariable<int>("InputDeviceMouseInstanceCount", 1);
|
||||
|
||||
// Register for raw mouse input
|
||||
RAWINPUTDEVICE rawInputDevice;
|
||||
rawInputDevice.usUsagePage = RAW_INPUT_MOUSE_USAGE_PAGE;
|
||||
rawInputDevice.usUsage = RAW_INPUT_MOUSE_USAGE;
|
||||
rawInputDevice.dwFlags = 0;
|
||||
rawInputDevice.hwndTarget = 0;
|
||||
rawInputDevice.usUsage = RAW_INPUT_MOUSE_USAGE;
|
||||
rawInputDevice.dwFlags = 0;
|
||||
rawInputDevice.hwndTarget = 0;
|
||||
const BOOL result = RegisterRawInputDevices(&rawInputDevice, 1, sizeof(rawInputDevice));
|
||||
AZ_Assert(result, "Failed to register raw input device: mouse");
|
||||
AZ_UNUSED(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_instanceCount.Set(s_instanceCount.Get() + 1);
|
||||
}
|
||||
|
||||
RawInputNotificationBusWindows::Handler::BusConnect();
|
||||
}
|
||||
@@ -161,7 +168,8 @@ namespace AzFramework
|
||||
// Cleanup system cursor visibility and constraint
|
||||
SetSystemCursorState(SystemCursorState::Unknown);
|
||||
|
||||
if (--s_instanceCount == 0)
|
||||
int instanceCount = s_instanceCount.Get();
|
||||
if (--instanceCount == 0)
|
||||
{
|
||||
// Deregister from raw mouse input
|
||||
RAWINPUTDEVICE rawInputDevice;
|
||||
@@ -172,6 +180,12 @@ namespace AzFramework
|
||||
const BOOL result = RegisterRawInputDevices(&rawInputDevice, 1, sizeof(rawInputDevice));
|
||||
AZ_Assert(result, "Failed to deregister raw input device: mouse");
|
||||
AZ_UNUSED(result);
|
||||
|
||||
s_instanceCount.Reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
s_instanceCount.Set(instanceCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -186,6 +186,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
invalidateFilter();
|
||||
|
||||
Q_EMIT filterChanged();
|
||||
}
|
||||
|
||||
@@ -205,6 +206,6 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
} // namespace AssetBrowser
|
||||
} // namespace AzToolsFramework// namespace AssetBrowser
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
#include "AssetBrowser/moc_AssetBrowserFilterModel.cpp"
|
||||
|
||||
@@ -134,7 +134,8 @@ namespace AzToolsFramework
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//If the column of the parent is one of those we don't want any more rows as children
|
||||
if (parent.isValid())
|
||||
{
|
||||
if ((parent.column() != aznumeric_cast<int>(AssetBrowserEntry::Column::DisplayName)) &&
|
||||
|
||||
+32
-14
@@ -90,24 +90,38 @@ namespace AzToolsFramework
|
||||
const QAbstractItemModel* model, const QModelIndex& parent /*= QModelIndex()*/, int row /*= 0*/)
|
||||
{
|
||||
int rows = model ? model->rowCount(parent) : 0;
|
||||
for (int i = 0; i < rows; ++i)
|
||||
|
||||
if (parent == QModelIndex())
|
||||
{
|
||||
QModelIndex index = model->index(i, 0, parent);
|
||||
AssetBrowserEntry* entry = GetAssetEntry(m_filterModel->mapToSource(index));
|
||||
//We only wanna see the source assets.
|
||||
if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Source)
|
||||
{
|
||||
beginInsertRows(parent, row, row);
|
||||
m_indexMap[row] = index;
|
||||
endInsertRows();
|
||||
m_displayedItemsCounter = 0;
|
||||
}
|
||||
|
||||
Q_EMIT dataChanged(index, index);
|
||||
++row;
|
||||
for (int currentRow = 0; currentRow < rows; ++currentRow)
|
||||
{
|
||||
if (m_displayedItemsCounter < m_numberOfItemsDisplayed)
|
||||
{
|
||||
QModelIndex index = model->index(currentRow, 0, parent);
|
||||
AssetBrowserEntry* entry = GetAssetEntry(m_filterModel->mapToSource(index));
|
||||
// We only want to see the source assets.
|
||||
if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Source)
|
||||
{
|
||||
beginInsertRows(parent, row, row);
|
||||
m_indexMap[row] = index;
|
||||
endInsertRows();
|
||||
|
||||
Q_EMIT dataChanged(index, index);
|
||||
++row;
|
||||
++m_displayedItemsCounter;
|
||||
}
|
||||
|
||||
if (model->hasChildren(index))
|
||||
{
|
||||
row = BuildTableModelMap(model, index, row);
|
||||
}
|
||||
}
|
||||
|
||||
if (model->hasChildren(index))
|
||||
else
|
||||
{
|
||||
row = BuildTableModelMap(model, index, row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return row;
|
||||
@@ -135,6 +149,10 @@ namespace AzToolsFramework
|
||||
m_indexMap.clear();
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
AzToolsFramework::EditorSettingsAPIBus::BroadcastResult(
|
||||
m_numberOfItemsDisplayed, &AzToolsFramework::EditorSettingsAPIBus::Handler::GetMaxNumberOfItemsShownInSearchView);
|
||||
|
||||
BuildTableModelMap(sourceModel());
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QPointer>
|
||||
#endif
|
||||
#include <Editor/EditorSettingsAPIBus.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -50,6 +51,8 @@ namespace AzToolsFramework
|
||||
int BuildTableModelMap(const QAbstractItemModel* model, const QModelIndex& parent = QModelIndex(), int row = 0);
|
||||
|
||||
private:
|
||||
int m_numberOfItemsDisplayed = 50;
|
||||
int m_displayedItemsCounter = 0;
|
||||
QPointer<AssetBrowserFilterModel> m_filterModel;
|
||||
QMap<int, QModelIndex> m_indexMap;
|
||||
};
|
||||
|
||||
+1
-11
@@ -6,18 +6,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <API/EditorAssetSystemAPI.h>
|
||||
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserModel.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntryCache.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Entries/ProductAssetBrowserEntry.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Entries/SourceAssetBrowserEntry.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h>
|
||||
#include <AzToolsFramework/AssetBrowser/Views/EntryDelegate.h>
|
||||
|
||||
@@ -28,9 +20,7 @@ AZ_PUSH_DISABLE_WARNING(
|
||||
#include <QCoreApplication>
|
||||
#include <QHeaderView>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
|
||||
#include <QTimer>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
namespace AzToolsFramework
|
||||
|
||||
-2
@@ -9,7 +9,6 @@
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
|
||||
#include <AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h>
|
||||
@@ -55,7 +54,6 @@ namespace AzToolsFramework
|
||||
void OnAssetBrowserComponentReady() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void selectionChangedSignal(const QItemSelection& selected, const QItemSelection& deselected);
|
||||
void ClearStringFilter();
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace AzToolsFramework
|
||||
virtual SettingOutcome GetValue(const AZStd::string_view path) = 0;
|
||||
virtual SettingOutcome SetValue(const AZStd::string_view path, const AZStd::any& value) = 0;
|
||||
virtual ConsoleColorTheme GetConsoleColorTheme() const = 0;
|
||||
virtual int GetMaxNumberOfItemsShownInSearchView() const = 0;
|
||||
};
|
||||
|
||||
using EditorSettingsAPIBus = AZ::EBus<EditorSettingsAPIRequests>;
|
||||
|
||||
+29
@@ -65,6 +65,35 @@ namespace UnitTest
|
||||
}
|
||||
}
|
||||
|
||||
bool FocusInteractionWidget::event(QEvent* event)
|
||||
{
|
||||
using AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus;
|
||||
|
||||
auto eventType = event->type();
|
||||
|
||||
switch (eventType)
|
||||
{
|
||||
case QEvent::MouseButtonPress:
|
||||
EditorInteractionSystemViewportSelectionRequestBus::Event(
|
||||
AzToolsFramework::GetEntityContextId(), &EditorInteractionSystemViewportSelectionRequestBus::Events::SetDefaultHandler);
|
||||
return true;
|
||||
case QEvent::FocusIn:
|
||||
case QEvent::FocusOut:
|
||||
{
|
||||
bool handled = false;
|
||||
AzToolsFramework::ViewportInteraction::MouseInteraction mouseInteraction;
|
||||
EditorInteractionSystemViewportSelectionRequestBus::EventResult(
|
||||
handled, AzToolsFramework::GetEntityContextId(),
|
||||
&EditorInteractionSystemViewportSelectionRequestBus::Events::InternalHandleMouseViewportInteraction,
|
||||
AzToolsFramework::ViewportInteraction::MouseInteractionEvent(
|
||||
mouseInteraction, AzToolsFramework::ViewportInteraction::MouseEvent::Down));
|
||||
return handled;
|
||||
}
|
||||
}
|
||||
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
void TestEditorActions::Connect()
|
||||
{
|
||||
using AzToolsFramework::GetEntityContextId;
|
||||
|
||||
+15
-11
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
#include <AzCore/Slice/SliceAsset.h>
|
||||
@@ -31,6 +32,7 @@
|
||||
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
|
||||
#include <AzToolsFramework/SourceControl/PerforceConnection.h>
|
||||
#include <AzToolsFramework/UnitTest/ToolsTestApplication.h>
|
||||
#endif // !defined(Q_MOC_RUN)
|
||||
|
||||
#include <ostream>
|
||||
|
||||
@@ -40,7 +42,7 @@ AZ_POP_DISABLE_WARNING
|
||||
|
||||
#define AUTO_RESULT_IF_SETTING_TRUE(_settingName, _result) \
|
||||
{ \
|
||||
bool settingValue = true; \
|
||||
bool settingValue = true; \
|
||||
if (auto* registry = AZ::SettingsRegistry::Get()) \
|
||||
{ \
|
||||
registry->Get(settingValue, _settingName); \
|
||||
@@ -51,23 +53,16 @@ AZ_POP_DISABLE_WARNING
|
||||
EXPECT_TRUE(_result); \
|
||||
return; \
|
||||
} \
|
||||
}
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
class Entity;
|
||||
class EntityId;
|
||||
|
||||
} // namespace AZ
|
||||
}
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
constexpr AZStd::string_view prefabSystemSetting = "/Amazon/Preferences/EnablePrefabSystem";
|
||||
|
||||
/// Test widget to store QActions generated by EditorTransformComponentSelection.
|
||||
class TestWidget
|
||||
: public QWidget
|
||||
class TestWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TestWidget()
|
||||
: QWidget()
|
||||
@@ -79,6 +74,15 @@ namespace UnitTest
|
||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
};
|
||||
|
||||
/// Widget used to trigger a viewport interaction event while a focus change is happening.
|
||||
class FocusInteractionWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FocusInteractionWidget(QWidget* parent = nullptr) : QWidget(parent) {}
|
||||
bool event(QEvent* event) override;
|
||||
};
|
||||
|
||||
/// Stores actions registered for either normal mode (regular viewport) editing and
|
||||
/// component mode editing.
|
||||
class TestEditorActions
|
||||
|
||||
@@ -50,6 +50,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
ly_add_target(
|
||||
NAME AzToolsFrameworkTestCommon STATIC
|
||||
NAMESPACE AZ
|
||||
AUTOMOC
|
||||
FILES_CMAKE
|
||||
AzToolsFramework/aztoolsframeworktestcommon_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
@@ -68,6 +69,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
|
||||
ly_add_target(
|
||||
NAME AzToolsFramework.Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
|
||||
NAMESPACE AZ
|
||||
AUTOMOC
|
||||
FILES_CMAKE
|
||||
Tests/aztoolsframeworktests_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
|
||||
@@ -31,8 +31,10 @@
|
||||
#include <AzToolsFramework/Viewport/ActionBus.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorDefaultSelection.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorInteractionSystemViewportSelectionRequestBus.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorPickEntitySelection.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.h>
|
||||
#include <AzToolsFramework/ViewportSelection/EditorVisibleEntityDataCache.h>
|
||||
#include <AzToolsFramework/ViewportUi/ViewportUiManager.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -188,6 +190,47 @@ namespace UnitTest
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// EditorTransformComponentSelection Tests
|
||||
|
||||
TEST_F(EditorTransformComponentSelectionFixture, Focus_is_not_changed_while_switching_viewport_interaction_request_instance)
|
||||
{
|
||||
// setup a dummy widget and make it the active window to ensure focus in/out events are fired
|
||||
auto dummyWidget = AZStd::make_unique<QWidget>();
|
||||
QApplication::setActiveWindow(dummyWidget.get());
|
||||
|
||||
// note: it is important to make sure the focus widget is parented to the dummy widget to have focus in/out events fire
|
||||
auto focusWidget = AZStd::make_unique<UnitTest::FocusInteractionWidget>(dummyWidget.get());
|
||||
|
||||
const auto previousFocusWidget = QApplication::focusWidget();
|
||||
|
||||
// Given
|
||||
// setup viewport ui system
|
||||
AzToolsFramework::ViewportUi::ViewportUiManager viewportUiManager;
|
||||
viewportUiManager.ConnectViewportUiBus(AzToolsFramework::ViewportUi::DefaultViewportId);
|
||||
viewportUiManager.InitializeViewportUi(&m_editorActions.m_defaultWidget, focusWidget.get());
|
||||
|
||||
// begin EditorPickEntitySelection
|
||||
using AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus;
|
||||
EditorInteractionSystemViewportSelectionRequestBus::Event(
|
||||
AzToolsFramework::GetEntityContextId(), &EditorInteractionSystemViewportSelectionRequestBus::Events::SetHandler,
|
||||
[](const AzToolsFramework::EditorVisibleEntityDataCache* entityDataCache)
|
||||
{
|
||||
return AZStd::make_unique<AzToolsFramework::EditorPickEntitySelection>(entityDataCache);
|
||||
});
|
||||
|
||||
// When
|
||||
// a mouse event is sent to the focus widget (set to be the render overlay in the viewport ui system)
|
||||
QTest::mouseClick(focusWidget.get(), Qt::MouseButton::LeftButton);
|
||||
|
||||
// Then
|
||||
// focus should not change
|
||||
EXPECT_FALSE(focusWidget->hasFocus());
|
||||
EXPECT_EQ(previousFocusWidget, QApplication::focusWidget());
|
||||
|
||||
// clean up
|
||||
viewportUiManager.DisconnectViewportUiBus();
|
||||
focusWidget.reset();
|
||||
dummyWidget.reset();
|
||||
}
|
||||
|
||||
TEST_F(EditorTransformComponentSelectionFixture, ManipulatorOrientationIsResetWhenEntityOrientationIsReset)
|
||||
{
|
||||
using AzToolsFramework::EditorTransformComponentSelectionRequestBus;
|
||||
|
||||
Reference in New Issue
Block a user