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
|
// 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) {
|
static if (true) {
|
||||||
VerticalLayout contentLayout = new VerticalLayout();
|
VerticalLayout contentLayout = new VerticalLayout();
|
||||||
|
|
|
@ -181,7 +181,12 @@ private __gshared int PRIVATE_SCREEN_DPI = 96;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property void SCREEN_DPI(int dpi) {
|
@property void SCREEN_DPI(int dpi) {
|
||||||
|
if (dpi >= 72 && dpi <= 500) {
|
||||||
|
if (PRIVATE_SCREEN_DPI != dpi) {
|
||||||
|
// changed DPI
|
||||||
PRIVATE_SCREEN_DPI = dpi;
|
PRIVATE_SCREEN_DPI = dpi;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// one point is 1/72 of inch
|
/// one point is 1/72 of inch
|
||||||
|
|
|
@ -271,11 +271,15 @@ class FrameDrawable : Drawable {
|
||||||
@property override Rect padding() { return _frameWidths; }
|
@property override Rect padding() { return _frameWidths; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum DimensionUnits {
|
||||||
|
pixels,
|
||||||
|
points
|
||||||
|
}
|
||||||
|
|
||||||
/// decode size string, e.g. 1px or 2 or 3pt
|
/// decode size string, e.g. 1px or 2 or 3pt
|
||||||
static uint decodeDimension(string s) {
|
static uint decodeDimension(string s) {
|
||||||
uint value = 0;
|
uint value = 0;
|
||||||
int units = 0;
|
DimensionUnits units = DimensionUnits.pixels;
|
||||||
foreach(c; s) {
|
foreach(c; s) {
|
||||||
int digit = -1;
|
int digit = -1;
|
||||||
if (c >='0' && c <= '9')
|
if (c >='0' && c <= '9')
|
||||||
|
@ -283,9 +287,17 @@ static uint decodeDimension(string s) {
|
||||||
if (digit >= 0)
|
if (digit >= 0)
|
||||||
value = value * 10 + digit;
|
value = value * 10 + digit;
|
||||||
else if (c == 't') // just test by containing 't' - for NNNpt
|
else if (c == 't') // just test by containing 't' - for NNNpt
|
||||||
units = 1; // "pt"
|
units = DimensionUnits.points; // "pt"
|
||||||
}
|
}
|
||||||
// TODO: convert points to pixels
|
// TODO: convert points to pixels
|
||||||
|
switch(units) {
|
||||||
|
case DimensionUnits.points:
|
||||||
|
// convert points to pixels
|
||||||
|
value = pointsToPixels(value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,13 +180,14 @@ class SDLWindow : Window {
|
||||||
int w = 0;
|
int w = 0;
|
||||||
int h = 0;
|
int h = 0;
|
||||||
SDL_GL_GetDrawableSize(_win, &w, &h);
|
SDL_GL_GetDrawableSize(_win, &w, &h);
|
||||||
if (w != width || h != height) {
|
version (Windows) {
|
||||||
Log.d("SDL_GL_GetDrawableSize returned ", w, "x", h, " while resize event reports ", width, "x", height);
|
// DPI already calculated
|
||||||
|
} else {
|
||||||
|
// scale DPI
|
||||||
|
if (w > width && h > height && width > 0 && height > 0)
|
||||||
|
SCREEN_DPI = 96 * w / width;
|
||||||
}
|
}
|
||||||
if (w && h)
|
onResize(std.algorithm.max(width, w), std.algorithm.max(height, h));
|
||||||
onResize(w, h);
|
|
||||||
else
|
|
||||||
onResize(width, height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@property uint windowId() {
|
@property uint windowId() {
|
||||||
|
@ -195,7 +196,6 @@ class SDLWindow : Window {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override void show() {
|
override void show() {
|
||||||
Log.d("SDLWindow.show()");
|
Log.d("SDLWindow.show()");
|
||||||
if (_mainWidget && !(_flags & WindowFlag.Resizable)) {
|
if (_mainWidget && !(_flags & WindowFlag.Resizable)) {
|
||||||
|
@ -364,9 +364,7 @@ class SDLWindow : Window {
|
||||||
void redraw() {
|
void redraw() {
|
||||||
//Log.e("Widget instance count in SDLWindow.redraw: ", Widget.instanceCount());
|
//Log.e("Widget instance count in SDLWindow.redraw: ", Widget.instanceCount());
|
||||||
// check if size has been changed
|
// check if size has been changed
|
||||||
int w, h;
|
fixSize();
|
||||||
SDL_GetWindowSize(_win, &w, &h);
|
|
||||||
onResize(w, h);
|
|
||||||
|
|
||||||
if (_enableOpengl) {
|
if (_enableOpengl) {
|
||||||
version(USE_OPENGL) {
|
version(USE_OPENGL) {
|
||||||
|
@ -1139,6 +1137,21 @@ version (Windows) {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Runtime.initialize();
|
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);
|
result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
|
||||||
Log.i("calling Runtime.terminate()");
|
Log.i("calling Runtime.terminate()");
|
||||||
// commented out to fix hanging runtime.terminate when there are background threads
|
// commented out to fix hanging runtime.terminate when there are background threads
|
||||||
|
|
|
@ -868,6 +868,14 @@ int DLANGUIWinMain(void* hInstance, void* hPrevInstance,
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Runtime.initialize();
|
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);
|
result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
|
||||||
// TODO: fix hanging on multithreading app
|
// TODO: fix hanging on multithreading app
|
||||||
//Runtime.terminate();
|
//Runtime.terminate();
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<theme id="theme_dark" parent="theme_default"
|
<theme id="theme_dark" parent="theme_default"
|
||||||
fontSize="12"
|
|
||||||
fontFace="Verdana,Arial,DejaVu Sans"
|
fontFace="Verdana,Arial,DejaVu Sans"
|
||||||
fontFamily="SansSerif"
|
fontFamily="SansSerif"
|
||||||
textColor="#E0E0E0"
|
textColor="#E0E0E0"
|
||||||
|
@ -166,7 +165,6 @@
|
||||||
backgroundImageId="tab_btn_dark_up_dark"
|
backgroundImageId="tab_btn_dark_up_dark"
|
||||||
/>
|
/>
|
||||||
<style id="TAB_UP_BUTTON_DARK_TEXT"
|
<style id="TAB_UP_BUTTON_DARK_TEXT"
|
||||||
fontSize="12"
|
|
||||||
textColor="#E0E0E0"
|
textColor="#E0E0E0"
|
||||||
align="Center"
|
align="Center"
|
||||||
>
|
>
|
||||||
|
@ -185,7 +183,6 @@
|
||||||
</style>
|
</style>
|
||||||
<style id="TAB_UP_BUTTON_TEXT"
|
<style id="TAB_UP_BUTTON_TEXT"
|
||||||
textColor="#C0C0C0"
|
textColor="#C0C0C0"
|
||||||
fontSize="12"
|
|
||||||
align="Center"
|
align="Center"
|
||||||
>
|
>
|
||||||
<state state_selected="true" state_focused="true" textColor="#FFFFC0"/>
|
<state state_selected="true" state_focused="true" textColor="#FFFFC0"/>
|
||||||
|
@ -334,7 +331,6 @@
|
||||||
layoutWidth="FILL_PARENT"
|
layoutWidth="FILL_PARENT"
|
||||||
layoutHeight="WRAP_CONTENT"
|
layoutHeight="WRAP_CONTENT"
|
||||||
padding="3,3,3,3"
|
padding="3,3,3,3"
|
||||||
fontSize="12"
|
|
||||||
align="Left|VCenter"
|
align="Left|VCenter"
|
||||||
/>
|
/>
|
||||||
<style id="DOCK_WINDOW_BODY"
|
<style id="DOCK_WINDOW_BODY"
|
||||||
|
@ -426,7 +422,6 @@
|
||||||
|
|
||||||
<style id="SETTINGS_PAGE_TITLE"
|
<style id="SETTINGS_PAGE_TITLE"
|
||||||
margins="4,4,4,14"
|
margins="4,4,4,14"
|
||||||
fontSize="18"
|
|
||||||
layoutWeight="0"
|
layoutWeight="0"
|
||||||
layoutWidth="FILL_PARENT"
|
layoutWidth="FILL_PARENT"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<theme id="theme_default"
|
<theme id="theme_default"
|
||||||
fontSize="12"
|
fontSize="9pt"
|
||||||
fontFace="Verdana,Arial,DejaVu Sans"
|
fontFace="Verdana,Arial,DejaVu Sans"
|
||||||
fontFamily="SansSerif"
|
fontFamily="SansSerif"
|
||||||
>
|
>
|
||||||
|
@ -156,7 +156,6 @@
|
||||||
backgroundImageId="tab_btn_dark_up"
|
backgroundImageId="tab_btn_dark_up"
|
||||||
/>
|
/>
|
||||||
<style id="TAB_UP_BUTTON_DARK_TEXT"
|
<style id="TAB_UP_BUTTON_DARK_TEXT"
|
||||||
fontSize="12"
|
|
||||||
textColor="#E0E0E0"
|
textColor="#E0E0E0"
|
||||||
align="Center"
|
align="Center"
|
||||||
>
|
>
|
||||||
|
@ -175,7 +174,6 @@
|
||||||
</style>
|
</style>
|
||||||
<style id="TAB_UP_BUTTON_TEXT"
|
<style id="TAB_UP_BUTTON_TEXT"
|
||||||
textColor="#000000"
|
textColor="#000000"
|
||||||
fontSize="12"
|
|
||||||
align="Center"
|
align="Center"
|
||||||
>
|
>
|
||||||
<state state_selected="true" state_focused="true" textColor="#000000"/>
|
<state state_selected="true" state_focused="true" textColor="#000000"/>
|
||||||
|
@ -324,7 +322,6 @@
|
||||||
layoutWidth="FILL_PARENT"
|
layoutWidth="FILL_PARENT"
|
||||||
layoutHeight="WRAP_CONTENT"
|
layoutHeight="WRAP_CONTENT"
|
||||||
padding="3,3,3,3"
|
padding="3,3,3,3"
|
||||||
fontSize="12"
|
|
||||||
align="Left|VCenter"
|
align="Left|VCenter"
|
||||||
/>
|
/>
|
||||||
<style id="DOCK_WINDOW_BODY"
|
<style id="DOCK_WINDOW_BODY"
|
||||||
|
@ -416,7 +413,7 @@
|
||||||
|
|
||||||
<style id="SETTINGS_PAGE_TITLE"
|
<style id="SETTINGS_PAGE_TITLE"
|
||||||
margins="4,4,4,14"
|
margins="4,4,4,14"
|
||||||
fontSize="18"
|
fontSize="11pt"
|
||||||
layoutWeight="0"
|
layoutWeight="0"
|
||||||
layoutWidth="FILL_PARENT"
|
layoutWidth="FILL_PARENT"
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue