Old 05-06-2020, 10:10 AM   #1
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default How to get minimum track height?

When I minimize a track, e.g. like this


or zoom out TCP via scroll wheel etc., track height seems to be 24 pixels here.
Is this a hardcoded value, or theme/HiDPI dependent, if so, how to get that value?
nofish is offline   Reply With Quote
Old 05-06-2020, 10:21 AM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

From my unfinished StateChunk-docs, the trackheight is between 24 and 443 pixels for regular tracks in TCP and 24 to 260 for the master-track in tcp.

The mastertrackheight I gave sounds wrong to me, so this could be an error on my side(there's a reason, why my statechunk-docs are unreleased yet )
__________________
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 05-06-2020, 10:32 AM   #3
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Thanks. According to this 24 pixels seems indeed hardcoded min. track height.
nofish is offline   Reply With Quote
Old 05-06-2020, 11:15 AM   #4
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,238
Default

I think it depends on the theme.
in walter look for the "tcp_heights"

tcp_heights 4 24 35 58 ; supercollapsed, collapsed, small(norecarm), recarm size
heda is offline   Reply With Quote
Old 05-06-2020, 11:33 AM   #5
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by heda View Post
I think it depends on the theme.
in walter look for the "tcp_heights"

tcp_heights 4 24 35 58 ; supercollapsed, collapsed, small(norecarm), recarm size
If I get this right, it doesn't define the limits, rather the sizes when collapsing them.
Means, the limits are still 24 as the smallest one, though you can define others for collapsed states.

Though it's worth an experiment, whether its possible to set them to smaller than 24px for collapsed ones.
__________________
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 05-06-2020, 11:34 AM   #6
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by heda View Post
I think it depends on the theme.
in walter look for the "tcp_heights"

tcp_heights 4 24 35 58 ; supercollapsed, collapsed, small(norecarm), recarm size
Thanks.
But how to get this value in ReaScript then?
I'd like to do a minimize (i.e. collaps) tracks function.
nofish is offline   Reply With Quote
Old 05-06-2020, 11:37 AM   #7
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Setting I_HEIGHTOVERRIDE to 1 should result in the theme's minimum track height being used.
cfillion is offline   Reply With Quote
Old 05-06-2020, 11:37 AM   #8
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Unless they are exposed via the Theme get/setlayout parameters, its difficult.
If the theme is unpacked, you can simply read the rtconfig-file. If not, you need to unpack the file first.
Julian is planning to add an (un)zipper to his extension, which could be useful in this case.

Edit: cfillion was faster and more accurate than me
__________________
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 05-06-2020, 11:43 AM   #9
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by cfillion View Post
Setting I_HEIGHTOVERRIDE to 1 should result in the theme's minimum track height being used.

Hmm, this sets the collapsed trackheight, but only after I clicked on the track to select it. Before that, it will be ignored.
Not even UpdateArrange seems to have an effect on that.

Code:
fromTrack = reaper.GetTrack(0,0)
A,B=reaper.SetMediaTrackInfo_Value(fromTrack, "I_HEIGHTOVERRIDE", 1)
reaper.UpdateArrange()
Edit: Correction: will be updated only, when I change the track-selection-state of a track.
__________________
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 05-06-2020, 11:47 AM   #10
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by cfillion View Post
Setting I_HEIGHTOVERRIDE to 1 should result in the theme's minimum track height being used.
Isn't that "setting I_HEIGHTOVERRIDE to 0" (as SWS does)?

That's exactly what I want to work around as it disables track height lock:
https://forum.cockos.com/showthread.php?t=227045

Trying to fix this:
https://github.com/reaper-oss/sws/issues/1221
nofish is offline   Reply With Quote
Old 05-06-2020, 11:48 AM   #11
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Hmm, this sets the collapsed trackheight, but only after I clicked on the track to select it. Before that, it will be ignored.
TrackList_AdjustWindows is needed to apply the new height (not UpdateArrange).

Quote:
Originally Posted by nofish View Post
Isn't that "setting I_HEIGHTOVERRIDE to 0" (as SWS does)?
0 disables the height lock but 1 just results in the theme's minimum height.

EDIT: When the height lock is enabled, it uses the given 1px height as-is, so this won't work...

Last edited by cfillion; 05-06-2020 at 12:09 PM.
cfillion is offline   Reply With Quote
Old 05-06-2020, 11:55 AM   #12
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by cfillion View Post
TrackList_AdjustWindows is needed to apply the new height (not UpdateArrange).
Thanks. Do you have an idea, what the parameter "isminor" actually does?
__________________
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 05-06-2020, 12:19 PM   #13
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Thanks. Do you have an idea, what the parameter "isminor" actually does?
https://forum.cockos.com/showthread.php?t=208275
nofish is offline   Reply With Quote
Old 05-06-2020, 12:21 PM   #14
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by cfillion View Post
EDIT: When the height lock is enabled, it uses the given 1px height as-is, so this won't work...
Yes, noticed this too.
nofish is offline   Reply With Quote
Old 05-06-2020, 12:23 PM   #15
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Could this help as a workaround?

Code:
  local lockstate = reaper.GetMediaTrackInfo_Value(track, "B_HEIGHTLOCK", 0) -- get current lockstate
  reaper.SetMediaTrackInfo_Value(track, "B_HEIGHTLOCK", 0) -- unlock track
  reaper.SetMediaTrackInfo_Value(track, "I_HEIGHTOVERRIDE", 10) -- set new height
  reaper.TrackList_AdjustWindows(false) -- update TCP
  reaper.SetMediaTrackInfo_Value(track, "B_HEIGHTLOCK", lockstate) -- restore lockstate of track
__________________
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 05-06-2020, 12:28 PM   #16
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by nofish View Post
Thanks. Added that information to my API-docs.
__________________
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 05-06-2020, 12:28 PM   #17
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

I_TCPH can be used to get the minimum height but it probably flickers on Windows because it requires TrackList_AdjustWindows. (It cannot be used with PreventUIRefresh as TrackList_AdjustWindows would do nothing.)

Code:
local track = reaper.GetTrack(nil, 0)

reaper.SetMediaTrackInfo_Value(track, 'I_HEIGHTOVERRIDE', 1)
reaper.SetMediaTrackInfo_Value(track, 'B_HEIGHTLOCK', 0)
reaper.TrackList_AdjustWindows(true)
minimumHeight = reaper.GetMediaTrackInfo_Value(track, 'I_TCPH')

reaper.SetMediaTrackInfo_Value(track, 'I_HEIGHTOVERRIDE', minimumHeight)
reaper.SetMediaTrackInfo_Value(track, 'B_HEIGHTLOCK', 1)
reaper.TrackList_AdjustWindows(true)
cfillion is offline   Reply With Quote
Old 05-06-2020, 12:32 PM   #18
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Hm..maybe the easiest fix is indeed keeping the function as is and just restore the lock state afterwards (as Meo-Ada Mespotine said).

edit:
Nah, doesn't work because once I_HEIGHTOVERRIDE == 0 the tracks can't be heightlocked anymore, duh, I think I give up.

Last edited by nofish; 05-06-2020 at 01:10 PM.
nofish is offline   Reply With Quote
Old 05-06-2020, 12:40 PM   #19
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

As long as I_HEIGHTOVERRIDE is never smaller than the theme's minimum height when the track is re-locked, yes.

EDIT: VertZoomRange already ensures that:

Code:
int minTrackHeight = SNM_GetIconTheme()->tcp_small_height; // nice!

if (iEachHeight < minTrackHeight)
  iEachHeight = minTrackHeight;

Last edited by cfillion; 05-06-2020 at 12:51 PM.
cfillion is offline   Reply With Quote
Old 05-06-2020, 12:44 PM   #20
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

If you temporarily disable tracklock, this is no problem. Have tested it. The minimum trackheight is only overriden, when track is locked.

Which results in nice possibilities. Will write a function to do that for my API
__________________
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 05-06-2020, 01:21 PM   #21
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by cfillion View Post
Code:
int minTrackHeight = SNM_GetIconTheme()->tcp_small_height; // nice!
Ohhh totally missed that! I think I can work with it, thanks.

edit:
Quote:
As long as I_HEIGHTOVERRIDE is never smaller than the theme's minimum height when the track is re-locked, yes.
That would still not solve the unintended unlocking of the minimized tracks.
https://github.com/reaper-oss/sws/issues/1221

But I think this can be replaced with this nice minTrackHeight.

Last edited by nofish; 05-06-2020 at 01:30 PM.
nofish is offline   Reply With Quote
Old 05-06-2020, 05:06 PM   #22
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Nice funfact:

If you set the trackheight with trackheight locked, the maximum height of all tracks combined can be up to 2147483586 pixels.
__________________
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 12-16-2021, 11:17 AM   #23
MathieuC
Human being with feelings
 
Join Date: Apr 2021
Location: Brest, France
Posts: 52
Default

Quote:
Originally Posted by cfillion View Post
As long as I_HEIGHTOVERRIDE is never smaller than the theme's minimum height when the track is re-locked, yes.

EDIT: VertZoomRange already ensures that:

Code:
int minTrackHeight = SNM_GetIconTheme()->tcp_small_height; // nice!

if (iEachHeight < minTrackHeight)
  iEachHeight = minTrackHeight;

Hello, quite old post, I know but I'm trying to figure out what you mean with this reference to something that doesn't seems to be LUA, or at least "lua accessible" ?


I'm trying to get the minimum track height of a theme.
MathieuC is offline   Reply With Quote
Old 12-16-2021, 08:09 PM   #24
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by MathieuC View Post
Hello, quite old post, I know but I'm trying to figure out what you mean with this reference to something that doesn't seems to be LUA, or at least "lua accessible" ?


I'm trying to get the minimum track height of a theme.
Hi, I'm the thread starter and my question was related to an issue in SWS extension, so what cfillion posted is C++ code, only useable from within the SWS code base.
I still don't know of a way to do this in Lua, sorry.
nofish is offline   Reply With Quote
Old 12-17-2021, 06:01 AM   #25
MathieuC
Human being with feelings
 
Join Date: Apr 2021
Location: Brest, France
Posts: 52
Default

Hi NoFish,


Thanks for your reply, ok, I guess I have to wait for an API implementation of such a feature.
MathieuC is offline   Reply With Quote
Old 12-30-2023, 05:01 AM   #26
MathieuC
Human being with feelings
 
Join Date: Apr 2021
Location: Brest, France
Posts: 52
Default

Hello folks,
An updated version of this script, if it can help... :
Code:
    --- get the minimum track height on a project. This size is theme related so it may change from on theme to another.
    -- this is a workaround by CFillion : [https://forum.cockos.com/showpost.php?p=2283520&postcount=17](https://forum.cockos.com/showpost.php?p=2283520&postcount=17)
    -- @warning due to the workaround use here, screen will quickly blink once while looking for min track height.
    function minimumTrackHeight()
        --get first track avoiding folders and track with fixed lanes
        nbrTracks= reaper.CountTracks(0)
        
        for i=0, nbrTracks-1 do
            track=reaper.GetTrack(0, i)
            --if no lanes, nbr_f_lanes will be 1
            nbr_f_lanes=reaper.GetMediaTrackInfo_Value( track, "I_NUMFIXEDLANES" )
            
            if reaper.GetMediaTrackInfo_Value( track, "I_FOLDERDEPTH") ~= 1 and  
            reaper.IsTrackVisible(track,false )and
            nbr_f_lanes < 1 then
            --if the track is not a folder, is visible and hasn't lanes wee keep it
                track=reaper.GetTrack(0, i)
                break
            end
        end
        
        --1st track size info and lock it
        local tr_lock_state=reaper.GetMediaTrackInfo_Value(track, "B_HEIGHTLOCK") 
        local tr_height=reaper.GetMediaTrackInfo_Value(track, "I_TCPH")
        
        --remove potential refresh lock state. Potentialy toggling "reaper.TrackList_AdjustWindows(true)" function in a disable state
        reaper.PreventUIRefresh(-1)    
        --minimization of 1rst track to minimum tarck height
        reaper.SetMediaTrackInfo_Value(track, "I_HEIGHTOVERRIDE", 1)
        reaper.TrackList_AdjustWindows(true)
        minimumHeight = reaper.GetMediaTrackInfo_Value(track, "I_TCPH")
        
        --restore 1rst track size and unlock
        reaper.SetMediaTrackInfo_Value(track,"B_HEIGHTLOCK",tr_lock_state)
        reaper.SetMediaTrackInfo_Value(track,"I_HEIGHTOVERRIDE",tr_height)
        reaper.TrackList_AdjustWindows(true)
        
        --return to previous refresh UI state
        reaper.PreventUIRefresh(1)
        return minimumHeight
    end
__________________
Various scripts can be found here : https://github.com/MathieuCGit -- Donation is always welcome : https://paypal.me/MathieuCONAN -- or buy me a coffee : https://www.buymeacoffee.com/mathieucgit
MathieuC is offline   Reply With Quote
Old 12-30-2023, 09:16 AM   #27
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by MathieuC View Post
Hello folks,
An updated version of this script, if it can help... :
FWIW that solution only works when I remove the reaper.PreventUIRefresh() lines. Surprisingly it doesn't always flicker.
Also if source track is height locked it returns 1.0 here.

Win10_x64, REAPER v7.07

Last edited by Edgemeal; 12-30-2023 at 09:33 AM.
Edgemeal is offline   Reply With Quote
Old 12-30-2023, 11:56 AM   #28
MathieuC
Human being with feelings
 
Join Date: Apr 2021
Location: Brest, France
Posts: 52
Default

Quote:
Originally Posted by Edgemeal View Post
FWIW that solution only works when I remove the reaper.PreventUIRefresh() lines. Surprisingly it doesn't always flicker.
Also if source track is height locked it returns 1.0 here.
Yes, this is more a snippet you can, of course, tweak regarding your needs
You can also replace the fixed item lanes detection by
Code:
is_tr_fil, _ = reaper.GetSetMediaTrackInfo_String( tr, "P_LANENAME:0", "", 0 )
instead of
Code:
reaper.GetMediaTrackInfo_Value( track, "I_NUMFIXEDLANES" )
__________________
Various scripts can be found here : https://github.com/MathieuCGit -- Donation is always welcome : https://paypal.me/MathieuCONAN -- or buy me a coffee : https://www.buymeacoffee.com/mathieucgit
MathieuC is offline   Reply With Quote
Old 12-31-2023, 08:22 AM   #29
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by MathieuC View Post
Yes, this is more a snippet you can, of course, tweak regarding your needs
Just wanted to point out, your code won't work with height-locked tracks, I do it similar to post #17, I check if source track is Height Locked, if it is then I unlock it first, then resize, etc,, then restore track back to its original height and set height-lock state if needed. Happy New Year!

Last edited by Edgemeal; 12-31-2023 at 08:36 AM.
Edgemeal is offline   Reply With Quote
Old 12-31-2023, 08:37 AM   #30
MathieuC
Human being with feelings
 
Join Date: Apr 2021
Location: Brest, France
Posts: 52
Default

Regarding my previous post, I present another version that is more to my liking.

Code:
function minimumTrackHeight()
	--get first track avoiding folders and fixed lanes
	local nbr_tr= reaper.CountTracks(0)		
	
	for i=0, nbr_tr-1 do
		track=reaper.GetTrack(0, i)
		tr_lock_state=reaper.GetMediaTrackInfo_Value(track, "B_HEIGHTLOCK") 
		tr_height=reaper.GetMediaTrackInfo_Value(track, "I_TCPH")
		is_tr_fil, _ = reaper.GetSetMediaTrackInfo_String( track, "P_LANENAME:0", "", 0 ) -- check track to get FIL true/false
		
		if reaper.GetMediaTrackInfo_Value( track, "I_FOLDERDEPTH") ~= 1 and  
		reaper.IsTrackVisible(track,false ) and
		tr_lock_state == 0.0 and
		is_tr_fil == false then
		--if the track is not a folder, is visible and hasn't lanes wee keep it
			track=reaper.GetTrack(0, i)
			break
		end
	end
	
	--remove potential refresh lock state. Potentialy toggling "reaper.TrackList_AdjustWindows(true)" function in a disable state
	reaper.PreventUIRefresh(-1)	
	--minimization of 1rst track to minimum tarck height
	reaper.SetMediaTrackInfo_Value(track, "I_HEIGHTOVERRIDE", 1)
	reaper.TrackList_AdjustWindows(true)
	minimumHeight = reaper.GetMediaTrackInfo_Value(track, "I_TCPH")
	
	--restore 1rst track size and unlock
	reaper.SetMediaTrackInfo_Value(track,"B_HEIGHTLOCK",tr_lock_state)
	reaper.SetMediaTrackInfo_Value(track,"I_HEIGHTOVERRIDE",tr_height)
	reaper.TrackList_AdjustWindows(true)
	
	--return to previous refresh UI state
	reaper.PreventUIRefresh(1)
	return minimumHeight
end
__________________
Various scripts can be found here : https://github.com/MathieuCGit -- Donation is always welcome : https://paypal.me/MathieuCONAN -- or buy me a coffee : https://www.buymeacoffee.com/mathieucgit

Last edited by MathieuC; 12-31-2023 at 09:02 AM.
MathieuC is offline   Reply With Quote
Old 12-31-2023, 08:39 AM   #31
MathieuC
Human being with feelings
 
Join Date: Apr 2021
Location: Brest, France
Posts: 52
Default

Quote:
Originally Posted by Edgemeal View Post
Just wanted to point out, your code won't work with height-locked tracks, I do it similar to post #17, I check if source track is Height Locked, if it is then I unlock it first, then resize, etc,, then restore track back to its original height and set height-lock state if needed. Happy New Year!

Oh yes, thanks, the script i'm working on check this parameter in another place. I add it in the previous post with the edited code.
__________________
Various scripts can be found here : https://github.com/MathieuCGit -- Donation is always welcome : https://paypal.me/MathieuCONAN -- or buy me a coffee : https://www.buymeacoffee.com/mathieucgit

Last edited by MathieuC; 12-31-2023 at 09:03 AM.
MathieuC 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 03:05 AM.


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