@@ -596,6 +596,7 @@ default values. If an endpoint is already activated, that endpoint is not touche
596
596
@ tie_mod (FCTieMod) the tie mods for the note, if any.
597
597
@ for_pageview (bool) true if calculating for Page View, false for Scroll/Studio View
598
598
@ [tie_prefs] (FCTiePrefs) use these tie prefs if supplied
599
+ : (boolean) returns true if anything changed
599
600
]]
600
601
function tie .activate_endpoints (note , tie_mod , for_pageview , tie_prefs )
601
602
if not tie_prefs then
@@ -610,6 +611,7 @@ function tie.activate_endpoints(note, tie_mod, for_pageview, tie_prefs)
610
611
if lactivated and ractivated then
611
612
tie_mod :LocalizeFromPreferences ()
612
613
end
614
+ return lactivated or ractivated
613
615
end
614
616
615
617
local calc_tie_length = function (note , tie_mod , for_pageview , direction , tie_prefs , tie_placement_prefs )
@@ -655,7 +657,7 @@ local calc_tie_length = function(note, tie_mod, for_pageview, direction, tie_pre
655
657
656
658
if tie_mod :IsStartTie () and (not end_note or cell_metrics_start .StaffSystem ~= cell_metrics_end .StaffSystem ) then
657
659
local next_cell_metrics = finale .FCCellMetrics ()
658
- local next_metrics_loaded = next_cell_metrics :LoadAtCell (finale .FCCell (note .Entry .Measure + 1 , note .entry .Staff ))
660
+ local next_metrics_loaded = next_cell_metrics :LoadAtCell (finale .FCCell (note .Entry .Measure + 1 , note .Entry .Staff ))
659
661
if not next_metrics_loaded or cell_metrics_start .StaffSystem ~= cell_metrics_end .StaffSystem then
660
662
-- note: a tie to an empty measure on the same system will get here, but
661
663
-- currently we do not correctly calculate its span. To do so we would have to
@@ -730,4 +732,58 @@ function tie.calc_contour_index(note, tie_mod, for_pageview, direction, tie_pref
730
732
return finale .TCONTOURIDX_MEDIUM
731
733
end
732
734
735
+ local calc_inset_and_height = function (tie_prefs , tie_contour_prefs , length , contour_index , get_fixed_func , get_relative_func , get_height_func )
736
+ -- This function is based on observed Finale behavior and may not precisely capture the exact same interpolated values.
737
+ -- However, it appears that Finale interpolates from Short to Medium for lengths in that span and from Medium to Long
738
+ -- for lengths in that span.
739
+ local height = get_height_func (tie_contour_prefs , contour_index )
740
+ local inset = tie_prefs .FixedInsetStyle and get_fixed_func (tie_contour_prefs , contour_index ) or get_relative_func (tie_contour_prefs , contour_index )
741
+ if tie_prefs .UseInterpolation and contour_index == finale .TCONTOURIDX_MEDIUM then
742
+ local interpolation_length , interepolation_percent
743
+ if length <= tie_contour_prefs :GetSpan (finale .TCONTOURIDX_MEDIUM ) then
744
+ interpolation_length = tie_contour_prefs :GetSpan (finale .TCONTOURIDX_MEDIUM ) - tie_contour_prefs :GetSpan (finale .TCONTOURIDX_SHORT )
745
+ interpolation_percent = (tie_contour_prefs :GetSpan (finale .TCONTOURIDX_MEDIUM ) - length ) / interpolation_length
746
+ else
747
+ interpolation_length = tie_contour_prefs :GetSpan (finale .TCONTOURIDX_LONG ) - tie_contour_prefs :GetSpan (finale .TCONTOURIDX_MEDIUM )
748
+ interpolation_percent = (tie_contour_prefs :GetSpan (finale .TCONTOURIDX_LONG ) - length ) / interpolation_length
749
+ end
750
+ height = height * interpolation_percent
751
+ if not tie_prefs .FixedInsetStyle then
752
+ inset = inset * interpolation_percent
753
+ end
754
+ end
755
+ return inset , height
756
+ end
757
+
758
+ --[[
759
+ % activate_contour
760
+
761
+ Activates the contour fields of the input tie_mod and initializes them with their
762
+ default values. If the contour field are already activated, nothing is changed.
763
+
764
+ @ note (FCNote) the note for which to return the tie direction.
765
+ @ tie_mod (FCTieMod) the tie mods for the note, if any.
766
+ @ for_pageview (bool) true if calculating for Page View, false for Scroll/Studio View
767
+ @ [tie_prefs] (FCTiePrefs) use these tie prefs if supplied
768
+ : (boolean) returns true if anything changed
769
+ ]]
770
+ function tie .activate_contour (note , tie_mod , for_pageview , tie_contour_index , tie_prefs )
771
+ if tie_mod :IsContourActive () then
772
+ return false
773
+ end
774
+ if not tie_prefs then
775
+ tie_prefs = finale .FCTiePrefs ()
776
+ tie_prefs :Load (0 )
777
+ end
778
+ local direction = tie .calc_direction (note , tie_mod , tie_prefs )
779
+ local tie_contour_index = tie .calc_contour_index (note , tie_mod , for_pageview , direction , tie_prefs )
780
+ local tie_contour_prefs = tie_prefs :CreateTieContourPrefs ()
781
+ local left_height = tie_contour_prefs :GetLeftHeight (tie_contour_index )
782
+ local left_inset = tie_prefs .FixedInsetStyle and tie_contour_prefs :GetLeftFixedInset (tie_contour_index ) or tie_contour_prefs :GetLeftRawRelativeInset (tie_contour_index )
783
+ local right_height = tie_contour_prefs :GetRightHeight (tie_contour_index )
784
+ local right_inset = tie_prefs .FixedInsetStyle and tie_contour_prefs :GetRightFixedInset (tie_contour_index ) or tie_contour_prefs :GetRightRawRelativeInset (tie_contour_index )
785
+ tie_mod :ActivateContour (left_inset , left_height , right_inset , right_height , tie_prefs .FixedInsetStyle )
786
+ return true
787
+ end
788
+
733
789
return tie
0 commit comments