PowerToys/src/modules/fancyzones/FancyZonesLib/ZoneWindowDrawing.h
Seraphima Zykova c93eb92cd0
[FancyZones] Move FancyZones out of the runner process (#11818)
* rename dll -> FancyZonesModuleInterface (#11488)

* [FancyZones] Rename "fancyzones/tests" -> "fancyzones/FancyZonesTests" (#11492)

* [FancyZones] Rename "fancyzones/lib" -> "fancyzones/FancyZonesLib" (#11489)

* [FancyZones] New FancyZones project. (#11544)

* [FancyZones] Allow single instance of "PowerToys.FancyZones.exe" (#11558)

* [FancyZones] Updated bug reports (#11571)

* [FancyZones] Updated installer (#11572)

* [FancyZones] Update string resources (#11596)

* [FancyZones] Terminate FancyZones with runner (#11696)

* [FancyZones] Drop support for the module interface API to save settings (#11661)

* Settings telemetry for FancyZones (#11766)

* commented out test

* enable dpi awareness for the process
2021-06-23 13:48:54 +01:00

70 lines
1.5 KiB
C++

#pragma once
#include <map>
#include <vector>
#include <wil\resource.h>
#include <winrt/base.h>
#include <d2d1.h>
#include <dwrite.h>
#include "util.h"
#include "Zone.h"
#include "ZoneSet.h"
#include "FancyZones.h"
class ZoneWindowDrawing
{
struct DrawableRect
{
D2D1_RECT_F rect;
D2D1_COLOR_F borderColor;
D2D1_COLOR_F fillColor;
size_t id;
};
struct AnimationInfo
{
std::chrono::steady_clock::time_point tStart;
bool autoHide;
};
enum struct RenderResult
{
Ok,
AnimationEnded,
Failed,
};
HWND m_window = nullptr;
RECT m_clientRect{};
ID2D1HwndRenderTarget* m_renderTarget = nullptr;
std::optional<AnimationInfo> m_animation;
std::mutex m_mutex;
std::vector<DrawableRect> m_sceneRects;
float GetAnimationAlpha();
static ID2D1Factory* GetD2DFactory();
static IDWriteFactory* GetWriteFactory();
static D2D1_COLOR_F ConvertColor(COLORREF color);
static D2D1_RECT_F ConvertRect(RECT rect);
RenderResult Render();
void RenderLoop();
std::atomic<bool> m_shouldRender = false;
std::atomic<bool> m_abortThread = false;
std::condition_variable m_cv;
std::thread m_renderThread;
public:
~ZoneWindowDrawing();
ZoneWindowDrawing(HWND window);
void Hide();
void Show();
void Flash();
void DrawActiveZoneSet(const IZoneSet::ZonesMap& zones,
const std::vector<size_t>& highlightZones,
winrt::com_ptr<IZoneWindowHost> host);
};