2020-08-25 18:55:29 +02:00
|
|
|
#pragma once
|
|
|
|
|
2020-10-26 09:07:11 +01:00
|
|
|
#include <map>
|
2020-08-25 18:55:29 +02:00
|
|
|
#include <vector>
|
|
|
|
#include <wil\resource.h>
|
|
|
|
#include <winrt/base.h>
|
2020-10-14 14:45:50 +02:00
|
|
|
#include <d2d1.h>
|
2020-10-20 15:49:05 +02:00
|
|
|
#include <dwrite.h>
|
2020-08-25 18:55:29 +02:00
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
#include "Zone.h"
|
2020-10-26 09:07:11 +01:00
|
|
|
#include "ZoneSet.h"
|
2020-10-28 14:30:17 +01:00
|
|
|
#include "FancyZones.h"
|
2021-07-07 12:18:52 +02:00
|
|
|
#include "ZoneColors.h"
|
2020-08-25 18:55:29 +02:00
|
|
|
|
2021-11-25 16:39:03 +01:00
|
|
|
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;
|
2021-11-04 15:30:06 +01:00
|
|
|
D2D1_COLOR_F textColor;
|
2021-08-11 16:05:03 +02:00
|
|
|
ZoneIndex id;
|
2020-10-20 15:19:10 +02:00
|
|
|
};
|
|
|
|
|
2020-10-26 17:37:56 +01:00
|
|
|
struct AnimationInfo
|
|
|
|
{
|
|
|
|
std::chrono::steady_clock::time_point tStart;
|
2021-03-29 13:39:16 +02:00
|
|
|
bool autoHide;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum struct RenderResult
|
|
|
|
{
|
|
|
|
Ok,
|
|
|
|
AnimationEnded,
|
|
|
|
Failed,
|
2020-10-26 17:37:56 +01:00
|
|
|
};
|
|
|
|
|
2020-12-30 22:47:18 +01:00
|
|
|
HWND m_window = nullptr;
|
|
|
|
RECT m_clientRect{};
|
|
|
|
ID2D1HwndRenderTarget* m_renderTarget = nullptr;
|
2020-10-26 17:37:56 +01:00
|
|
|
std::optional<AnimationInfo> m_animation;
|
2020-10-20 15:19:10 +02:00
|
|
|
|
2020-10-22 15:43:20 +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);
|
2021-03-29 13:39:16 +02:00
|
|
|
RenderResult Render();
|
2021-03-25 13:44:55 +01:00
|
|
|
void RenderLoop();
|
2020-10-23 15:22:45 +02:00
|
|
|
|
2020-12-30 22:47:18 +01: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
|
|
|
|
2021-11-25 16:39:03 +01:00
|
|
|
~ZonesOverlay();
|
|
|
|
ZonesOverlay(HWND window);
|
2020-10-23 14:37:14 +02:00
|
|
|
void Hide();
|
2021-03-29 13:39:16 +02:00
|
|
|
void Show();
|
|
|
|
void Flash();
|
2020-10-26 12:20:01 +01:00
|
|
|
void DrawActiveZoneSet(const IZoneSet::ZonesMap& zones,
|
2021-08-11 16:05:03 +02:00
|
|
|
const ZoneIndexSet& highlightZones,
|
2021-07-07 12:18:52 +02:00
|
|
|
const ZoneColors& colors);
|
2020-10-20 15:19:10 +02:00
|
|
|
};
|