use of gaiasky.util.scene2d.OwnImageButton in project gaiasky by langurmonkey.
the class DesktopMusicActors method getActors.
@Override
public Actor[] getActors(Skin skin) {
ImageButton musicTooltip = new OwnImageButton(skin, "tooltip");
musicTooltip.addListener(new OwnTextTooltip(I18n.txt("gui.tooltip.music", SysUtils.getDefaultMusicDir()), skin));
ImageButton reloadMusic = new OwnImageButton(skin, "reload");
reloadMusic.setName("reload music");
reloadMusic.addListener(event -> {
if (event instanceof ChangeEvent) {
EventManager.publish(Event.MUSIC_RELOAD_CMD, this);
return true;
}
return false;
});
reloadMusic.addListener(new OwnTextTooltip(I18n.txt("gui.music.reload"), skin));
return new Actor[] { musicTooltip, reloadMusic };
}
use of gaiasky.util.scene2d.OwnImageButton in project gaiasky by langurmonkey.
the class MusicComponent method initialize.
@Override
public void initialize() {
float componentWidth = 264f;
nf = NumberFormatFactory.getFormatter("##0");
intf = NumberFormatFactory.getFormatter("#00");
/* Previous track */
prev = new OwnImageButton(skin, "audio-bwd");
prev.addListener(event -> {
if (event instanceof ChangeEvent) {
EventManager.publish(Event.MUSIC_PREVIOUS_CMD, prev);
return true;
}
return false;
});
prev.addListener(new OwnTextTooltip(I18n.txt("gui.music.previous"), skin));
/* Play/pause */
play = new OwnImageButton(skin, "audio-playpause");
play.setChecked(false);
play.addListener(event -> {
if (event instanceof ChangeEvent) {
EventManager.publish(Event.MUSIC_PLAYPAUSE_CMD, play);
return true;
}
return false;
});
play.addListener(new OwnTextTooltip(I18n.txt("gui.music.playpause"), skin));
/* Next track */
next = new OwnImageButton(skin, "audio-fwd");
next.addListener(event -> {
if (event instanceof ChangeEvent) {
EventManager.publish(Event.MUSIC_NEXT_CMD, next);
return true;
}
return false;
});
next.addListener(new OwnTextTooltip(I18n.txt("gui.music.next"), skin));
/* Volume */
vol = new OwnLabel(I18n.txt("gui.music.volume.short") + ": " + nf.format(getVolumePercentage()) + "%", skin, "mono-pink");
vol.addListener(new OwnTextTooltip(I18n.txt("gui.music.volume"), skin));
vol.receiveScrollEvents();
vol.addListener(event -> {
if (event instanceof InputEvent) {
InputEvent ie = (InputEvent) event;
if (ie.getType().equals(InputEvent.Type.scrolled)) {
float scroll = -ie.getScrollAmountY() * 0.1f;
float currentVol = getVolume();
float newVol = Math.max(0f, Math.min(1f, currentVol + scroll));
EventManager.publish(Event.MUSIC_VOLUME_CMD, vol, newVol);
vol.setText(I18n.txt("gui.music.volume.short") + ": " + nf.format(getVolumePercentage()) + "%");
return true;
}
}
return false;
});
/* Position mm:ss */
position = new OwnLabel(toMinutesSeconds(0f), skin, "mono");
/* Track name */
track = new OwnLabel("", skin, "mono");
float space3 = 4.8f;
VerticalGroup musicGroup = new VerticalGroup().align(Align.left).columnAlign(Align.left).space(space3);
HorizontalGroup playGroup = new HorizontalGroup();
playGroup.setWidth(componentWidth);
playGroup.space(18f);
prev.align(Align.left);
play.align(Align.left);
next.align(Align.left);
playGroup.addActor(prev);
playGroup.addActor(play);
playGroup.addActor(next);
playGroup.addActor(vol);
HorizontalGroup trackGroup = new HorizontalGroup();
trackGroup.space(16f);
trackGroup.addActor(position);
trackGroup.addActor(track);
musicGroup.addActor(playGroup);
musicGroup.addActor(trackGroup);
component = musicGroup;
Task musicUpdater = new Task() {
@Override
public void run() {
position.setText(toMinutesSeconds(MusicManager.instance.getPosition()));
slideTrackName();
}
};
Timer.schedule(musicUpdater, 1, 1);
}
use of gaiasky.util.scene2d.OwnImageButton in project gaiasky by langurmonkey.
the class GuiUtils method getTooltipHorizontalGroup.
public static HorizontalGroup getTooltipHorizontalGroup(Actor actor, String tooltipText, float space, Skin skin) {
HorizontalGroup hg = new HorizontalGroup();
hg.space(space);
hg.addActor(actor);
OwnImageButton tooltip = new OwnImageButton(skin, "tooltip");
tooltip.addListener(new OwnTextTooltip(tooltipText, skin));
hg.addActor(tooltip);
return hg;
}
Aggregations