@@ -16,6 +16,8 @@ PS.slot_labels_dirty = nil
1616
1717PS .poster_default_type = nil
1818
19+ -- ====== STYLES ======
20+
1921-- Not edited directly because we want preview / save features.
2022function 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 )
5658end
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
7676end
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 ()
8095end
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
99118end
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 )
103126end
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
105135function 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
110140end
111-
112141function PS .SetProjectPosterDefaultType (type )
113142 PS .poster_default_type = type
114143 PS .CommitProjectPosterDefaultType (type )
115144end
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
133158end
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 )
142162end
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-
158166return PS
0 commit comments