PowerToys/src/modules/fancyzones/FancyZonesLib/ZonesOverlay.h

72 lines
1.6 KiB
C
Raw Normal View History

#pragma once
#include <map>
#include <vector>
#include <wil\resource.h>
#include <winrt/base.h>
2020-10-14 14:45:50 +02:00
#include <d2d1.h>
#include <dwrite.h>
#include "util.h"
#include "Zone.h"
#include "ZoneSet.h"
2020-10-28 14:30:17 +01:00
#include "FancyZones.h"
#include "ZoneColors.h"
class ZonesOverlay
2020-10-14 14:45:50 +02:00
{
2020-10-20 15:19:10 +02:00
struct DrawableRect
{
D2D1_RECT_F rect;
D2D1_COLOR_F borderColor;
D2D1_COLOR_F fillColor;
D2D1_COLOR_F textColor;
ZoneIndex id;
2020-10-20 15:19:10 +02:00
};
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;
2020-10-20 15:19:10 +02:00
std::mutex m_mutex;
2020-10-20 15:19:10 +02:00
std::vector<DrawableRect> m_sceneRects;
2020-10-23 14:37:14 +02:00
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();
2020-10-23 15:22:45 +02:00
std::atomic<bool> m_shouldRender = false;
std::atomic<bool> m_abortThread = false;
2020-10-23 15:22:45 +02:00
std::condition_variable m_cv;
std::thread m_renderThread;
2020-10-14 14:45:50 +02:00
public:
2020-10-20 15:19:10 +02:00
~ZonesOverlay();
ZonesOverlay(HWND window);
2020-10-23 14:37:14 +02:00
void Hide();
void Show();
void Flash();
2020-10-26 12:20:01 +01:00
void DrawActiveZoneSet(const IZoneSet::ZonesMap& zones,
const ZoneIndexSet& highlightZones,
const ZoneColors& colors);
2020-10-20 15:19:10 +02:00
};