Skip to content

Commit

Permalink
Merge branch 'development' into BeforeAndAfterInputtingValueInNumberB…
Browse files Browse the repository at this point in the history
…arInconsistent-o3de#5234

Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>
  • Loading branch information
jjjoness committed Jan 14, 2022
2 parents 3e9fd6f + 193f529 commit 050870b
Show file tree
Hide file tree
Showing 69 changed files with 1,257 additions and 777 deletions.
17 changes: 0 additions & 17 deletions Code/Editor/Util/EditorUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,23 +176,6 @@ QString TrimTrailingZeros(QString str)
return str;
}

//////////////////////////////////////////////////////////////////////////
// This function is supposed to format float in user-friendly way,
// omitting the exponent notation.
//
// Why not using printf? Its formatting rules has following drawbacks:
// %g - will use exponent for small numbers;
// %.Nf - doesn't allow to control total amount of significant numbers,
// which exposes limited precision during binary-to-decimal fraction
// conversion.
//////////////////////////////////////////////////////////////////////////
void FormatFloatForUI(QString& str, int significantDigits, double value)
{
str = TrimTrailingZeros(QString::number(value, 'f', significantDigits));
return;
}
//////////////////////////////////////////////////////////////////////////-

//////////////////////////////////////////////////////////////////////////
QColor ColorLinearToGamma(ColorF col)
{
Expand Down
165 changes: 0 additions & 165 deletions Code/Editor/Util/EditorUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,22 +212,6 @@ namespace XmlHelpers
//////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////
// Drag Drop helper functions
//////////////////////////////////////////////////////////////////////////
namespace EditorDragDropHelpers
{
inline QString GetAnimationNameClipboardFormat()
{
return QStringLiteral("application/x-animation-browser-copy");
}

inline QString GetFragmentClipboardFormat()
{
return QStringLiteral("application/x-preview-fragment-properties");
}
}

//////////////////////////////////////////////////////////////////////////

/*!
Expand Down Expand Up @@ -292,116 +276,6 @@ struct StdMap
}
};


//////////////////////////////////////////////////////////////////////////
//
// Convert String representation of color to RGB integer value.
//
//////////////////////////////////////////////////////////////////////////
inline QColor String2Color(const QString& val)
{
unsigned int r = 0, g = 0, b = 0;
int res = 0;
res = azsscanf(val.toUtf8().data(), "R:%d,G:%d,B:%d", &r, &g, &b);
if (res != 3)
{
res = azsscanf(val.toUtf8().data(), "R:%d G:%d B:%d", &r, &g, &b);
}
if (res != 3)
{
res = azsscanf(val.toUtf8().data(), "%d,%d,%d", &r, &g, &b);
}
if (res != 3)
{
res = azsscanf(val.toUtf8().data(), "%d %d %d", &r, &g, &b);
}
if (res != 3)
{
azsscanf(val.toUtf8().data(), "%x", &r);
return r;
}

return QColor(r, g, b);
}

// Converts QColor to Vector.
inline Vec3 Rgb2Vec(const QColor& color)
{
return Vec3(aznumeric_cast<float>(color.redF()), aznumeric_cast<float>(color.greenF()), aznumeric_cast<float>(color.blueF()));
}

// Converts QColor to ColorF.
inline ColorF Rgb2ColorF(const QColor& color)
{
return ColorF(aznumeric_cast<float>(color.redF()), aznumeric_cast<float>(color.greenF()), aznumeric_cast<float>(color.blueF()), 1.0f);
}

// Converts QColor to Vector.
inline QColor Vec2Rgb(const Vec3& color)
{
return QColor(aznumeric_cast<int>(color.x * 255), aznumeric_cast<int>(color.y * 255), aznumeric_cast<int>(color.z * 255));
}

// Converts ColorF to QColor.
inline QColor ColorF2Rgb(const ColorF& color)
{
return QColor(aznumeric_cast<int>(color.r * 255), aznumeric_cast<int>(color.g * 255), aznumeric_cast<int>(color.b * 255));
}

//////////////////////////////////////////////////////////////////////////
// Tokenize string.
//////////////////////////////////////////////////////////////////////////
inline QString TokenizeString(const QString& s, LPCSTR pszTokens, int& iStart)
{
assert(iStart >= 0);

QByteArray str = s.toUtf8();

if (pszTokens == nullptr)
{
return str;
}

auto pszPlace = str.begin() + iStart;
auto pszEnd = str.end();
if (pszPlace < pszEnd)
{
int nIncluding = (int)strspn(pszPlace, pszTokens);
;

if ((pszPlace + nIncluding) < pszEnd)
{
pszPlace += nIncluding;
int nExcluding = (int)strcspn(pszPlace, pszTokens);

int iFrom = iStart + nIncluding;
int nUntil = nExcluding;
iStart = iFrom + nUntil + 1;

return (str.mid(iFrom, nUntil));
}
}

// return empty string, done tokenizing
iStart = -1;
return "";
}

// This template function will join strings from a vector into a single string, using a separator char
template<class T>
inline void JoinStrings(const QList<T>& rStrings, QString& rDestStr, char aSeparator = ',')
{
for (size_t i = 0, iCount = rStrings.size(); i < iCount; ++i)
{
rDestStr += rStrings[i];

if (i < iCount - 1)
{
rDestStr += aSeparator;
}
}
}

// This function will split a string containing separated strings, into a vector of strings
// better version of TokenizeString
inline void SplitString(const QString& rSrcStr, QStringList& rDestStrings, char aSeparator = ',')
Expand Down Expand Up @@ -435,45 +309,6 @@ inline void SplitString(const QString& rSrcStr, QStringList& rDestStrings, char
}
}

// Format unsigned number to string with 1000s separator
inline QString FormatWithThousandsSeperator(const unsigned int number)
{
QString string;

string = QString::number(number);

for (int p = string.length() - 3; p > 0; p -= 3)
{
string.insert(p, ',');
}

return string;
}


void FormatFloatForUI(QString& str, int significantDigits, double value);

//////////////////////////////////////////////////////////////////////////
// Simply sub string searching case insensitive.
//////////////////////////////////////////////////////////////////////////
inline const char* strstri(const char* pString, const char* pSubstring)
{
int i, j, k;
for (i = 0; pString[i]; i++)
{
for (j = i, k = 0; tolower(pString[j]) == tolower(pSubstring[k]); j++, k++)
{
if (!pSubstring[k + 1])
{
return (pString + i);
}
}
}

return nullptr;
}


inline bool CheckVirtualKey(Qt::MouseButton button)
{
return (qApp->property("pressedMouseButtons").toInt() & button) != 0;
Expand Down
38 changes: 28 additions & 10 deletions Code/Framework/AzCore/AzCore/UnitTest/TestTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,35 @@ namespace UnitTest
};

/**
* RAII wrapper of AllocatorBase.
* The benefit of using this wrapper instead of AllocatorsTestFixture is that SetUp/TearDown of the allocator is managed
* on construction/destruction, allowing member variables of derived classes to exist as value (and do heap allocation).
*/
class ScopedAllocatorSetupFixture
* RAII wrapper of AllocatorBase.
* The benefit of using this wrapper instead of AllocatorsTestFixture is that SetUp/TearDown of the allocator is managed
* on construction/destruction, allowing member variables of derived classes to exist as value (and do heap allocation).
*/
class ScopedAllocatorFixture : AllocatorsBase
{
public:
ScopedAllocatorFixture()
{
SetupAllocator();
}
explicit ScopedAllocatorFixture(const AZ::SystemAllocator::Descriptor& allocatorDesc)
{
SetupAllocator(allocatorDesc);
}
~ScopedAllocatorFixture() override
{
TeardownAllocator();
}
};

// Like ScopedAllocatorFixture, but includes the Test base class
class ScopedAllocatorSetupFixture
: public ::testing::Test
, AllocatorsBase
, public ScopedAllocatorFixture
{
public:
ScopedAllocatorSetupFixture() { SetupAllocator(); }
explicit ScopedAllocatorSetupFixture(const AZ::SystemAllocator::Descriptor& allocatorDesc) { SetupAllocator(allocatorDesc); }
~ScopedAllocatorSetupFixture() { TeardownAllocator(); }
ScopedAllocatorSetupFixture() = default;
explicit ScopedAllocatorSetupFixture(const AZ::SystemAllocator::Descriptor& allocatorDesc) : ScopedAllocatorFixture(allocatorDesc){}
};

/**
Expand Down Expand Up @@ -114,6 +131,7 @@ namespace UnitTest
using AllocatorsFixture = AllocatorsTestFixture;

#if defined(HAVE_BENCHMARK)

/**
* Helper class to handle the boiler plate of setting up a benchmark fixture that uses the system allocators
* If you wish to do additional setup and tear down be sure to call the base class SetUp first and TearDown
Expand Down Expand Up @@ -218,7 +236,7 @@ namespace UnitTest
static constexpr bool sHasPadding = size < alignment;
AZStd::enable_if<sHasPadding, char[(alignment - size) % alignment]> mPadding;
};

template <AZ::u32 size, AZ::u8 instance, size_t alignment>
int CreationCounter<size, instance, alignment>::s_count = 0;
template <AZ::u32 size, AZ::u8 instance, size_t alignment>
Expand Down
1 change: 1 addition & 0 deletions Code/Tools/AssetProcessor/assetprocessor_test_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ set(FILES
native/tests/InternalBuilders/SettingsRegistryBuilderTests.cpp
native/tests/MissingDependencyScannerTests.cpp
native/tests/SourceFileRelocatorTests.cpp
native/tests/PathDependencyManagerTests.cpp
native/tests/AssetProcessorMessagesTests.cpp
native/unittests/AssetProcessingStateDataUnitTests.cpp
native/unittests/AssetProcessingStateDataUnitTests.h
Expand Down
Loading

0 comments on commit 050870b

Please sign in to comment.