com.badlogic.gdx.scenes.scene2d.ui.Slider Java Examples

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.Slider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NoiseModuleWrapper.java    From talos with Apache License 2.0 6 votes vote down vote up
@Override
protected void configureSlots() {

    addInputSlot("X: (0 to 1)", NoiseModule.X);
    addInputSlot("Y: (0 to 1)", NoiseModule.Y);

    addOutputSlot("output", NoiseModule.OUTPUT);

    slider = new Slider(0.5f, 20f, 0.1f, false, getSkin());
    leftWrapper.add(slider).growX().padRight(2f).padBottom(5f).row();
    slider.setValue(0.5f);

    noiseImage = new NoiseImage(getSkin());
    leftWrapper.add(noiseImage).expandX().fillX().growX().height(100).padRight(3).padBottom(3);

    slider.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            float frequency = 20f - slider.getValue() + 0.5f;
            noiseImage.setFrequency(frequency);
            module.setFrequency(frequency);
        }
    });

    rightWrapper.add().expandY();
}
 
Example #2
Source File: SteeringTestBase.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
protected void addMaxAngularSpeedController (Table table, final Limiter limiter, float minValue, float maxValue, float step) {
	final Label labelMaxAngSpeed = new Label("Max.Ang.Speed [" + limiter.getMaxAngularSpeed() + "]", container.skin);
	table.add(labelMaxAngSpeed);
	table.row();
	Slider maxAngSpeed = new Slider(minValue, maxValue, step, false, container.skin);
	maxAngSpeed.setValue(limiter.getMaxAngularSpeed());
	maxAngSpeed.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			Slider slider = (Slider)actor;
			limiter.setMaxAngularSpeed(slider.getValue());
			labelMaxAngSpeed.setText("Max.Ang.Speed [" + limiter.getMaxAngularSpeed() + "]");
		}
	});
	table.add(maxAngSpeed);
}
 
Example #3
Source File: Vector4UI.java    From gdx-gltf with Apache License 2.0 6 votes vote down vote up
public Vector4UI(Skin skin, final Color value) {
	super(skin);
	this.value = value;
	for(int i=0 ; i<4 ; i++){
		final Slider slider = new Slider(0, 1, .01f, false, skin);
		add(name(i));
		add(slider).row();
		slider.setValue(get(i));
		final int index = i;
		slider.addListener(new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {
				set(index, slider.getValue());
			}
		});
		sliders.add(slider);
	}
}
 
Example #4
Source File: FloatAttributeUI.java    From gdx-gltf with Apache License 2.0 6 votes vote down vote up
public FloatAttributeUI(Skin skin, final FloatAttribute attribute) {
	super(skin);
	this.attribute = attribute;
	slider = new Slider(0, 1, .01f, false, skin);
	if(attribute != null){
		add(FloatAttribute.getAttributeAlias(attribute.type));
		add(slider).row();
		slider.setValue(attribute.value);
		slider.addListener(new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {
				attribute.value = slider.getValue();
			}
		});
	}
}
 
Example #5
Source File: Vector3UI.java    From gdx-gltf with Apache License 2.0 6 votes vote down vote up
public Vector3UI(Skin skin, final Vector3 value) {
	super(skin);
	this.value = value;
	for(int i=0 ; i<3 ; i++){
		final Slider slider = new Slider(-1, 1, .01f, false, skin);
		add(name(i));
		add(slider).row();
		slider.setValue(get(i));
		final int index = i;
		slider.addListener(new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {
				set(index, slider.getValue());
			}
		});
		sliders.add(slider);
	}
}
 
Example #6
Source File: Vector2UI.java    From gdx-gltf with Apache License 2.0 6 votes vote down vote up
public Vector2UI(Skin skin, final Vector2 value) {
	super(skin);
	this.value = value;
	for(int i=0 ; i<2 ; i++){
		final Slider slider = new Slider(0, 1, .01f, false, skin);
		add(name(i));
		add(slider).row();
		slider.setValue(get(i));
		final int index = i;
		slider.addListener(new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {
				set(index, slider.getValue());
			}
		});
	}
}
 
Example #7
Source File: ColorAttributeUI.java    From gdx-gltf with Apache License 2.0 6 votes vote down vote up
public ColorAttributeUI(Skin skin, final ColorAttribute attribute) {
	super(skin);
	if(attribute == null) return;
	this.attribute = attribute;
	add(ColorAttribute.getAttributeAlias(attribute.type));
	for(int i=0 ; i<4 ; i++){
		if(i != 0) add();
		final Slider slider = new Slider(0, 1, .01f, false, skin);
		add(slider).row();
		slider.setValue(get(i));
		final int index = i;
		slider.addListener(new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {
				set(index, slider.getValue());
			}
		});
		sliders.add(slider);
	}
}
 
Example #8
Source File: WeightsUI.java    From gdx-gltf with Apache License 2.0 6 votes vote down vote up
public WeightsUI(Skin skin, final WeightVector value, final Array<String> names) {
	super(skin);
	this.value = value;
	for(int i=0 ; i<value.count ; i++){
		final Slider slider = new Slider(0, 1, .01f, false, skin);
		final int index = i;
		slider.addListener(new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {
				set(index, slider.getValue());
			}
		});
		String name = names != null && i < names.size ? names.get(i) : "#" + (i+1);
		add(name);
		add(slider).row();
		slider.setValue(get(i));
		sliders.add(slider);
	}
}
 
Example #9
Source File: SteeringTestBase.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
protected void addMaxAngularAccelerationController (Table table, final Limiter limiter, float minValue, float maxValue,
	float step) {
	final Label labelMaxAngAcc = new Label("Max.Ang.Acc.[" + limiter.getMaxAngularAcceleration() + "]", container.skin);
	table.add(labelMaxAngAcc);
	table.row();
	Slider maxAngAcc = new Slider(minValue, maxValue, step, false, container.skin);
	maxAngAcc.setValue(limiter.getMaxAngularAcceleration());
	maxAngAcc.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			Slider slider = (Slider)actor;
			limiter.setMaxAngularAcceleration(slider.getValue());
			labelMaxAngAcc.setText("Max.Ang.Acc.[" + limiter.getMaxAngularAcceleration() + "]");
		}
	});
	table.add(maxAngAcc);
}
 
Example #10
Source File: CCSliderTest.java    From cocos-ui-libgdx with Apache License 2.0 6 votes vote down vote up
@Test
@NeedGL
public void shouldParseSliderBar() throws Exception {
    CocoStudioUIEditor editor = new CocoStudioUIEditor(
        Gdx.files.internal("slideBar/MainScene.json"), null, null, null, null);

    Group group = editor.createGroup();
    Slider slider = group.findActor("Slider_1");
    assertThat(slider.getWidth(), is(200f));
    assertThat(slider.getHeight(), is(14f));
    assertThat(slider.getValue(), is(50f));
    Slider.SliderStyle style = slider.getStyle();
    assertThat(style.knob, instanceOf(TextureRegionDrawable.class));
    assertThat(style.background, instanceOf(TextureRegionDrawable.class));
    assertThat(style.knobBefore, instanceOf(TextureRegionDrawable.class));
    //assertThat(style.disabledKnob, instanceOf(TextureRegionDrawable.class));
   // assertThat(style.knobDown, instanceOf(TextureRegionDrawable.class));
}
 
Example #11
Source File: SteeringTestBase.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
protected void addMaxLinearAccelerationController (Table table, final Limiter limiter, float minValue, float maxValue,
	float step) {
	final Label labelMaxLinAcc = new Label("Max.Linear Acc.[" + limiter.getMaxLinearAcceleration() + "]", container.skin);
	table.add(labelMaxLinAcc);
	table.row();
	Slider maxLinAcc = new Slider(minValue, maxValue, step, false, container.skin);
	maxLinAcc.setValue(limiter.getMaxLinearAcceleration());
	maxLinAcc.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			Slider slider = (Slider)actor;
			limiter.setMaxLinearAcceleration(slider.getValue());
			labelMaxLinAcc.setText("Max.Linear Acc.[" + limiter.getMaxLinearAcceleration() + "]");
		}
	});
	table.add(maxLinAcc);
}
 
Example #12
Source File: SteeringTestBase.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
protected void addMaxLinearSpeedController (Table table, final Limiter limiter, float minValue, float maxValue, float step) {
	final Label labelMaxSpeed = new Label("Max.Lin.Speed [" + limiter.getMaxLinearSpeed() + "]", container.skin);
	table.add(labelMaxSpeed);
	table.row();
	Slider maxSpeed = new Slider(minValue, maxValue, step, false, container.skin);
	maxSpeed.setValue(limiter.getMaxLinearSpeed());
	maxSpeed.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			Slider slider = (Slider)actor;
			limiter.setMaxLinearSpeed(slider.getValue());
			labelMaxSpeed.setText("Max.Lin.Speed [" + limiter.getMaxLinearSpeed() + "]");
		}
	});
	table.add(maxSpeed);
}
 
Example #13
Source File: GameStage.java    From GdxDemo3D with Apache License 2.0 6 votes vote down vote up
public LayerController(TextureAtlas buttonAtlas) {
	Slider.SliderStyle sliderStyle = new Slider.SliderStyle();
	sliderStyle.knob = new TextureRegionDrawable(buttonAtlas.findRegion("slider-knob-up"));
	sliderStyle.knobDown = new TextureRegionDrawable(buttonAtlas.findRegion("slider-knob-down"));
	sliderStyle.knobOver = new TextureRegionDrawable(buttonAtlas.findRegion("slider-knob-down"));
	sliderStyle.background = new TextureRegionDrawable(buttonAtlas.findRegion("slider-background"));

	slider = new Slider(minLayer, maxLayer, 1, true, sliderStyle);
	slider.setValue(maxLayer);
	slider.setAnimateDuration(0.1f);

	slider.addCaptureListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			setLayer((int) slider.getValue());
		}
	});
	add(slider).height(300);
}
 
Example #14
Source File: TestVertical.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
private void addNormalWidgets () {
	ProgressBar progressbar = new ProgressBar(0, 100, 1, true, VisUI.getSkin());
	Slider slider = new Slider(0, 100, 1, true, VisUI.getSkin());
	Slider sliderDisabled = new Slider(0, 100, 1, true, VisUI.getSkin());

	progressbar.setValue(50);
	slider.setValue(50);
	sliderDisabled.setValue(50);
	sliderDisabled.setDisabled(true);

	VisTable progressbarTable = new VisTable(true);
	progressbarTable.add(progressbar);
	progressbarTable.add(slider);
	progressbarTable.add(sliderDisabled);

	add(progressbarTable);
}
 
Example #15
Source File: FloatSetting.java    From Cubes with MIT License 5 votes vote down vote up
@Override
public Actor getActor(String settingName, VisualSettingManager visualSettingManager) {
  switch (type) {
    case TextField:
      return getTextField(visualSettingManager);
    case Slider:
      return getSlider(visualSettingManager);
  }
  return null;
}
 
Example #16
Source File: IntegerSetting.java    From Cubes with MIT License 5 votes vote down vote up
@Override
public Actor getActor(String settingName, VisualSettingManager visualSettingManager) {
  switch (type) {
    case TextField:
      return getTextField(visualSettingManager);
    case Slider:
      return getSlider(visualSettingManager);
  }
  return null;
}
 
Example #17
Source File: PdAudioRemoteTest.java    From gdx-pd with Apache License 2.0 5 votes vote down vote up
private void valueTest(String label, final ActionHandler<Float> runnable) {
	final Slider sl = new Slider(-100, 100, 0.1f, false, skin);
	sl.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			runnable.run(sl.getValue());
		}
	});
	table.add(label);
	table.add(sl);
	table.row();
}
 
Example #18
Source File: UIUtils.java    From uracer-kotd with Apache License 2.0 5 votes vote down vote up
public static Slider newSlider (float min, float max, float step, float value, ChangeListener listener) {
	Slider s = new Slider(min, max, step, false, Art.scrSkin);
	s.setValue(value);
	if (listener != null) {
		s.addListener(listener);
	}
	return s;
}
 
Example #19
Source File: Scene2dPursueTest.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
@Override
public void create () {
	super.create();

	character = new SteeringActor(container.badlogicSmall, false);
	character.setPosition(MathUtils.random(container.stageWidth), MathUtils.random(container.stageHeight), Align.center);
	character.setMaxLinearSpeed(100);
	character.setMaxLinearAcceleration(600);

	prey = new SteeringActor(container.target, false);
	prey.setPosition(MathUtils.random(container.stageWidth), MathUtils.random(container.stageHeight), Align.center);
	prey.setMaxLinearSpeed(100);
	prey.setMaxLinearAcceleration(250);
	prey.setMaxAngularAcceleration(0); // used by Wander; set to 0 because independent facing is disabled
	prey.setMaxAngularSpeed(5);

	final Pursue<Vector2> pursueSB = new Pursue<Vector2>(character, prey, 0.3f);
	character.setSteeringBehavior(pursueSB);

	Wander<Vector2> wanderSB = new Wander<Vector2>(prey) //
		// Don't use Face internally because independent facing is off
		.setFaceEnabled(false) //
		// No need to call setAlignTolerance, setDecelerationRadius and setTimeToTarget for the same reason
		.setWanderOffset(110) //
		.setWanderOrientation(10) //
		.setWanderRadius(64) //
		.setWanderRate(MathUtils.PI2 * 3.5f);
	prey.setSteeringBehavior(wanderSB);

	testTable.addActor(character);
	testTable.addActor(prey);

	Table detailTable = new Table(container.skin);

	detailTable.row();
	addMaxLinearAccelerationController(detailTable, character, 0, 2000, 20);

	detailTable.row();
	final Label labelMaxPredictionTime = new Label("Max.Prediction Time[" + pursueSB.getMaxPredictionTime() + "] sec.",
		container.skin);
	detailTable.add(labelMaxPredictionTime);
	detailTable.row();
	Slider maxPredictionTime = new Slider(0, 5, .1f, false, container.skin);
	maxPredictionTime.setValue(pursueSB.getMaxPredictionTime());
	maxPredictionTime.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			Slider slider = (Slider)actor;
			pursueSB.setMaxPredictionTime(slider.getValue());
			labelMaxPredictionTime.setText("Max.Prediction Time [" + slider.getValue() + "] sec.");
		}
	});
	detailTable.add(maxPredictionTime);

	detailTable.row();
	addSeparator(detailTable);

	detailTable.row();
	addMaxLinearSpeedController(detailTable, character, 0, 300, 10);

	detailWindow = createDetailWindow(detailTable);
}
 
Example #20
Source File: LiveOptionsScreen.java    From SIFTrain with MIT License 4 votes vote down vote up
@Override
public void changed(ChangeEvent event, Actor actor) {
    if (actor == playbackRateSlider) {
        newPlaybackRate = ((Slider) actor).getValue();
        GlobalConfiguration.playbackRate = newPlaybackRate;
        playbackRateLabel.setText("Playback Rate" + (newPlaybackRate.compareTo(1.0f) == 0 ? "" : "(no music)"));
        playbackRateValueLabel.setText(String.format("%.2f", newPlaybackRate) + "x");
    }
    if (actor == aSlider) {
        newAPosition = ((Slider) actor).getValue();
        GlobalConfiguration.aTime = newAPosition;
        aLabel.setText("Start Time: " + String.format("%.2f", newAPosition));
        if (newAPosition + 5f > newBPosition) {
            newBPosition = newAPosition + 5f;
            bSlider.setValue(newBPosition);
            bLabel.setText("End Time: " + String.format("%.2f", newBPosition));
            GlobalConfiguration.bTime = newBPosition;
        }
        if (theSong != null) {
            theSong.pause();
            theSong.setPosition(newAPosition);
            theSong.setVolume(GlobalConfiguration.songVolume / 100f);
            theSong.play();
        }
    }
    if (actor == bSlider) {
        newBPosition = ((Slider) actor).getValue();
        GlobalConfiguration.bTime = newBPosition;
        bLabel.setText("End Time: " + String.format("%.2f", newBPosition));
        if (newBPosition - 5f < newAPosition) {
            newAPosition = newBPosition - 5f;
            aSlider.setValue(newAPosition);
            aLabel.setText("Start Time: " +  String.format("%.2f", newAPosition));
            GlobalConfiguration.aTime = newAPosition;
        }
    }
    if (actor == abModeChooser) {
        GlobalConfiguration.playbackMode = GlobalConfiguration.playbackMode == null ? 1 : (GlobalConfiguration.playbackMode + 1) % modes.length;
        abModeChooser.setText("Game Mode (Tap to change): " + modes[GlobalConfiguration.playbackMode]);

        aLabel.setVisible(GlobalConfiguration.playbackMode.equals(SongUtils.GAME_MODE_ABREPEAT));
        aSlider.setVisible(GlobalConfiguration.playbackMode.equals(SongUtils.GAME_MODE_ABREPEAT));
        bLabel.setVisible(GlobalConfiguration.playbackMode.equals(SongUtils.GAME_MODE_ABREPEAT));
        bSlider.setVisible(GlobalConfiguration.playbackMode.equals(SongUtils.GAME_MODE_ABREPEAT));
    }
}
 
Example #21
Source File: FloatSetting.java    From Cubes with MIT License 4 votes vote down vote up
public FloatSetting(float f, float rangeStart, float rangeEnd) {
  this(f, rangeStart, rangeEnd, Type.Slider);
}
 
Example #22
Source File: IntegerSetting.java    From Cubes with MIT License 4 votes vote down vote up
public IntegerSetting(int i, int rangeStart, int rangeEnd) {
  this(i, rangeStart, rangeEnd, Type.Slider);
}
 
Example #23
Source File: VerticalScrollSliderLmlAttribute.java    From gdx-vfx with Apache License 2.0 4 votes vote down vote up
@Override
public Class<Slider> getHandledType() {
    return Slider.class;
}
 
Example #24
Source File: UIUtils.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
public static Slider newSlider (float min, float max, float step, float value) {
	return newSlider(min, max, step, value, null);
}
 
Example #25
Source File: FloatUI.java    From gdx-gltf with Apache License 2.0 4 votes vote down vote up
public FloatUI(Skin skin, final float value) {
	super(skin);
	slider = new Slider(0, 1, .01f, false, skin);
	add(slider).row();
	slider.setValue(value);
}
 
Example #26
Source File: MainMenuInterface.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
private void createStageActors() {
	faster = new CheckBox(LABEL_FASTER, skin);

	color = new CheckBox(LABEL_COLOR, skin);

	animate = new CheckBox(LABEL_ANIMATE, skin);

	sound = new CheckBox(LABEL_SOUND, skin);
	table.setPosition(210, 30);

	outline = new CheckBox(LABEL_OUTLINE, skin);

	permOutline = new CheckBox(LABEL_PERM_OUTLINE, skin);

	fasterLabel = new Label(LABEL_FASTER_SELECT, skin);
	fasterLabel.setPosition(240 - fasterLabel.getWidth() / 2, 115);

	fasterSlider = new Slider(0, 5, 1, false, skin);
	fasterSlider.setWidth(outline.getWidth());
	fasterSlider.setPosition(240 - fasterSlider.getWidth() / 2, 100);

	levelLabel = new Label(LABEL_LEVEL_SELECT, skin);
	levelLabel.setPosition(240 - levelLabel.getWidth() / 2, 85);

	levelSlider = new Slider(0, 5, 1, false, skin);
	levelSlider.setWidth(outline.getWidth());
	levelSlider.setPosition(240 - levelSlider.getWidth() / 2, 70);

	start = new TextButton("Start", skin);
	start.setPosition(210, 36);

	license = new TextButton("License", skin);
	license.setPosition(205, 2);

	fasterLabel.setY(215);
	fasterSlider.setY(200);

	levelLabel.setY(185);
	levelSlider.setY(170);
}