Files
PowerToys/src/modules/MeasureTool/MeasureToolCore/Measurement.h
Andrey Nekrasov 9d7c9c1746 [Screen Ruler] Better error handling and reuse D3D device (#20223)
* [Screen Ruler] simplify lines calculation

* [Screen Ruler] Add inches and centimeters support

* [Chore] prefer x64 toolset to avoid hitting C1076

* [Screen Ruler] Allow making screenshots in non-continuous mode

* [Screen Ruler] Use single d3d device for all ops

* [Screen Ruler] remove gpu mutex and clean up screen capturing

* [Screen Ruler] handle and log DXGI initialization failure

* [Screen Ruler] Add unhandled exception handler

* [Screen Ruler] comment out Units of Measure setting

* [Screen Ruler] introduce a separate device dedicated for capturing
2022-09-05 15:39:56 +03:00

39 lines
845 B
C++

#pragma once
#include <dcommon.h>
#include <windef.h>
struct Measurement
{
enum Unit
{
Pixel,
Inch,
Centimetre
};
D2D1_RECT_F rect = {}; // corners are inclusive
Measurement() = default;
Measurement(const Measurement&) = default;
Measurement& operator=(const Measurement&) = default;
explicit Measurement(D2D1_RECT_F d2dRect);
explicit Measurement(RECT winRect);
float Width(const Unit units) const;
float Height(const Unit units) const;
struct PrintResult
{
std::optional<size_t> crossSymbolPos;
size_t strLen = {};
};
PrintResult Print(wchar_t* buf,
const size_t bufSize,
const bool printWidth,
const bool printHeight,
const Unit units) const;
};