@Override public void init () {
GroupLayer slider = graphics().createGroupLayer();
CanvasImage image = graphics().createImage(WIDTH + 10, HEIGHT);
image.canvas().setFillColor(0xff808080);
image.canvas().fillRect(0, 0, WIDTH + 10, HEIGHT);
ImageLayer bg = graphics().createImageLayer(image);
slider.add(bg);
image = graphics().createImage(WIDTH, HWIDTH);
image.canvas().setFillColor(0xffffffff);
image.canvas().fillRect(0, 0, WIDTH, HWIDTH);
image.canvas().setStrokeColor(0xff000000);
image.canvas().drawLine(0, HWIDTH / 2, WIDTH, HWIDTH / 2);
image.canvas().setStrokeColor(0xffff0000);
image.canvas().strokeRect(0, 0, WIDTH - 1, HWIDTH - 1);
slider.add(il = graphics().createImageLayer(image));
il.setOrigin(0, HWIDTH / 2);
il.setTranslation(0, HEIGHT / 2);
il.setDepth(1);
graphics().rootLayer().add(slider);
slider.setTranslation(25, 25);
bg.addListener(new Mouse.LayerAdapter() {
@Override public void onMouseWheelScroll (WheelEvent event) {
float y = il.ty() + event.velocity();
y = Math.max(0, Math.min(y, HEIGHT));
il.setTranslation(0, y);
}
});
}