com.badlogic.gdx.scenes.scene2d.utils.ChangeListener Java Examples

The following examples show how to use com.badlogic.gdx.scenes.scene2d.utils.ChangeListener. 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: SeekBar.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Called by {@link SeekBarModel}. Notifies when underlying model value has changed and text field and slider must update.
 * Typically there is no need to call this method manually.
 * @param fireEvent if true then {@link ChangeListener.ChangeEvent} will be fired
 */
public void notifyValueChanged (boolean updateTextField, boolean updateSlider, boolean fireEvent) {
    if (updateTextField) {
        VisValidatableTextField textField = getTextField();
        int cursor = textField.getCursorPosition();
        textField.setCursorPosition(0);
        this.setListenTextChangeEvents(false);
        textField.setText(model.prepareTextValue());
        this.setListenTextChangeEvents(true);
        textField.setCursorPosition(cursor);
    }

    if (updateSlider) {
        VisSlider slider = getSlider();
        this.setListenSliderChangeEvents(false);
        slider.setValue(model.prepareSliderValue());
        this.setListenSliderChangeEvents(true);
    }

    if (fireEvent) {
        ChangeListener.ChangeEvent changeEvent = Pools.obtain(ChangeListener.ChangeEvent.class);
        fire(changeEvent);
        Pools.free(changeEvent);
    }
}
 
Example #2
Source File: TextureUnpackerDialogController.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
private void showSuccessfulDialog(final FileHandle outputDir) {
    VisDialog dialog = (VisDialog)interfaceService.getParser().parseTemplate(Gdx.files.internal("lml/textureunpacker/dialogSuccess.lml")).first();

    dialog.findActor("btnOpenOutputDir").addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            try {
                Desktop.getDesktop().open(outputDir.file());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });

    dialog.show(stage);
    stage.setScrollFocus(dialog);
}
 
Example #3
Source File: InputModuleWrapper.java    From talos with Apache License 2.0 6 votes vote down vote up
@Override
protected void configureSlots() {
    map = new IntMap<>();
    map.put(ScopePayload.EMITTER_ALPHA, "Emitter.alpha - Duration");
    map.put(ScopePayload.PARTICLE_ALPHA, "Particle.alpha - Lifetime");
    map.put(ScopePayload.EMITTER_ALPHA_AT_P_INIT, "Duration at particle init");
    map.put(ScopePayload.SECONDARY_SEED, "Primary Seed");
    map.put(ScopePayload.PARTICLE_SEED, "Secondary Seed");
    map.put(ScopePayload.PARTICLE_POSITION, "Particle position");
    map.put(ScopePayload.TOTAL_TIME, "Global Time");


    selectBox = addSelectBox(map.values());
    addOutputSlot("output", 0);


    selectBox.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            String selectedString = selectBox.getSelected();
            int key = map.findKey(selectedString, false, 0);

            module.setInput(key);
        }
    });
}
 
Example #4
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 #5
Source File: FloatInputWidget.java    From talos with Apache License 2.0 6 votes vote down vote up
private void buildAngle() {
    Table table = flavourContainers.get(NumericalValue.Flavour.ANGLE);

    angleCarrier = new RotatorWidget(getSkin());

    angleCarrier.setListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            getValue();
            if(listener != null) {
                listener.changed(event, actor);
            }
        }
    });

    table.add(angleCarrier).size(68);
}
 
Example #6
Source File: FloatPropertyWidget.java    From talos with Apache License 2.0 6 votes vote down vote up
@Override
public Actor getSubWidget() {
    textField = new TextField("", TalosMain.Instance().getSkin(), "panel");
    textField.setTextFieldFilter(new FloatFieldFilter());

    listener = new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if(textField.getText().isEmpty()) return;
            try {
                valueChanged(Float.parseFloat(textField.getText()));
            } catch (NumberFormatException e){
                valueChanged(0f);
            }
        }
    };
    textField.addListener(listener);
    return textField;
}
 
Example #7
Source File: GlobalScopeModuleWrapper.java    From talos with Apache License 2.0 6 votes vote down vote up
protected VisSelectBox addSelectBox(Array<String> values) {
    Table slotRow = new Table();
    final VisSelectBox selectBox = new VisSelectBox();

    selectBox.setItems(values);

    selectBox.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            updateFromSelectBox();
        }
    });

    slotRow.add(selectBox).width(50).left().padBottom(4).padLeft(5).padRight(10);

    leftWrapper.add(slotRow).left().expandX();
    leftWrapper.row();

    return selectBox;
}
 
Example #8
Source File: TestIssue326.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
public TestIssue326 () {
	super("issue #326");

	final VisTextField passwordTextField = new VisTextField("password");

	final IntSpinnerModel intModel = new IntSpinnerModel(10, -5, 20, 2);
	Spinner intSpinner = new Spinner("int", intModel);
	intSpinner.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			passwordTextField.setDisabled(true);
		}
	});

	add(new LinkLabel("issue #326 - FocusManager crash", "https://github.com/kotcrab/vis-ui/issues/326")).colspan(2).row();
	add(passwordTextField);
	row();
	add(intSpinner);

	setResizable(false);
	setModal(false);
	addCloseButton();
	closeOnEscape();
	pack();
	centerWindow();
}
 
Example #9
Source File: BasicColorPicker.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
private VisTable createHexTable () {
	VisTable table = new VisTable(true);
	table.add(new VisLabel(HEX.get()));
	table.add(hexField = new VisValidatableTextField("00000000")).width(HEX_FIELD_WIDTH * sizes.scaleFactor);
	table.row();

	hexField.setMaxLength(HEX_COLOR_LENGTH);
	hexField.setProgrammaticChangeEvents(false);
	hexField.setTextFieldFilter(new TextFieldFilter() {
		@Override
		public boolean acceptChar (VisTextField textField, char c) {
			return Character.isDigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
		}
	});

	hexField.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			if (hexField.getText().length() == (allowAlphaEdit ? HEX_COLOR_LENGTH_WITH_ALPHA : HEX_COLOR_LENGTH)) {
				setColor(Color.valueOf(hexField.getText()), false);
			}
		}
	});

	return table;
}
 
Example #10
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 #11
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 #12
Source File: GeneralListeners.java    From skin-composer with MIT License 6 votes vote down vote up
public static EventListener widgetResetListener(String name, Runnable runnable) {
    var popTableClickListener = new PopTableClickListener(DialogSceneComposer.skin);
    var popTable = popTableClickListener.getPopTable();
    
    var label = new Label("Are you sure you want to reset this " + name + "?", DialogSceneComposer.skin, "scene-label-colored");
    popTable.add(label);
    
    popTable.row();
    var textButton = new TextButton("RESET", DialogSceneComposer.skin, "scene-small");
    popTable.add(textButton).minWidth(100);
    textButton.addListener(DialogSceneComposer.main.getHandListener());
    textButton.addListener(new TextTooltip("Resets the settings of the " + name + " to the defaults.", DialogSceneComposer.main.getTooltipManager(), DialogSceneComposer.skin, "scene"));
    textButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            popTable.hide();
            runnable.run();
        }
    });
    
    return popTableClickListener;
}
 
Example #13
Source File: SelectBoxWidget.java    From talos with Apache License 2.0 6 votes vote down vote up
@Override
public Actor getSubWidget() {
    selectBox = new SelectBox<>(TalosMain.Instance().UIStage().getSkin(), "propertyValue");
    noValueLabel = new Label("", TalosMain.Instance().UIStage().getSkin());
    noValueLabel.setAlignment(Align.right);
    stack = new Stack();
    stack.add(noValueLabel);
    stack.add(selectBox);

    noValueLabel.setVisible(false);

    listener = new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            String newValue = selectBox.getSelected();
            valueChanged(newValue);
        }
    };
    selectBox.addListener(listener);

    return stack;
}
 
Example #14
Source File: PdAudioRemoteTest.java    From gdx-pd with Apache License 2.0 6 votes vote down vote up
private void testSendList(String label, final Object...values)
{
	String valText = "";
	for(Object v : values) valText += "," + v.toString();
	valText = "(" + valText.substring(1) + ")";
	
	TextButton bt = new TextButton(label + " " + valText, skin);
	bt.addListener(new ChangeListener() {
		
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			Pd.audio.sendList("recv_list", values);
		}
	});
	table.add("Send List on recv_list");
	table.add(bt);
	table.row();
}
 
Example #15
Source File: SystemProfilerGUI.java    From riiablo with Apache License 2.0 6 votes vote down vote up
public void init(final SystemProfiler profiler) {
  this.profiler = profiler;
  if (listener != null) draw.removeListener(listener);
  draw.setChecked(profiler.getDrawGraph());
  draw.addListener(listener = new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
      profiler.setDrawGraph(!profiler.getDrawGraph());
      if (profiler.getDrawGraph()) {
        setChildColor(profiler.getColor());
      } else {
        setChildColor(Color.LIGHT_GRAY);
      }
    }
  });
  name.setText(profiler.getName());
  setChildColor(profiler.getColor());
  lastMax = lastLocalMax = lastAvg = -1;
  invalidateHierarchy();
  layout();
}
 
Example #16
Source File: SignInWindow.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
@Override protected void doShow(String signInReasonKey) {
    Table content = new Table(Config.skin);
    content.setBackground("ui-store-window-background");
    content.defaults().pad(4);

    LocLabel label = new LocLabel(signInReasonKey);
    label.setWrap(true);
    label.setAlignment(Align.center);

    Button button = new Button(Config.skin);
    button.defaults().pad(2);
    button.add(new LocLabel("ui-sign-in")).padTop(1).padLeft(4).expand().right();
    button.add(new Tile("ui/button/services-icon")).padTop(4).padBottom(2).padRight(4).expand().left();
    button.addListener(new ChangeListener() {
        @Override public void changed(ChangeEvent event, Actor actor) {
            signIn = true;
            hide();
        }
    });

    content.add(label).width(130).row();
    content.add(button).width(70).padBottom(8);

    table.add(content);
}
 
Example #17
Source File: GameMapState.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
private void addDiceButton() {
    diceWindowButton = new Button(Config.skin, "dice");
    SoundHelper.initButton(diceWindowButton);
    diceWindowButton.setPosition(stage.getWidth() / 2 - diceWindowButton.getWidth() / 2, stage.getHeight() - diceWindowButton.getHeight());
    stage.addActor(diceWindowButton);
    diceWindowButton.addListener(new ChangeListener() {
        @Override public void changed(ChangeEvent event, Actor actor) {
            if (diceWindow.isShown()) {
                diceWindow.hide();
            } else {
                diceWindow.show(userData);
            }
            if (potionsWindow.isShown())
                potionsWindow.hide();
        }
    });
}
 
Example #18
Source File: GameMapState.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
private void addItemView(final Item item) {
    if (item.type != Item.Type.resource)
        return;
    Button button = new Button(Config.skin, "get" + item.name);
    button.addListener(new ChangeListener() {
        @Override public void changed(ChangeEvent event, Actor actor) {
            purchaseWindow.show(new PurchaseWindow.Params(item, new PurchaseWindow.Callback() {
                @Override public void onBuy(PurchaseInfo info) {
                    callback.onBuy(info);
                }
            }));
        }
    });
    SoundHelper.initButton(button);
    itemTable.add(button).padRight(-8).padLeft(-2);
    itemTable.add(new Image(Config.skin, "item/" + item.name));
    Label label = new Label(String.valueOf(userData.getItemCount(item)), Config.skin, "default", Color.WHITE);
    labelsByItem.put(item, label);
    itemTable.add(label).minWidth(27).padTop(-3).padLeft(-2).padRight(-2);
}
 
Example #19
Source File: GameSpeedController.java    From GdxDemo3D with Apache License 2.0 6 votes vote down vote up
public GameSpeedController(TextureAtlas buttonAtlas) {
	btnPauseStyle = new ImageButton.ImageButtonStyle();
	btnPauseStyle.up = new TextureRegionDrawable(buttonAtlas.findRegion("pause-up"));
	btnPauseStyle.down = new TextureRegionDrawable(buttonAtlas.findRegion("pause-down"));

	btnPlayStyle = new ImageButton.ImageButtonStyle();
	btnPlayStyle.up = new TextureRegionDrawable(buttonAtlas.findRegion("play-up"));
	btnPlayStyle.down = new TextureRegionDrawable(buttonAtlas.findRegion("play-down"));

	btnSlowStyle = new ImageButton.ImageButtonStyle();
	btnSlowStyle.up = new TextureRegionDrawable(buttonAtlas.findRegion("slow-up"));
	btnSlowStyle.down = new TextureRegionDrawable(buttonAtlas.findRegion("slow-down"));

	imageButton = new ImageButton(btnPauseStyle);

	add(imageButton);

	imageButton.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			setGameSpeed();
			event.cancel();
		}
	});
}
 
Example #20
Source File: ParallelVsSequenceTest.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
@Override
public Actor createActor (final Skin skin) {
	Table table = new Table();

	LabelStyle labelStyle = new LabelStyle(skin.get(LabelStyle.class));
	labelStyle.background = skin.newDrawable("white", .6f, .6f, .6f, 1);
	String branchChildren = "\n    selectTarget\n    pursue";
	table.add(new Label("parallel policy:\"sequence\" orchestrator:\"resume\"" + branchChildren, labelStyle)).pad(5);
	table.add(new Label("vs", skin)).padLeft(10).padRight(10);
	table.add(new Label("sequence" + branchChildren, labelStyle)).pad(5);

	table.row().padTop(15);

	TextButton startButton = new TextButton("Start", skin);
	startButton.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			oldScreen = container.getScreen();
			container.setScreen(new TestScreen(ParallelVsSequenceTest.this, skin));
		}
	});
	table.add();
	table.add(startButton);
	table.add();
	return table;
}
 
Example #21
Source File: GeneralListeners.java    From skin-composer with MIT License 6 votes vote down vote up
public static EventListener widgetDeleteListener(String name, Runnable runnable) {
    var popTableClickListener = new PopTableClickListener(DialogSceneComposer.skin);
    var popTable = popTableClickListener.getPopTable();
    
    var label = new Label("Are you sure you want to delete this " + name + "?", DialogSceneComposer.skin, "scene-label-colored");
    popTable.add(label);
    
    popTable.row();
    var textButton = new TextButton("DELETE", DialogSceneComposer.skin, "scene-small");
    popTable.add(textButton).minWidth(100);
    textButton.addListener(DialogSceneComposer.main.getHandListener());
    textButton.addListener(new TextTooltip("Removes this " + name + " from its parent.", DialogSceneComposer.main.getTooltipManager(), DialogSceneComposer.skin, "scene"));
    textButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            popTable.hide();
            runnable.run();
        }
    });
    
    return popTableClickListener;
}
 
Example #22
Source File: InfoTable.java    From skin-composer with MIT License 6 votes vote down vote up
public InfoTable(final Skin skin, final Stage stage) {
    pad(10.0f);
    
    var label = new Label(Core.readAndReplace("about.txt"), skin, "small");
    label.setWrap(true);
    label.setTouchable(Touchable.disabled);
    add(label).growX().expandY().top();
    
    row();
    var textButton = new TextButton("OK", skin);
    add(textButton).growX().height(30.0f);
    textButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            Core.transition(InfoTable.this, new MenuTable(skin, stage));
        }
    });
}
 
Example #23
Source File: ResurrectLikeSummonVisualizer.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override public IFuture<Void> visualize(final SummonResult result) {
    final Future<Void> future = new Future<Void>();
    final ParticleActor particle = new ParticleActor(Config.particles.get("ability-summon-" + result.summoned.profession.name).obtain());
    particle.addListener(new ChangeListener() {
        @Override public void changed(ChangeEvent event, Actor actor) {
            particle.remove();
            particle.effect.free();
        }
    });
    particle.setPosition(
        ViewController.CELL_SIZE * result.coordinate.x() + ViewController.CELL_SIZE / 2f,
        ViewController.CELL_SIZE * result.coordinate.y() + PARTICLE_OFFSET
    );
    particle.addAction(Actions.moveBy(0, -PARTICLE_OFFSET + 5, 1f));
    visualizer.viewController.effectLayer.addActor(particle);
    result.summoned.setPosition(result.coordinate.x(), result.coordinate.y());
    WorldObjectView view = visualizer.viewController.addView(result.summoned);
    view.getColor().a = 0;
    SoundManager.instance.playMusicAsSound("ability-boss-summon");
    view.addAction(Actions.sequence(
        Actions.alpha(1f, 1f),
        Actions.run(new Runnable() {
            @Override public void run() {
                particle.effect.allowCompletion();
                visualizer.viewController.removeView(result.summoned);
                future.happen();
            }
        })
    ));
    return future;
}
 
Example #24
Source File: DialogFreeTypeFont.java    From skin-composer with MIT License 5 votes vote down vote up
private void showMoreInfoDialog() {
    Dialog dialog = new Dialog("Custom serializer for FreeType Fonts", skin, "bg");
    dialog.setFillParent(true);
    
    dialog.getTitleLabel().setAlignment(Align.center);
    dialog.getContentTable().pad(15.0f);
    dialog.getButtonTable().pad(15.0f);
    
    Label label = new Label("Integrating TTF files and specifying FreeType within a Skin JSON requires a custom serializer. This is done by overriding getJsonLoader(). See the example below:", skin);
    label.setWrap(true);
    dialog.getContentTable().add(label).growX();
    
    dialog.getContentTable().row();
    Image image = new Image(skin, "code-sample");
    image.setScaling(Scaling.fit);
    dialog.getContentTable().add(image);
    
    dialog.getContentTable().row();
    TextButton textButton = new TextButton("Copy sample code to clipboard", skin);
    dialog.getContentTable().add(textButton);
    
    textButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            Gdx.app.getClipboard().setContents(SERIALIZER_TEXT);
        }
    });

    dialog.key(Keys.ENTER, true).key(Keys.ESCAPE, false);
    dialog.getButtonTable().defaults().minWidth(100.0f);
    dialog.button("OK", true);
    dialog.show(main.getStage());
}
 
Example #25
Source File: ResurrectVisualizer.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override public IFuture<Void> visualize(final ResurrectResult result) {
    final Future<Void> future = new Future<Void>();
    final ParticleActor particle = new ParticleActor(Config.particles.get("ability-resurrection-" + result.resurrected.profession.name).obtain());
    particle.addListener(new ChangeListener() {
        @Override public void changed(ChangeEvent event, Actor actor) {
            particle.remove();
            particle.effect.free();
        }
    });
    particle.setPosition(
        ViewController.CELL_SIZE * result.coordinate.x() + ViewController.CELL_SIZE / 2f,
        ViewController.CELL_SIZE * result.coordinate.y() + PARTICLE_OFFSET
    );
    particle.addAction(Actions.moveBy(0, -PARTICLE_OFFSET + 5, 1f));
    visualizer.viewController.effectLayer.addActor(particle);
    result.resurrected.setPosition(result.coordinate.x(), result.coordinate.y());
    WorldObjectView view = visualizer.viewController.addView(result.resurrected);
    view.getColor().a = 0;
    SoundManager.instance.playSound("ability-resurrect");
    view.addAction(Actions.sequence(
        Actions.alpha(1f, 1f),
        Actions.run(new Runnable() {
            @Override public void run() {
                particle.effect.allowCompletion();
                visualizer.viewController.removeView(result.resurrected);
                future.happen();
            }
        })
    ));
    return future;
}
 
Example #26
Source File: MenuButton.java    From skin-composer with MIT License 5 votes vote down vote up
public MenuButton(String text, MenuButtonStyle style) {
    super(text, style);
    setStyle(style);
    
    menuList = new MenuList(style.menuListStyle);
    
    menuList.addCaptureListener(new MenuList.MenuListListener() {
        @Override
        public void menuClicked() {
            fire(new MenuButtonEvent());
            setChecked(false);
        }
    });
    
    menuListPosition = new Vector2();
    
    addListener(new MbGroupInputListener(this));
    
    addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            if (isChecked() && getStage() != null) {
                localToStageCoordinates(menuListPosition.set(0.0f, 0.0f));
                menuList.show(menuListPosition, getStage());
                
                if (menuButtonGroup != null) {
                    menuButtonGroup.check((MenuButton) actor);
                }

                hideListener = new StageHideListener((MenuButton) actor, getStage());
                getStage().addListener(hideListener);
            } else {
                menuList.hide();
                menuButtonGroup.uncheckAll();
            }
        }
    });
}
 
Example #27
Source File: DialogAbout.java    From skin-composer with MIT License 5 votes vote down vote up
public DialogAbout(Main main, Skin skin, String windowStyleName) {
    super("", skin, windowStyleName);
    
    key(Keys.ENTER, true);
    key(Keys.ESCAPE, false);
    Table table = getContentTable();
    table.defaults().pad(10.0f);
    
    Label label = new Label("About", skin, "title");
    table.add(label);
    
    table.row();
    label = new Label("Skin Composer is developed by Raeleus for the LibGDX community.\nVersion " + Main.VERSION + "\nCopyright © Raymond \"Raeleus\" Buckley 2020", skin);
    label.setAlignment(Align.center);
    table.add(label).padBottom(0);
    table.row();
    TextButton button = new TextButton("github.com/raeleus/skin-composer", skin, "link");
    button.addListener(main.getHandListener());
    button.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            Gdx.net.openURI("https://github.com/raeleus/skin-composer");
        }
    });
    table.add(button).padTop(0);
    
    button("Close");
    getButtonTable().getCells().first().getActor().addListener(main.getHandListener());
    getCell(getButtonTable()).padBottom(20.0f);
    
    table.setWidth(200);
}
 
Example #28
Source File: DialogFactory.java    From skin-composer with MIT License 5 votes vote down vote up
public void showDialogUpdate(Skin skin, Stage stage) {
    Dialog dialog = new Dialog("Download Update", skin, "bg");
    dialog.getContentTable().pad(10.0f);
    dialog.getButtonTable().pad(10.0f).padTop(0);
    
    Table table = dialog.getContentTable();
    
    Label label = new Label("Version " + Main.newVersion + " available for download.", skin);
    table.add(label);
    
    table.row();
    TextButton textButton = new TextButton("Download Here", skin, "link");
    table.add(textButton);
    textButton.addListener(main.getHandListener());
    textButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            Gdx.net.openURI("https://github.com/raeleus/skin-composer/releases");
        }
    });
    
    dialog.getButtonTable().defaults().minWidth(80.0f);
    textButton = new TextButton("OK", skin);
    dialog.button(textButton);
    textButton.addListener(main.getHandListener());
    
    dialog.key(Keys.ENTER, true).key(Keys.ESCAPE, false);
    
    dialog.show(stage);
}
 
Example #29
Source File: TestColorPicker.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
public TestColorPicker () {
	super("color picker");

	final Image image = new Image(white);

	picker = new ColorPicker("color picker", new ColorPickerAdapter() {
		@Override
		public void finished (Color newColor) {
			image.setColor(newColor);
		}
	});

	VisTextButton showPickerButton = new VisTextButton("show color picker");
	showPickerButton.addListener(new ChangeListener() {
		@Override
		public void changed (ChangeEvent event, Actor actor) {
			getStage().addActor(picker.fadeIn());
		}
	});

	Color c = new Color(27 / 255.0f, 161 / 255.0f, 226 / 255.0f, 1);
	picker.setColor(c);
	image.setColor(c);

	TableUtils.setSpacingDefaults(this);

	add(showPickerButton);
	add(image).size(32).pad(3);

	pack();
	setPosition(948, 148);
}
 
Example #30
Source File: CollapsableUI.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
public CollapsableUI(Skin skin, String name, boolean visible) {
	toggle = new TextButton(name, skin, "toggle");
	toggle.setChecked(visible);
	add(toggle).row();
	optTable = new Table(skin);
	optCell = add();
	row();
	show(visible);
	toggle.addListener(new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			show(toggle.isChecked());
		}
	});
}