diff options
author | crupest <crupest@outlook.com> | 2020-10-28 18:45:27 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-10-28 18:45:27 +0800 |
commit | a09a9645d3c823e3559659dc1ddd213510755820 (patch) | |
tree | 1d20232346bcd3e5e37f52b3d935f1e42dea4a82 /include/cru/win/native/Window.hpp | |
parent | c1c5a185e4f4c4706e8a641f25add3885203f202 (diff) | |
download | cru-a09a9645d3c823e3559659dc1ddd213510755820.tar.gz cru-a09a9645d3c823e3559659dc1ddd213510755820.tar.bz2 cru-a09a9645d3c823e3559659dc1ddd213510755820.zip |
...
Diffstat (limited to 'include/cru/win/native/Window.hpp')
-rw-r--r-- | include/cru/win/native/Window.hpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/cru/win/native/Window.hpp b/include/cru/win/native/Window.hpp index 3e0b11cd..37df0768 100644 --- a/include/cru/win/native/Window.hpp +++ b/include/cru/win/native/Window.hpp @@ -2,6 +2,7 @@ #include "Resource.hpp" #include "WindowNativeMessageEventArgs.hpp" +#include "cru/platform/GraphBase.hpp" #include "cru/platform/native/Window.hpp" #include <memory> @@ -89,6 +90,28 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { return window_render_target_.get(); } + //*************** region: dpi *************** + float GetDpi() const { return dpi_; } + + inline int DipToPixel(const float dip) { + return static_cast<int>(dip * GetDpi() / 96.0f); + } + + inline POINT DipToPixel(const Point& dip_point) { + POINT result; + result.x = DipToPixel(dip_point.x); + result.y = DipToPixel(dip_point.y); + return result; + } + + inline float PixelToDip(const int pixel) { + return static_cast<float>(pixel) * 96.0f / GetDpi(); + } + + inline Point PixelToDip(const POINT& pi_point) { + return Point(PixelToDip(pi_point.x), PixelToDip(pi_point.y)); + } + private: // Get the client rect in pixel. RECT GetClientRectPixel(); @@ -129,6 +152,8 @@ class WinNativeWindow : public WinNativeResource, public virtual INativeWindow { HWND hwnd_; WinNativeWindow* parent_window_; + float dpi_; + bool has_focus_ = false; bool is_mouse_in_ = false; |