-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial placement of page indicator bar on home screen, for device te…
…sting.
- Loading branch information
1 parent
f314855
commit 73524a3
Showing
5 changed files
with
163 additions
and
15 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
core/src/main/java/com/agifans/agile/ui/PaginationWidget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.agifans.agile.ui; | ||
|
||
import com.agifans.agile.HomeScreen; | ||
import com.badlogic.gdx.Gdx; | ||
import com.badlogic.gdx.graphics.Color; | ||
import com.badlogic.gdx.graphics.Pixmap; | ||
import com.badlogic.gdx.graphics.Texture; | ||
import com.badlogic.gdx.graphics.g2d.Batch; | ||
import com.badlogic.gdx.scenes.scene2d.InputListener; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Widget; | ||
|
||
/** | ||
* A widget from drawing the pagination at the bottom of the PagedScrollPane. | ||
*/ | ||
public class PaginationWidget extends Widget { | ||
|
||
private static final int ICON_SIZE = 80; | ||
|
||
private HomeScreen homeScreen; | ||
|
||
private Pixmap pixmap; | ||
|
||
private Texture texture; | ||
|
||
private Pixmap nextIconPixmap; | ||
|
||
private Pixmap prevIconPixmap; | ||
|
||
private int width; | ||
|
||
/** | ||
* Constructor for PaginationWidget. | ||
* | ||
* @param homeScreen | ||
* @param width | ||
*/ | ||
public PaginationWidget(HomeScreen homeScreen, float width) { | ||
this.homeScreen = homeScreen; | ||
this.width = (int)width; | ||
|
||
prevIconPixmap = new Pixmap(Gdx.files.internal("png/prev.png")); | ||
nextIconPixmap = new Pixmap(Gdx.files.internal("png/next.png")); | ||
pixmap = new Pixmap((int)width, ICON_SIZE, Pixmap.Format.RGBA8888); | ||
texture = new Texture(pixmap, Pixmap.Format.RGBA8888, false); | ||
|
||
setSize(getPrefWidth(), getPrefHeight()); | ||
|
||
addListener(new InputListener() { | ||
// TODO: Handle click/touch | ||
}); | ||
} | ||
|
||
public void draw(Batch batch, float parentAlpha) { | ||
validate(); | ||
|
||
Color c = getColor(); | ||
batch.setColor(c.r, c.g, c.b, c.a * parentAlpha); | ||
|
||
pixmap.setColor(1.0f, 1.0f, 1.0f, 0.10f); | ||
pixmap.fill(); | ||
pixmap.drawPixmap(prevIconPixmap, 0, 0); | ||
pixmap.drawPixmap(nextIconPixmap, width - ICON_SIZE, 0); | ||
|
||
texture.draw(pixmap, 0, 0); | ||
|
||
batch.draw(texture, 0, 0); | ||
} | ||
|
||
public float getPrefWidth () { | ||
return width; | ||
} | ||
|
||
public float getPrefHeight () { | ||
return ICON_SIZE; | ||
} | ||
|
||
public float getMaxHeight() { | ||
return ICON_SIZE; | ||
} | ||
|
||
public void dispose() { | ||
texture.dispose(); | ||
pixmap.dispose(); | ||
nextIconPixmap.dispose(); | ||
prevIconPixmap.dispose(); | ||
} | ||
} |