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

#22 Form input

parent 587a920a
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,7 @@ import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.loader.application.ApplicationFontManager;
import cz.nic.tablexia.model.User;
import cz.nic.tablexia.screen.AbstractAutoloadTablexiaScreen;
import cz.nic.tablexia.screen.createuser.form.FormInputListener;
import cz.nic.tablexia.util.ScaleUtil;
import cz.nic.tablexia.util.listener.DragActorListener;
import cz.nic.tablexia.util.listener.DragSwitchListener;
......@@ -89,9 +90,20 @@ public class FormScreen extends AbstractAutoloadTablexiaScreen<Void> {
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(buttonPlus = ScaleUtil.createImageWidthPosition(getTexture("button_plus"), getStage().getWidth() * 0.035f, getStage().getWidth() * 0.535f, getStage().getWidth() * 0.18f)); // size for all mugshots
group.addActor(buttonMinus = ScaleUtil.createImageWidthPosition(getTexture("button_minus"), getStage().getWidth() * 0.035f, getStage().getWidth() * 0.615f, getStage().getWidth() * 0.18f)); // size for all mugshots
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() {
@Override
public void clicked(InputEvent event, float x, float y) {
setAge(Math.min(FormScreen.this.age + 1, 99));
}
});
buttonMinus.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
setAge(Math.max(FormScreen.this.age - 1, 1));
}
});
group.addActor(ScaleUtil.createImageWidthPosition(getTexture("switch_background"), getStage().getWidth() * 0.07f, getStage().getWidth() * 0.715f, getStage().getWidth() * 0.18f));
Group selector = new Group();
......@@ -129,12 +141,17 @@ public class FormScreen extends AbstractAutoloadTablexiaScreen<Void> {
stamp.addListener(new DragActorListener(stamp, true));
getStage().addActor(group);
getStage().addListener(new FormInputListener(nameLabel));
}
private Label.LabelStyle getLabelStyle() {
return new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_REGULAR), Color.BLACK);
}
public void setAge(int age) {
ageLabel.setText(String.valueOf(this.age = age));
}
class StampStack extends Stack {
public StampStack(float width) {
// TODO position dependet images
......
package cz.nic.tablexia.screen.createuser.form;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
/**
* Created by lhoracek on 4/16/15.
*/
public class FormInputListener extends InputListener{
private final Label label;
public FormInputListener(Label label) {
this.label = label;
}
@Override
public boolean keyTyped(InputEvent event, char character) {
label.getText().append(character);
label.invalidateHierarchy();
return true;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment