Search in sources :

Example 1 with SystemCursorStamping

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

the class PlaybackLayouter method createCursorAt.

/**
 * Returns a new {@link SystemCursorStamping} at the given {@link Time},
 * representing the current playback position, or null if there is none.
 */
public SystemCursorStamping createCursorAt(Time time) {
    ScoreFrameLayout frame = scoreLayout.getScoreFrameLayout(time.getMeasure());
    if (frame != null) {
        StaffStamping topStaff = frame.getStaffStamping(0, time.getMeasure());
        StaffStamping bottomStaff = frame.getStaffStamping(scoreLayout.score.getStavesCount() - 1, time.getMeasure());
        if (topStaff != null && bottomStaff != null)
            return new SystemCursorStamping(topStaff, bottomStaff, frame.getPositionX(time));
    }
    return null;
}
Also used : SystemCursorStamping(com.xenoage.zong.musiclayout.stampings.SystemCursorStamping) StaffStamping(com.xenoage.zong.musiclayout.stampings.StaffStamping) ScoreFrameLayout(com.xenoage.zong.musiclayout.ScoreFrameLayout)

Example 2 with SystemCursorStamping

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

the class SystemCursorRenderer method draw.

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

Example 3 with SystemCursorStamping

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

the class PlaybackLayouter method setCursorAt.

/**
 * Sets a {@link SystemCursorStamping} at the given {@link MP},
 * representing the current playback position.
 */
public void setCursorAt(Time time) {
    // remove old playback cursors
    removePlaybackStampings();
    // create new one
    SystemCursorStamping cursor = createCursorAt(time);
    // find frame
    if (cursor != null) {
        ScoreFrameLayout frame = scoreLayout.getScoreFrameLayout(time.getMeasure());
        frame.setPlaybackStampings(ilist(cursor));
    }
}
Also used : SystemCursorStamping(com.xenoage.zong.musiclayout.stampings.SystemCursorStamping) ScoreFrameLayout(com.xenoage.zong.musiclayout.ScoreFrameLayout)

Aggregations

SystemCursorStamping (com.xenoage.zong.musiclayout.stampings.SystemCursorStamping)3 ScoreFrameLayout (com.xenoage.zong.musiclayout.ScoreFrameLayout)2 StaffStamping (com.xenoage.zong.musiclayout.stampings.StaffStamping)2 Point2f (com.xenoage.utils.math.geom.Point2f)1 BitmapStaff (com.xenoage.zong.musiclayout.stampings.bitmap.BitmapStaff)1