Mac: Display Scaling Setting

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Mac: Display Scaling Setting

Post by richmond62 » Sat Jan 20, 2024 3:32 pm

Screenshot 2024-01-20 at 16.28.05.png
-
Coo, err, humpy-duck time.

Is there a way, inwith LC, to detect either:

the displace scaling setting, or

the height of the menu bar at the top of the desktop?

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Mac: Display Scaling Setting

Post by stam » Sat Jan 20, 2024 6:22 pm

Not sure about display scaling setting, but you can certainly compute the height of MacOS Menubar.

The question is why you would need this? Are you for example trying to zoom a stack to fill available space between menubar and the Dock?
If that is what you are trying to do, it's a 1-liner:

Code: Select all

set the effective rect of this stack to the working screenRect
You can calculate the height of the menubar by comparing the top of a stack by examining the difference between the rect and the effective rect of the stack, when both are set to the screenRect. This function returns the current menuBar height:

Code: Select all

function getMenuBarHeight
    return item 2 of the working screenRect
end getMenuBarHeight
On top of this you need to factor in the stack's titlebar height - I think this is fixed at 28 px for 'normal' stacks (I think 19 for palette titlebar).

As I mentioned in a previous thread on this, my menu bar height on a 16' MPB M2 on Sonoma with the standard resolution is 38 px, and this is different from any other number previously mentioned. OTOH, I no longer needed to know this because I can fill the space between menubar and dock with the 1-liner above...

EDITED : silly code in function replaced with 1-liner
Last edited by stam on Sat Jan 20, 2024 8:45 pm, edited 3 times in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Mac: Display Scaling Setting

Post by richmond62 » Sat Jan 20, 2024 7:10 pm

I want to make sure that a stack when opened will position itself so its top is exactly below the Mac menu bar.

Thank you very much.

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Mac: Display Scaling Setting

Post by stam » Sat Jan 20, 2024 8:33 pm

First of all allow me to improve on my previous silly script (the script above edited to reflect the below):

the bottom of the menubar / height of the menubar can be calculated as:

Code: Select all

item 2 of the working screenRect
However if you set the top of this stack to this, it will set the top of the content of the stack to this, not the titlebar, so the titlebar is hidden. I believe the titlebar height is fixed at 28 px for 'normal' topLevel stacks and 19 px for palette titlebars.

You can check titlebar height yourself by positioning a stack at the top of the screen, and then in the msgBox:

Code: Select all

put the top of this stack - item 2 of the working screenrect 


Assuming the titlebar height is constant at 28 px, to position at topLevel stack properly at the bottom of the menubar:

Code: Select all

set the top of this stack to item 2 of the working screenRect + 28
Keep in mind a previous thread about the impact of changing scaleFactor - if you want. to make sure this always works with any scaleFactor, you need to divide the numbers with the stack's scalefactor:

Code: Select all

set the top of this stack to item 2 of the working screenrect/the scalefactor of this stack + 28/the scaleFactor of this stack
this should should position the titlebar of the stack exactly at the bottom of the menubar regardless of the stack's scaleFactor.

HTH
Stam
Last edited by stam on Sat Jan 20, 2024 8:54 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Mac: Display Scaling Setting

Post by richmond62 » Sat Jan 20, 2024 8:54 pm

That detail anent the window bar is well taken.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9389
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Mac: Display Scaling Setting

Post by richmond62 » Sat Jan 20, 2024 9:02 pm

I don't know what to "speak Richmond" means; especially as 'is well taken' is good English.

Anyway; to simplify things: your point about window bars is extremely relevant.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”