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)));
}
}
}
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));
}
Aggregations