Skip to content

Commit bbf7df0

Browse files
committedJan 25, 2024
chore: autopublish 2024-01-25T12:39:33Z
1 parent 9374e44 commit bbf7df0

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed
 

‎dist/page_format_wizard.lua

+26-27
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ function plugindef()
295295
finaleplugin.Author = "Jacob Winkler"
296296
finaleplugin.Copyright = "©2024 Jacob Winkler"
297297
finaleplugin.AuthorEmail = "jacob.winkler@mac.com"
298-
finaleplugin.Date = "2024/1/21"
299-
finaleplugin.Version = "1.1"
298+
finaleplugin.Date = "2024/1/25"
299+
finaleplugin.Version = "1.2"
300300
finaleplugin.HandlesUndo = true
301301
finaleplugin.NoStore = false
302302
finaleplugin.MinJWLuaVersion = 0.70
@@ -370,12 +370,13 @@ function bold_control(control)
370370
font:SetBold(true)
371371
control:SetFont(font)
372372
end
373-
function math.sign(number)
373+
function math_sign(number)
374374
return (number >= 0 and 1) or -1
375375
end
376-
function math.round(number, round_to)
376+
function math_round(number, round_to)
377+
number = number or 0
377378
round_to = round_to or 1
378-
return math.floor(number/round_to + math.sign(number) * 0.5) * round_to
379+
return math.floor(math.abs(number)/round_to + 0.5) * round_to * math_sign(number)
379380
end
380381
local function mm_to_efix(mm)
381382
local efix = mm * (18432 / 25.4)
@@ -392,7 +393,7 @@ end
392393
local function efix_to_mm_string(efix)
393394
str:SetMeasurement(efix/64*10, finale.MEASUREMENTUNIT_CENTIMETERS)
394395
local temp = str.LuaString
395-
temp = math.round(tonumber(temp), .1)
396+
temp = math_round(tonumber(temp), .1)
396397
str.LuaString = tostring(temp)
397398
return str
398399
end
@@ -459,8 +460,8 @@ local special_enable_checkbox
459460
local special_ctrls = {}
460461
local special_ctrls_collection = {}
461462
local function match_page(w, h)
462-
w = math.round(w, 1)
463-
h = math.round(h, 1)
463+
w = math_round(w, 1)
464+
h = math_round(h, 1)
464465
local matched = -1
465466
local landscape = 0
466467
for k, v in pairs(page_sizes) do
@@ -527,11 +528,6 @@ local function orientation_set(w, h, mode)
527528
else
528529
return h, w
529530
end
530-
if mode == 1 and w > h then
531-
return w, h
532-
else
533-
return h, w
534-
end
535531
end
536532
local function orientation_set_popup(w, h, popup)
537533
if not hold then
@@ -769,7 +765,7 @@ local function format_wizard()
769765
controls.first_system_left_edit:SetMeasurement(page_settings.first_system_left_margin, page_settings.system_units)
770766
controls.system_bottom_edit:SetMeasurement(page_settings.system_bottom_margin-96, page_settings.system_units)
771767

772-
temp = math.round(efix_to_mm(page_settings.staff_h)*10, 1)
768+
temp = math_round(efix_to_mm(page_settings.staff_h)*10, 1)
773769
controls.staff_h_invisible:SetInteger(temp)
774770
controls.staff_h_updown:SetValue(temp)
775771
controls.staff_h_edit:SetText(efix_to_mm_string(page_settings.staff_h))
@@ -870,7 +866,6 @@ local function format_wizard()
870866
end
871867
local function format_pages_and_save()
872868
local controls = {}
873-
local page_settings = {}
874869
local score_format_prefs = finale.FCPageFormatPrefs()
875870
local parts_format_prefs = finale.FCPageFormatPrefs()
876871
parts_format_prefs:LoadParts()
@@ -936,7 +931,7 @@ local function format_wizard()
936931
end
937932
local function check_for_special(part_num)
938933
for i = 0, special_ctrls.parts_datalist:GetCount()-1 do
939-
local row = special_ctrls.parts_datalist:GetItemAt(i)
934+
row = special_ctrls.parts_datalist:GetItemAt(i)
940935
str = row:GetItemAt(1)
941936
if part_num == tonumber(str.LuaString) then
942937
if row:GetCheck() then
@@ -1027,9 +1022,7 @@ local function format_wizard()
10271022
end
10281023

10291024
staff_height_set(system, page_settings.staff_h)
1030-
if controls.staff_spacing_popup:GetSelectedItem() == 0 then
1031-
1032-
else
1025+
if controls.staff_spacing_popup:GetSelectedItem() > 0 then
10331026
local sysstaves = finale.FCSystemStaves()
10341027
sysstaves:LoadAllForItem(system:GetItemNo())
10351028
local last_staff_pos = 0
@@ -1162,7 +1155,7 @@ local function format_wizard()
11621155
special_enable_checkbox = add_ctrl(dialog, "checkbox", "", x, 0, 10, 10)
11631156
special_enable_checkbox:SetCheck(config.special_enable)
11641157
local special_static = add_ctrl(dialog, "static", "SPECIAL PARTS", x + 12, 0, col_w, row_h)
1165-
local function section_create(controls, page_settings, ctrls_collection, section_n)
1158+
local function section_create(controls, page_settings, ctrls_collection)
11661159
row = 1
11671160
y = row*row_h
11681161
x = section_n*section_w
@@ -1401,7 +1394,7 @@ local function format_wizard()
14011394
controls.staff_h_updown:ConnectIntegerEdit(controls.staff_h_invisible, 30, 100)
14021395
controls.staff_h_mm_static = add_ctrl(dialog, "static", "mm", x+col[4]+12, y, 20, row_h)
14031396

1404-
temp = math.round(efix_to_mm(page_settings.staff_h)*10, .1)
1397+
temp = math_round(efix_to_mm(page_settings.staff_h)*10, .1)
14051398
controls.staff_h_invisible:SetInteger(temp ,1)
14061399
controls.staff_h_edit:SetText(efix_to_mm_string(page_settings.staff_h))
14071400
controls.staff_h_updown:SetValue(controls.staff_h_invisible:GetInteger())
@@ -1470,7 +1463,7 @@ local function format_wizard()
14701463
for part in each(parts) do
14711464
if part:IsPart() then
14721465
part:GetName(str)
1473-
local row = controls.parts_datalist:CreateRow()
1466+
row = controls.parts_datalist:CreateRow()
14741467
row:GetItemAt(0).LuaString = str.LuaString
14751468
row:GetItemAt(1).LuaString = part:GetItemNo()
14761469
end
@@ -1550,9 +1543,15 @@ local function format_wizard()
15501543
page_size_update(controls, page_settings, ctrls_collection)
15511544
return controls, page_settings, ctrls_collection
15521545
end
1553-
score_ctrls, score_settings, score_ctrls_collection = section_create(score_ctrls, score_settings, score_ctrls_collection, 0)
1554-
parts_ctrls, parts_settings, parts_ctrls_collection = section_create(parts_ctrls, parts_settings, parts_ctrls_collection, 1)
1555-
special_ctrls, special_settings, special_ctrls_collection = section_create(special_ctrls, special_settings, special_ctrls_collection, 2)
1546+
section_n = 0
1547+
score_ctrls, score_settings, score_ctrls_collection = section_create(score_ctrls, score_settings, score_ctrls_collection)
1548+
section_n = 1
1549+
1550+
parts_ctrls, parts_settings, parts_ctrls_collection = section_create(parts_ctrls, parts_settings, parts_ctrls_collection)
1551+
section_n = 2
1552+
1553+
special_ctrls, special_settings, special_ctrls_collection = section_create(special_ctrls, special_settings, special_ctrls_collection)
1554+
15561555
section_enable(score_enable_checkbox, score_ctrls, score_settings, score_ctrls_collection)
15571556
section_enable(parts_enable_checkbox, parts_ctrls, parts_settings, parts_ctrls_collection)
15581557
section_enable(special_enable_checkbox, special_ctrls, special_settings, special_ctrls_collection)
@@ -1791,7 +1790,7 @@ local function format_wizard()
17911790
if not hold then
17921791
hold = true
17931792
page_settings.staff_h = mm_to_efix(controls.staff_h_edit:GetMeasurement(finale.MEASUREMENTUNIT_MILLIMETERS))
1794-
temp = math.round(controls.staff_h_edit:GetMeasurement(finale.MEASUREMENTUNIT_MILLIMETERS)*10, 1)
1793+
temp = math_round(controls.staff_h_edit:GetMeasurement(finale.MEASUREMENTUNIT_MILLIMETERS)*10, 1)
17951794
controls.staff_h_invisible:SetInteger(temp)
17961795
controls.staff_h_updown:SetValue(temp)
17971796
hold = false
@@ -1871,7 +1870,7 @@ local function format_wizard()
18711870
end)
18721871
dialog:RegisterHandleControlEvent (controls.clear_datalist_button, function(control)
18731872
for i = 0, controls.parts_datalist:GetCount()-1 do
1874-
local row = controls.parts_datalist:GetItemAt(i)
1873+
row = controls.parts_datalist:GetItemAt(i)
18751874
row:SetCheck(false)
18761875
end
18771876
end)

‎hash/page_format_wizard.hash

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
741711c5866677b3d15545a3aed82f5660a0f9b7c1a9db11592243bf8daa2dad63cd25cd1d48f86a9926f97faeed78780632276c5e36965313b3f27df37a76ea page_format_wizard.lua
1+
fa091b5ddbbc53e3d065cb33dba18ad13e100a1b0939d9b9b10123a92de47180b35c40597407eb2f2b92a9d297fd5452fdd1843bc90702048062ba0f1bee646f page_format_wizard.lua

0 commit comments

Comments
 (0)
Please sign in to comment.