Old 03-09-2024, 10:25 AM   #1
FeedTheCat
Human being with feelings
 
FeedTheCat's Avatar
 
Join Date: May 2019
Location: Berlin
Posts: 2,198
Default Detect OS window scaling without opening gfx window

Howdy folks,

has anyone found a way to detect OS window scaling without opening a gfx window? I'm looking for the return value of gfx.ext_retina.

For Gridbox, I am currently using a method that measures the tooltip window with JS_ReaScriptAPI, but turns out that this is unreliable.
__________________
Featured scripts: REAPER Update UtilityLil ChordboxGridbox/Adaptive gridMX TunerRS5K LinkMIDI Editor Magic Donate💝: PayPal|ko-fi
FeedTheCat is offline   Reply With Quote
Old 03-09-2024, 08:14 PM   #2
whats_up
Human being with feelings
 
Join Date: Nov 2020
Posts: 185
Default

with windows api (js extentions) you can do it easly.
you can verify reaper main window,
or create a hidden window, verify and destroy
__________________
Easy EEL to VST Building system
https://forum.cockos.com/showthread.php?t=245285
github: https://github.com/VisualCodeBase/CodeBase
whats_up is online now   Reply With Quote
Old 03-10-2024, 03:05 AM   #3
FeedTheCat
Human being with feelings
 
FeedTheCat's Avatar
 
Join Date: May 2019
Location: Berlin
Posts: 2,198
Default

Quote:
Originally Posted by whats_up View Post
with windows api (js extentions) you can do it easly.
you can verify reaper main window,
or create a hidden window, verify and destroy
Hi whats_up, thank you for your response. I'm aware of the "create hidden window" method (it's plan B ).

Curious what you mean with "verify reaper main window"?
__________________
Featured scripts: REAPER Update UtilityLil ChordboxGridbox/Adaptive gridMX TunerRS5K LinkMIDI Editor Magic Donate💝: PayPal|ko-fi
FeedTheCat is offline   Reply With Quote
Old 03-10-2024, 05:42 AM   #4
whats_up
Human being with feelings
 
Join Date: Nov 2020
Posts: 185
Default

find it by class name
and then verify its scaling
__________________
Easy EEL to VST Building system
https://forum.cockos.com/showthread.php?t=245285
github: https://github.com/VisualCodeBase/CodeBase
whats_up is online now   Reply With Quote
Old 03-10-2024, 08:22 AM   #5
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,629
Default

Code:
reaper.ThemeLayout_GetLayout("tcp", -3)
returns the dpi currently used by Reaper. Just compare it with scaling factors.

Code I used to determine scalings from 1x to 8x is the following:
Code:
      local retval, dpi = reaper.ThemeLayout_GetLayout("tcp", -3)
      local dpi=tonumber(dpi)
      
      if dpi<384 then scale=1
      elseif dpi>=384 and dpi<512 then scale=1--.5
      elseif dpi>=512 and dpi<640 then scale=2
      elseif dpi>=640 and dpi<768 then scale=2--.5
      elseif dpi>=768 and dpi<896 then scale=3
      elseif dpi>=896 and dpi<1024 then scale=3--.5
      elseif dpi>=1024 and dpi<1152 then scale=4 
      elseif dpi>=1152 and dpi<1280 then scale=4--.5
      elseif dpi>=1280 and dpi<1408 then scale=5
      elseif dpi>=1408 and dpi<1536 then scale=5--.5
      elseif dpi>=1536 and dpi<1664 then scale=6
      elseif dpi>=1664 and dpi<1792 then scale=6--.5
      elseif dpi>=1792 and dpi<1920 then scale=7
      elseif dpi>=1920 and dpi<2048 then scale=7--.5
      else scale=8
      end
The variable scale returns the scaling factor.

It is compatible to retina-resolutions, afaik.
Scale=2 is Retina/HiDPI.

The benefit of the code above is, that it considers the scaling factor set by the user in the Prefs General->Advanced UI settings.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 03-10-2024, 04:11 PM   #6
FeedTheCat
Human being with feelings
 
FeedTheCat's Avatar
 
Join Date: May 2019
Location: Berlin
Posts: 2,198
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Code:
reaper.ThemeLayout_GetLayout("tcp", -3)
This is perfect!! Thank you!

Better than anything I was hoping for actually This gives me exactly what I was looking for, the scaling of the transport window:

Code:
local _, dpi = reaper.ThemeLayout_GetLayout('trans', -3)
transport_scale = tonumber(dpi) / 256
__________________
Featured scripts: REAPER Update UtilityLil ChordboxGridbox/Adaptive gridMX TunerRS5K LinkMIDI Editor Magic Donate💝: PayPal|ko-fi
FeedTheCat is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:39 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.