It is currently Fri Dec 06, 2019 2:54 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject: Re: How I make DPI-aware apps
PostPosted: Wed Jan 16, 2019 5:38 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13640
Location: France
I will take a look


Top
 Profile  
Reply with quote  
 Post subject: Re: How I make DPI-aware apps
PostPosted: Wed Jan 16, 2019 6:35 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 630
Location: Linz, Austria
Fred wrote:
I will take a look
Great, thanks a lot!


Top
 Profile  
Reply with quote  
 Post subject: Re: How I make DPI-aware apps
PostPosted: Sun Jan 20, 2019 9:48 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3715
Location: Berlin, Germany
Whether or not a text is too big for a given gadget because of the DPI setting also depends on the Windows version. Namely Windows versions < 8.1 do different font scaling compared to Windows versions >= 8.1.
For details see this code.

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: How I make DPI-aware apps
PostPosted: Sun Jan 20, 2019 10:37 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 630
Location: Linz, Austria
Looks pretty much the same to me...
ImageImage


Top
 Profile  
Reply with quote  
 Post subject: Re: How I make DPI-aware apps
PostPosted: Sun Jan 20, 2019 11:00 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3715
Location: Berlin, Germany
chi wrote:
Looks pretty much the same to me...

AFAIR we alread had that discussion ...

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: How I make DPI-aware apps
PostPosted: Mon Jan 21, 2019 1:04 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 630
Location: Linz, Austria
yup


Top
 Profile  
Reply with quote  
 Post subject: Re: How I make DPI-aware apps
PostPosted: Mon Jan 21, 2019 2:44 am 
Offline
PureBasic Protozoa
PureBasic Protozoa
User avatar

Joined: Fri Apr 25, 2003 3:08 pm
Posts: 4505
Location: Not Sydney!!! (Bad water, no goats)
Windows 10 makes this even worse. I am using a 34 inch ultrawide and on 2560x1080 at 125% for my old eyes, the entire form gets enlarged off the screen.

I thought DPI awareness was supposed to somehow adjust everything to fit inside the current screen resolution even if the dpi was above 100%?

This has been the same with or without dpi settings on pb 5.7 and on older versions of pb.

Just weird. And each release of windows 10 keeps fiddling with the api used to produce the results.

_________________
Amateur Radio, D-STAR/VK3HAF


Top
 Profile  
Reply with quote  
 Post subject: Re: How I make DPI-aware apps
PostPosted: Mon Jan 21, 2019 8:12 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1904
Fangbeast wrote:
I thought DPI awareness was supposed to somehow adjust everything to fit inside the current screen resolution even if the dpi was above 100%?

That's what I thought, but it doesn't. I use Win 10 now (and Win 7 and Win XP for testing) and my tip in the first post of this topic works perfectly on all three systems at three different Windows DPI settings (100%, 125%, and 150%). That's good enough for me.


Top
 Profile  
Reply with quote  
 Post subject: Re: How I make DPI-aware apps
PostPosted: Tue Jan 22, 2019 10:05 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3715
Location: Berlin, Germany
Fangbeast wrote:
Windows 10 makes this even worse.

Here is a good overview about different DPI scaling methods used by different Windows versions.

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: How I make DPI-aware apps
PostPosted: Tue Jan 22, 2019 10:21 pm 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1904
Excellent article, LJ. Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: How I make DPI-aware apps
PostPosted: Wed Jan 23, 2019 11:22 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Mar 11, 2009 4:06 pm
Posts: 166
Location: NL
So what exactly does the new dpi aware feature do and doesnt do in pb 5.7? And if not fuly implemented yet, can we expect a fix soon? Or does it work “as designed”? A best practice tutorial would be welcome.


Top
 Profile  
Reply with quote  
 Post subject: Re: How I make DPI-aware apps
PostPosted: Fri Jan 25, 2019 1:50 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 6:41 am
Posts: 794
Ulix wrote:
Translation by google!

Hello everyone !

Very interesting as a code, if I understand correctly if it is to obtain the same dimension (windows and gadgets)
whatever the resolution of the screen? or / and the setting of OS!

What is the equivalent of the instruction:

Code:
Global dpi.d = GetDeviceCaps_ (GetDC_ (0), # LOGPIXELSX) / 100; The magic!


for other OS (Linux and Mac)?
The idea: Make it a multi-platform feature! :lol:

Can we use the dpi to size the fonts?

I will follow this post with interest

Ulix :wink:

Code:
Global dpi.d

Define pic=CreateImage(#PB_Any,1,1)
StartVectorDrawing(ImageVectorOutput(pic))

dpi = VectorResolutionX()/100

StopDrawing()
FreeImage(pic)

OpenWindow(0,200,200,180*dpi,100*dpi,"test",#PB_Window_SystemMenu)

x=10*dpi
w=155*dpi
h=20*dpi

TextGadget(1,x,10*dpi,w,h,"This is text that fills the gadget",#PB_Text_Border)

StringGadget(2,x,40*dpi,w,h,"Another small test of fitted text")

ButtonGadget(3,x,70*dpi,w,h,"And last example of exact text")

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow


Top
 Profile  
Reply with quote  
 Post subject: Re: How I make DPI-aware apps
PostPosted: Fri Jan 25, 2019 4:32 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 630
Location: Linz, Austria
You have to divide by the OS' default PPI... [Since the 1980s, the Microsoft Windows operating system has set the default display "DPI" to 96 PPI, while Apple/Macintosh computers have used a default of 72 PPI. Dots per inch - Wikipedia]
Code:
Global dpi.d

Define pic=CreateImage(#PB_Any,1,1)
StartVectorDrawing(ImageVectorOutput(pic))

CompilerSelect #PB_Compiler_OS   
  CompilerCase #PB_OS_Windows
    ppi = 96   
  CompilerCase #PB_OS_MacOS
    ppi = 72 ;not tested (might have changed) 
  CompilerCase #PB_OS_Linux
    ppi = 96 ;not tested (might have changed) 
CompilerEndSelect

dpi = VectorResolutionX() / ppi

StopDrawing()
FreeImage(pic)

OpenWindow(0,200,200,180*dpi,100*dpi,"test",#PB_Window_SystemMenu)

x=10*dpi
w=155*dpi
h=20*dpi

TextGadget(1,x,10*dpi,w,h,"This is text that fills the gadget",#PB_Text_Border)

StringGadget(2,x,40*dpi,w,h,"Another small test of fitted text")

ButtonGadget(3,x,70*dpi,w,h,"And last example of exact text")

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow


Top
 Profile  
Reply with quote  
 Post subject: Re: How I make DPI-aware apps
PostPosted: Fri Jan 25, 2019 6:12 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3715
Location: Berlin, Germany
Well ... what is the advantage of that code?

I changed it a bit, so that the actual result will be shown (tested on Windows 10).
Code:
Define ppi.i, dpi.d

CreateImage(0, 1, 1)
StartVectorDrawing(ImageVectorOutput(0))

CompilerSelect #PB_Compiler_OS   
   CompilerCase #PB_OS_Windows
      ppi = 96   
   CompilerCase #PB_OS_MacOS
      ppi = 72   ; not tested (might have changed)
   CompilerCase #PB_OS_Linux
      ppi = 96   ; not tested (might have changed)
CompilerEndSelect

dpi = VectorResolutionX() / ppi
StopDrawing()
FreeImage(0)

Debug dpi

CompilerIf #PB_Compiler_Version >= 570
   Debug DesktopResolutionX()
CompilerEndIf

With PB 5.70, the value of dpi is always the same as the value of DesktopResolutionX():
  • 1.25 here if DPI aware is checked in the compiler options,
  • 1.0 if DPI aware is unchecked in the compiler options.

And with PB versions prior to 5.70, the value of dpi will always be 1.0, of course (except when there is additional code or a manifest that makes the program DPI aware).

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: How I make DPI-aware apps
PostPosted: Fri Jan 25, 2019 6:38 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat May 05, 2007 5:31 pm
Posts: 630
Location: Linz, Austria
Little John wrote:
Well ... what is the advantage of that code?
PB's DPI-Awareness is only available on Windows right now... So this is a multi-platform approach ;)


Last edited by chi on Fri Jan 25, 2019 6:49 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 49 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye