Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
413 changes: 413 additions & 0 deletions ACTION-PLAN.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions PowerToys.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,7 @@
<Platform Solution="*|ARM64" Project="ARM64" />
<Platform Solution="*|x64" Project="x64" />
</Project>
<Project Path="src/modules/MeasureTool/UnitTests/UnitTests-MeasureTool.vcxproj" Id="a8f12d3e-5b6c-4e7f-9a0b-c1d2e3f4a5b6" />
</Folder>
<Folder Name="/modules/MouseWithoutBorders/">
<Project Path="src/modules/MouseWithoutBorders/App/Helper/MouseWithoutBordersHelper.csproj">
Expand Down
8 changes: 8 additions & 0 deletions src/modules/MeasureTool/MeasureToolCore/Measurement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ namespace
}
}

#ifndef UNIT_TEST
winrt::hstring Measurement::abbreviations[4]{};
#endif

inline float Measurement::Width(const Unit units) const
{
Expand Down Expand Up @@ -86,6 +88,10 @@ Measurement::Unit Measurement::GetUnitFromIndex(int index)
}
}

// Functions below require Windows App SDK (winrt::ResourceManager) and are
// excluded from unit-test builds to avoid pulling in the heavy WinRT pch.
#ifndef UNIT_TEST

void Measurement::InitResources()
{
auto rm = winrt::ResourceManager{};
Expand Down Expand Up @@ -235,3 +241,5 @@ void Measurement::PrintToStream(std::wostream& stream,
stream << L" " << Measurement::GetUnitAbbreviation(units);
}
}

#endif // !UNIT_TEST
7 changes: 6 additions & 1 deletion src/modules/MeasureTool/MeasureToolCore/Measurement.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ struct Measurement
D2D1_RECT_F rect = {}; // corners are inclusive

float px2mmRatio = 0;
#ifndef UNIT_TEST
static winrt::hstring abbreviations[4]; // Abbreviations of units.
#endif

Measurement(const Measurement&) = default;
Measurement& operator=(const Measurement&) = default;
Expand All @@ -29,14 +31,16 @@ struct Measurement
float Width(const Unit units) const;
float Height(const Unit units) const;

static Unit GetUnitFromIndex(int index);

#ifndef UNIT_TEST
struct PrintResult
{
size_t crossSymbolPos[2] = {};
size_t strLen = {};
};

static void InitResources();
static Unit GetUnitFromIndex(int index);
static const wchar_t* GetUnitAbbreviation(const Unit units);

PrintResult Print(wchar_t* buf,
Expand All @@ -50,4 +54,5 @@ struct Measurement
const bool printWidth,
const bool printHeight,
const Unit units) const;
#endif // !UNIT_TEST
};
Loading
Loading