mainpage ui improved

This commit is contained in:
Harrison Deng 2017-10-26 22:38:23 -05:00
parent a1278eed9b
commit 8d8ef15ce4
3 changed files with 9 additions and 14 deletions

View File

@ -90,9 +90,6 @@ public class MusicControls extends HorizontalGroup {
space(15); space(15);
invalidate(); invalidate();
debugAll();
debug();
} }
@Override @Override

View File

@ -94,13 +94,15 @@ public class ScrollText extends Widget {
clipBounds.setSize(getWidth()-2, getHeight()*1.5f); clipBounds.setSize(getWidth()-2, getHeight()*1.5f);
text2Offset = clipBounds.getWidth(); text2Offset = clipBounds.getWidth();
if (text1Width < clipBounds.getWidth()) {
text1Offset = (clipBounds.getWidth()-text1Width)/2f;
}
super.layout(); super.layout();
} }
@Override @Override
public void act(float delta) { public void act(float delta) {
validate(); setSize(getWidth(), textHeight + 4);
setSize(getMinWidth(), textHeight + 4);
clipBounds.setSize(getWidth()-2, getHeight()*1.5f); clipBounds.setSize(getWidth()-2, getHeight()*1.5f);
if (text1Width + text2Width > clipBounds.getWidth()) { if (text1Width + text2Width > clipBounds.getWidth()) {
if (scrollOnHover) { if (scrollOnHover) {
@ -171,10 +173,7 @@ public class ScrollText extends Widget {
gLayout = new GlyphLayout(font, text1); gLayout = new GlyphLayout(font, text1);
text1Width = gLayout.width; text1Width = gLayout.width;
textHeight = gLayout.height; textHeight = gLayout.height;
text2Offset = clipBounds.getWidth();
if (text1Width < clipBounds.getWidth()) {
text1Offset = (clipBounds.getWidth()-text1Width)/2f;
}
if (text2 != null) { if (text2 != null) {
this.text2 = text2; this.text2 = text2;
gLayout = new GlyphLayout(font, text2); gLayout = new GlyphLayout(font, text2);
@ -183,5 +182,7 @@ public class ScrollText extends Widget {
this.text2 = text1; this.text2 = text1;
this.text2Width = text1Width; this.text2Width = text1Width;
} }
layout();
} }
} }

View File

@ -85,15 +85,12 @@ public class MainPage extends Page implements Observer {
musicControls = new MusicControls(core.getDefaultSkin(), sc); musicControls = new MusicControls(core.getDefaultSkin(), sc);
musicControls.setPosition((getWidth()-musicControls.getMinWidth() - 20f), getHeight()-musicControls.getMinHeight()-15f); musicControls.setPosition((getWidth()-musicControls.getMinWidth() - 20f), getHeight()-musicControls.getMinHeight()-15f);
musicControls.invalidate();
addActor(musicControls); addActor(musicControls);
scrollText = new ScrollText("...", "...", core.getDefaultSkin(), false, true); scrollText = new ScrollText("...", "...", core.getDefaultSkin(), false, true);
scrollText.setWidth(Gdx.graphics.getWidth() - musicControls.getWidth() - 30f); scrollText.setWidth(0.5f*getWidth());
scrollText.setPosition(musicControls.getX() - scrollText.getWidth() - 20f, Gdx.graphics.getHeight() - 15f); scrollText.setPosition(15, getHeight() - scrollText.getHeight()-15f);
scrollText.invalidate();
addActor(scrollText); addActor(scrollText);
} }
@Override @Override