From 66bca386387d28393e2f011af0aae8381f0e6056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludwig=20Fr=C3=BChsch=C3=BCtz?= Date: Mon, 27 Jan 2020 13:23:42 +0100 Subject: [PATCH] 4PointCutting: Restore arranger viewport after edit --- 4PointCutting/4Pcut_execute.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/4PointCutting/4Pcut_execute.lua b/4PointCutting/4Pcut_execute.lua index 891afec..aa1900d 100644 --- a/4PointCutting/4Pcut_execute.lua +++ b/4PointCutting/4Pcut_execute.lua @@ -12,6 +12,8 @@ local stored_timeSelStart = 0 local stored_timeSelEnd = 0 local stored_sel_tracks = {} local stored_sel_items = {} +local stored_view_start = 0 +local stored_view_end = 0 local mark_srcin_pos = -1 local mark_srcin_id = -1 local mark_srcout_pos = -1 @@ -26,6 +28,12 @@ function msg(m) reaper.ShowConsoleMsg(tostring(m) .. "\n") end +-- Round number +function round(num, numDecimalPlaces) + local mult = 10^(numDecimalPlaces or 0) + return math.floor(num * mult + 0.5) / mult +end + -- Selects the source tracks, or, if not stored in rpp, selects all tracks function select_src_tracks() local tracks_str = '' @@ -104,6 +112,9 @@ end -- Do stuff before actual edits... reaper.Undo_BeginBlock() +--store viewport off arranger +stored_view_start, stored_view_end = reaper.GetSet_ArrangeView2(0, false, 0, 0) + -- Store cursor position, time selection, selected tracks, selected items stored_cursorPos = reaper.GetCursorPosition() stored_timeSelStart, stored_timeSelEnd = reaper.GetSet_LoopTimeRange(false, true, 0, 1, false) @@ -140,5 +151,7 @@ for _, item in ipairs(stored_sel_items) do reaper.SetMediaItemSelected(item, true) end reaper.GetSet_LoopTimeRange(true, true, stored_timeSelStart, stored_timeSelEnd, false) +-- Restore view port of arranger +reaper.GetSet_ArrangeView2(0, true, 0, 0, stored_view_start, stored_view_end) -reaper.Undo_EndBlock('4 point cut: Execute', 4) -- 4 is a flag for actions concerning items \ No newline at end of file +reaper.Undo_EndBlock('4 point cut: Execute', 4) -- 4 is a flag for actions concerning items