Skip to content
Snippets Groups Projects
Commit 1349c70b authored by Luboš Horáček's avatar Luboš Horáček
Browse files

#22 Stamp and signature dialog

parent 162447c2
Branches
Tags
No related merge requests found
......@@ -8,6 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
......@@ -27,13 +28,15 @@ import cz.nic.tablexia.util.Log;
import cz.nic.tablexia.util.ScaleUtil;
import cz.nic.tablexia.util.listener.DragActorListener;
import cz.nic.tablexia.util.listener.DragSwitchListener;
import cz.nic.tablexia.util.ui.dialog.TablexiaDialog;
import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent;
public class FormScreen extends AbstractAutoloadTablexiaScreen<Void> {
public static final String BASET_ASSET_PATH = "screen/createuser/form";
private static final int MUGSHOT_HEIGHT = 250;
private Actor stamp, pen, mugshotFrame;
private Image mugshotImage;
private Actor pen, mugshotFrame, stamp;
private Image stampPlaceholder, mugshotImage;
private Actor buttonPlus, buttonMinus;
private Label ageLabel, nameLabel;
private int age;
......@@ -61,7 +64,7 @@ public class FormScreen extends AbstractAutoloadTablexiaScreen<Void> {
group.addActor(mugshotImage = ScaleUtil.createImageWidthPosition(getTexture("avatar/0"), getStage().getWidth() * 0.13f, getStage().getWidth() * 0.6f, getStage().getWidth() * 0.34f)); // size for all mugshots
group.addActor(mugshotFrame = ScaleUtil.createImageWidthPosition(getTexture("mugshotframe"), getStage().getWidth() * 0.17f, getStage().getWidth() * 0.58f, getStage().getWidth() * 0.32f));
group.addActor(ScaleUtil.createImageWidthPosition(getTexture("textfield_covername"), getStage().getWidth() * 0.2f, getStage().getWidth() * 0.57f, getStage().getWidth() * 0.27f));
group.addActor(ScaleUtil.createImageWidthPosition(getTexture("stampplaceholder"), getStage().getWidth() * 0.1f, getStage().getWidth() * 0.73f, getStage().getWidth() * 0.04f));
group.addActor(stampPlaceholder = ScaleUtil.createImageWidthPosition(getTexture("stampplaceholder"), getStage().getWidth() * 0.1f, getStage().getWidth() * 0.73f, getStage().getWidth() * 0.04f));
group.addActor(ScaleUtil.createImageWidthPosition(getTexture("texfield_signature"), getStage().getWidth() * 0.15f, getStage().getWidth() * 0.55f, getStage().getWidth() * 0.07f));
// TODO pens and stamps variant
mugshotFrame.addListener(new ClickListener() {
......@@ -90,8 +93,6 @@ public class FormScreen extends AbstractAutoloadTablexiaScreen<Void> {
@Override
public void clicked(InputEvent event, float x, float y) {
Gdx.input.setOnscreenKeyboardVisible(true);
// TODO input listener for writing
getStage().setKeyboardFocus(nameLabel);
}
......@@ -103,7 +104,6 @@ public class FormScreen extends AbstractAutoloadTablexiaScreen<Void> {
group.addActor(gender);
group.addActor(ScaleUtil.createImageWidthPosition(getTexture("sex_female"), getStage().getWidth() * 0.015f, getStage().getWidth() * 0.69f, getStage().getWidth() * 0.18f));
group.addActor(ScaleUtil.createImageWidthPosition(getTexture("sex_male"), getStage().getWidth() * 0.015f, getStage().getWidth() * 0.80f, getStage().getWidth() * 0.18f));
// TODO age buttons actions
group.addActor(buttonMinus = ScaleUtil.createImageWidthPosition(getTexture("button_minus"), getStage().getWidth() * 0.035f, getStage().getWidth() * 0.535f, getStage().getWidth() * 0.18f)); // size for all mugshots
group.addActor(buttonPlus = ScaleUtil.createImageWidthPosition(getTexture("button_plus"), getStage().getWidth() * 0.035f, getStage().getWidth() * 0.615f, getStage().getWidth() * 0.18f)); // size for all mugshots
buttonPlus.addListener(new ClickListener() {
......@@ -151,8 +151,23 @@ public class FormScreen extends AbstractAutoloadTablexiaScreen<Void> {
// TODO pencil and stamp layers
group.addActor(pen = ScaleUtil.createImageWidthPosition(getTexture("pencil_dropped"), getStage().getWidth() * 0.2f, getStage().getWidth() * 0.85f, getStage().getWidth() * -0.13f));
group.addActor(stamp = ScaleUtil.createImageWidthPosition(getTexture("stamp_left_dropped"), getStage().getWidth() * 0.2f, getStage().getWidth() * -0.01f, getStage().getWidth() * -0.05f));
pen.addListener(new DragActorListener(pen, true));
stamp.addListener(new DragActorListener(stamp, true));
pen.addListener(new DragActorListener(pen, true, new DragActorListener.DragDropListener() {
@Override
public void dropped(float x, float y) {
if ((x > 526 && x < 700) && (y > -300 && y < -190)) {
showSubscribeDialog();
}
}
}));
stamp.addListener(new DragActorListener(stamp, true, new DragActorListener.DragDropListener() {
@Override
public void dropped(float x, float y) {
if ((x > 636 && x < 775) && (y > -130 && y < 50)) {
Drawable d = new TextureRegionDrawable(new TextureRegion(getTexture("stamp")));
stampPlaceholder.setDrawable(d);
}
}
}));
getStage().addActor(group);
}
......@@ -179,7 +194,7 @@ public class FormScreen extends AbstractAutoloadTablexiaScreen<Void> {
HorizontalGroup hg = new HorizontalGroup();
for (int i = 0; i < TablexiaSettings.AVATAR_COUNT; i++) {
final Actor avatar = prepareAvatarPicture(i + 1);
avatar.setName(String.valueOf(i+1));
avatar.setName(String.valueOf(i + 1));
avatar.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
......@@ -249,10 +264,28 @@ public class FormScreen extends AbstractAutoloadTablexiaScreen<Void> {
ageLabel.setText(String.valueOf(this.age = age));
}
class StampStack extends Stack {
public StampStack(float width) {
// TODO position dependent images
}
private void showSubscribeDialog() {
final Group signature = new Group();
// grey translucent overlay
Image overlay = new Image(getTexture("avatar/overlay"));
overlay.getColor().a = 0.5f;
signature.addActor(ScaleUtil.setFullScreen(overlay, getStage()));
overlay.addListener(new InputListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
event.stop();
signature.remove();
return false;
}
});
// TODO show sign dialog
getStage().addActor(signature);
Dialog dialog = new TablexiaDialog(getStage().getWidth() * 0.1f, getStage().getWidth() * 0.1f - (getStage().getCamera().position.y - getStage().getHeight()/2)/2, getStage().getWidth() * 0.8f, getStage().getHeight() * 0.8f, TablexiaDialog.BackGroundType.DIALOG_RECTANGLE, new DialogTextContent("", "")).show(getStage());
}
}
......@@ -6,6 +6,8 @@ import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import cz.nic.tablexia.util.Log;
/**
* Created by lhoracek on 4/10/15.
*/
......@@ -13,6 +15,7 @@ public class DragActorListener extends InputListener {
private float grabX, grabY, startX, startY;
private final Actor actor;
private boolean bounceBack;
private DragDropListener dragDropListener;
public DragActorListener(Actor actor) {
this.actor = actor;
......@@ -23,6 +26,15 @@ public class DragActorListener extends InputListener {
this.bounceBack = bounceBack;
}
public DragActorListener(Actor actor, boolean bounceBack, DragDropListener dragDropListener) {
this(actor,bounceBack);
this.dragDropListener = dragDropListener;
}
public void setDragDropListener(DragDropListener dragDropListener) {
this.dragDropListener = dragDropListener;
}
// TODO add callback method
private void moveBack() {
actor.addAction(Actions.moveTo(startX, startY, 0.5f, Interpolation.elasticOut));
......@@ -31,29 +43,46 @@ public class DragActorListener extends InputListener {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
super.touchDown(event, x, y, pointer, button);
grabX = x;
grabY = y;
startX = actor.getX();
startY = actor.getY();
event.stop();
return true;
if (pointer == 0 && button == 0) {
grabX = x;
grabY = y;
startX = actor.getX();
startY = actor.getY();
event.stop();
return true;
}
return false;
}
@Override
public void touchDragged(InputEvent event, float x, float y, int pointer) {
super.touchDragged(event, x, y, pointer);
float bx = actor.getX() + (x - grabX);
float by = actor.getY() + (y - grabY);
actor.setPosition(bx, by);
event.stop();
if (pointer == 0) {
float bx = actor.getX() + (x - grabX);
float by = actor.getY() + (y - grabY);
actor.setPosition(bx, by);
if (actor.getDebug()) {
Log.info(((Object) this).getClass().getName(), "Position " + bx + "x" + by);
}
event.stop();
}
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
super.touchUp(event, x, y, pointer, button);
if(bounceBack){
moveBack();
if (pointer == 0 && button == 0) {
super.touchUp(event, x, y, pointer, button);
if (bounceBack) {
moveBack();
}
if(dragDropListener != null){
dragDropListener.dropped(actor.getX(),actor.getY());
}
event.stop();
}
event.stop();
}
public static interface DragDropListener {
public void dropped(float x, float y);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment