diff options
author | StapleButter <thetotalworm@gmail.com> | 2018-12-21 05:01:37 +0100 |
---|---|---|
committer | StapleButter <thetotalworm@gmail.com> | 2018-12-21 05:01:37 +0100 |
commit | 63ae6bf8fbd1e9d6c00ecdfc3680dece465e0c6c (patch) | |
tree | 5b3185b2596a838bca1f1b1d97fdb9c40b524a14 | |
parent | f86fe460350838d288a4515ac3b3865874a53e5b (diff) |
libui/windows: some work on hiDPI shit
still looks derpy but atleast the rendering and touchscreen aren't broken
-rw-r--r-- | melonDS.cbp | 8 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/areadraw.cpp | 10 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/areaevents.cpp | 2 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/areautil.cpp | 1 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/draw.cpp | 7 | ||||
-rw-r--r-- | src/libui_sdl/libui/windows/init.cpp | 2 |
6 files changed, 27 insertions, 3 deletions
diff --git a/melonDS.cbp b/melonDS.cbp index 3829187..81cc0b1 100644 --- a/melonDS.cbp +++ b/melonDS.cbp @@ -26,12 +26,14 @@ <Add library="advapi32" /> <Add library="wsock32" /> <Add library="oleacc" /> + <Add library="ole32" /> <Add library="usp10" /> <Add library="gdi32" /> <Add library="d2d1" /> <Add library="dwrite" /> <Add library="uxtheme" /> - <Add library="ole32" /> + <Add library="iphlpapi" /> + <Add library="user32" /> </Linker> </Target> <Target title="Release Windows"> @@ -61,6 +63,8 @@ <Add library="d2d1" /> <Add library="dwrite" /> <Add library="uxtheme" /> + <Add library="iphlpapi" /> + <Add library="user32" /> </Linker> </Target> <Target title="DebugFast Windows"> @@ -89,6 +93,8 @@ <Add library="d2d1" /> <Add library="dwrite" /> <Add library="uxtheme" /> + <Add library="iphlpapi" /> + <Add library="user32" /> </Linker> </Target> </Build> diff --git a/src/libui_sdl/libui/windows/areadraw.cpp b/src/libui_sdl/libui/windows/areadraw.cpp index 0bdf58a..a9ad477 100644 --- a/src/libui_sdl/libui/windows/areadraw.cpp +++ b/src/libui_sdl/libui/windows/areadraw.cpp @@ -26,6 +26,16 @@ static HRESULT doPaint(uiArea *a, ID2D1RenderTarget *rt, RECT *clip) rt->BeginDraw(); + { + float dpi_x, dpi_y; + D2D1_MATRIX_3X2_F dm; + rt->GetDpi(&dpi_x, &dpi_y); + ZeroMemory(&dm, sizeof (D2D1_MATRIX_3X2_F)); + dm._11 = 96.f/dpi_x; + dm._22 = 96.f/dpi_y; + rt->SetTransform(&dm); + } + if (a->scrolling) { ZeroMemory(&scrollTransform, sizeof (D2D1_MATRIX_3X2_F)); scrollTransform._11 = 1; diff --git a/src/libui_sdl/libui/windows/areaevents.cpp b/src/libui_sdl/libui/windows/areaevents.cpp index 842f2d7..d65b11d 100644 --- a/src/libui_sdl/libui/windows/areaevents.cpp +++ b/src/libui_sdl/libui/windows/areaevents.cpp @@ -101,7 +101,7 @@ static void areaMouseEvent(uiArea *a, int down, int up, WPARAM wParam, LPARAM l xpix = (double) GET_X_LPARAM(lParam); ypix = (double) GET_Y_LPARAM(lParam); // these are in pixels; we need points - pixelsToDIP(a, &xpix, &ypix); + //pixelsToDIP(a, &xpix, &ypix); me.X = xpix; me.Y = ypix; if (a->scrolling) { diff --git a/src/libui_sdl/libui/windows/areautil.cpp b/src/libui_sdl/libui/windows/areautil.cpp index 9dc72fb..212ea42 100644 --- a/src/libui_sdl/libui/windows/areautil.cpp +++ b/src/libui_sdl/libui/windows/areautil.cpp @@ -14,6 +14,7 @@ void loadAreaSize(uiArea *a, ID2D1RenderTarget *rt, double *width, double *heigh size = realGetSize(rt); *width = size.width; *height = size.height; + dipToPixels(a, width, height); } } diff --git a/src/libui_sdl/libui/windows/draw.cpp b/src/libui_sdl/libui/windows/draw.cpp index 65f2535..11a777d 100644 --- a/src/libui_sdl/libui/windows/draw.cpp +++ b/src/libui_sdl/libui/windows/draw.cpp @@ -560,6 +560,13 @@ void uiDrawBitmapDraw(uiDrawContext* c, uiDrawBitmap* bmp, uiRect* srcrect, uiRe D2D_RECT_F _srcrect = D2D1::RectF(srcrect->X, srcrect->Y, srcrect->X+srcrect->Width, srcrect->Y+srcrect->Height); D2D_RECT_F _dstrect = D2D1::RectF(dstrect->X, dstrect->Y, dstrect->X+dstrect->Width, dstrect->Y+dstrect->Height); + float dpix, dpiy; + c->rt->GetDpi(&dpix, &dpiy); + _srcrect.left = (_srcrect.left * 96.0f) / dpix; + _srcrect.top = (_srcrect.top * 96.0f) / dpiy; + _srcrect.right = (_srcrect.right * 96.0f) / dpix; + _srcrect.bottom = (_srcrect.bottom * 96.0f) / dpiy; + c->rt->DrawBitmap(bmp->bmp, &_dstrect, 1.0f, filter ? D2D1_BITMAP_INTERPOLATION_MODE_LINEAR : D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, &_srcrect); } diff --git a/src/libui_sdl/libui/windows/init.cpp b/src/libui_sdl/libui/windows/init.cpp index 2287416..5b4fe1d 100644 --- a/src/libui_sdl/libui/windows/init.cpp +++ b/src/libui_sdl/libui/windows/init.cpp @@ -70,7 +70,7 @@ const char *uiInit(uiInitOptions *o) if ((si.dwFlags & STARTF_USESHOWWINDOW) != 0) nCmdShow = si.wShowWindow; - // LONGTERM set DPI awareness + SetProcessDPIAware(); hDefaultIcon = LoadIconW(NULL, IDI_APPLICATION); if (hDefaultIcon == NULL) |