selection now highlighting

This commit is contained in:
Harrison Deng 2017-10-30 18:33:46 -05:00
parent 49f454a21f
commit 5f2dd6ef75
3 changed files with 28 additions and 3 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -4,16 +4,20 @@ import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup; import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup; import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Disposable; import com.badlogic.gdx.utils.Disposable;
import zero1hd.rhythmbullet.audio.SongInfo; import zero1hd.rhythmbullet.audio.SongInfo;
import zero1hd.rhythmbullet.graphics.ui.pages.MusicSelectionPage;
public class MusicSelectable extends WidgetGroup implements Disposable { public class MusicSelectable extends WidgetGroup implements Disposable {
private Table table; private Table table;
@ -32,7 +36,7 @@ public class MusicSelectable extends WidgetGroup implements Disposable {
private VerticalGroup vGroup; private VerticalGroup vGroup;
public MusicSelectable(FileHandle musicFile, Preferences musicAnnotation, Skin skin, Texture defaultAlbumC) { public MusicSelectable(FileHandle musicFile, Preferences musicAnnotation, Skin skin, Texture defaultAlbumC, MusicSelectionPage msp) {
table = new Table(skin); table = new Table(skin);
table.setBackground("holo-pane"); table.setBackground("holo-pane");
vGroup = new VerticalGroup(); vGroup = new VerticalGroup();
@ -59,6 +63,19 @@ public class MusicSelectable extends WidgetGroup implements Disposable {
table.add(vGroup).expandX().fillX().center(); table.add(vGroup).expandX().fillX().center();
addActor(table); addActor(table);
addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (selected) {
deselect();
} else {
msp.deselectAll();
select();
}
super.clicked(event, x, y);
}
});
} }
/** /**
@ -116,7 +133,7 @@ public class MusicSelectable extends WidgetGroup implements Disposable {
selected = true; selected = true;
} }
public void diselect() { public void deselect() {
table.setBackground("holo-pane"); table.setBackground("holo-pane");
selected = false; selected = false;
} }

View File

@ -13,12 +13,14 @@ import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import zero1hd.rhythmbullet.audio.SongInfo; import zero1hd.rhythmbullet.audio.SongInfo;
@ -113,7 +115,7 @@ public class MusicSelectionPage extends Page {
Gdx.app.debug("MusicSelectionPage", "Refreshing..."); Gdx.app.debug("MusicSelectionPage", "Refreshing...");
for (int i = 0; i < songList.getAmountOfSongs(); i++) { for (int i = 0; i < songList.getAmountOfSongs(); i++) {
MusicSelectable selectable = new MusicSelectable(songList.getSongFileHandleFromIndex(i), musicFileAnnotation, skin, assets.get("defaultCover.png", Texture.class)); MusicSelectable selectable = new MusicSelectable(songList.getSongFileHandleFromIndex(i), musicFileAnnotation, skin, assets.get("defaultCover.png", Texture.class), this);
selectables.add(selectable); selectables.add(selectable);
songTable.add(selectable).expandX().fillX().height((getHeight() >= 2160 ? 300f : 200f)); songTable.add(selectable).expandX().fillX().height((getHeight() >= 2160 ? 300f : 200f));
@ -139,4 +141,10 @@ public class MusicSelectionPage extends Page {
white.dispose(); white.dispose();
super.dispose(); super.dispose();
} }
public void deselectAll() {
for (int i = 0; i < selectables.size; i++) {
selectables.get(i).deselect();
}
}
} }