mirror of https://github.com/buggins/dlangui.git
possible fix for issue #72 - GUI is blurry when using retina displays; theme font size in pt
This commit is contained in:
parent
0b126d6c4e
commit
027cfdb685
|
@ -251,7 +251,7 @@ extern (C) int UIAppMain(string[] args) {
|
|||
//}
|
||||
|
||||
// create window
|
||||
Window window = Platform.instance.createWindow("My Window", null, WindowFlag.Resizable, 700, 500);
|
||||
Window window = Platform.instance.createWindow("My Window", null, WindowFlag.Resizable, pointsToPixels(600), pointsToPixels(500));
|
||||
|
||||
static if (true) {
|
||||
VerticalLayout contentLayout = new VerticalLayout();
|
||||
|
|
|
@ -181,7 +181,12 @@ private __gshared int PRIVATE_SCREEN_DPI = 96;
|
|||
}
|
||||
|
||||
@property void SCREEN_DPI(int dpi) {
|
||||
PRIVATE_SCREEN_DPI = dpi;
|
||||
if (dpi >= 72 && dpi <= 500) {
|
||||
if (PRIVATE_SCREEN_DPI != dpi) {
|
||||
// changed DPI
|
||||
PRIVATE_SCREEN_DPI = dpi;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// one point is 1/72 of inch
|
||||
|
|
|
@ -271,11 +271,15 @@ class FrameDrawable : Drawable {
|
|||
@property override Rect padding() { return _frameWidths; }
|
||||
}
|
||||
|
||||
enum DimensionUnits {
|
||||
pixels,
|
||||
points
|
||||
}
|
||||
|
||||
/// decode size string, e.g. 1px or 2 or 3pt
|
||||
static uint decodeDimension(string s) {
|
||||
uint value = 0;
|
||||
int units = 0;
|
||||
DimensionUnits units = DimensionUnits.pixels;
|
||||
foreach(c; s) {
|
||||
int digit = -1;
|
||||
if (c >='0' && c <= '9')
|
||||
|
@ -283,9 +287,17 @@ static uint decodeDimension(string s) {
|
|||
if (digit >= 0)
|
||||
value = value * 10 + digit;
|
||||
else if (c == 't') // just test by containing 't' - for NNNpt
|
||||
units = 1; // "pt"
|
||||
units = DimensionUnits.points; // "pt"
|
||||
}
|
||||
// TODO: convert points to pixels
|
||||
switch(units) {
|
||||
case DimensionUnits.points:
|
||||
// convert points to pixels
|
||||
value = pointsToPixels(value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
@ -180,13 +180,14 @@ class SDLWindow : Window {
|
|||
int w = 0;
|
||||
int h = 0;
|
||||
SDL_GL_GetDrawableSize(_win, &w, &h);
|
||||
if (w != width || h != height) {
|
||||
Log.d("SDL_GL_GetDrawableSize returned ", w, "x", h, " while resize event reports ", width, "x", height);
|
||||
version (Windows) {
|
||||
// DPI already calculated
|
||||
} else {
|
||||
// scale DPI
|
||||
if (w > width && h > height && width > 0 && height > 0)
|
||||
SCREEN_DPI = 96 * w / width;
|
||||
}
|
||||
if (w && h)
|
||||
onResize(w, h);
|
||||
else
|
||||
onResize(width, height);
|
||||
onResize(std.algorithm.max(width, w), std.algorithm.max(height, h));
|
||||
}
|
||||
|
||||
@property uint windowId() {
|
||||
|
@ -194,7 +195,6 @@ class SDLWindow : Window {
|
|||
return SDL_GetWindowID(_win);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
override void show() {
|
||||
Log.d("SDLWindow.show()");
|
||||
|
@ -364,9 +364,7 @@ class SDLWindow : Window {
|
|||
void redraw() {
|
||||
//Log.e("Widget instance count in SDLWindow.redraw: ", Widget.instanceCount());
|
||||
// check if size has been changed
|
||||
int w, h;
|
||||
SDL_GetWindowSize(_win, &w, &h);
|
||||
onResize(w, h);
|
||||
fixSize();
|
||||
|
||||
if (_enableOpengl) {
|
||||
version(USE_OPENGL) {
|
||||
|
@ -1139,6 +1137,21 @@ version (Windows) {
|
|||
try
|
||||
{
|
||||
Runtime.initialize();
|
||||
|
||||
// call SetProcessDPIAware to support HI DPI - fix by Kapps
|
||||
auto ulib = LoadLibraryA("user32.dll");
|
||||
alias SetProcessDPIAwareFunc = int function();
|
||||
auto setDpiFunc = cast(SetProcessDPIAwareFunc)GetProcAddress(ulib, "SetProcessDPIAware");
|
||||
if(setDpiFunc) // Should never fail, but just in case...
|
||||
setDpiFunc();
|
||||
|
||||
// Get screen DPI
|
||||
HDC dc = CreateCompatibleDC(NULL);
|
||||
SCREEN_DPI = GetDeviceCaps(dc, LOGPIXELSY);
|
||||
DeleteObject(dc);
|
||||
|
||||
//SCREEN_DPI = 96 * 3 / 2;
|
||||
|
||||
result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
|
||||
Log.i("calling Runtime.terminate()");
|
||||
// commented out to fix hanging runtime.terminate when there are background threads
|
||||
|
|
|
@ -868,6 +868,14 @@ int DLANGUIWinMain(void* hInstance, void* hPrevInstance,
|
|||
try
|
||||
{
|
||||
Runtime.initialize();
|
||||
|
||||
// call SetProcessDPIAware to support HI DPI - fix by Kapps
|
||||
auto ulib = LoadLibraryA("user32.dll");
|
||||
alias SetProcessDPIAwareFunc = int function();
|
||||
auto setDpiFunc = cast(SetProcessDPIAwareFunc)GetProcAddress(ulib, "SetProcessDPIAware");
|
||||
if(setDpiFunc) // Should never fail, but just in case...
|
||||
setDpiFunc();
|
||||
|
||||
result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
|
||||
// TODO: fix hanging on multithreading app
|
||||
//Runtime.terminate();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<theme id="theme_dark" parent="theme_default"
|
||||
fontSize="12"
|
||||
fontFace="Verdana,Arial,DejaVu Sans"
|
||||
fontFamily="SansSerif"
|
||||
textColor="#E0E0E0"
|
||||
|
@ -166,7 +165,6 @@
|
|||
backgroundImageId="tab_btn_dark_up_dark"
|
||||
/>
|
||||
<style id="TAB_UP_BUTTON_DARK_TEXT"
|
||||
fontSize="12"
|
||||
textColor="#E0E0E0"
|
||||
align="Center"
|
||||
>
|
||||
|
@ -185,7 +183,6 @@
|
|||
</style>
|
||||
<style id="TAB_UP_BUTTON_TEXT"
|
||||
textColor="#C0C0C0"
|
||||
fontSize="12"
|
||||
align="Center"
|
||||
>
|
||||
<state state_selected="true" state_focused="true" textColor="#FFFFC0"/>
|
||||
|
@ -334,7 +331,6 @@
|
|||
layoutWidth="FILL_PARENT"
|
||||
layoutHeight="WRAP_CONTENT"
|
||||
padding="3,3,3,3"
|
||||
fontSize="12"
|
||||
align="Left|VCenter"
|
||||
/>
|
||||
<style id="DOCK_WINDOW_BODY"
|
||||
|
@ -426,7 +422,6 @@
|
|||
|
||||
<style id="SETTINGS_PAGE_TITLE"
|
||||
margins="4,4,4,14"
|
||||
fontSize="18"
|
||||
layoutWeight="0"
|
||||
layoutWidth="FILL_PARENT"
|
||||
/>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<theme id="theme_default"
|
||||
fontSize="12"
|
||||
fontSize="9pt"
|
||||
fontFace="Verdana,Arial,DejaVu Sans"
|
||||
fontFamily="SansSerif"
|
||||
>
|
||||
|
@ -156,7 +156,6 @@
|
|||
backgroundImageId="tab_btn_dark_up"
|
||||
/>
|
||||
<style id="TAB_UP_BUTTON_DARK_TEXT"
|
||||
fontSize="12"
|
||||
textColor="#E0E0E0"
|
||||
align="Center"
|
||||
>
|
||||
|
@ -175,7 +174,6 @@
|
|||
</style>
|
||||
<style id="TAB_UP_BUTTON_TEXT"
|
||||
textColor="#000000"
|
||||
fontSize="12"
|
||||
align="Center"
|
||||
>
|
||||
<state state_selected="true" state_focused="true" textColor="#000000"/>
|
||||
|
@ -324,7 +322,6 @@
|
|||
layoutWidth="FILL_PARENT"
|
||||
layoutHeight="WRAP_CONTENT"
|
||||
padding="3,3,3,3"
|
||||
fontSize="12"
|
||||
align="Left|VCenter"
|
||||
/>
|
||||
<style id="DOCK_WINDOW_BODY"
|
||||
|
@ -416,7 +413,7 @@
|
|||
|
||||
<style id="SETTINGS_PAGE_TITLE"
|
||||
margins="4,4,4,14"
|
||||
fontSize="18"
|
||||
fontSize="11pt"
|
||||
layoutWeight="0"
|
||||
layoutWidth="FILL_PARENT"
|
||||
/>
|
||||
|
|
Loading…
Reference in New Issue