Search in sources :

Example 1 with OwnImageButton

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 };
}
Also used : OwnImageButton(gaiasky.util.scene2d.OwnImageButton) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) OwnTextTooltip(gaiasky.util.scene2d.OwnTextTooltip) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) Actor(com.badlogic.gdx.scenes.scene2d.Actor) OwnImageButton(gaiasky.util.scene2d.OwnImageButton)

Example 2 with OwnImageButton

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);
}
Also used : Task(com.badlogic.gdx.utils.Timer.Task) OwnTextTooltip(gaiasky.util.scene2d.OwnTextTooltip) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) OwnImageButton(gaiasky.util.scene2d.OwnImageButton) OwnLabel(gaiasky.util.scene2d.OwnLabel) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) VerticalGroup(com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup)

Example 3 with OwnImageButton

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;
}
Also used : OwnTextTooltip(gaiasky.util.scene2d.OwnTextTooltip) OwnImageButton(gaiasky.util.scene2d.OwnImageButton) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)

Aggregations

OwnImageButton (gaiasky.util.scene2d.OwnImageButton)3 OwnTextTooltip (gaiasky.util.scene2d.OwnTextTooltip)3 HorizontalGroup (com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)2 ChangeEvent (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent)2 Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)1 VerticalGroup (com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup)1 Task (com.badlogic.gdx.utils.Timer.Task)1 OwnLabel (gaiasky.util.scene2d.OwnLabel)1