Merge branch 'development' into redcode/driller_removal

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-12-02 18:12:48 -08:00
307 changed files with 5238 additions and 1228 deletions
+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();
@@ -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 });
}
@@ -18,12 +18,11 @@
#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
@@ -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);
@@ -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();
@@ -69,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