Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 01-05-2018, 04:27 PM   #1
mawi
Human being with feelings
 
Join Date: Apr 2011
Location: Germany
Posts: 1,186
Default Grid and snap automatically adapts to zoom level (solved)

Is there a grid and snap feature that can be adapted to the zoom level? If not, is this planned for the future?

Last edited by mawi; 07-15-2021 at 01:02 PM.
mawi is offline   Reply With Quote
Old 01-06-2018, 04:07 AM   #2
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,067
Default

Was asking myself the same question
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 01-06-2018, 11:38 AM   #3
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 5,247
Default

What i use for that is a "workaround" cause i believe your wish isn't implemented natively in Reaper (yet).

When you have ReaPack installed (www.reapack.com) , you will have this Action:

Script: mpl_Zoom horizontally, change grid relatively, preserve grid visibility and snap state (mousewheel).lua

Assign it to your mousewheel (mousewheel plus modifier key like SHIFT is also possible).

- Make sure you have Snap turned on.
- Dial mousewheel.

Now, Arrange View will be zoomed horizontally and the grid values will change accordingly.

Kudos ofcourse to great scripter mpl for this great script !
__________________
Macbook Pro INTEL | Reaper, always latest version | OSX Ventura | Presonus Studio 24c
My Reaper Tips&Tricks YouTube Channel: https://www.youtube.com/user/vanhaze2000/playlists
vanhaze is offline   Reply With Quote
Old 01-09-2018, 12:53 PM   #4
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,067
Default

That's indeed a marvelous script, thanks for mentioning vanhaze and thanks for codind MPL!
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 01-09-2018, 01:28 PM   #5
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 5,247
Default

!!
__________________
Macbook Pro INTEL | Reaper, always latest version | OSX Ventura | Presonus Studio 24c
My Reaper Tips&Tricks YouTube Channel: https://www.youtube.com/user/vanhaze2000/playlists
vanhaze is offline   Reply With Quote
Old 01-10-2018, 10:20 AM   #6
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,067
Default

I made a version where you can assign zoom in and out to shortcuts.
I don't feel like adding those to my repo, since all kudos go to MPL, maybe he can add them to his repo.
Basically, I only removed the mousewheel assignment and the if condition.

Zoom out
Code:
-- @description Zoom horizontally, change grid relatively, preserve grid visibility and snap state  (mousewheel) 
-- @version 1.0
-- @author mpl
-- @changelog
--   + init
-- @website http://forum.cockos.com/member.php?u=70694
 
 
  function main()
--------------------------------------------------------------------
  zoom_adjust = 1  
  stages = {0.38, -- no grid
            5, -- 2
            16,--1
            22.84,
            48.84, -- 1/4
            117.86,
            351.95,-- 1/16
            1050.92,
            3200.07,
            6077} -- no grid
            
------------------------------------------------------------------            
  function log(value, base) return math.log(value) /math.log(base)end      
  function msg(s) reaper.ShowConsoleMsg(s..'\n') end
  


    reaper.adjustZoom( -zoom_adjust,
                       0,--forceset, 
                       true,--doupd, 
                       -1)--centermode )    
  
  
  grid_t = {}
  for i = 2, -7, -1 do grid_t[#grid_t+1] = 2^i end
 
  zoom_lev = reaper.GetHZoomLevel()   
  --[[if zoom_lev < stages[2] or zoom_lev > stages[10] then 
    reaper.Main_OnCommand(40753,0) -- disable snap
    if reaper.GetToggleCommandState( 40145 ) == 1 then
      reaper.Main_OnCommand(40145,0) -- toggle grid lines
    end
   else
    reaper.Main_OnCommand(40754,0) -- enable snap
    if reaper.GetToggleCommandState( 40145 ) == 0 then
      reaper.Main_OnCommand(40145,0) -- toggle grid lines
    end
  end]]
  
  for i = 1, #stages-1 do
    if zoom_lev > stages[i] and zoom_lev <= stages[i+1] then
      reaper.SetProjectGrid( 0, grid_t[i] )
      --[[reaper.ShowConsoleMsg("")
      msg('zoom_lev '..zoom_lev)
      msg('grid_t '..i..' // '..grid_t[i]..'\n 2 ^'..log(grid_t[i], 2) )
      msg('stages '..i..'  '..stages[i]) ]]     
      break
    end
  end
  end
  
  
  reaper.defer(main)

Zoom in
Code:
-- @description Zoom horizontally, change grid relatively, preserve grid visibility and snap state  (mousewheel) 
-- @version 1.0
-- @author mpl
-- @changelog
--   + init
-- @website http://forum.cockos.com/member.php?u=70694
 
 
  function main()
--------------------------------------------------------------------
  zoom_adjust = 1  
  stages = {0.38, -- no grid
            5, -- 2
            16,--1
            22.84,
            48.84, -- 1/4
            117.86,
            351.95,-- 1/16
            1050.92,
            3200.07,
            6077} -- no grid
            
------------------------------------------------------------------            
  function log(value, base) return math.log(value) /math.log(base)end      
  function msg(s) reaper.ShowConsoleMsg(s..'\n') end
  
 
    reaper.adjustZoom( zoom_adjust,
                       0,--forceset, 
                       true,--doupd, 
                       -1)--centermode )
 
  grid_t = {}
  for i = 2, -7, -1 do grid_t[#grid_t+1] = 2^i end
 
  zoom_lev = reaper.GetHZoomLevel()   
  --[[if zoom_lev < stages[2] or zoom_lev > stages[10] then 
    reaper.Main_OnCommand(40753,0) -- disable snap
    if reaper.GetToggleCommandState( 40145 ) == 1 then
      reaper.Main_OnCommand(40145,0) -- toggle grid lines
    end
   else
    reaper.Main_OnCommand(40754,0) -- enable snap
    if reaper.GetToggleCommandState( 40145 ) == 0 then
      reaper.Main_OnCommand(40145,0) -- toggle grid lines
    end
  end]]
  
  for i = 1, #stages-1 do
    if zoom_lev > stages[i] and zoom_lev <= stages[i+1] then
      reaper.SetProjectGrid( 0, grid_t[i] )
      --[[reaper.ShowConsoleMsg("")
      msg('zoom_lev '..zoom_lev)
      msg('grid_t '..i..' // '..grid_t[i]..'\n 2 ^'..log(grid_t[i], 2) )
      msg('stages '..i..'  '..stages[i]) ]]     
      break
    end
  end
  end
  
  
  reaper.defer(main)
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 01-25-2021, 09:56 AM   #7
fbeauvaisc
Human being with feelings
 
Join Date: Nov 2018
Location: Montreal
Posts: 405
Default

This is amazing! Exactly what I needed!
fbeauvaisc 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 12:45 PM.


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