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"
|
2020-08-25 18:55:29 +02:00
|
|
|
|
2020-10-14 14:45:50 +02:00
|
|
|
class ZoneWindowDrawing
|
|
|
|
|
{
|
2020-10-20 15:19:10 +02:00
|
|
|
struct DrawableRect
|
|
|
|
|
{
|
|
|
|
|
D2D1_RECT_F rect;
|
|
|
|
|
D2D1_COLOR_F borderColor;
|
|
|
|
|
D2D1_COLOR_F fillColor;
|
2020-10-20 15:49:05 +02:00
|
|
|
size_t 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-31 00:47:18 +03: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 15:44:55 +03:00
|
|
|
void RenderLoop();
|
2020-10-23 15:22:45 +02:00
|
|
|
|
2020-12-31 00:47:18 +03: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
|
|
|
|
2020-10-23 15:22:45 +02:00
|
|
|
~ZoneWindowDrawing();
|
2020-10-23 14:37:14 +02:00
|
|
|
ZoneWindowDrawing(HWND window);
|
|
|
|
|
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,
|
2020-10-20 15:19:10 +02:00
|
|
|
const std::vector<size_t>& highlightZones,
|
2020-10-23 14:37:14 +02:00
|
|
|
winrt::com_ptr<IZoneWindowHost> host);
|
2020-10-20 15:19:10 +02:00
|
|
|
};
|