It is currently Tue Oct 15, 2019 5:41 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: DPI Scaling for linux
PostPosted: Wed Dec 12, 2018 10:16 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Apr 26, 2003 2:49 pm
Posts: 614
Functions that do the same as DesktopScaled/Unscaled() for linux. Resizing in gtk can be tricky but some kind of support like in windows would be nice.

There is no difference between x / y scaling, but i leave the two functions.
dpi::Init() must be called before using them.
Code:
DeclareModule dpi
   Declare Init()
   Declare ScaleX(x.i)
   Declare ScaleY(y.i)
   Declare UnScaleX(x.i)
   Declare UnScaleY(y.i)
EndDeclareModule

Module dpi
   EnableExplicit
   
   ImportC ""
     gdk_screen_get_resolution_.d(scr.i) As "gdk_screen_get_resolution"
   EndImport

   Global.f g_DPIScaleX, g_DPIScaleY

   Procedure ScaleX(x.i)
      ProcedureReturn Round(x * g_DPIScaleX, #PB_Round_Down)
   EndProcedure
   
   Procedure ScaleY(y.i)
      ProcedureReturn Round(y * g_DPIScaleY, #PB_Round_Down)
   EndProcedure
   
   Procedure UnScaleX(x.i)
      ProcedureReturn x / g_DPIScaleX
   EndProcedure
   
   Procedure UnScaleY(y.i)
      ProcedureReturn y / g_DPIScaleY
   EndProcedure
   
   Procedure Init()
      Define.i scr      

      gtk_init_(0, 0)
      
      scr = gdk_screen_get_default_()

      g_DPIScaleX =  gdk_screen_get_resolution_(scr) / 96.0
      g_DPIScaleY = g_DPIScaleX
   EndProcedure
EndModule

;- TEST
dpi::Init()

Debug dpi::ScaleX(100)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

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