com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle Java Examples

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle. 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: NinePatchEditorDialog.java    From gdx-skineditor with Apache License 2.0 6 votes vote down vote up
private void reviewTablePreview() {
	tablePreview.clear();
	//tablePreview.debug();
	tablePreview.center().left();
	
	TextButtonStyle stylePreview = new TextButton.TextButtonStyle();
	stylePreview.font = game.skin.getFont("default-font");
	buttonPreview1 = new TextButton("1x Button", stylePreview);
	buttonPreview1.setSize(imgWidth, imgHeight);
	cellPreview1 = tablePreview.add(buttonPreview1).width(buttonPreview1.getWidth()).height(buttonPreview1.getHeight()).padBottom(15);
	tablePreview.row();

	buttonPreview2 = new TextButton("2x Button", stylePreview);
	buttonPreview2.setSize(imgWidth * 2.0f, imgHeight * 2.0f);
	cellPreview2 = tablePreview.add(buttonPreview2).width(buttonPreview2.getWidth()).height(buttonPreview2.getHeight()).padBottom(15);
	tablePreview.row();

	buttonPreview3 = new TextButton("3x Button", stylePreview);
	buttonPreview3.setSize(imgWidth * 3.0f, imgHeight * 3.0f);
	cellPreview3 = tablePreview.add(buttonPreview3).width(buttonPreview3.getWidth()).height(buttonPreview3.getHeight()).padBottom(15);
	tablePreview.row();
	
}
 
Example #2
Source File: MenuItem.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
@Override
public void setStyle (ButtonStyle style) {
	if (!(style instanceof MenuItemStyle)) throw new IllegalArgumentException("style must be a MenuItemStyle.");
	super.setStyle(style);
	this.style = (MenuItemStyle) style;
	if (label != null) {
		TextButtonStyle textButtonStyle = (TextButtonStyle) style;
		LabelStyle labelStyle = label.getStyle();
		labelStyle.font = textButtonStyle.font;
		labelStyle.fontColor = textButtonStyle.fontColor;
		label.setStyle(labelStyle);
	}
}
 
Example #3
Source File: MainMenuInterface.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
private void setUpSkin() {
	Pixmap pixmap = new Pixmap(1, 1, Format.RGBA8888);
	pixmap.setColor(Color.LIGHT_GRAY);
	pixmap.fill();
	skin.add("grey", new Texture(pixmap));
	titleSprite.setX(TITLE_SPRITE_POS_X);
	titleSprite.setY(TITLE_SPRITE_POS_Y);

	LabelStyle labelStyle = new LabelStyle();
	skin.add("default", finePrint);
	labelStyle.font = skin.getFont("default");
	skin.add("default", labelStyle);

	CheckBoxStyle checkBoxStyle = new CheckBoxStyle();
	checkBoxStyle.checkboxOff = skin.newDrawable("grey", Color.LIGHT_GRAY);
	checkBoxStyle.checkboxOn = skin.newDrawable("grey", Color.LIGHT_GRAY);
	checkBoxStyle.font = skin.getFont("default");
	checkBoxStyle.checkboxOff = new TextureRegionDrawable(unchecked);
	checkBoxStyle.checkboxOn = new TextureRegionDrawable(checked);
	skin.add("default", checkBoxStyle);

	SliderStyle sliderStyle = new SliderStyle();
	sliderStyle.background = new TextureRegionDrawable(background);
	sliderStyle.knob = new TextureRegionDrawable(knob);
	skin.add("default-horizontal", sliderStyle);

	ButtonStyle buttonStyle = new ButtonStyle();
	skin.add("default", buttonStyle);

	TextButtonStyle textButtonStyle = new TextButtonStyle();
	textButtonStyle.font = skin.getFont("default");
	textButtonStyle.up = new NinePatchDrawable(patchBox);
	skin.add("default", textButtonStyle);
}
 
Example #4
Source File: Dialog.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
/** Adds a text button to the button table. The dialog must have been constructed with a skin to use this method.
 * @param object The object that will be passed to {@link #result(Object)} if this button is clicked. May be null. */
public Dialog button (String text, Object object) {
	if (skin == null)
		throw new IllegalStateException("This method may only be used if the dialog was constructed with a Skin.");
	return button(text, object, skin.get(TextButtonStyle.class));
}
 
Example #5
Source File: Dialog.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
/** Adds a text button to the button table.
 * @param object The object that will be passed to {@link #result(Object)} if this button is clicked. May be null. */
public Dialog button (String text, Object object, TextButtonStyle buttonStyle) {
	return button(new TextButton(text, buttonStyle), object);
}
 
Example #6
Source File: StyleData.java    From skin-composer with MIT License 4 votes vote down vote up
public void resetProperties() {
    properties.clear();
    parent = null;
    
    if (clazz.equals(Button.class)) {
        newStyleProperties(ButtonStyle.class);
    } else if (clazz.equals(CheckBox.class)) {
        newStyleProperties(CheckBoxStyle.class);
        properties.get("checkboxOn").optional = false;
        properties.get("checkboxOff").optional = false;
        properties.get("font").optional = false;
    } else if (clazz.equals(ImageButton.class)) {
        newStyleProperties(ImageButtonStyle.class);
    } else if (clazz.equals(ImageTextButton.class)) {
        newStyleProperties(ImageTextButtonStyle.class);
        properties.get("font").optional = false;
    } else if (clazz.equals(Label.class)) {
        newStyleProperties(LabelStyle.class);
        properties.get("font").optional = false;
    } else if (clazz.equals(List.class)) {
        newStyleProperties(ListStyle.class);
        properties.get("font").optional = false;
        properties.get("fontColorSelected").optional = false;
        properties.get("fontColorUnselected").optional = false;
        properties.get("selection").optional = false;
    } else if (clazz.equals(ProgressBar.class)) {
        newStyleProperties(ProgressBarStyle.class);
        
        //Though specified as optional in the doc, there are bugs without "background" being mandatory
        properties.get("background").optional = false;
    } else if (clazz.equals(ScrollPane.class)) {
        newStyleProperties(ScrollPaneStyle.class);
    } else if (clazz.equals(SelectBox.class)) {
        newStyleProperties(SelectBoxStyle.class);
        properties.get("font").optional = false;
        properties.get("fontColor").optional = false;
        properties.get("scrollStyle").optional = false;
        properties.get("scrollStyle").value = "default";
        properties.get("listStyle").optional = false;
        properties.get("listStyle").value = "default";
    } else if (clazz.equals(Slider.class)) {
        newStyleProperties(SliderStyle.class);
        
        //Though specified as optional in the doc, there are bugs without "background" being mandatory
        properties.get("background").optional = false;
    } else if (clazz.equals(SplitPane.class)) {
        newStyleProperties(SplitPaneStyle.class);
        properties.get("handle").optional = false;
    } else if (clazz.equals(TextButton.class)) {
        newStyleProperties(TextButtonStyle.class);
        properties.get("font").optional = false;
    } else if (clazz.equals(TextField.class)) {
        newStyleProperties(TextFieldStyle.class);
        properties.get("font").optional = false;
        properties.get("fontColor").optional = false;
    } else if (clazz.equals(TextTooltip.class)) {
        newStyleProperties(TextTooltipStyle.class);
        properties.get("label").optional = false;
        properties.get("label").value = "default";
    } else if (clazz.equals(Touchpad.class)) {
        newStyleProperties(TouchpadStyle.class);
    } else if (clazz.equals(Tree.class)) {
        newStyleProperties(TreeStyle.class);
        properties.get("plus").optional = false;
        properties.get("minus").optional = false;
    } else if (clazz.equals(Window.class)) {
        newStyleProperties(WindowStyle.class);
        properties.get("titleFont").optional = false;
    }
}
 
Example #7
Source File: BrowseField.java    From skin-composer with MIT License 4 votes vote down vote up
public BrowseFieldStyle(ImageButtonStyle imageButtonStyle, TextButtonStyle textButtonStyle, LabelStyle labelStyle) {
    this.mainButtonStyle = textButtonStyle;
    this.rightButtonStyle = imageButtonStyle;
    this.labelStyle = labelStyle;
}
 
Example #8
Source File: LoadSaveScreen.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void clicked(InputEvent event, float x, float y) {
	final Actor listenerActor = event.getListenerActor();

	Dialog d = new Dialog("", ui.getSkin()) {
		@Override
		protected void result(Object object) {
			if (((Boolean) object).booleanValue()) {
				final World world = ui.getWorld();
				final String filename = listenerActor.getName() + WorldSerialization.GAMESTATE_EXT;

				try {
					world.removeGameState(filename);

					listenerActor.getParent().getParent().getParent()
							.removeActor(listenerActor.getParent().getParent());

				} catch (IOException e) {
					EngineLogger.error(e.getMessage());
				}
			}
		}
	};

	d.pad(DPIUtils.getMarginSize());
	d.getButtonTable().padTop(DPIUtils.getMarginSize());
	d.getButtonTable().defaults().padLeft(DPIUtils.getMarginSize()).padRight(DPIUtils.getMarginSize());

	Label l = new Label(ui.getWorld().getI18N().getString("ui.remove"), ui.getSkin(), "ui-dialog");
	l.setWrap(true);
	l.setAlignment(Align.center);

	d.getContentTable().add(l).prefWidth(Gdx.graphics.getWidth() * .7f);

	d.button(ui.getWorld().getI18N().getString("ui.yes"), true,
			ui.getSkin().get("ui-dialog", TextButtonStyle.class));
	d.button(ui.getWorld().getI18N().getString("ui.no"), false,
			ui.getSkin().get("ui-dialog", TextButtonStyle.class));
	d.key(Keys.ENTER, true).key(Keys.ESCAPE, false);

	d.show(stage);
}