OK, so far the closest solution was in Dofman's scripts along with idea to fully zoom in/out before zooming to specific level:
https://forum.cockos.com/showthread.php?t=171389
There are also scripts to zoom MIDI editor / piano roll horizontally to 5 bars etc., based on utilizing "zoom to loop" functions:
https://forum.cockos.com/showthread.php?t=91048&page=4
I've made another simple script [for horizontal zooming in MIDI editor] which works by zooming in as far as possible and then zooming out a number of steps.
It works for me, but I have no idea how this is internally related to DPI etc. of a monitor, so anyone who wants to use this might have to customize zoom levels in the script to their own needs.
Good thing is - the script is so simple, anyone can do that (and make several variations for different zoom levels if needed).
Lua code below:
Code:
-- get MIDI editor window to address
active_MIDI_editor = reaper.MIDIEditor_GetActive()
-- don't show intermediate steps
reaper.PreventUIRefresh(1)
--zoom in to maximum (200 steps is likely to cover most cases)
for i=0,200,1
do
reaper.MIDIEditor_OnCommand(active_MIDI_editor, 1012) --zoom in horizontally
end
--zoom back out a specific number of steps
for i=0,35,1
do
reaper.MIDIEditor_OnCommand(active_MIDI_editor, 1011) --zoom out horizontally
end
-- update UI
reaper.PreventUIRefresh(-1)
NOTE: the script might not work if it's currently being edited in ReaScript Development Environment. Closing the script editor fixes that.
My way of using this is to load the script into Main section of Actions list, then make a button for it in a custom toolbar. If intended as a button for MIDI Editor toolbar, the script would have to be loaded into MIDI Editor section of Actions list.
If buttons for multiple zoom levels are needed, they can be done by copying the .lua file, changing its name and the number of steps in the script [and loading that file into Actions list, and so on].