Skip to content

Commit

Permalink
Release Insert project marker under mouse or play cursor v1.0 (#1311)
Browse files Browse the repository at this point in the history
  • Loading branch information
cfillion authored Feb 8, 2024
1 parent 44b620f commit c80b4d5
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Markers/az_Insert project marker under mouse or play cursor.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
-- @description Insert project marker under mouse or play cursor
-- @author AZ
-- @version 1.0
-- @provides
-- [main=main,midi_editor] .
-- [main=main,midi_editor] az_Insert project marker under mouse or play cursor/az_Insert project marker and edit it under mouse or play cursor.lua
-- @link Forum thread https://forum.cockos.com/showthread.php?t=288069
-- @donation Donate via PayPal https://www.paypal.me/AZsound
-- @about
-- SWS is required
--
-- This script brings usability of project markers closer to the take markers.
--
-- If mouse placed in arrange - use mouse position for marker, else use edit or play cursor position.

function ins_proj_marker()
window, segment, details = reaper.BR_GetMouseCursorContext()

if window == "arrange" or window == "midi_editor" then
pos = reaper.BR_GetMouseCursorContext_Position()

if window == "midi_editor" then
if segment == "unknown"or segment == "notes"or segment == "cc_lane" then
reaper.AddProjectMarker2( 0, false, pos, 0, "", -1, 0 )
else
reaper.Main_OnCommandEx( reaper.NamedCommandLookup( "_S&M_INS_MARKER_PLAY" ), 0, 0 )
end
else
reaper.AddProjectMarker2( 0, false, pos, 0, "", -1, 0 )
end
else
reaper.Main_OnCommandEx( reaper.NamedCommandLookup( "_S&M_INS_MARKER_PLAY" ), 0, 0 )
end

end



reaper.Undo_BeginBlock2( 0 )
ins_proj_marker()
reaper.Undo_EndBlock2( 0, "Insert project marker", -1 )
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
-- @noindex

function ins_marker_mouse()
reaper.Main_OnCommandEx( 40513, 0, 0 ) --View: Move edit cursor to mouse cursor
reaper.Main_OnCommandEx( 40171, 0, 0 ) --Insert and/or edit marker at current position
reaper.SetEditCurPos2( 0, edit_cur_pos, false, false )
end

----------
----------

function ins_marker_play()
reaper.Main_OnCommandEx( 40434, 0, 0 ) --View: Move edit cursor to play cursor
reaper.Main_OnCommandEx( 40171, 0, 0 ) --Insert and/or edit marker at current position
reaper.SetEditCurPos2( 0, edit_cur_pos, false, false )
end

-------------------------------
-------------------------------

function ins_proj_marker()
edit_cur_pos = reaper.GetCursorPositionEx( 0 )
window, segment, details = reaper.BR_GetMouseCursorContext()

if window == "arrange" or window == "midi_editor" then
pos = reaper.BR_GetMouseCursorContext_Position()

if window == "midi_editor" then
if segment == "unknown"or segment == "notes"or segment == "cc_lane" then
ins_marker_mouse()
else
ins_marker_play()
end
else
ins_marker_mouse()
end
else
ins_marker_play()
end

end



reaper.Undo_BeginBlock2( 0 )
reaper.PreventUIRefresh( 1 )
ins_proj_marker()
reaper.PreventUIRefresh( -1 )
reaper.Undo_EndBlock2( 0, "Insert project marker", -1 )

0 comments on commit c80b4d5

Please sign in to comment.