Skip to content

Commit 69a4698

Browse files
authored
Update Reannotate v0.3.2 > v0.3.3 (#1647)
1 parent 486b996 commit 69a4698

4 files changed

Lines changed: 136 additions & 46 deletions

File tree

Various/talagan_Reannotate.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--[[
22
@description Reannotate - Annotation tool for REAPER
3-
@version 0.3.2
3+
@version 0.3.3
44
@author Ben 'Talagan' Babut
55
@donation https://www.paypal.com/donate/?business=3YEZMY9D6U8NC&no_recurring=1&currency_code=EUR
66
@license MIT
@@ -10,7 +10,8 @@
1010
Forum Thread https://forum.cockos.com/showthread.php?t=304147
1111
@metapackage
1212
@changelog
13-
- [Bug Fix] Check dependency on Markdown Library not working under windows
13+
- [Bug Fix] Pinned track zone overlaps with the rest of the arrange view (thanks @smandrap !)
14+
- [Bug Fixes] Fixed various bug linked to envelope visibility
1415
@provides
1516
[nomain] talagan_Reannotate/ext/**/*
1617
[nomain] talagan_Reannotate/classes/**/*
@@ -31,4 +32,6 @@
3132
You can consult the forum thread for more info.
3233
3334
Please note that this tool is very young and may contain bugs.
35+
36+
Special thanks to Christian Fillion for the infallible support on ReaImGui, and Arkadata for the continuous and precious feedback and comments during the dev !
3437
--]]

Various/talagan_Reannotate/classes/app_context.lua

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
local LaunchContext = require "classes/launch_context"
77
local ArrangeViewWatcher = require "classes/arrange_view_watcher"
88
local ImGui = require "ext/imgui"
9-
109
local Notes = require "classes/notes"
1110

11+
local reaper_ext = require "modules/reaper_ext"
12+
13+
1214
local AppContext = {}
1315
AppContext.__index = AppContext
1416

@@ -104,6 +106,51 @@ function AppContext:retrieveCoordinates(sub, scrollbar_w, scrollbar_h)
104106

105107
end
106108

109+
function AppContext:retrievePinnedTcpHeight()
110+
-- Loop on all tracks
111+
local track_count = reaper.CountTracks(0)
112+
113+
local bypos = nil
114+
local btrack = nil
115+
116+
-- Among the visible pinned tracks, find the bottomost
117+
for i = -1, track_count - 1 do
118+
local track = (i==-1) and reaper.GetMasterTrack(0) or reaper.GetTrack(0, i)
119+
120+
if reaper_ext.IsTrackPinned(track) and reaper_ext.IsTrackVisibleInTcp(track, i == -1) then
121+
local typos = reaper.GetMediaTrackInfo_Value(track, "I_TCPY")
122+
if bypos == nil or typos > bypos then
123+
bypos = typos
124+
btrack = track
125+
end
126+
end
127+
end
128+
129+
if not btrack then return 0 end
130+
131+
local ph = bypos + reaper.GetMediaTrackInfo_Value(btrack, "I_TCPH")
132+
133+
local ei = 0
134+
while true do
135+
local envelope = reaper.GetTrackEnvelope(btrack, ei)
136+
if not envelope then break end
137+
138+
if reaper_ext.IsEnvelopeVisible(envelope) then
139+
local env_height = reaper.GetEnvelopeInfo_Value(envelope, "I_TCPH")
140+
ph = ph + env_height
141+
end
142+
143+
ei = ei + 1
144+
end
145+
146+
if ph > 0 then
147+
-- Add extra space for resizing grip
148+
ph = ph + 10
149+
end
150+
151+
return ph
152+
end
153+
107154
function AppContext:updateWindowLayouts()
108155

109156
self:retrieveCoordinates(self.av, 16, 16)
@@ -114,6 +161,8 @@ function AppContext:updateWindowLayouts()
114161
self:retrieveCoordinates(self.main_toolbar)
115162
self:retrieveCoordinates(self.time_ruler)
116163

164+
self.av.pinned_height = self:retrievePinnedTcpHeight()
165+
117166
self.av.start_time, self.av.end_time = reaper.GetSet_ArrangeView2(0, false, 0, 0)
118167
end
119168

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
-- @noindex
2+
-- @author Ben 'Talagan' Babut
3+
-- @license MIT
4+
-- @description This file is part of Reannotate
5+
6+
local function IsEnvelopeVisible(envelope)
7+
local _, env_vis = reaper.GetSetEnvelopeInfo_String(envelope, "VISIBLE", "", false)
8+
return env_vis == "1"
9+
end
10+
11+
local function IsTrackVisibleInTcp(track, is_master)
12+
if is_master then
13+
return (reaper.GetMasterTrackVisibility() & 1 ~= 0)
14+
end
15+
return (reaper.IsTrackVisible(track, false))
16+
end
17+
18+
local function IsTrackVisibleInMcp(track, is_master)
19+
if is_master then
20+
return (reaper.GetMasterTrackVisibility() & 2 == 0)
21+
end
22+
return (reaper.IsTrackVisible(track, true))
23+
end
24+
25+
local function IsTrackPinned(track)
26+
return reaper.GetMediaTrackInfo_Value(track, "B_TCPPIN") == 1
27+
end
28+
29+
return {
30+
IsEnvelopeVisible = IsEnvelopeVisible,
31+
IsTrackPinned = IsTrackPinned,
32+
IsTrackVisibleInTcp = IsTrackVisibleInTcp,
33+
IsTrackVisibleInMcp = IsTrackVisibleInMcp
34+
}

Various/talagan_Reannotate/widgets/quick_preview_overlay.lua

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ local ImGuiMd = require "reaimgui_markdown"
99
local Notes = require "classes/notes"
1010
local NoteEditor = require "widgets/note_editor"
1111
local SettingsEditor = require "widgets/settings_editor"
12+
local S = require "modules/settings"
13+
14+
local reaper_ext = require "modules/reaper_ext"
1215

13-
local S = require "modules/settings"
1416

1517
local OS = reaper.GetOS()
1618
local is_windows = OS:match('Win')
@@ -152,7 +154,7 @@ function QuickPreviewOverlay:updateVisibleThings()
152154
-- Get total number of tracks
153155
local track_count = reaper.CountTracks(0)
154156

155-
local function block_clamp(minx,miny,w,h, limitx, limity)
157+
local function block_clamp(minx, miny, w, h, limitx, limity, low_limit_y)
156158
local maxx = minx + w
157159
local maxy = miny + h
158160

@@ -167,8 +169,10 @@ function QuickPreviewOverlay:updateVisibleThings()
167169
clamped_right = true
168170
end
169171

170-
if miny < 0 then miny = 0 end
171-
if maxy > limity then maxy = limity end
172+
low_limit_y = low_limit_y or 0
173+
174+
if miny < low_limit_y then miny = low_limit_y end
175+
if maxy > limity then maxy = limity end
172176

173177
w = maxx - minx
174178
h = maxy - miny
@@ -178,57 +182,58 @@ function QuickPreviewOverlay:updateVisibleThings()
178182

179183
-- Iterate through tracks
180184
for i = -1, track_count - 1 do
181-
local track = (i==-1) and reaper.GetMasterTrack(0) or reaper.GetTrack(0, i)
182-
183-
local _, tname = reaper.GetTrackName(track)
184-
local track_height = reaper.GetMediaTrackInfo_Value(track, "I_TCPH")
185-
local track_top = reaper.GetMediaTrackInfo_Value(track, "I_TCPY")
186-
local track_bottom = track_top + track_height
187-
local tcp_entry = nil
185+
local is_master = (i==-1)
186+
local track = is_master and reaper.GetMasterTrack(0) or reaper.GetTrack(0, i)
187+
local _, tname = reaper.GetTrackName(track)
188+
local track_height = reaper.GetMediaTrackInfo_Value(track, "I_TCPH")
189+
local track_top = reaper.GetMediaTrackInfo_Value(track, "I_TCPY")
190+
local track_bottom = track_top + track_height
191+
local track_is_pinned = reaper_ext.IsTrackPinned(track)
192+
local hlimit = track_is_pinned and 0 or avi.pinned_height
193+
local tcp_entry = nil
194+
195+
local track_is_visible_in_tcp = reaper_ext.IsTrackVisibleInTcp(track, is_master)
188196

189197
-- Loop on track envelopes
190-
local ei = 0
191-
while true do
192-
local envelope = reaper.GetTrackEnvelope(track, ei)
193-
if not envelope then break end
194-
195-
local env_vis = reaper.GetSetEnvelopeInfo_String(envelope, "VISIBLE", "", false)
196-
if env_vis then
197-
local env_top = reaper.GetEnvelopeInfo_Value(envelope, "I_TCPY") + track_top
198-
local env_height = reaper.GetEnvelopeInfo_Value(envelope, "I_TCPH")
199-
local env_bottom = env_top + env_height
200-
local tcp_entry = nil
201-
202-
if env_height > 0 and ((env_top >= 0 and env_top <= avi.h) or (env_bottom >= 0 and env_bottom <= avi.h)) then
203-
204-
local pos_x_pixels = 0
205-
local len_x_pixels = tcp.w
206-
local pos_y_pixels, len_y_pixels = env_top, env_height
207-
local clamped_left, clamped_right = false, false
198+
if track_is_visible_in_tcp then
199+
local ei = 0
200+
while true do
201+
local envelope = reaper.GetTrackEnvelope(track, ei)
202+
if not envelope then break end
203+
204+
if reaper_ext.IsEnvelopeVisible(envelope) then
205+
local env_top = reaper.GetEnvelopeInfo_Value(envelope, "I_TCPY") + track_top
206+
local env_height = reaper.GetEnvelopeInfo_Value(envelope, "I_TCPH")
207+
local env_bottom = env_top + env_height
208+
209+
if env_height > 0 and ((env_top >= hlimit and env_top <= avi.h) or (env_bottom >= hlimit and env_bottom <= avi.h)) then
208210

209-
pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, clamped_left, clamped_right = block_clamp(pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, tcp.w, tcp.h)
211+
local pos_x_pixels = 0
212+
local len_x_pixels = tcp.w
213+
local pos_y_pixels, len_y_pixels = env_top, env_height
214+
local clamped_left, clamped_right = false, false
210215

211-
local env_entry = self:buildEditContextForThing(envelope, "env", i, "tcp", pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, clamped_left, clamped_right)
216+
pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, clamped_left, clamped_right = block_clamp(pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, tcp.w, tcp.h, hlimit)
212217

213-
table.insert(self.visible_things, env_entry)
218+
local env_entry = self:buildEditContextForThing(envelope, "env", i, "tcp", pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, clamped_left, clamped_right)
219+
220+
table.insert(self.visible_things, env_entry)
221+
end
214222
end
215-
end
216223

217-
ei = ei + 1
224+
ei = ei + 1
225+
end
218226
end
219227

220-
local track_is_visible_in_tcp = false
221-
if (i==-1) then track_is_visible_in_tcp = (reaper.GetMasterTrackVisibility() & 1 ~= 0) else track_is_visible_in_tcp = (reaper.IsTrackVisible(track, false)) end
222-
223228
-- Loop on items. Process item only if visible.
224-
if track_height > 0 and ((track_top >= 0 and track_top <= avi.h) or (track_bottom >= 0 and track_bottom <= avi.h)) and track_is_visible_in_tcp then
229+
if track_is_visible_in_tcp and track_height > 0 and ((track_top >= hlimit and track_top <= avi.h) or (track_bottom >= hlimit and track_bottom <= avi.h)) then
225230

226231
local pos_x_pixels = 0
227232
local len_x_pixels = tcp.w
228233
local pos_y_pixels, len_y_pixels = track_top, track_height
229234
local clamped_left, clamped_right = false, false
230235

231-
pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, clamped_left, clamped_right = block_clamp(pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, tcp.w, tcp.h)
236+
pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, clamped_left, clamped_right = block_clamp(pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, tcp.w, tcp.h, hlimit)
232237

233238
tcp_entry = self:buildEditContextForThing(track, "track", i, "tcp", pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, clamped_left, clamped_right)
234239

@@ -256,19 +261,18 @@ function QuickPreviewOverlay:updateVisibleThings()
256261
local pos_y_pixels, len_y_pixels = self:getItemYBounds(track, item)
257262
local clamped_left, clamped_right = false, false
258263

259-
pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, clamped_left, clamped_right = block_clamp(pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, avi.w, avi.h)
264+
pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, clamped_left, clamped_right = block_clamp(pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, avi.w, avi.h, hlimit)
260265

261266
table.insert(self.visible_things, self:buildEditContextForThing(item, "item", i, "arrange", pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, clamped_left, clamped_right))
262267
end
263268
end
264269
end
265270

266-
local track_is_visible_in_mcp = false
267-
if (i==-1) then track_is_visible_in_mcp = (reaper.GetMasterTrackVisibility() & 2 == 0) else track_is_visible_in_mcp = (reaper.IsTrackVisible(track, true)) end
271+
local track_is_visible_in_mcp = reaper_ext.IsTrackVisibleInMcp(track, is_master)
268272

269273
-- Handle track in mcp
270274
local mcp = (i==-1) and app_ctx.mcp_master or app_ctx.mcp_other
271-
if mcp.hwnd and reaper.JS_Window_IsVisible(mcp.hwnd) and track_is_visible_in_mcp then
275+
if track_is_visible_in_mcp and mcp.hwnd and reaper.JS_Window_IsVisible(mcp.hwnd) then
272276

273277
local mcp_track_left = reaper.GetMediaTrackInfo_Value(track, "I_MCPX")
274278
local mcp_track_width = reaper.GetMediaTrackInfo_Value(track, "I_MCPW")

0 commit comments

Comments
 (0)