@@ -8957,19 +8957,19 @@ end
89578957function plugindef ()
89588958 finaleplugin .RequireSelection = true
89598959 finaleplugin .Author = " Carl Vine after CJ Garcia"
8960- finaleplugin .AuthorURL = " http://carlvine.com/lua"
8960+ finaleplugin .AuthorURL = " http://carlvine.com/lua/ "
89618961 finaleplugin .Copyright = " CC0 https://creativecommons.org/publicdomain/zero/1.0/"
8962- finaleplugin .Version = " v0.60 "
8963- finaleplugin .Date = " 2022/07/25 "
8962+ finaleplugin .Version = " v0.61 "
8963+ finaleplugin .Date = " 2022/08/07 "
89648964 finaleplugin .AdditionalMenuOptions = [[
8965- Hairpin create diminuendo
8966- Hairpin create swell
8967- Hairpin create unswell
8965+ Hairpin Create Diminuendo
8966+ Hairpin Create Swell
8967+ Hairpin Create Unswell
89688968 ]]
89698969 finaleplugin .AdditionalUndoText = [[
8970- Hairpin create diminuendo
8971- Hairpin create swell
8972- Hairpin create unswell
8970+ Hairpin Create Diminuendo
8971+ Hairpin Create Swell
8972+ Hairpin Create Unswell
89738973 ]]
89748974 finaleplugin .AdditionalDescriptions = [[
89758975 Create diminuendo spanning the selected region
@@ -8982,7 +8982,8 @@ function plugindef()
89828982 hairpin_type = -2 -- "unswell"
89838983 ]]
89848984 finaleplugin .MinJWLuaVersion = 0.63
8985- finaleplugin .ScriptGroupName = " Hairpin creator"
8985+ finaleplugin .ScriptGroupName = " Hairpin Creator"
8986+ finaleplugin .ScriptGroupDescription = " Create four different types of hairpin spanning the currently selected music region"
89868987 finaleplugin .Notes = [[
89878988 This script creates hairpins spanning the currently selected music region.
89888989 The default hairpin type is `CRESCENDO`, with three additional menu items provided to create:
@@ -9011,7 +9012,7 @@ function plugindef()
90119012 For simple hairpins that don't mess around with trailing barlines and dynamics try selecting
90129013 `dynamics_match_hairpin` and de-selecting the other options.
90139014 ]]
9014- return " Hairpin create crescendo " , " Hairpin create crescendo " , " Create crescendo spanning the selected region"
9015+ return " Hairpin Create Crescendo " , " Hairpin Create Crescendo " , " Create crescendo spanning the selected region"
90159016end
90169017
90179018hairpin_type = hairpin_type or finale .SMARTSHAPE_CRESCENDO
@@ -9031,18 +9032,15 @@ local dialog_options = { -- key value in config, explanation
90319032 { " left_dynamic_cushion" , " gap between first dynamic and start of hairpin" },
90329033 { " right_dynamic_cushion" , " gap between end of the hairpin and ending dynamic" },
90339034}
9034-
90359035local boolean_options = {
90369036 dynamics_match_hairpin = true ,
90379037 include_trailing_items = true ,
90389038 attach_over_end_barline = true ,
90399039 attach_over_system_break = true ,
90409040}
9041-
90429041local integer_options = {
90439042 inclusions_EDU_margin = true ,
90449043}
9045-
90469044local config = {
90479045 dynamics_match_hairpin = true ,
90489046 include_trailing_items = true ,
@@ -9054,9 +9052,9 @@ local config = {
90549052 downstem_cushion = 44 ,
90559053 below_artic_cushion = 40 ,
90569054 left_horiz_offset = 16 ,
9057- right_horiz_offset = - 14 ,
9055+ right_horiz_offset = - 16 ,
90589056 left_dynamic_cushion = 18 ,
9059- right_dynamic_cushion = - 16 ,
9057+ right_dynamic_cushion = - 18 ,
90609058 measurement_unit = finale .MEASUREMENTUNIT_DEFAULT ,
90619059 window_pos_x = false ,
90629060 window_pos_y = false ,
@@ -9335,6 +9333,7 @@ local function design_staff_swell(rgn, hairpin_shape, lowest_vert)
93359333 local new_end_measure , new_end_postion = nil , nil -- assume they're nil for now
93369334 local dynamic_list = simple_dynamic_scan (rgn )
93379335 if # dynamic_list > 0 then -- check horizontal alignments + positions
9336+
93389337 local first_dyn = dynamic_list [1 ]
93399338 if duration_gap (rgn .StartMeasure , rgn .StartMeasurePos , first_dyn .Measure , first_dyn .MeasurePos ) < config .inclusions_EDU_margin then
93409339 local offset = dynamic_horiz_offset (first_dyn , " left" )
@@ -9503,16 +9502,8 @@ local function create_hairpin(shape_type)
95039502 end
95049503end
95059504
9506- function activity_selector ()
9507- if hairpin_type < 0 then -- SWELL / UNSWELL
9508- create_swell (hairpin_type == - 1 ) -- true for SWELL, otherwise UNSWELL
9509- else
9510- create_hairpin (hairpin_type ) -- preset CRESC / DIM
9511- end
9512- end
9513-
9514- function create_user_dialog () -- attempting MODELESS operation
9515- local dialog = mixin .FCXCustomLuaWindow ():SetTitle (" HAIRPIN CREATOR CONFIGURATION" )
9505+ function create_dialog_box ()
9506+ local dialog = mixin .FCXCustomLuaWindow ():SetTitle (" Hairpin Creator Configuration" )
95169507 local y_step = 20
95179508 local max_text_width = 385
95189509 local x_offset = {0 , 130 , 155 , 190 }
@@ -9521,7 +9512,7 @@ function create_user_dialog() -- attempting MODELESS operation
95219512 local function make_static (msg , horiz , vert , width , sepia )
95229513 local static = dialog :CreateStatic (horiz , vert ):SetText (msg ):SetWidth (width )
95239514 if sepia and static .SetTextColor then
9524- static :SetTextColor (102 , 0 , 0 )
9515+ static :SetTextColor (153 , 51 , 0 )
95259516 end
95269517 end
95279518
@@ -9534,7 +9525,8 @@ function create_user_dialog() -- attempting MODELESS operation
95349525 else -- integer or measurement value
95359526 y_current = y_current + 10 -- gap before the integer variables
95369527 make_static (msg .. " :" , x_offset [1 ], y_current , x_offset [2 ], false ) -- parameter name
9537- dialog [" Create" .. (integer_options [v [1 ]] and " " or " Measurement" ) .. " Edit" ](dialog , x_offset [2 ], y_current - mac_offset , v [1 ]):SetWidth (50 )
9528+ local control_type = integer_options [v [1 ]] and " CreateEdit" or " CreateMeasurementEdit"
9529+ dialog [control_type ](dialog , x_offset [2 ], y_current - mac_offset , v [1 ]):SetWidth (50 )
95389530 make_static (v [2 ], x_offset [4 ], y_current , max_text_width , true ) -- parameter explanation
95399531 end
95409532 end
@@ -9561,48 +9553,43 @@ function create_user_dialog() -- attempting MODELESS operation
95619553 dialog :CreateCancelButton ()
95629554 dialog :RegisterHandleOkButtonPressed (function (self )
95639555 for _ , v in ipairs (dialog_options ) do
9564- if boolean_options [v [1 ]] then
9556+ if boolean_options [v [1 ]] then -- set config values in dialog
95659557 config [v [1 ]] = (self :GetControl (v [1 ]):GetCheck () == 1 )
95669558 elseif integer_options [v [1 ]] then
95679559 config [v [1 ]] = self :GetControl (v [1 ]):GetInteger ()
95689560 else
95699561 config [v [1 ]] = self :GetControl (v [1 ]):GetMeasurementInteger ()
95709562 end
95719563 end
9572- -- save user choices in user_settings
95739564 config .measurement_unit = self :GetMeasurementUnit ()
95749565 self :StorePosition ()
95759566 config .window_pos_x = self .StoredX
95769567 config .window_pos_y = self .StoredY
95779568 configuration .save_user_settings (" hairpin_creator" , config )
9578- finenv .StartNewUndoBlock (" Hairpin Creator" , false )
9579- activity_selector () -- **** THE WORK IS DONE HERE! ****
9580- if finenv .EndUndoBlock then
9581- finenv .EndUndoBlock (true )
9582- finenv .Region ():Redraw ()
9583- else
9584- finenv .StartNewUndoBlock (" Hairpin creator" , true )
9585- end
95869569 end )
95879570 return dialog
95889571end
95899572
9590- function action_type ()
9591- configuration .get_user_settings (" hairpin_creator" , config ) -- overwrite default preferences
9592- if finenv .QueryInvokedModifierKeys and
9593- (finenv .QueryInvokedModifierKeys (finale .CMDMODKEY_ALT ) or finenv .QueryInvokedModifierKeys (finale .CMDMODKEY_SHIFT ))
9594- then -- USER wants to change their preferences
9595- global_dialog = create_user_dialog ()
9573+ function hairpin_selector ()
9574+ configuration .get_user_settings (" hairpin_creator" , config ) -- get last saved user preferences
9575+ local mod_down = finenv .QueryInvokedModifierKeys and (finenv .QueryInvokedModifierKeys (finale .CMDMODKEY_ALT ) or finenv .QueryInvokedModifierKeys (finale .CMDMODKEY_SHIFT ))
9576+ if mod_down then -- user wants to change their preferences
9577+ local dialog = create_dialog_box ()
95969578 if config .window_pos_x and config .window_pos_y then
9597- global_dialog :StorePosition ()
9598- global_dialog :SetRestorePositionOnlyData (config .window_pos_x , config .window_pos_y )
9599- global_dialog :RestorePosition ()
9579+ dialog :StorePosition ()
9580+ dialog :SetRestorePositionOnlyData (config .window_pos_x , config .window_pos_y )
9581+ dialog :RestorePosition ()
96009582 end
9601- global_dialog .OkButtonCanClose = true
9602- global_dialog :ShowModeless ()
9583+ if dialog :ExecuteModal (nil ) ~= finale .EXECMODAL_OK then
9584+ return -- user cancelled
9585+ end
9586+ end
9587+ -- do the work!!!
9588+ if hairpin_type < 0 then -- SWELL / UNSWELL
9589+ create_swell (hairpin_type == - 1 ) -- true for SWELL, otherwise UNSWELL
96039590 else
9604- activity_selector ( ) -- just go do the work
9591+ create_hairpin ( hairpin_type ) -- finale CRESC / DIM enums
96059592 end
96069593end
96079594
9608- action_type ()
9595+ hairpin_selector ()
0 commit comments