It is currently Sat Dec 16, 2017 4:13 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: DPI aware
PostPosted: Sat Feb 16, 2013 2:27 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2005 5:05 pm
Posts: 1769
Location: Norway
Just one feature I wish you guys had added just one more feature.
As today I had to add Window_ScaleDPIx() and Window_ScaleDPIy() to every place a window or gadget had a X or Y or W or H value, and with the program in question it had around 56 GUI elements.
This mean I had to repeat/write Window_ScaleDPIx() 112 times and Window_ScaleDPIy() 112 times in my code.
If PureBasic supported DPIAware and had a DPI Aware option under compiler Options this could be avoided.

With more and more High DPI devices appearing (monitors, pads, tvs) having to make special macros like I do is cumbersome indeed.
Add to this fact that I make sure ALL my applications are DPI Aware and you can imagine all the extra time lost when coding (or rather not coding due to having to replicate this code all the time).
(MacOS X applications are probably DPI Aware by default? Not sure about Linux, but I don't see why not!)

Feature request from 2010 viewtopic.php?f=3&t=40515
Code Example (with screenshots) from 2010 viewtopic.php?f=12&t=40507


So besides the lack DPI Aware support in 5.10, it is otherwise great, and I'm loving it. Awesome work guys.


Top
 Profile  
Reply with quote  
 Post subject: Re: DPI aware
PostPosted: Sat Feb 16, 2013 3:26 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Apr 26, 2003 8:26 am
Posts: 2916
Location: Planet Earth
GDI+ on Windows has a system for switching units used for the function arguments.

By using my gDrawing include for GDI+ on Windows, it works as easy as that:
Code:
gSetUnit(#UnitMillimeter)


After changing the unit, the drawing commands use this unit for their params. Width and height of 10,20 is now 10mm x 20mm,
so output size is the same on devices with different DPI, for example screens and printers.
There are other units available:
Code:
Enumeration ; Unit
    #UnitWorld       ; 0 -- World coordinate (non-physical unit)
    #UnitDisplay     ; 1 -- Variable -- For PageTransform only
    #UnitPixel       ; 2 -- Each unit is one device pixel.
    #UnitPoint       ; 3 -- Each unit is a printer's point, or 1/72 inch.
    #UnitInch        ; 4 -- Each unit is 1 inch.
    #UnitDocument    ; 5 -- Each unit is 1/300 inch.
    #UnitMillimeter  ; 6 -- Each unit is 1 millimeter.
EndEnumeration


Incorporating such a system into PureBasic would be a big task for sure, but it could solve the DPI awareness
problem, if I didn't forget to think about some details?

Use PBSetUnit(#UnitMillimeter) or PBSetUnit(#UnitInch) or PBSetUnit(#UnitPoint) etc., and all commands that
use size and width parameters use the actual unit.
Use it for windows, gadgets, images and drawing, fonts, printing... everything would be independent of the DPI of the output devices.

The huge task would be to add it to PureBasic. Adding a convert function internally for every function param that makes sense:
Code:
Procedure PB_CreateImage(image, width, height)
    width  = CurrentUnitToPixel(width)
    height = CurrentUnitToPixel(height)
    ...
    do usual stuff
EndProcedure

Procedure PB_Box(x,y, width, height)
    x      = CurrentUnitToPixel(x)
    y      = CurrentUnitToPixel(y)
    width  = CurrentUnitToPixel(width)
    height = CurrentUnitToPixel(height)
    ...
    do usual stuff
EndProcedure

- Doable.
- Much work.
- Big benefit for all users on all platforms (in my opinion).

What do you think?


Top
 Profile  
Reply with quote  
 Post subject: Re: DPI aware
PostPosted: Sat Feb 16, 2013 6:16 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 3625
Location: Italy
I agree it would be nice, but about your current problem:

Rescator wrote:
This mean I had to repeat/write Window_ScaleDPIx() 112 times and Window_ScaleDPIy() 112 times in my code.



I know it's not a terrific solution, but if you do that kind of thing often, maybe you could build an include like the one below:

Code:
EnableExplicit


#dpi_aware = 1

; your include start here

CompilerIf #dpi_aware = 1

Procedure.i _OpenWindow (w,x,y,iw,ih,title$,flags,parent)
 ProcedureReturn OpenWindow (w,x*2,y*2,iw*2,ih*2,title$,flags, parent)
EndProcedure

Macro OpenWindow(w,x,y,iw,ih,title,flags=#PB_Window_SystemMenu,parent=0)
 _OpenWindow(w,x,y,iw,ih,title,flags,parent)
EndMacro

CompilerEndIf
; include end


Procedure Main()
 Protected iEvent
 
 If OpenWindow(0, 50, 50, 640, 480, "Test Window") 
    Repeat
        iEvent = WaitWindowEvent()             
    Until iEvent = #PB_Event_CloseWindow   
 EndIf
EndProcedure

Main()


In practice you add redefinitions of the PB gui commands you use, you don't need to to them all at once, one at the time, those you find yourself using in a particular project. So it will populate itself almost effortlessly.

You replace the *2 in the example with your dpi aware functions and you can transparently activate/remove the include hopefully without side effects (you have to pay attention to define suitable values for the optional params).

_________________
[ My little PureBasic review ]


Top
 Profile  
Reply with quote  
 Post subject: Re: DPI aware
PostPosted: Sat Feb 16, 2013 6:24 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Fri Apr 25, 2003 4:51 pm
Posts: 2808
Location: Portugal, Lisbon
I also use your DPI aware code alot, but a trick i use is to make the gadget extra large to start with, so there is no problem when the system runs at a larger DPI (like mine, i use 119DPI in windows for extra large font!)

I use this trick because gadgets in linux usually need to be larger than in windows.

_________________
Software: http://xipa.org
Elevator Maintenance: http://central-elevadores.pt
Good web hosting!


Top
 Profile  
Reply with quote  
 Post subject: Re: DPI aware
PostPosted: Sat Sep 03, 2016 10:42 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Oct 26, 2015 2:55 am
Posts: 890
Location: Ukraine
Should up that topic. Idea to add adaptive design support to PB UI system looks good now as for me, recently DPI question became really painful thing, there are too many ppl using "125% scaling", etc, and not more enough to make some nice fixed GUI basing on 96 DPI.

( Yet another stupid trend to deal with. How I like to see when people making things complicated -- just because they had nothing to do, after did something which was fine already :3 )

_________________
Time beyond time

Like a copyleft notify: all the source code created by me and posted on Purebasic official forums is free to use and modification in all possible (and several impossible) ways for anyone, without asking my permission


Top
 Profile  
Reply with quote  
 Post subject: Re: DPI aware
PostPosted: Sun Sep 04, 2016 5:21 pm 
Offline
User
User
User avatar

Joined: Wed Mar 25, 2015 1:06 pm
Posts: 44
Location: Norway
A fixed GUI at 96 DPI would have almost unreadable text on a 20-30 inch 5K monitor, and since it's fixed you can't make it larger. If it was DPI aware the user could just adjust the DPI setting in the OS.



But back to PureBasic. We need the implementation such that we avoid using a macro 112 times like I mentioned in the original post, or wrapping all PB GUI functions used.
The best way is to simply use 96 DPI internally and then use the Windows API to translate that to the OS/session DPI.

But even then there are still some minor things to be aware of, a GUI may end up with a pixel just being 1 or 2 pixels big but even 1.4 pixels big.
So all GUI design need to be aware of how things can seem 1 pixel off sometimes at certain DPI settings.
The simplest fix is to simply leave a minimum of 1 pixel space around all elements (And test at various DPI settings, a virtual machine is a nice way to test this with a older OS, with Windows 10 and 8 and 7 you can make testing accounts for this, a 200% DPI account for example, plenty apps break horribly).

_________________
4 music albums under CC BY license available for free (any use, even commercial) at Skuldwyrm.no


Top
 Profile  
Reply with quote  
 Post subject: Re: DPI aware
PostPosted: Sun Sep 04, 2016 10:47 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5695
Location: Wales, UK
I really like Danilo's suggestion. We don't need to have so many unit choices, just the one - perhaps PB's own unit?

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: DPI aware
PostPosted: Wed Sep 07, 2016 2:51 pm 
Offline
User
User
User avatar

Joined: Wed Mar 25, 2015 1:06 pm
Posts: 44
Location: Norway
@IdeasVacuum
PB would not need it's own unit, it would simply be "Pixel" but at 96 PPI.
I forget exactly which API it was but you can use a Windows API to transform from virtual pixels (96PPI) to screen pixels (user/display set PPI).

This means that as a GUI designer you'd work with a window that is 1000x500 pixels, but on screen it will be 1250x625 if the user/display/system/os/monitor is set to 125% "DPI".
Internally PB will need to juggle a few more numbers though, but as the developer you won't have to worry about this.
PB would also need some handling code to deal with Windows 8 and later when it comes to multiple monitors with different PPI, as the main monitor could be 125% DPI but the left could be only 107% DPI.

For example there are people out there that like to use a measuring tape and align the custom DPI slider so the lines match up with the real measuring tape and that way get a 1:1 real world pixel density ratio, aka native per monitor DPI.
That way when moving a window from one monitor to another it will remain exactly the same size despite the monitors having different sizes and different PPIs.

_________________
4 music albums under CC BY license available for free (any use, even commercial) at Skuldwyrm.no


Top
 Profile  
Reply with quote  
 Post subject: Re: DPI aware
PostPosted: Fri Aug 11, 2017 2:07 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 14, 2011 6:07 pm
Posts: 322
+1

Thank you PB team for considering this badly needed feature


Top
 Profile  
Reply with quote  
 Post subject: Re: DPI aware
PostPosted: Fri Aug 11, 2017 2:11 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 1081
Location: germany
In general, DPI awareness would be great. But for all supported platforms and also for XML dialogues.

+1


Top
 Profile  
Reply with quote  
 Post subject: Re: DPI aware
PostPosted: Fri Aug 11, 2017 7:13 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3142
Location: Berlin, Germany
How could I miss this thread? :? :D
+1 from me, too, of course :!:

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


Top
 Profile  
Reply with quote  
 Post subject: Re: DPI aware
PostPosted: Sun Aug 13, 2017 7:24 pm 
Offline
Addict
Addict

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1465
Location: Uttoxeter, UK
+1

_________________
DE AA EB


Top
 Profile  
Reply with quote  
 Post subject: Re: DPI aware
PostPosted: Sun Aug 13, 2017 8:00 pm 
Offline
User
User

Joined: Mon Apr 10, 2017 6:17 pm
Posts: 35
+1


Top
 Profile  
Reply with quote  
 Post subject: Re: DPI aware
PostPosted: Fri Sep 15, 2017 12:59 pm 
Offline
User
User

Joined: Wed Mar 11, 2009 4:06 pm
Posts: 41
Location: NL
+2


Top
 Profile  
Reply with quote  
 Post subject: Re: DPI aware
PostPosted: Mon Sep 18, 2017 2:55 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 382
Location: Berlin and Ibiza
+∞ :D

_________________
ImageImageImageImage


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 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:  
cron

 


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