OverlayUI.h
 1  #pragma once
 2  
 3  #include "DxgiAPI.h"
 4  #include "D2DState.h"
 5  
 6  #include "ToolState.h"
 7  
 8  #include <common/display/monitors.h>
 9  #include <common/utils/serialized.h>
10  
11  class OverlayUIState final
12  {
13      template<typename StateT, typename TickFuncT>
14      OverlayUIState(const DxgiAPI* dxgiAPI,
15                     StateT& toolState,
16                     TickFuncT tickFunc,
17                     const CommonState& commonState,
18                     HWND window);
19  
20      Box _monitorArea;
21      HWND _window = {};
22      const CommonState& _commonState;
23      D2DState _d2dState;
24      std::function<void()> _tickFunc;
25      std::thread _uiThread;
26  
27      template<typename ToolT, typename TickFuncT>
28      static std::unique_ptr<OverlayUIState> CreateInternal(const DxgiAPI* dxgi,
29                                                            ToolT& toolState,
30                                                            TickFuncT tickFunc,
31                                                            CommonState& commonState,
32                                                            const wchar_t* toolWindowClassName,
33                                                            void* windowParam,
34                                                            const MonitorInfo& monitor,
35                                                            const bool excludeFromCapture);
36  
37  public:
38      OverlayUIState(OverlayUIState&&) noexcept = default;
39      ~OverlayUIState();
40  
41      static std::unique_ptr<OverlayUIState> Create(const DxgiAPI* dxgi,
42                                                    BoundsToolState& toolState,
43                                                    CommonState& commonState,
44                                                    const MonitorInfo& monitor);
45      static std::unique_ptr<OverlayUIState> Create(const DxgiAPI* dxgi,
46                                                    Serialized<MeasureToolState>& toolState,
47                                                    CommonState& commonState,
48                                                    const MonitorInfo& monitor);
49      inline HWND overlayWindowHandle() const
50      {
51          return _window;
52      }
53  
54      void RunUILoop();
55  };