Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add be_right_back #121

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions src/be_right_back.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
function plugindef()
finaleplugin.Author = "Michael McClennan"
finaleplugin.Version = 1.0
finaleplugin.Copyright = "2022/01/03"
finaleplugin.HandlesUndo = false
finaleplugin.NoStore = true
end

local str = finale.FCString()
str.LuaString = "BRB v1.0"
BRB_dialog = finale.FCCustomLuaWindow()
BRB_dialog:SetTitle(str)
BRB_dialog:SetClientWidth(90)

local button_go_back = BRB_dialog:CreateButton(0, 0)
str.LuaString = "Go Back"
button_go_back:SetWidth(60)
button_go_back:SetText(str)
local button_set = BRB_dialog:CreateButton(65, 0)
str.LuaString = "Set"
button_set:SetWidth(40)
button_set:SetText(str)
local buttonCancel = BRB_dialog:CreateCancelButton()
str.LuaString = "Close"
buttonCancel:SetWidth(50)
buttonCancel:SetText(str)

BRB_table = {}
trigger = {}
function trigger.buttonGo()
local part = finale.FCPart(BRB_table.part)
part:ViewInDocument()

--VIEWPAGE/SCROLL
if BRB_table.page_view == true then --PAGE VIEW
local ui = finenv.UI()
ui:MenuCommand(finale.MENUCMD_VIEWSCROLLVIEW )
finenv.UI():MoveToMeasure(BRB_table.measure_num, 1)
ui:MenuCommand(finale.MENUCMD_VIEWPAGEVIEW )
--insert a Zoom Level call when PDK allows

else --SCROLL VIEW
local ui = finenv.UI()
ui:MenuCommand(finale.MENUCMD_VIEWSCROLLVIEW )
--insert a Zoom Level call when PDK allows
finenv.UI():MoveToMeasure(BRB_table.measure_num, 1)
end

local ui = finenv.UI()
ui:RedrawDocument()
end

function trigger.button_set()

-- local selected_region = finenv.Region()
-- BRB_table.region = selected_region:GetStartMeasure()
BRB_table.page_view = finenv.UI():IsPageView()
local p = finale.FCPart(finale.PARTID_CURRENT)
BRB_table.part = p:GetID()
BRB_table.zoom = finenv.UI():GetZoomLevel()
cur_docID = finale.FCDocument(-1)
BRB_table.document = cur_docID:GetID()
if is_page_view == true then --PAGE VIEW
local ui = finenv.UI()
BRB_table.page_num = finenv.UI():GetCurrentPage()
ui:MenuCommand(finale.MENUCMD_VIEWSCROLLVIEW )
BRB_table.measure_num = finenv.UI():GetCurrentMeasure()
ui:MenuCommand(finale.MENUCMD_VIEWPAGEVIEW )
else
BRB_table.measure_num = finenv.UI():GetCurrentMeasure() --SCROLL VIEW
end
end

BRB_dialog:RegisterHandleControlEvent (
button_go_back,
function(control)
trigger.buttonGo()
end
)
BRB_dialog:RegisterHandleControlEvent (
button_set,
function(control)
trigger.button_set()
end
)

finenv.RegisterModelessDialog(BRB_dialog)
BRB_dialog:ShowModeless()

30 changes: 30 additions & 0 deletions src/replicate_music.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function plugindef()
finaleplugin.Author = "Michael McClennan"
finaleplugin.Version = 1.0
finaleplugin.Copyright = "2022/01/03"
finaleplugin.HandlesUndo = true
return "Replicate Music", "Replicate Music", "Inspired by the 'r' key in Sibelius, this script copies the selected music, and pastes it directly to the right"
end

--[[
Inspired by the 'r' key in Sibelius, this script copies the selected music, and pastes it directly to the right.
Works with a single or multiple measures.
When activated with a shortcut or hotkey, ultra fast replication is possible.
--]]


local function replicate_music()
local region = finenv.Region()
local start_measure = finenv.Region().StartMeasure
local end_measure = finenv.Region().EndMeasure
local sum_measures = end_measure - start_measure
local start_paste_region = end_measure + 1

region:CopyMusic()
finenv.Region():SetStartMeasure(start_paste_region)
finenv.Region():SetEndMeasure(start_paste_region + sum_measures)
region:PasteMusic()
region:ReleaseMusic()
end

replicate_music()