Skip to content

Commit c3d4ada

Browse files
authored
Merge pull request #758 from cv-on-hub/cv-minor-updates
Minor Code Improvements
2 parents a713471 + 296fcc5 commit c3d4ada

File tree

3 files changed

+167
-149
lines changed

3 files changed

+167
-149
lines changed

src/measure_span.lua

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ function plugindef()
33
finaleplugin.Author = "Carl Vine"
44
finaleplugin.AuthorURL = "https://carlvine.com/lua/"
55
finaleplugin.Copyright = "https://creativecommons.org/licenses/by/4.0/"
6-
finaleplugin.Version = "0.94"
7-
finaleplugin.Date = "2024/04/30"
6+
finaleplugin.Version = "0.95b"
7+
finaleplugin.Date = "2024/07/29"
88
finaleplugin.CategoryTags = "Measure, Time Signature, Meter"
99
finaleplugin.MinJWLuaVersion = 0.70
1010
finaleplugin.AdditionalMenuOptions = [[
@@ -105,8 +105,8 @@ local function dialog_save_position(dialog)
105105
end
106106

107107
local function user_options()
108-
local x_grid = { 15, 70, 190, 210, 305, 110 }
109-
local i_width = 142
108+
local x_grid = { 15, 70, 193, 210, 305, 110 }
109+
local i_width = 138
110110
local y = 0
111111

112112
local dlg = mixin.FCXCustomLuaWindow():SetTitle(finaleplugin.ScriptGroupName)
@@ -121,7 +121,7 @@ local function user_options()
121121
if chigh then stat:SetHeight(chigh) end
122122
end
123123
local function ccheck(cx, cy, cname, cwide, check, ctext, chigh)
124-
cx = x_grid[cx]
124+
cx = (type(cx) == "string") and tonumber(cx) or x_grid[cx]
125125
local chk = dlg:CreateCheckbox(cx, cy, cname):SetWidth(cwide)
126126
:SetText(ctext):SetCheck(check)
127127
if chigh then chk:SetHeight(chigh) end
@@ -130,91 +130,97 @@ local function user_options()
130130
dlg:CreateHorizontalLine(cx, cy, cwide)
131131
end
132132

133-
cstat(1, y + 1, "DIVIDE EACH MEASURE INTO TWO:", x_grid[4], nil, "div1")
133+
cstat("0", y + 1, "DIVIDE", 50, nil, "div1")
134+
cstat("43", y + 1, "Every Measure Into Two:", x_grid[3], nil, nil)
134135
yd(20)
135-
cstat(1, y, "Halve the numerator:", x_grid[3])
136+
cstat(1, y, "Halve the Numerator:", x_grid[3])
136137
ccheck(3, y, "1", i_width, (config.halve_numerator and 1 or 0), " [6/4] → [3/4][3/4]")
137138
yd()
138139
cstat(2, y, "OR")
139140
yd()
140-
cstat(1, y, "Double the denominator:", x_grid[3])
141+
cstat(1, y, "Double the Denominator:", x_grid[3])
141142
ccheck(3, y, "2", i_width, (config.halve_numerator and 0 or 1), " [6/4] → [6/8][6/8]")
142143
yd(25)
143144
chl(1, y, x_grid[5])
144145
yd(10)
145-
cstat(1, y, "If halving a numerator with an ODD number of beats:", x_grid[5])
146+
cstat(1, y, "If Halving a Numerator With an Odd Number of Beats:", x_grid[5])
146147
yd(17)
147-
cstat(1, y, "More beats in first measure:", x_grid[4] + 20)
148+
cstat(1, y, "More Beats in First Measure:", x_grid[4] + 20)
148149
ccheck(3, y, "3", i_width, (config.odd_more_first and 1 or 0), " 3 → 2 + 1 etc.")
149150
yd()
150151
cstat(2, y, "OR")
151152
yd()
152-
cstat(1, y, "More beats in second measure:", x_grid[4] + 20)
153+
cstat(1, y, "More Beats in Second Measure:", x_grid[4] + 20)
153154
ccheck(3, y, "4", i_width, (config.odd_more_first and 0 or 1), " 3 → 1 + 2 etc.")
154155
yd(27)
155156
chl(0, y, x_grid[3] + i_width)
156157
chl(0, y + 2, x_grid[3] + i_width)
157158
chl(0, y + 3, x_grid[3] + i_width)
158159
yd(13)
159-
cstat(1, y + 1, "JOIN PAIRS OF MEASURES:", x_grid[3], nil, "div2")
160+
cstat("0", y + 1, "JOIN", 35, nil, "div2")
161+
cstat("33", y + 1, "Each Pair of Measures:", x_grid[3])
160162
yd(20)
161-
cstat(1, y, "If both measures have the same time signature ...", x_grid[5])
163+
cstat(1, y, "If Both Measures Have the Same Time Signature:", x_grid[5])
162164
yd(17)
163-
cstat(1, y, "Double the numerator:", x_grid[3])
164-
ccheck(3, y, "5", i_width, (config.double_join and 1 or 0), " [3/8][3/8] → [6/8]")
165+
cstat("30", y, "Halve the Denominator:", x_grid[3])
166+
ccheck(3, y, "6", i_width, (config.double_join and 0 or 1), " [6/8][6/8] → [6/4]")
165167
yd()
166-
cstat(2, y, "OR")
168+
cstat("85", y, "OR")
167169
yd()
168-
cstat(1, y, "Halve the denominator:", x_grid[3])
169-
ccheck(3, y, "6", i_width, (config.double_join and 0 or 1), " [3/8][3/8] → [3/4]")
170+
cstat("30", y, "Double the Numerator:", x_grid[3])
171+
ccheck(3, y, "5", i_width, (config.double_join and 1 or 0), " [6/8][6/8] → [12/8]")
170172
yd(25)
171173
chl(1, y, x_grid[5])
172174
yd(5)
173-
cstat(1, y, "otherwise ...", x_grid[2])
175+
cstat(1, y, "Else if They Have Different Time Signatures:", x_grid[5])
174176
yd(17)
175-
cstat(1, y, "Consolidate time signatures:", x_grid[4])
177+
cstat("30", y, "Consolidate Time Signatures:", x_grid[4])
176178
ccheck(3, y, "8", i_width, (config.composite_join and 0 or 1),
177-
" [2/4][3/8] → [7/8]\n (lose beaming groups)", 30)
179+
" [2/4][3/8] → [7/8]\n (Lose Beam Groups)", 30)
178180
yd(17)
179-
cstat(2, y, "OR")
181+
cstat("85", y, "OR")
180182
yd(17)
181-
cstat(1, y, "Composite time signatures:", x_grid[3])
183+
cstat("30", y, "Composite Time Signatures:", x_grid[3])
182184
ccheck(3, y, "7", i_width, (config.composite_join and 1 or 0),
183-
" [2/4][3/8] → [2/4+3/8]\n (keep beaming groups)", 30)
185+
" [2/4][3/8] → [2/4+3/8]\n (Keep Beam Groups)", 30)
184186
yd(35)
185-
ccheck(1, y, "display_meter", x_grid[5] + 10, (config.display_meter and 1 or 0),
186-
" Create \"display\" time signature when compositing\n "
187-
.. "[2/4][3/8] → [2/4+3/8] displaying \"7/8\" )", 30
187+
ccheck("30", y, "display_meter", x_grid[5] + 10, (config.display_meter and 1 or 0),
188+
" Create \"Display\" Time Signature When Compositing\n "
189+
.. " ([2/4][3/8] → [2/4+3/8] Displaying \"7/8\")", 32
188190
)
189191
yd(36)
190192
chl(0, y, x_grid[3] + i_width)
191193
chl(0, y + 2, x_grid[3] + i_width)
192194
chl(0, y + 3, x_grid[3] + i_width)
193195
yd(12)
194-
cstat("0", y, "Preserve smart shapes within\n(Larger spans take longer)", x_grid[3], 30)
196+
cstat("0", y, "Preserve Smart Shapes Within\n(Larger Spans Take Longer)", x_grid[3], 32)
195197
local popup = dlg:CreatePopup(x_grid[3] - 27, y - 1, "shape_extend")
196198
:SetWidth(40):SetSelectedItem(config.shape_extend - 2)
197199
for i = 2, 10 do
198200
popup:AddString(i)
199201
end
200-
cstat("206", y, "measure span")
202+
cstat("204", y, "- Measure Span")
201203
yd(38)
202204
cstat("0", y, "ON COMPLETION:", i_width, nil, "div3")
203-
ccheck(6, y, "note_spacing", i_width, (config.note_spacing and 1 or 0), "Respace notes")
205+
ccheck(6, y, "note_spacing", i_width, (config.note_spacing and 1 or 0), "Respace Notes")
204206
dlg:CreateButton(x_grid[5], y, "q"):SetText("?"):SetWidth(20)
205207
:AddHandleCommand(function()
206208
utils.show_notes_dialog(dlg, "About " .. finaleplugin.ScriptGroupName)
207209
refocus_document = true
208210
end)
209211
yd(18)
210-
ccheck(6, y, "rebeam", i_width + 40, (config.rebeam and 1 or 0), "Rebeam note groups")
212+
ccheck(6, y, "rebeam", i_width + 20, (config.rebeam and 1 or 0), "Rebeam Note Groups")
211213
yd(18)
212-
ccheck(6, y, "repaginate", i_width, (config.repaginate and 1 or 0), "Repaginate entire score")
214+
ccheck(6, y, "repaginate", i_width + 20, (config.repaginate and 1 or 0), "Repaginate Entire Score")
213215

214216
-- radio button action
215217
local function radio_change(id, check) -- for checkboxes "1" to "8"
216218
local toggle = (id % 2 == 0) and (id - 1) or (id + 1)
217219
dlg:GetControl(tostring(toggle)):SetCheck((check + 1) % 2) -- "ON" <-> "OFF"
220+
if id > 6 then
221+
local state = check == ((id == 7) and 1 or 0)
222+
dlg:GetControl("display_meter"):SetEnable(state)
223+
end
218224
end
219225
for id = 1, 8 do -- add to HandleCommand to 8 buttons
220226
dlg:GetControl(tostring(id))
@@ -236,13 +242,12 @@ local function user_options()
236242
config.shape_extend = (self:GetControl("shape_extend"):GetSelectedItem() + 2)
237243
end)
238244
dlg:RegisterCloseWindow(function(self) dialog_save_position(self) end)
239-
dlg:RegisterInitWindow(function()
240-
local div1 = dlg:GetControl("div1")
241-
local bold = div1:CreateFontInfo():SetBold(true)
242-
div1:SetFont(bold)
243-
dlg:GetControl("div2"):SetFont(bold)
244-
dlg:GetControl("div3"):SetFont(bold)
245-
dlg:GetControl("q"):SetFont(bold)
245+
dlg:RegisterInitWindow(function(self)
246+
local bold = self:GetControl("div1"):CreateFontInfo():SetBold(true)
247+
for _, v in ipairs{"div1", "div2", "div3", "q"} do
248+
dlg:GetControl(v):SetFont(bold)
249+
end
250+
self:GetControl("display_meter"):SetEnable(config.composite_join)
246251
end)
247252
return (dlg:ExecuteModal(nil) == finale.EXECMODAL_OK)
248253
end
@@ -275,8 +280,8 @@ local function repaginate()
275280
end
276281

277282
function copy_measure_values(measure_1, measure_2)
278-
for _, v in ipairs({ "PositioningNotesMode", "Barline",
279-
"SpaceAfter", "SpaceBefore", "UseTimeSigForDisplay" }) do
283+
for _, v in ipairs{ "PositioningNotesMode", "Barline",
284+
"SpaceAfter", "SpaceBefore", "UseTimeSigForDisplay" } do
280285
measure_2[v] = measure_1[v]
281286
end
282287
measure_1.Barline = finale.BARLINE_NORMAL

0 commit comments

Comments
 (0)