Search in sources :

Example 1 with StaffCursorStamping

use of com.xenoage.zong.musiclayout.stampings.StaffCursorStamping in project Zong by Xenoage.

the class ScoreSelectionLayouter method setCursor.

/**
 * Sets a {@link StaffCursorStamping} for the given {@link Cursor}.
 */
private void setCursor(Cursor cursor) {
    // remove old stampings
    removeSelectionStampings();
    // find frame
    MP mp = cursor.getMP();
    int measure = mp.measure;
    ScoreFrameLayout frame = scoreLayout.getScoreFrameLayout(measure);
    if (frame != null) {
        StaffStamping staff = frame.getStaffStamping(mp.staff, measure);
        if (staff != null) {
            frame.setSelectionStampings(ilist(new StaffCursorStamping(frame.getPositionX(mp.getTime()), -0.5f, staff)));
        }
    }
}
Also used : MP(com.xenoage.zong.core.position.MP) StaffCursorStamping(com.xenoage.zong.musiclayout.stampings.StaffCursorStamping) StaffStamping(com.xenoage.zong.musiclayout.stampings.StaffStamping) ScoreFrameLayout(com.xenoage.zong.musiclayout.ScoreFrameLayout)

Example 2 with StaffCursorStamping

use of com.xenoage.zong.musiclayout.stampings.StaffCursorStamping in project Zong by Xenoage.

the class StaffCursorRenderer method draw.

/**
 * Draws the given {@link StaffCursorStamping} on the given {@link Canvas},
 * using the given {@link RendererArgs}.
 */
@Override
public void draw(Stamping stamping, Canvas canvas, RendererArgs args) {
    StaffCursorStamping cursor = (StaffCursorStamping) stamping;
    float viewScaling = args.targetScaling;
    StaffStamping parentStaff = cursor.parentStaff;
    float x, y1, y2;
    if (canvas.getFormat() == CanvasFormat.Raster) {
        float staffY = parentStaff.positionMm.y;
        BitmapStaff ss = parentStaff.getBitmapInfo().getBitmapStaff(viewScaling);
        // top: one interline space above staff
        y1 = staffY + ss.getYMm(parentStaff.linesCount * 2);
        // bottom: one interline space under staff
        y2 = staffY + ss.getYMm(-2);
    } else {
        y1 = parentStaff.computeYMm(parentStaff.linesCount * 2);
        y2 = parentStaff.computeYMm(-2);
    }
    x = parentStaff.positionMm.x + cursor.xMm + cursor.offsetIs * parentStaff.is;
    canvas.drawLine(new Point2f(x, y1), new Point2f(x, y2), Companion.color(30, 200, 30), getCursorWidth(viewScaling));
}
Also used : StaffCursorStamping(com.xenoage.zong.musiclayout.stampings.StaffCursorStamping) Point2f(com.xenoage.utils.math.geom.Point2f) StaffStamping(com.xenoage.zong.musiclayout.stampings.StaffStamping) BitmapStaff(com.xenoage.zong.musiclayout.stampings.bitmap.BitmapStaff)

Aggregations

StaffCursorStamping (com.xenoage.zong.musiclayout.stampings.StaffCursorStamping)2 StaffStamping (com.xenoage.zong.musiclayout.stampings.StaffStamping)2 Point2f (com.xenoage.utils.math.geom.Point2f)1 MP (com.xenoage.zong.core.position.MP)1 ScoreFrameLayout (com.xenoage.zong.musiclayout.ScoreFrameLayout)1 BitmapStaff (com.xenoage.zong.musiclayout.stampings.bitmap.BitmapStaff)1