-- Version 0.1 --[[-------------------------------------------------------------------------- This plugin will connect barlines with the staff below. You must specify if the current staff is Upper, Middle or Lower staff in order to draw connections correctly. --]]-------------------------------------------------------------------------- local userObjTypeName = ... local nextBar = nwc.drawpos.new() local prevBoundary = nwc.drawpos.new() local drawpos = nwcdraw.user local drawidx1 = nwc.drawpos local objidx = nwc.ntnidx local searchidx = objidx.new() local c = nwcdraw local object_spec = { { id='System', label='Staff Location', type='enum', default='Top Staff', list={'Top Staff', 'Middle Staff', 'Bottom Staff'}}, } local function do_create(t) t.Class = 'StaffSig' end local function do_draw(t) local w = nwc.toolbox.drawStaffSigLabel('BarLines3') if not nwcdraw.isDrawing() then return w end -- if nwcdraw.getTarget() ~= 'print' then return end if drawpos:isHidden() then return end local yPosTop local yPosBottom local setTopIfNil = function(value) if not yPosTop then yPosTop = value end end local setBottomIfNil = function(value) if not yPosBottom then yPosBottom = value end end local drawSegment = function(x,y,bType) if t.System == 'Top Staff' then nwcdraw.moveTo(x,y) nwcdraw.barSegment(bType,y-4,y-yPosBottom) elseif t.System == 'Middle Staff' then nwcdraw.moveTo(x,y) nwcdraw.barSegment(bType,y+yPosTop,y+4) nwcdraw.moveTo(x,y) nwcdraw.barSegment(bType,y-4,y-yPosBottom) elseif t.System == 'Bottom Staff' then nwcdraw.moveTo(x,y) nwcdraw.barSegment(bType,y+yPosTop,y+4) end end --- I do not understand the following (copied from BarCounter) local me = c.user local me_autoins = me:isAutoInsert() drawidx1:reset() -- don't do anything when hidden if me:isHidden() then return end if me_autoins then drawidx1:find('first') else drawidx1:find('prior','bar') end if me_autoins and drawidx1:find('first','noteOrRest') then if drawidx1:isAutoInsert() and (drawidx1:objType() == 'RestMultiBar') then pendingBar = drawidx1:barCounter() end else drawidx1:reset() end -- start from the first note and count bars backwards objidx:reset() searchidx:find(drawidx1) while searchidx:find('prior') and (searchidx > objidx) do --- end "I do not understand" if searchidx:objType() == 'Boundary' and searchidx:objProp('Style') == 'NewSize' then setTopIfNil(searchidx:objProp('Upper')) setBottomIfNil(searchidx:objProp('Lower')) nwc.debug("c2", yPosTop, yPosBottom) elseif searchidx:objType() == 'Boundary' and searchidx:objProp('Style') == 'Reset' then setTopIfNil(nwcdraw.getStaffProp('BoundaryTop')) setBottomIfNil(nwcdraw.getStaffProp('BoundaryBottom')) nwc.debug("c3", yPosTop, yPosBottom) end end setTopIfNil(nwcdraw.getStaffProp('BoundaryTop')) setBottomIfNil(nwcdraw.getStaffProp('BoundaryBottom')) nwc.debug("c5", yPosTop, yPosBottom) nextBar:reset() local found = nextBar:find('last', 'bar') if found then found = nextBar:find('next', 'bar') end if found then local x,y = nextBar:xyAnchor() local barType = nextBar:objProp('Style') drawSegment(x, y, barType) end nextBar:reset() while nextBar:find('next', 'bar') do local x,y = nextBar:xyAnchor() drawSegment(x, y, 'BrokenDouble') end end return { spec = object_spec, create = do_create, width = do_draw, draw = do_draw, }