Skip to content

Commit 9e90d68

Browse files
committed
Spacing "hack" -> "options"
Spacing "hack" -> "options". Updated script name, dialog title and documentation, streamlined code.
1 parent 3aac70d commit 9e90d68

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed
Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@ function plugindef()
44
finaleplugin.Author = "Carl Vine"
55
finaleplugin.AuthorURL = "http://carlvine.com/lua/"
66
finaleplugin.Copyright = "https://creativecommons.org/licenses/by/4.0/"
7-
finaleplugin.Version = "0.12"
8-
finaleplugin.Date = "2024/06/21"
9-
finaleplugin.MinJWLuaVersion = 0.62
7+
finaleplugin.Version = "0.14"
8+
finaleplugin.Date = "2024/07/21"
9+
finaleplugin.MinJWLuaVersion = 0.70
1010
finaleplugin.Notes = [[
11-
There's a couple of __Music Spacing__ options that I
12-
change frequently for different spacing scenarios.
13-
This little hack uses a couple of hotkeys to do that
14-
quickly using only keyboard entry without navigating
15-
the whole __Document__ → __Document Options__ →
16-
__Music Spacing__ → __Avoid Collision of__ → menu/dialog system.
11+
Quickly change __music spacing__ options (with optional hotkeys).
12+
These options are otherwise only available using the messy combined
13+
menu/dialog/menu process of
14+
__Document__ → __Document Options__ → __Music Spacing__ → __Avoid Collision of__...
15+
16+
It also offers easy access to the __Automatic Music Spacing__ option
17+
which is otherwise only available at
18+
__Finale__ → __Settings__ → __Edit__ → __Automatic Music Spacing__.
1719
]]
18-
return "Music Spacing Hack...",
19-
"Music Spacing Hack",
20-
"A keyboard hack to quickly change music spacing options"
20+
return "Music Spacing Options...",
21+
"Music Spacing Options",
22+
"Quickly change music spacing options (with optional hotkeys)"
2123
end
2224

2325
local config = {
@@ -40,10 +42,10 @@ local unisons = {
4042
{ finale.UNISSPACE_ALLNOTEHEADS, "N", "All Noteheads" },
4143
}
4244
local others = {
43-
{"change_hotkeys", "H", "Change Hotkeys"},
44-
{"AutomaticMusicSpacing", "Z", "Automatic Music Spacing"},
45-
{"script_info", "Q", "Show Script Info"},
46-
{"manual_pos", "X", "Manual Positioning"}
45+
{ "change_hotkeys", "H", "Change Hotkeys" },
46+
{ "auto_spacing", "Z", "Automatic Music Spacing" },
47+
{ "script_info", "Q", "Show Script Info" },
48+
{ "manual_pos", "X", "Manual Positioning" }
4749
}
4850
local manual_pos = { "Clear", "Incorporate", "Ignore" } -- 0 .. 1 .. 2 popup
4951

@@ -62,8 +64,8 @@ local script_name = library.calc_script_name()
6264
local name = plugindef():gsub("%.%.%.", "")
6365
local refocus_document = false
6466
local spacing_prefs = finale.FCMusicSpacingPrefs()
65-
local gen_prefs = finale.FCGeneralPrefs()
6667
spacing_prefs:LoadFirst()
68+
local gen_prefs = finale.FCGeneralPrefs()
6769
gen_prefs:LoadFirst()
6870
configuration.get_user_settings(script_name, config)
6971

@@ -164,12 +166,12 @@ local function run_the_dialog()
164166
local m_offset = finenv.UI():IsOnMac() and 3 or 0
165167
local saved
166168

167-
local dialog = mixin.FCXCustomLuaWindow():SetTitle(name:sub(1, -5))
169+
local dialog = mixin.FCXCustomLuaWindow():SetTitle(name:sub(1, 13))
168170
dialog:SetMeasurementUnit(config.measurement_unit)
169171
-- local functions
170172
local function dy(diff) y = y + (diff and diff or 17) end
171173
local function show_info()
172-
utils.show_notes_dialog(dialog, "About " .. name, 300, 150)
174+
utils.show_notes_dialog(dialog, "About " .. name, 300, 175)
173175
refocus_document = true
174176
end
175177
local function cstat(cx, cy, ctext, cwide, cname)
@@ -208,7 +210,6 @@ local function run_the_dialog()
208210
end
209211
end
210212
end
211-
configuration.save_user_settings(script_name, config)
212213
else -- re-seed hotkeys from user config
213214
configuration.get_user_settings(script_name, config)
214215
end
@@ -217,11 +218,9 @@ local function run_the_dialog()
217218
end
218219
local function key_check(ctl)
219220
local s = ctl:GetText():upper()
220-
if s:find("[^.P0-9]") then
221-
if s:find(config.change_hotkeys) then
222-
change_keys()
223-
elseif s:find(config.AutomaticMusicSpacing) then
224-
toggle_check("AutomaticMusicSpacing")
221+
if s:find("[^ .P0-9]") then
222+
if s:find(config.change_hotkeys) then change_keys()
223+
elseif s:find(config.auto_spacing) then toggle_check("auto_spacing")
225224
elseif s:find(config.script_info) then show_info()
226225
elseif s:find(config.manual_pos) then -- toggle ManPosn Popup
227226
local c = dialog:GetControl(others[4][1])
@@ -245,7 +244,7 @@ local function run_the_dialog()
245244
end
246245
ctl:SetText(saved)
247246
end
248-
cstat(0, y, "THE " .. name:upper(), 160, "title")
247+
cstat(10, y, name:upper(), 155, "title")
249248
dy(25)
250249
cstat(0, y, "Avoid Collisions of:", x[3])
251250
dialog:CreateButton(x[2] + x[3] - 50, y, "q"):SetText("?"):SetWidth(20)
@@ -286,9 +285,9 @@ local function run_the_dialog()
286285
dialog:CreateButton(x[1], y):SetText("Change Hotkeys"):SetWidth(100)
287286
:AddHandleCommand(function() change_keys() end)
288287
dy(22)
289-
local val = others[2]
288+
local val = others[2] -- AUTOMATIC MUSIC SPACING
290289
cstat(0, y, config[val[1]], x[1], "T" .. val[1])
291-
ccheck(x[1], y, val[1], val[3], x[3], (gen_prefs[val[1]] and 1 or 0))
290+
ccheck(x[1], y, val[1], val[3], x[3], (gen_prefs.AutomaticMusicSpacing and 1 or 0))
292291

293292
dialog:CreateOkButton()
294293
dialog:CreateCancelButton()
@@ -313,7 +312,7 @@ local function run_the_dialog()
313312
spacing_prefs.MaxMeasureWidth = math.max(n, 50)
314313
spacing_prefs.ManualPositioning = manpos:GetSelectedItem()
315314
spacing_prefs:Save()
316-
gen_prefs.AutomaticMusicSpacing = (self:GetControl("AutomaticMusicSpacing"):GetCheck() == 1)
315+
gen_prefs.AutomaticMusicSpacing = (self:GetControl("auto_spacing"):GetCheck() == 1)
317316
gen_prefs:Save()
318317
config.measurement_unit = self:GetMeasurementUnit()
319318
end)

0 commit comments

Comments
 (0)