Skip to content

Commit 0503eb5

Browse files
authored
Update Reannotate v0.4.2 > v0.4.3 (#1687)
1 parent b373f9e commit 0503eb5

15 files changed

Lines changed: 1284 additions & 421 deletions

Various/talagan_Reannotate.lua

Lines changed: 7 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.4.2
3+
@version 0.4.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,12 @@
1010
Forum Thread https://forum.cockos.com/showthread.php?t=304147
1111
@metapackage
1212
@changelog
13-
- [Feature] Can now use stickers without a text
13+
- [Feature] The markdown stylesheet is now customizable
14+
- [Feature] UI Font size is now customizable
15+
- [Feature] Note editor's width is now remembered
16+
- [Bug Fix] Tooltips with vertical scrollbars could affect the layout of other tooltips shown immediately after
17+
- [Rework] Moved project notes to the transport zone instead of the time ruler (will be used for regions / markers ?)
18+
- [Rework] Optimizations
1419
@provides
1520
[nomain] talagan_Reannotate/ext/**/*
1621
[nomain] talagan_Reannotate/classes/**/*

Various/talagan_Reannotate/classes/app_context.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
local LaunchContext = require "classes/launch_context"
77
local ArrangeViewWatcher = require "classes/arrange_view_watcher"
88
local ImGui = require "ext/imgui"
9-
local Notes = require "classes/notes"
10-
119
local reaper_ext = require "modules/reaper_ext"
10+
local D = require "modules/defines"
1211

1312
local AppContext = {}
1413
AppContext.__index = AppContext
@@ -65,6 +64,7 @@ function AppContext:findMainToolbarHwnd(main_hwnd, time_ruler_hwnd, tcp_hwnd)
6564
local _, tcp_l, tcp_t, tcp_r, tcp_b = reaper.JS_Window_GetRect(tcp_hwnd)
6665
local _, l = reaper.JS_Window_ListAllChild(main_hwnd)
6766
for token in string.gmatch(l, "[^,]+") do
67+
---@diagnostic disable-next-line: param-type-mismatch
6868
local subhwnd = reaper.JS_Window_HandleFromAddress(token)
6969
if subhwnd then
7070
local _, a_l, a_t, a_r, a_b = reaper.JS_Window_GetRect(subhwnd)
@@ -88,6 +88,8 @@ function AppContext:_initialize()
8888
self.mv = { hwnd=reaper.GetMainHwnd() }
8989
-- Arrange view
9090
self.av = { hwnd=reaper.JS_Window_FindChildByID(self.mv.hwnd, 1000) }
91+
92+
self.transport = { hwnd=reaper.JS_Window_FindChild(reaper.GetMainHwnd(), "Transport", true) }
9193
-- TCP view
9294
self.tcp = { hwnd=reaper.JS_Window_FindEx(reaper.GetMainHwnd(), reaper.GetMainHwnd(), "REAPERTCPDisplay", "") }
9395
-- Time Ruler
@@ -122,7 +124,7 @@ function AppContext:_initialize()
122124
ImGui.Attach(self.imgui_ctx, self.arial_font_italic)
123125

124126
self.enabled_category_filters = {}
125-
for i=1, Notes.MAX_SLOTS do
127+
for i=1, D.MAX_SLOTS do
126128
self.enabled_category_filters[i] = true
127129
end
128130

@@ -210,6 +212,7 @@ function AppContext:updateWindowLayouts()
210212
self:retrieveCoordinates(self.main_toolbar)
211213
self:retrieveCoordinates(self.time_ruler)
212214
self:retrieveCoordinates(self.mcp_window)
215+
self:retrieveCoordinates(self.transport)
213216

214217
self.av.pinned_height = self:retrievePinnedTcpHeight()
215218

Various/talagan_Reannotate/classes/color.lua

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ function Color:new(r_or_string_or_rgb_int,g,b,a)
162162
return instance
163163
end
164164

165+
function Color:new_from_iargb(argb)
166+
return Color:new( (argb & 0x00FF0000) >> 16, (argb & 0x0000FF00) >> 8, (argb & 0x000000FF), (argb & 0xFF000000) >> 24)
167+
end
168+
169+
function Color:new_from_irgba(rgba)
170+
return Color:new((rgba & 0xFF000000) >> 24, (rgba & 0x00FF0000) >> 16, (rgba & 0x0000FF00) >> 8, (rgba & 0x000000FF))
171+
end
172+
165173
function Color:validateComponent(name, presence)
166174
local val = self[name]
167175

@@ -220,6 +228,14 @@ function Color:setHsv(h,s,l)
220228
self.r, self.g, self.b = math.floor(r * 255 + 0.5), math.floor(g * 255 + 0.5), math.floor(b * 255 + 0.5)
221229
end
222230

231+
function Color:css_rgb()
232+
return string.format("#%02X%02X%02X", self.r, self.g, self.b)
233+
end
234+
235+
function Color:css_argb()
236+
return string.format("#%%02X02X%02X%02X", self.a, self.r, self.g, self.b)
237+
end
238+
223239
function Color:to_irgb()
224240
return (self.r << 16) | (self.g << 8) | (self.b << 0)
225241
end
@@ -232,7 +248,6 @@ function Color:to_irgba()
232248
return (self:to_irgb() << 8) | ((self.a or 255) << 0)
233249
end
234250

235-
236251
function Color.irgba(str)
237252
return Color.parse(str):to_irgba()
238253
end
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
-- @noindex
2+
-- @author Ben 'Talagan' Babut
3+
-- @license MIT
4+
-- @description This file is part of Reannotate
5+
6+
local Notes = require 'classes/notes'
7+
8+
local MemCache = {}
9+
MemCache.__index = MemCache
10+
11+
function MemCache:new()
12+
local instance = {}
13+
setmetatable(instance, self)
14+
instance:_initialize()
15+
return instance
16+
end
17+
18+
function MemCache:_initialize()
19+
self._repo = {}
20+
21+
MemCache.__singleton = self
22+
end
23+
24+
function MemCache.GetObjectGUID(object)
25+
local guid = ''
26+
if reaper.ValidatePtr(object, "MediaTrack*") then
27+
local tguid = reaper.GetTrackGUID(object)
28+
guid = tguid
29+
elseif reaper.ValidatePtr(object,"MediaItem*") then
30+
local _, tguid = reaper.GetSetMediaItemInfo_String(object, "GUID", "", false)
31+
guid = tguid
32+
elseif reaper.ValidatePtr(object, "TrackEnvelope*") then
33+
local _, tguid = reaper.GetSetEnvelopeInfo_String(object, "GUID", "", false)
34+
guid = tguid
35+
elseif reaper.ValidatePtr(object, "ReaProject*") then
36+
local _, tguid = reaper.GetSetProjectInfo_String(object, "PROJECT_NAME", "", false)
37+
guid = tguid
38+
else
39+
error("Unhandled type for object")
40+
end
41+
return guid
42+
end
43+
44+
function MemCache:getObjectCache(object)
45+
46+
local guid = MemCache.GetObjectGUID(object)
47+
48+
if not self._repo[guid] then
49+
-- Build object cache
50+
51+
local name = ''
52+
local type = ''
53+
if reaper.ValidatePtr(object, "MediaTrack*") then
54+
local _, tname = reaper.GetTrackName(object)
55+
name = tname
56+
type = 'track'
57+
elseif reaper.ValidatePtr(object,"MediaItem*") then
58+
local take = reaper.GetActiveTake(object)
59+
if take then
60+
name = reaper.GetTakeName(take)
61+
end
62+
type = 'item'
63+
elseif reaper.ValidatePtr(object, "TrackEnvelope*") then
64+
local _, ename = reaper.GetEnvelopeName(object)
65+
name = ename
66+
type = 'env'
67+
elseif reaper.ValidatePtr(object, "ReaProject*") then
68+
name = "Project"
69+
type = 'project'
70+
else
71+
error("Unhandled type for object")
72+
end
73+
74+
-- Cache miss, pull info from object
75+
self._repo[guid] = {
76+
guid = guid,
77+
object = object,
78+
name = name,
79+
type = type,
80+
-- Notes cache
81+
notes = Notes:new(object)
82+
}
83+
end
84+
85+
return self._repo[guid]
86+
end
87+
88+
function MemCache.instance()
89+
if not MemCache.__singleton then
90+
MemCache.__singleton = MemCache:new()
91+
end
92+
93+
return MemCache.__singleton
94+
end
95+
96+
return MemCache

0 commit comments

Comments
 (0)