Skip to content

Commit fd60e91

Browse files
chore: autopublish 2024-07-21T11:51:05Z
1 parent 8912e32 commit fd60e91

File tree

3 files changed

+77
-58
lines changed

3 files changed

+77
-58
lines changed
Lines changed: 76 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -5206,54 +5206,60 @@ function plugindef()
52065206
finaleplugin.Author = "Carl Vine"
52075207
finaleplugin.AuthorURL = "http://carlvine.com/lua/"
52085208
finaleplugin.Copyright = "https://creativecommons.org/licenses/by/4.0/"
5209-
finaleplugin.Version = "0.10"
5210-
finaleplugin.Date = "2024/05/03"
5211-
finaleplugin.MinJWLuaVersion = 0.62
5209+
finaleplugin.Version = "0.14"
5210+
finaleplugin.Date = "2024/07/21"
5211+
finaleplugin.MinJWLuaVersion = 0.70
52125212
finaleplugin.Notes = [[
5213-
There's a couple of __Music Spacing__ options that I
5214-
change frequently for different spacing scenarios.
5215-
This little hack uses a couple of hotkeys
5216-
to do that very quickly, without a mouse and without navigating
5217-
the whole __Document__ → __Document Options__ →
5218-
__Music Spacing__ → __Avoid Collision of__ → menu/dialog system.
5213+
Quickly change __music spacing__ options (with optional hotkeys).
5214+
These options are otherwise only available using the messy combined
5215+
menu/dialog/menu process of
5216+
__Document__ → __Document Options__ → __Music Spacing__ → __Avoid Collision of__...
5217+
5218+
It also offers easy access to the __Automatic Music Spacing__ option
5219+
which is otherwise only available at
5220+
__Finale__ → __Settings__ → __Edit__ → __Automatic Music Spacing__.
52195221
]]
52205222
finaleplugin.RTFNotes = [[
52215223
{\rtf1\ansi\deff0{\fonttbl{\f0 \fswiss Helvetica;}{\f1 \fmodern Courier New;}}
52225224
{\colortbl;\red255\green0\blue0;\red0\green0\blue255;}
52235225
\widowctrl\hyphauto
52245226
\fs18
52255227
{\info{\comment "os":"mac","fs18":"fs24","fs26":"fs32","fs23":"fs29","fs20":"fs26"}}
5226-
{\pard \sl264 \slmult1 \ql \f0 \sa180 \li0 \fi0 There\u8217's a couple of {\b Music Spacing} options that I change frequently for different spacing scenarios. This little hack uses a couple of hotkeys to do that very quickly, without a mouse and without navigating the whole {\b Document} \u8594? {\b Document Options} \u8594? {\b Music Spacing} \u8594? {\b Avoid Collision of} \u8594? menu/dialog system.\par}
5228+
{\pard \sl264 \slmult1 \ql \f0 \sa180 \li0 \fi0 Quickly change {\b music spacing} options (with optional hotkeys). These options are otherwise only available using the messy combined menu/dialog/menu process of {\b Document} \u8594? {\b Document Options} \u8594? {\b Music Spacing} \u8594? {\b Avoid Collision of}\u8230?\par}
5229+
{\pard \sl264 \slmult1 \ql \f0 \sa180 \li0 \fi0 It also offers easy access to the {\b Automatic Music Spacing} option which is otherwise only available at {\b Finale} \u8594? {\b Settings} \u8594? {\b Edit} \u8594? {\b Automatic Music Spacing}.\par}
52275230
}
52285231
]]
5229-
finaleplugin.HashURL = "https://raw.githubusercontent.com/finale-lua/lua-scripts/master/hash/music_spacing_hack.hash"
5230-
return "Music Spacing Hack...",
5231-
"Music Spacing Hack",
5232-
"A keyboard hack to quickly change music spacing options"
5232+
finaleplugin.HashURL = "https://raw.githubusercontent.com/finale-lua/lua-scripts/master/hash/music_spacing_options.hash"
5233+
return "Music Spacing Options...",
5234+
"Music Spacing Options",
5235+
"Quickly change music spacing options (with optional hotkeys)"
52335236
end
52345237
local config = {
5238+
dummy = "dummy",
52355239
window_pos_x = false,
52365240
window_pos_y = false,
52375241
measurement_unit = finale.MEASUREMENTUNIT_DEFAULT,
52385242
}
52395243
local checks = {
52405244
{ "AvoidArticulations", "A", "Articulations" },
5241-
{ "AvoidChords", "S", "Chords" },
5242-
{ "AvoidClefs", "D", "Clefs" },
5243-
{ "AvoidHiddenNotes", "W", "Hidden Notes" },
5244-
{ "AvoidLedgerLines", "E", "Ledger Lines" },
5245-
{ "AvoidLyrics", "R", "Lyrics" },
5245+
{ "AvoidChords", "S", "Chords" },
5246+
{ "AvoidClefs", "D", "Clefs" },
5247+
{ "AvoidHiddenNotes", "W", "Hidden Notes" },
5248+
{ "AvoidLedgerLines", "E", "Ledger Lines" },
5249+
{ "AvoidLyrics", "R", "Lyrics" },
52465250
}
52475251
local unisons = {
5248-
{ finale.UNISSPACE_NONE, "X", "None" },
5249-
{ finale.UNISSPACE_DIFFERENTNOTEHEADS, "V", "Different Noteheads" },
5250-
{ finale.UNISSPACE_ALLNOTEHEADS, "B", "All Noteheads" },
5252+
{ finale.UNISSPACE_NONE, "V", "None" },
5253+
{ finale.UNISSPACE_DIFFERENTNOTEHEADS, "B", "Different Noteheads" },
5254+
{ finale.UNISSPACE_ALLNOTEHEADS, "N", "All Noteheads" },
52515255
}
52525256
local others = {
5253-
{"change_hotkeys", "H", "Change Hotkeys"},
5254-
{"AutomaticMusicSpacing", "Z", "Automatic Music Spacing"},
5255-
{"script_info", "Q", "Show Script Info"}
5257+
{ "change_hotkeys", "H", "Change Hotkeys" },
5258+
{ "auto_spacing", "Z", "Automatic Music Spacing" },
5259+
{ "script_info", "Q", "Show Script Info" },
5260+
{ "manual_pos", "X", "Manual Positioning" }
52565261
}
5262+
local manual_pos = { "Clear", "Incorporate", "Ignore" }
52575263
for _, t in ipairs{checks, unisons, others} do
52585264
for _, v in ipairs(t) do
52595265
config[tostring(v[1])] = v[2]
@@ -5266,9 +5272,9 @@ local library = require("library.general_library")
52665272
local script_name = library.calc_script_name()
52675273
local name = plugindef():gsub("%.%.%.", "")
52685274
local refocus_document = false
5269-
local prefs = finale.FCMusicSpacingPrefs()
5275+
local spacing_prefs = finale.FCMusicSpacingPrefs()
5276+
spacing_prefs:LoadFirst()
52705277
local gen_prefs = finale.FCGeneralPrefs()
5271-
prefs:LoadFirst()
52725278
gen_prefs:LoadFirst()
52735279
configuration.get_user_settings(script_name, config)
52745280
local function dialog_set_position(dialog)
@@ -5364,12 +5370,12 @@ local function run_the_dialog()
53645370
local y = 0
53655371
local m_offset = finenv.UI():IsOnMac() and 3 or 0
53665372
local saved
5367-
local dialog = mixin.FCXCustomLuaWindow():SetTitle(name:sub(1, -5))
5373+
local dialog = mixin.FCXCustomLuaWindow():SetTitle(name:sub(1, 13))
53685374
dialog:SetMeasurementUnit(config.measurement_unit)
53695375

53705376
local function dy(diff) y = y + (diff and diff or 17) end
53715377
local function show_info()
5372-
utils.show_notes_dialog(dialog, "About " .. name, 300, 150)
5378+
utils.show_notes_dialog(dialog, "About " .. name, 300, 175)
53735379
refocus_document = true
53745380
end
53755381
local function cstat(cx, cy, ctext, cwide, cname)
@@ -5379,14 +5385,22 @@ local function run_the_dialog()
53795385
dialog:CreateCheckbox(cx, cy, cname):SetText(ctext):SetWidth(cwide):SetCheck(check)
53805386
end
53815387
local function toggle_check(id)
5382-
local ctl = dialog:GetControl(id)
5383-
ctl:SetCheck((ctl:GetCheck() + 1) % 2)
5388+
local c = dialog:GetControl(id)
5389+
c:SetCheck((c:GetCheck() + 1) % 2)
53845390
end
53855391
local function toggle_unison(id)
53865392
for i = unisons[1][1], unisons[3][1] do
53875393
dialog:GetControl(tostring(i)):SetCheck(i == id and 1 or 0)
53885394
end
53895395
end
5396+
local function fill_pos_popup()
5397+
local popup = dialog:GetControl(others[4][1])
5398+
popup:Clear()
5399+
for _, v in ipairs(manual_pos) do
5400+
popup:AddString(v .. " (" .. config.manual_pos .. ")")
5401+
end
5402+
popup:SetSelectedItem(spacing_prefs.ManualPositioning)
5403+
end
53905404
local function change_keys()
53915405
local ok, is_duplicate = true, true
53925406
while ok and is_duplicate do
@@ -5395,31 +5409,33 @@ local function run_the_dialog()
53955409
if ok then
53965410
for _, t in ipairs{checks, unisons, others} do
53975411
for _, v in ipairs(t) do
5398-
if v[1] ~= "script_info" then
5412+
if v[1] ~= "script_info" and v[1] ~= "manual_pos" then
53995413
dialog:GetControl("T" .. v[1]):SetText(config[tostring(v[1])])
54005414
end
54015415
end
54025416
end
54035417
else
54045418
configuration.get_user_settings(script_name, config)
54055419
end
5420+
fill_pos_popup()
54065421
dialog:GetControl("max_width"):SetKeyboardFocus()
54075422
end
54085423
local function key_check(ctl)
54095424
local s = ctl:GetText():upper()
5410-
if s:find("[^.P0-9]") then
5411-
if s:find(config.change_hotkeys) then
5412-
change_keys()
5413-
elseif s:find(config.AutomaticMusicSpacing) then
5414-
toggle_check("AutomaticMusicSpacing")
5425+
if s:find("[^ .P0-9]") then
5426+
if s:find(config.change_hotkeys) then change_keys()
5427+
elseif s:find(config.auto_spacing) then toggle_check("auto_spacing")
54155428
elseif s:find(config.script_info) then show_info()
5429+
elseif s:find(config.manual_pos) then
5430+
local c = dialog:GetControl(others[4][1])
5431+
c:SetSelectedItem((c:GetSelectedItem() + 1) % 3)
54165432
else
54175433
local matched = false
5418-
for _, array in ipairs{{checks, toggle_check}, {unisons, toggle_unison}} do
5434+
for _, t in ipairs{{checks, toggle_check}, {unisons, toggle_unison}} do
54195435
if not matched then
5420-
for _, v in ipairs(array[1]) do
5436+
for _, v in ipairs(t[1]) do
54215437
if s:find(config[tostring(v[1])]) then
5422-
array[2](v[1])
5438+
t[2](v[1])
54235439
matched = true
54245440
break
54255441
end
@@ -5432,71 +5448,74 @@ local function run_the_dialog()
54325448
end
54335449
ctl:SetText(saved)
54345450
end
5435-
cstat(0, y, "THE " .. name:upper(), 160, "title")
5451+
cstat(10, y, name:upper(), 155, "title")
54365452
dy(25)
54375453
cstat(0, y, "Avoid Collisions of:", x[3])
54385454
dialog:CreateButton(x[2] + x[3] - 50, y, "q"):SetText("?"):SetWidth(20)
54395455
:AddHandleCommand(function() show_info() end)
54405456
dy()
54415457
for _, v in ipairs(checks) do
54425458
cstat(0, y, config[v[1]], x[1], "T" .. v[1])
5443-
ccheck(x[1], y, v[1], v[3], x[3], (prefs[v[1]] and 1 or 0))
5459+
ccheck(x[1], y, v[1], v[3], x[3], (spacing_prefs[v[1]] and 1 or 0))
54445460
dy()
54455461
end
54465462
cstat(x[1], y, "Unison Noteheads:", x[3])
54475463
dy()
54485464
for _, v in ipairs(unisons) do
54495465
local id = tostring(v[1])
54505466
cstat(x[1], y, config[id], x[2], "T" .. v[1])
5451-
ccheck(x[2], y, id, v[3], x[3] - x[1], (prefs.UnisonsMode == v[1]) and 1 or 0)
5452-
dialog:GetControl(id)
5453-
:AddHandleCommand(function() toggle_unison(v[1]) end)
5467+
ccheck(x[2], y, id, v[3], x[3] - x[1], (spacing_prefs.UnisonsMode == v[1]) and 1 or 0)
5468+
dialog:GetControl(id):AddHandleCommand(function() toggle_unison(v[1]) end)
54545469
dy()
54555470
end
54565471
dy(8)
54575472
cstat(0, y, "Max Width:", x[2] + 25)
5458-
dialog:CreateMeasurementEdit(x[2] + 27, y - m_offset, "max_width")
5459-
:SetWidth(90):SetMeasurementInteger(prefs.MaxMeasureWidth)
5473+
dialog:CreateMeasurementEdit(x[2] + 27, y - m_offset, "max_width"):SetWidth(105)
5474+
:SetMeasurementInteger(spacing_prefs.MaxMeasureWidth)
54605475
:AddHandleCommand(function(self) key_check(self) end)
54615476
saved = dialog:GetControl("max_width"):GetText()
54625477
dy(25)
54635478
cstat(x[2] - 10, y, "Units:", 37)
5464-
dialog:CreateMeasurementUnitPopup(x[2] + 27, y, "popup"):SetWidth(90)
5479+
dialog:CreateMeasurementUnitPopup(x[2] + 27, y, "popup"):SetWidth(105)
54655480
:AddHandleCommand(function()
54665481
saved = dialog:GetControl("max_width"):GetText()
54675482
end)
54685483
dy(25)
5484+
cstat(3, y, "Man. Posn:", x[2] + 27)
5485+
local manpos = dialog:CreatePopup(x[2] + 27, y, others[4][1]):SetWidth(105)
5486+
fill_pos_popup()
5487+
dy(25)
54695488
cstat(0, y, config.change_hotkeys, x[2], "Tchange_hotkeys")
54705489
dialog:CreateButton(x[1], y):SetText("Change Hotkeys"):SetWidth(100)
54715490
:AddHandleCommand(function() change_keys() end)
54725491
dy(22)
54735492
local val = others[2]
54745493
cstat(0, y, config[val[1]], x[1], "T" .. val[1])
5475-
ccheck(x[1], y, val[1], val[3], x[3], (gen_prefs[val[1]] and 1 or 0))
5494+
ccheck(x[1], y, val[1], val[3], x[3], (gen_prefs.AutomaticMusicSpacing and 1 or 0))
54765495
dialog:CreateOkButton()
54775496
dialog:CreateCancelButton()
54785497
dialog_set_position(dialog)
54795498
dialog:RegisterInitWindow(function(self)
54805499
self:GetControl("max_width"):SetKeyboardFocus()
5481-
local q = self:GetControl("q")
5482-
local bold = q:CreateFontInfo():SetBold(true)
5483-
q:SetFont(bold)
5500+
local bold = self:GetControl("q"):CreateFontInfo():SetBold(true)
5501+
self:GetControl("q"):SetFont(bold)
54845502
self:GetControl("title"):SetFont(bold)
54855503
end)
54865504
dialog:RegisterHandleOkButtonPressed(function(self)
54875505
for _, v in ipairs(checks) do
5488-
prefs[v[1]] = (self:GetControl(v[1]):GetCheck() == 1)
5506+
spacing_prefs[v[1]] = (self:GetControl(v[1]):GetCheck() == 1)
54895507
end
54905508
for _, v in ipairs(unisons) do
54915509
if (self:GetControl(tostring(v[1])):GetCheck() == 1) then
5492-
prefs.UnisonsMode = v[1]
5510+
spacing_prefs.UnisonsMode = v[1]
54935511
break
54945512
end
54955513
end
54965514
local n = self:GetControl("max_width"):GetMeasurementInteger()
5497-
prefs.MaxMeasureWidth = math.max(n, 50)
5498-
prefs:Save()
5499-
gen_prefs.AutomaticMusicSpacing = (self:GetControl("AutomaticMusicSpacing"):GetCheck() == 1)
5515+
spacing_prefs.MaxMeasureWidth = math.max(n, 50)
5516+
spacing_prefs.ManualPositioning = manpos:GetSelectedItem()
5517+
spacing_prefs:Save()
5518+
gen_prefs.AutomaticMusicSpacing = (self:GetControl("auto_spacing"):GetCheck() == 1)
55005519
gen_prefs:Save()
55015520
config.measurement_unit = self:GetMeasurementUnit()
55025521
end)

hash/music_spacing_hack.hash

Lines changed: 0 additions & 1 deletion
This file was deleted.

hash/music_spacing_options.hash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
b1bff7c45df2d96053a43a9a65c3de7212445ef733d6039d7f19018ba0e20e6ffb2dc4c93e446073bf36d6aac9d6ad682423a9c513bf2d1a53be931cc95af83c music_spacing_options.lua

0 commit comments

Comments
 (0)