Skip to content

Commit ccda65f

Browse files
authored
Update Reannotate v0.4.4 > v0.4.5 (#1696)
* Update Reannotate v0.4.4 > v0.4.5 * Accidentally left the debug flag on * Add bug fix for last region interfering with project notes
1 parent 0c821b2 commit ccda65f

File tree

8 files changed

+158
-84
lines changed

8 files changed

+158
-84
lines changed

Various/talagan_Reannotate.lua

Lines changed: 5 additions & 5 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.4
3+
@version 0.4.5
44
@author Ben 'Talagan' Babut
55
@donation https://www.paypal.com/donate/?business=3YEZMY9D6U8NC&no_recurring=1&currency_code=EUR
66
@license MIT
@@ -10,10 +10,10 @@
1010
Forum Thread https://forum.cockos.com/showthread.php?t=304147
1111
@metapackage
1212
@changelog
13-
- [Feature] Posters
14-
- [Feature] Can now add annotations to regions
15-
- [Feature] Progress bar sticker
16-
- [Bug fixes] Various bug fixes
13+
- [Feature] Stickers can be positioned top or bottom
14+
- [Bug Fix] Last Region interfering with project notes
15+
- [Bug Fix] Markdown is now wrapped in posters
16+
- [Bug Fix] Plain text is now wrapped in posters
1717
@provides
1818
[nomain] talagan_Reannotate/ext/**/*
1919
[nomain] talagan_Reannotate/classes/**/*

Various/talagan_Reannotate/classes/mem_cache.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function MemCache.GetObjectGUID(object)
2525
local guid = ''
2626
if type(object) == "table" then
2727
if object.t == 'region' then
28-
return object.guid
28+
guid = object.guid
2929
else
3030
error("Unhandled custom type " .. object.t .. " for object")
3131
end

Various/talagan_Reannotate/modules/defines.lua

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ Defines.POSTER_TYPES = {
4141
POSTER_TYPE_COUNT = 6
4242
}
4343

44+
Defines.STICKER_POSITIONINGS = {
45+
TOP_RIGHT = 0,
46+
BOTTOM_RIGHT = 1,
47+
48+
POSITIONING_COUNT = 2
49+
}
50+
4451
function Defines.deepCopy(orig)
4552
local orig_type = type(orig)
4653
local copy
@@ -125,7 +132,7 @@ function Defines.PosterTypeToName(type, default_type)
125132
if type == Defines.POSTER_TYPES.NOTE_RENDERERED_AS_PLAIN_POSTER then return "Note as plain" end
126133
if type == Defines.POSTER_TYPES.NOTE_RENDERERED_AS_MARKDOWN_POSTER then return "Note as markdown" end
127134

128-
error("DEVELOPER ERROR : Unknown post type" .. type)
135+
error("DEVELOPER ERROR : Unknown poster type " .. type)
129136
end
130137

131138
function Defines.PosterTypeComboInfo(default_type)
@@ -141,4 +148,22 @@ function Defines.PosterTypeComboInfo(default_type)
141148
end
142149

143150

151+
152+
function Defines.StickerPositioningToName(val)
153+
if val == Defines.STICKER_POSITIONINGS.TOP_RIGHT then return "Top Right" end
154+
if val == Defines.STICKER_POSITIONINGS.BOTTOM_RIGHT then return "Bottom Right" end
155+
error("DEVELOPER ERROR : Unknown positioning type" .. val)
156+
end
157+
function Defines.StickerPositiongComboInfo()
158+
local start = 0
159+
local ret = { list = {} , reverse_lookup = {} }
160+
for i=start, Defines.STICKER_POSITIONINGS.POSITIONING_COUNT-1 do
161+
local s = Defines.StickerPositioningToName(i)
162+
ret.list[#ret.list+1] = s
163+
ret.reverse_lookup[s] = i
164+
end
165+
return ret
166+
end
167+
168+
144169
return Defines

Various/talagan_Reannotate/modules/project_settings.lua

Lines changed: 66 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ PS.slot_labels_dirty = nil
1616

1717
PS.poster_default_type = nil
1818

19+
-- ====== STYLES ======
20+
1921
-- Not edited directly because we want preview / save features.
2022
function PS.RetrieveProjectMarkdownStyle()
2123
local _, str = reaper.GetSetMediaTrackInfo_String(D.ActiveProjectMasterTrack(), "P_EXT:Reannotate_ProjectMarkdownStyle", "", false)
@@ -55,104 +57,110 @@ function PS.CommitProjectMarkdownStyle(markdown_style)
5557
reaper.GetSetMediaTrackInfo_String(D.ActiveProjectMasterTrack(),"P_EXT:Reannotate_ProjectMarkdownStyle", str, true)
5658
end
5759

60+
-- ====== LABELS ======
5861

59-
60-
function PS.RetrieveProjectStickerSize()
61-
local _, str = reaper.GetSetMediaTrackInfo_String(D.ActiveProjectMasterTrack(), "P_EXT:Reannotate_ProjectStickerSize", "", false)
62-
local fallback = false
63-
local size = nil
62+
function PS.RetrieveProjectSlotLabels()
63+
local _, str = reaper.GetSetMediaTrackInfo_String(D.ActiveProjectMasterTrack(), "P_EXT:Reannotate_ProjectSlotLabels", "", false)
64+
local slot_labels = {}
6465
if str == "" or str == nil then
65-
fallback = true
6666
else
67-
size = tonumber(str)
67+
slot_labels = JSON.decode(str)
6868
end
6969

70-
if fallback then
71-
size = S.getSetting("NewProjectStickerSize")
72-
PS.CommitProjectStickerSize(size)
70+
-- Ensure labels have names by defaulting to global setting
71+
for i = 0, D.MAX_SLOTS -1 do
72+
slot_labels[i+1] = slot_labels[i+1] or S.getSetting("SlotLabel_" .. i)
7373
end
7474

75-
return size
75+
PS.slot_labels = slot_labels
7676
end
7777

78-
function PS.CommitProjectStickerSize(size)
79-
reaper.GetSetMediaTrackInfo_String(D.ActiveProjectMasterTrack(),"P_EXT:Reannotate_ProjectStickerSize", "" .. size, true)
78+
function PS.CommitProjectSlotLabels()
79+
if not PS.slot_labels_dirty then return end
80+
if not PS.slot_labels then PS.RetrieveProjectSlotLabels() end
81+
82+
local str = JSON.encode(PS.slot_labels)
83+
reaper.GetSetMediaTrackInfo_String(D.ActiveProjectMasterTrack(), "P_EXT:Reannotate_ProjectSlotLabels", str, true)
84+
PS.slot_labels_dirty = false
85+
end
86+
function PS.SlotLabel(slot)
87+
if not PS.slot_labels then PS.RetrieveProjectSlotLabels() end
88+
return PS.slot_labels[slot+1]
89+
end
90+
function PS.SetSlotLabel(slot, label)
91+
if not PS.slot_labels then PS.RetrieveProjectSlotLabels() end
92+
PS.slot_labels[slot+1] = label
93+
PS.slot_labels_dirty = true
94+
PS.CommitProjectSlotLabels()
8095
end
8196

8297

83-
function PS.RetrieveProjectPosterDefaultType()
84-
local _, str = reaper.GetSetMediaTrackInfo_String(D.ActiveProjectMasterTrack(), "P_EXT:Reannotate_PosterDefaultType", "", false)
85-
local fallback = false
86-
local type = nil
98+
99+
function PS.CommitProjectSetting(project_key, value)
100+
reaper.GetSetMediaTrackInfo_String(D.ActiveProjectMasterTrack(),"P_EXT:" .. project_key, "" .. value, true)
101+
end
102+
function PS.RetrieveProjectSettingWithFallback(project_key, global_setting_key)
103+
local _, str = reaper.GetSetMediaTrackInfo_String(D.ActiveProjectMasterTrack(), "P_EXT:" .. project_key, "", false)
104+
local fallback = false
105+
local value = nil
87106
if str == "" or str == nil then
88107
fallback = true
89108
else
90-
type = tonumber(str)
109+
value = tonumber(str)
91110
end
92111

93112
if fallback then
94-
type = S.getSetting("NewProjectPosterDefaultType")
95-
PS.CommitProjectPosterDefaultType(type)
113+
value = S.getSetting(global_setting_key)
114+
PS.CommitProjectSetting(project_key, value)
96115
end
97116

98-
return type
117+
return value
99118
end
100119

101-
function PS.CommitProjectPosterDefaultType(type)
102-
reaper.GetSetMediaTrackInfo_String(D.ActiveProjectMasterTrack(),"P_EXT:Reannotate_PosterDefaultType", "" .. type, true)
120+
121+
function PS.RetrieveProjectStickerSize()
122+
return PS.RetrieveProjectSettingWithFallback("Reannotate_ProjectStickerSize","NewProjectStickerSize")
123+
end
124+
function PS.CommitProjectStickerSize(size)
125+
PS.CommitProjectSetting("Reannotate_ProjectStickerSize", size)
103126
end
104127

128+
129+
function PS.RetrieveProjectPosterDefaultType()
130+
return PS.RetrieveProjectSettingWithFallback("Reannotate_PosterDefaultType", "NewProjectPosterDefaultType")
131+
end
132+
function PS.CommitProjectPosterDefaultType(type)
133+
PS.CommitProjectSetting("Reannotate_PosterDefaultType", type)
134+
end
105135
function PS.ProjectPosterDefaultType()
106136
if not PS.poster_default_type then
107137
PS.poster_default_type = PS.RetrieveProjectPosterDefaultType()
108138
end
109139
return PS.poster_default_type
110140
end
111-
112141
function PS.SetProjectPosterDefaultType(type)
113142
PS.poster_default_type = type
114143
PS.CommitProjectPosterDefaultType(type)
115144
end
116145

117146

118-
119-
function PS.RetrieveProjectSlotLabels()
120-
local _, str = reaper.GetSetMediaTrackInfo_String(D.ActiveProjectMasterTrack(), "P_EXT:Reannotate_ProjectSlotLabels", "", false)
121-
local slot_labels = {}
122-
if str == "" or str == nil then
123-
else
124-
slot_labels = JSON.decode(str)
125-
end
126-
127-
-- Ensure labels have names by defaulting to global setting
128-
for i = 0, D.MAX_SLOTS -1 do
129-
slot_labels[i+1] = slot_labels[i+1] or S.getSetting("SlotLabel_" .. i)
147+
function PS.RetrieveProjectStickerPositioning()
148+
return PS.RetrieveProjectSettingWithFallback("Reannotate_StickerPositioning", "NewProjectStickerPositioning")
149+
end
150+
function PS.CommitProjectStickerPositioning(val)
151+
PS.CommitProjectSetting("Reannotate_StickerPositioning", val)
152+
end
153+
function PS.ProjectStickerPositioning()
154+
if not PS.sticker_positioning then
155+
PS.sticker_positioning = PS.RetrieveProjectStickerPositioning()
130156
end
131-
132-
PS.slot_labels = slot_labels
157+
return PS.sticker_positioning
133158
end
134-
135-
function PS.CommitProjectSlotLabels()
136-
if not PS.slot_labels_dirty then return end
137-
if not PS.slot_labels then PS.RetrieveProjectSlotLabels() end
138-
139-
local str = JSON.encode(PS.slot_labels)
140-
reaper.GetSetMediaTrackInfo_String(D.ActiveProjectMasterTrack(), "P_EXT:Reannotate_ProjectSlotLabels", str, true)
141-
PS.slot_labels_dirty = false
159+
function PS.SetProjectStickerPositioning(val)
160+
PS.sticker_positioning = val
161+
PS.CommitProjectStickerPositioning(val)
142162
end
143163

144164

145165

146-
function PS.SlotLabel(slot)
147-
if not PS.slot_labels then PS.RetrieveProjectSlotLabels() end
148-
return PS.slot_labels[slot+1]
149-
end
150-
151-
function PS.SetSlotLabel(slot, label)
152-
if not PS.slot_labels then PS.RetrieveProjectSlotLabels() end
153-
PS.slot_labels[slot+1] = label
154-
PS.slot_labels_dirty = true
155-
PS.CommitProjectSlotLabels()
156-
end
157-
158166
return PS

Various/talagan_Reannotate/modules/settings.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ local DefaultMarkdownStyle = {
2828
separator = { padding_top = 3, padding_bottom = 7 }
2929
}
3030

31-
local DefaultPosterType = D.POSTER_TYPES.NOTE_RENDERERED_AS_PLAIN_POSTER
31+
local DefaultPosterType = D.POSTER_TYPES.NOTE_RENDERERED_AS_PLAIN_POSTER
32+
local DefaultStickerPositioning = D.STICKER_POSITIONINGS.BOTTOM_RIGHT
3233

3334
local SettingDefs = {
3435
UseDebugger = { type = "bool", default = false },
@@ -47,7 +48,8 @@ local SettingDefs = {
4748
UIFontSize = { type = "int", default = 12 },
4849
NewProjectMarkdown = { type = "json", default = DefaultMarkdownStyle },
4950
NewProjectStickerSize = { type = "int", default = 12 },
50-
NewProjectPosterDefaultType = { type = "int", default = DefaultPosterType }
51+
NewProjectPosterDefaultType = { type = "int", default = DefaultPosterType },
52+
NewProjectStickerPositioning = { type = "int", default = DefaultStickerPositioning }
5153
};
5254

5355
local function unsafestr(str)

Various/talagan_Reannotate/widgets/overlay_canvas.lua

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,12 @@ function OverlayCanvas:renderThingSlotPoster(thing, slot, ctx, draw_list, x1, x2
294294
local tttext = (use_note_text and thing.notes:slotText(slot) or thing.notes:slotCustomPoster(slot)) or ''
295295
cache.plain = ImGuiMdText.ASTToPlainText( ImGuiMdAst(tttext), {newlines=true})
296296
end
297-
ImGui.Text(ctx, cache.plain)
297+
ImGui.TextWrapped(ctx, cache.plain)
298+
--ImGui.Text(ctx, cache.plain)
298299
else
299300
if not cache.mdwidget then
300301
local tttext = (use_note_text and thing.notes:slotText(slot) or thing.notes:slotCustomPoster(slot)) or ''
301-
cache.mdwidget = ImGuiMd:new(ctx, "thing_md_widget_" .. thing.rand .. "_" .. slot, {wrap = false, skip_last_whitespace = true, autopad = true, additional_window_flags = ImGui.WindowFlags_NoSavedSettings | ImGui.WindowFlags_NoFocusOnAppearing | ImGui.WindowFlags_NoInputs | ImGui.WindowFlags_NoScrollbar }, PS.RetrieveProjectMarkdownStyle() )
302+
cache.mdwidget = ImGuiMd:new(ctx, "thing_md_widget_" .. thing.rand .. "_" .. slot, {wrap = true, skip_last_whitespace = true, autopad = true, additional_window_flags = ImGui.WindowFlags_NoSavedSettings | ImGui.WindowFlags_NoFocusOnAppearing | ImGui.WindowFlags_NoInputs | ImGui.WindowFlags_NoScrollbar }, PS.RetrieveProjectMarkdownStyle() )
302303
cache.mdwidget:setText(tttext)
303304
end
304305
cache.mdwidget:render(ctx)
@@ -328,10 +329,6 @@ function OverlayCanvas:renderThingSlotStickers(thing, slot, ctx, x1, x2, y1, y2)
328329
end
329330
end
330331

331-
local num_on_line = 0
332-
local cursor_x, cursor_y = x2 - hmargin, y1 + vmargin -- Align top right
333-
334-
ImGui.SetCursorScreenPos(ctx, x1, y1)
335332
local window_flags = ImGui.WindowFlags_NoBackground |
336333
ImGui.WindowFlags_NoScrollbar |
337334
ImGui.WindowFlags_NoDecoration |
@@ -342,28 +339,37 @@ function OverlayCanvas:renderThingSlotStickers(thing, slot, ctx, x1, x2, y1, y2)
342339
ImGui.WindowFlags_NoMove
343340

344341
-- Use a child for receiving all stickers, this will allow clipping and using standard ImGui directives
342+
-- Make the child overlap the thing
343+
ImGui.SetCursorScreenPos(ctx, x1, y1)
345344
if ImGui.BeginChild(ctx, "stickers_for_thing_" .. thing.rand .. "_" .. slot, x2-x1, y2-y1, ImGui.ChildFlags_None, window_flags) then
345+
-- Initialize the cursor
346346
ImGui.SetCursorPos(ctx, 0, 0)
347+
-- Clip the subzone
347348
local draw_list = ImGui.GetWindowDrawList(ctx)
348349
ImGui.DrawList_PushClipRect(draw_list, x1 + 3, y1 + 3, x2 + 3, y2 - 3)
350+
351+
local bottom_to_top_mode = PS.ProjectStickerPositioning() == D.STICKER_POSITIONINGS.BOTTOM_RIGHT
352+
local num_on_line = 0
353+
local cursor_x, cursor_y = x2 - hmargin, (bottom_to_top_mode) and (y2 - vmargin) or (y1 + vmargin) -- Align bottom right
354+
349355
for _, sticker in ipairs(slot_stickers) do
350356
local metrics = sticker:PreRender(ctx, font_size)
351357

352358
local available_width = cursor_x - (x1 + hmargin)
353359
if num_on_line ~= 0 and (available_width < metrics.width) then
354360
cursor_x = x2 - hmargin
355-
cursor_y = cursor_y + metrics.height + vpad
361+
cursor_y = (bottom_to_top_mode) and (cursor_y - metrics.height - vpad) or (cursor_y + metrics.height + vpad)
356362
num_on_line = 0
357363
end
358364

359-
sticker:Render(ctx, metrics, cursor_x - metrics.width, cursor_y)
365+
sticker:Render(ctx, metrics, cursor_x - metrics.width, (bottom_to_top_mode) and (cursor_y - metrics.height) or (cursor_y))
360366
cursor_x = cursor_x - metrics.width - hpad
361367
num_on_line = num_on_line + 1
362368
end
363-
-- Force ImGui to extend bounds
369+
364370
ImGui.DrawList_PopClipRect(draw_list)
371+
-- Force ImGui to extend bounds
365372
ImGui.Dummy(ctx,0,0)
366-
367373
ImGui.EndChild(ctx)
368374
end
369375
end
@@ -582,8 +588,6 @@ function OverlayCanvas:draw()
582588

583589
if succ then
584590

585-
local draw_list = ImGui.GetWindowDrawList(ctx)
586-
587591
if self.grab_focus then
588592
ImGui.SetWindowFocus(ctx)
589593
self.grab_focus = false
@@ -605,6 +609,7 @@ function OverlayCanvas:draw()
605609
self:drawQuickSettings()
606610
end
607611

612+
-- Check for hovered thing
608613
for _, thing in ipairs(visible_things) do
609614
if self:thingBelongsToThisCanvas(thing) then
610615
local x1 = thing.pos_x + thing.parent.x

Various/talagan_Reannotate/widgets/quick_preview_overlay.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ function QuickPreviewOverlay:buildEditContextForThing(object, track_num, parent_
100100
return {
101101
-- Basic info
102102
object = object,
103-
type = type,
104103
-- Parent info
105104
parent = parent,
106105
widget = parent_widget_name,
@@ -390,7 +389,7 @@ function QuickPreviewOverlay:updateVisibleThings()
390389
local clamped_left, clamped_right, clamped_top, clamped_bottom = false, false, false, false
391390
pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, clamped_left, clamped_right, clamped_top, clamped_bottom = block_clamp(pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, app_ctx.time_ruler.w, app_ctx.time_ruler.h, 0, 0)
392391

393-
local _, region_guid = reaper.GetSetProjectInfo_String( 0, "MARKER_GUID:" .. markrgnindexnumber, "", false )
392+
local _, region_guid = reaper.GetSetProjectInfo_String( 0, "MARKER_GUID:" .. idx, "", false )
394393

395394
local region_entry = self:buildEditContextForThing({t="region", n = 'name', guid=region_guid}, -1, "time_ruler", pos_x_pixels, pos_y_pixels, len_x_pixels, len_y_pixels, clamped_left, clamped_right, clamped_top, clamped_bottom)
396395
table.insert(self.visible_things, region_entry)

0 commit comments

Comments
 (0)