2020-08-26 00:55:29 +08:00
|
|
|
#pragma once
|
|
|
|
|
2020-10-26 16:07:11 +08:00
|
|
|
#include <map>
|
2020-08-26 00:55:29 +08:00
|
|
|
#include <vector>
|
|
|
|
#include <wil\resource.h>
|
|
|
|
#include <winrt/base.h>
|
2020-10-14 20:45:50 +08:00
|
|
|
#include <d2d1.h>
|
2020-10-20 21:49:05 +08:00
|
|
|
#include <dwrite.h>
|
2020-08-26 00:55:29 +08:00
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
#include "Zone.h"
|
2020-10-26 16:07:11 +08:00
|
|
|
#include "ZoneSet.h"
|
2020-10-28 21:30:17 +08:00
|
|
|
#include "FancyZones.h"
|
2020-08-26 00:55:29 +08:00
|
|
|
|
2020-10-14 20:45:50 +08:00
|
|
|
class ZoneWindowDrawing
|
|
|
|
{
|
2020-10-20 21:19:10 +08:00
|
|
|
struct DrawableRect
|
|
|
|
{
|
|
|
|
D2D1_RECT_F rect;
|
|
|
|
D2D1_COLOR_F borderColor;
|
|
|
|
D2D1_COLOR_F fillColor;
|
2020-10-20 21:49:05 +08:00
|
|
|
size_t id;
|
2020-10-20 21:19:10 +08:00
|
|
|
};
|
|
|
|
|
2020-10-27 00:37:56 +08:00
|
|
|
struct AnimationInfo
|
|
|
|
{
|
|
|
|
std::chrono::steady_clock::time_point tStart;
|
|
|
|
unsigned duration;
|
|
|
|
};
|
|
|
|
|
2020-10-14 20:45:50 +08:00
|
|
|
HWND m_window;
|
2020-10-20 21:19:10 +08:00
|
|
|
RECT m_clientRect;
|
|
|
|
ID2D1HwndRenderTarget* m_renderTarget;
|
2020-10-27 00:37:56 +08:00
|
|
|
std::optional<AnimationInfo> m_animation;
|
2020-10-20 21:19:10 +08:00
|
|
|
|
2020-10-22 21:43:20 +08:00
|
|
|
std::mutex m_mutex;
|
2020-10-20 21:19:10 +08:00
|
|
|
std::vector<DrawableRect> m_sceneRects;
|
|
|
|
|
2020-10-23 20:37:14 +08:00
|
|
|
float GetAnimationAlpha();
|
|
|
|
static ID2D1Factory* GetD2DFactory();
|
|
|
|
static IDWriteFactory* GetWriteFactory();
|
|
|
|
static D2D1_COLOR_F ConvertColor(COLORREF color);
|
|
|
|
static D2D1_RECT_F ConvertRect(RECT rect);
|
2020-10-23 21:22:45 +08:00
|
|
|
void Render();
|
|
|
|
|
|
|
|
std::atomic<bool> m_shouldRender;
|
|
|
|
std::atomic<bool> m_abortThread;
|
|
|
|
std::atomic<bool> m_lowLatencyLock;
|
|
|
|
std::condition_variable m_cv;
|
|
|
|
std::thread m_renderThread;
|
2020-10-14 20:45:50 +08:00
|
|
|
|
|
|
|
public:
|
2020-10-20 21:19:10 +08:00
|
|
|
|
2020-10-23 21:22:45 +08:00
|
|
|
~ZoneWindowDrawing();
|
2020-10-23 20:37:14 +08:00
|
|
|
ZoneWindowDrawing(HWND window);
|
|
|
|
void Hide();
|
|
|
|
void Show(unsigned animationMillis);
|
2020-10-23 21:22:45 +08:00
|
|
|
void ForceRender();
|
2020-10-26 19:20:01 +08:00
|
|
|
void DrawActiveZoneSet(const IZoneSet::ZonesMap& zones,
|
2020-10-20 21:19:10 +08:00
|
|
|
const std::vector<size_t>& highlightZones,
|
2020-10-23 20:37:14 +08:00
|
|
|
winrt::com_ptr<IZoneWindowHost> host);
|
2020-10-20 21:19:10 +08:00
|
|
|
};
|