begin work on scroll-text
This commit is contained in:
parent
a97f435a52
commit
df5eea0a1b
@ -31,7 +31,7 @@ public class MusicSelectable extends Button implements Disposable {
|
||||
private byte[] albumWorkBytes;
|
||||
|
||||
private Image imageIcon;
|
||||
private Label displayName;
|
||||
private ScrollText displayName;
|
||||
private Label runTime;
|
||||
private Skin skin;
|
||||
public MusicSelectable(FileHandle musicFile, Preferences musicData, final Skin skin, Texture defaultAlbumC) {
|
||||
@ -71,10 +71,12 @@ public class MusicSelectable extends Button implements Disposable {
|
||||
ratedDifficulty = musicData.getInteger(songName + ":difficulty");
|
||||
}
|
||||
|
||||
public void addInfoToPanel(float width) {
|
||||
displayName = new Label(songName, skin);
|
||||
displayName.setWrap(true);
|
||||
add(displayName).prefWidth(width-5).spaceBottom(20f);
|
||||
|
||||
public void addInfoToPanel() {
|
||||
debug();
|
||||
|
||||
displayName = new ScrollText(songName, skin);
|
||||
add(displayName).fillX().spaceBottom(20f);
|
||||
|
||||
row();
|
||||
|
||||
@ -100,8 +102,7 @@ public class MusicSelectable extends Button implements Disposable {
|
||||
}
|
||||
Gdx.app.debug("UI", "album cover invalid or null for image: " + songName);
|
||||
}
|
||||
add(imageIcon).prefSize(width, width);
|
||||
|
||||
add(imageIcon);
|
||||
}
|
||||
|
||||
public int getPreviousTop() {
|
||||
|
42
core/src/zero1hd/polyjet/ui/builders/ScrollText.java
Executable file
42
core/src/zero1hd/polyjet/ui/builders/ScrollText.java
Executable file
@ -0,0 +1,42 @@
|
||||
package zero1hd.polyjet.ui.builders;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Widget;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ScissorStack;
|
||||
|
||||
public class ScrollText extends Widget {
|
||||
Rectangle scissors = new Rectangle();
|
||||
Rectangle clipBounds = new Rectangle();
|
||||
|
||||
String text;
|
||||
BitmapFont font;
|
||||
|
||||
public ScrollText(String text, Skin skin) {
|
||||
this.text = text;
|
||||
font = skin.getFont("default-font");
|
||||
setWidth(20f);
|
||||
setHeight(40f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void layout() {
|
||||
clipBounds.setPosition(getX(), getY());
|
||||
clipBounds.setSize(getWidth(), getHeight());
|
||||
super.layout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
ScissorStack.calculateScissors(getStage().getCamera(), batch.getTransformMatrix(), clipBounds, scissors);
|
||||
if (ScissorStack.pushScissors(scissors)) {
|
||||
font.draw(batch, text, getX(), getY());
|
||||
batch.flush();
|
||||
ScissorStack.popScissors();
|
||||
};
|
||||
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
}
|
@ -81,11 +81,10 @@ public class MusicSelectionPage extends Page {
|
||||
for (int music = 0; music < musicFiles.length; music++) {
|
||||
final MusicSelectable selectable = new MusicSelectable(musicFiles[music], musicFileAnnotation, core.defaultSkin, core.assetManager.get("defaultCover.png", Texture.class));
|
||||
Gdx.app.postRunnable(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
selectable.addInfoToPanel(0.2f*getWidth()-20);
|
||||
musicChoices.add(selectable).prefSize(0.2f*getWidth(), 0.8f*getHeight());
|
||||
musicChoices.add(selectable).size(0.2f*getWidth(), 0.8f*getHeight());
|
||||
selectable.addInfoToPanel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user