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

The following examples show how to use com.badlogic.gdx.scenes.scene2d.utils.ChangeListener. These examples are extracted from open source projects. 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 Project: talos   Source File: FloatPropertyWidget.java    License: 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 2
Source Project: talos   Source File: SelectBoxWidget.java    License: 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 3
Source Project: talos   Source File: FloatInputWidget.java    License: 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 4
Source Project: GdxDemo3D   Source File: GameStage.java    License: 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 Project: talos   Source File: InputModuleWrapper.java    License: 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 6
Source Project: talos   Source File: GlobalScopeModuleWrapper.java    License: 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 7
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 8
Source Project: vis-ui   Source File: TestIssue326.java    License: 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 Project: vis-ui   Source File: BasicColorPicker.java    License: 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 Project: gdx-gltf   Source File: Vector3UI.java    License: 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 Project: gdx-gltf   Source File: Vector2UI.java    License: 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 Project: skin-composer   Source File: InfoTable.java    License: 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 13
Source Project: skin-composer   Source File: GeneralListeners.java    License: 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 14
Source Project: skin-composer   Source File: GeneralListeners.java    License: 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 15
Source Project: gdx-ai   Source File: ParallelVsSequenceTest.java    License: 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 16
Source Project: GdxDemo3D   Source File: GameSpeedController.java    License: 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 17
Source Project: dice-heroes   Source File: GameMapState.java    License: 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 18
Source Project: dice-heroes   Source File: GameMapState.java    License: 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 19
Source Project: dice-heroes   Source File: SignInWindow.java    License: 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 20
Source Project: riiablo   Source File: SystemProfilerGUI.java    License: 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 21
Source Project: gdx-pd   Source File: PdAudioRemoteTest.java    License: 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 22
Source Project: gdx-texture-packer-gui   Source File: SeekBar.java    License: 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 23
Source Project: talos   Source File: CheckboxWidget.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Actor getSubWidget() {
	checkBox = new CheckBox("", TalosMain.Instance().getSkin(), "panel-checkbox");

	listener = new ChangeListener() {
		@Override
		public void changed(ChangeEvent event, Actor actor) {
			valueChanged(checkBox.isChecked());
		}
	};
	checkBox.addListener(listener);

	return checkBox;
}
 
Example 24
Source Project: gdx-texture-packer-gui   Source File: MainController.java    License: Apache License 2.0 5 votes vote down vote up
private void updateRecentProjects() {
    Array<FileHandle> recentProjects = this.recentProjects.getRecentProjects();
    actorsFileMenu.miOpenRecent.setDisabled(recentProjects.size == 0);
    actorsFileMenu.pmOpenRecent.clear();
    for (final FileHandle file : recentProjects) {
        if (file.equals(getProject().getProjectFile())) continue;

        MenuItem menuItem = new MenuItem(file.nameWithoutExtension());
        menuItem.setShortcut(CommonUtils.ellipsize(file.path(), 72)); // Will use shortcut label to display file path
        menuItem.getShortcutCell().left().expandX();
        menuItem.getLabelCell().expand(false, false).left();
        menuItem.getImageCell().width(0); // Shrink image cell to zero, we don't need it
        menuItem.pack();
        menuItem.addListener(new ChangeListener() {
            @Override
            public void changed(ChangeEvent event, Actor actor) {
                Gdx.app.postRunnable(new Runnable() {
                    @Override
                    public void run() {
                        final ProjectModel project = projectSerializer.loadProject(file);
                        if (project != null) {
                            globalActions.commonDialogs.checkUnsavedChanges(new Runnable() {
                                @Override
                                public void run() {
                                    modelService.setProject(project);
                                }
                            });
                        }
                    }
                });
            }
        });
        actorsFileMenu.pmOpenRecent.addItem(menuItem);
    }
}
 
Example 25
Source Project: talos   Source File: PolylineModuleWrapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configureSlots() {
    defaultRegion = new TextureRegion(new Texture(Gdx.files.internal("fire.png")));

    addInputSlot("offset",  PolylineModule.OFFSET);
    addInputSlot("thickness",  PolylineModule.THICKNESS);
    addInputSlot("color",  PolylineModule.COLOR);
    addInputSlot("transparency",  PolylineModule.TRANSPARENCY);

    addInputSlot("left tangent",  PolylineModule.LEFT_TANGENT);
    addInputSlot("right tangent",  PolylineModule.RIGHT_TANGENT);

    interpolationPoints = new IntegerInputWidget("interpolation points", getSkin());
    interpolationPoints.setValue(0);
    leftWrapper.add(interpolationPoints).left().expandX();

    interpolationPoints.setListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            module.setInterpolationPoints(interpolationPoints.getValue());
        }
    });

    dropWidget = new TextureDropWidget<AbstractModule>(defaultRegion, getSkin());
    rightWrapper.add(dropWidget).size(50).right().row();

    rightWrapper.add().growY().row();
    addOutputSlot("output", PolylineModule.OUTPUT);
}
 
Example 26
Source Project: talos   Source File: NinePatchModuleWrapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configureSlots () {
    addInputSlot("input",  NinePatchModule.INPUT);
    addOutputSlot("output", NinePatchModule.OUTPUT);

    leftSplit = new IntegerInputWidget("left split", getSkin());
    leftWrapper.add(leftSplit).left().expandX().padLeft(3).row();

    rightSplit = new IntegerInputWidget("right split", getSkin(), Align.right);
    rightWrapper.add(rightSplit).right().expandX().padRight(3).row();

    topSplit = new IntegerInputWidget("top split", getSkin());
    leftWrapper.add(topSplit).left().expandX().padLeft(3);

    bottomSplit = new IntegerInputWidget("bottom split", getSkin(), Align.right);
    rightWrapper.add(bottomSplit).right().expandX().padRight(3);

    ChangeListener changeListener = new ChangeListener() {
        @Override
        public void changed (ChangeEvent event, Actor actor) {
            updateValues();
        }
    };

    leftSplit.addListener(changeListener);
    rightSplit.addListener(changeListener);
    topSplit.addListener(changeListener);
    rightWrapper.addListener(changeListener);
}
 
Example 27
Source Project: gdx-gltf   Source File: GLTFDemoUI.java    License: Apache License 2.0 5 votes vote down vote up
protected void setNode(String nodeID) {
	nodeTable.clearChildren();
	selectedNode = null;
	if(nodeID == null || nodeID.isEmpty()){
		showHideOtherNodes(false);
		return;
	}
	
	final Node node = nodeMap.get(nodeID);
	
	selectedNode = node;
	
	showHideOtherNodes(btNodeExclusive.isChecked());
	
	if(node instanceof NodePlus){
		final NodePlus np = (NodePlus)node;
		if(np.weights != null){
			WeightsUI weightEditor = new WeightsUI(getSkin(), np.weights, np.morphTargetNames);
			nodeTable.add("Morph Targets").row();
			nodeTable.add(weightEditor);
			weightEditor.addListener(new ChangeListener() {
				@Override
				public void changed(ChangeEvent event, Actor actor) {
					for(NodePart part : np.parts){
						NodePartPlus npp = (NodePartPlus)part;
						if(npp.morphTargets != null){
							npp.morphTargets.set(np.weights);
						}
					}
				}
			});
			
		}
	}
}
 
Example 28
Source Project: gdx-gltf   Source File: GLTFDemoUI.java    License: Apache License 2.0 5 votes vote down vote up
private void addMaterialTextureSwitch(String name, final Material material, long type){
	final PBRTextureAttribute attribute = material.get(PBRTextureAttribute.class, type);
	if(attribute != null){
		final TextButton bt = new TextButton(name, getSkin(), "toggle");
		bt.setChecked(true);
		materialTable.add(bt);
		
		Image pict = new Image(attribute.textureDescription.texture);
		
		pict.setScaling(Scaling.fit);
		
		materialTable.add(pict).size(64);
		
		materialTable.row();
		
		bt.addListener(new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {
				if(bt.isChecked()){
					material.set(attribute);
				}else{
					material.remove(attribute.type);
				}
			}
		});
	}
	
}
 
Example 29
Source Project: gdx-gltf   Source File: CollapsableUI.java    License: 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());
		}
	});
}
 
Example 30
Source Project: vis-ui   Source File: Spinner.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Called by {@link SpinnerModel}. Notifies when underlying model value has changed and spinner text field must updated.
 * 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 fireEvent) {
	VisValidatableTextField textField = getTextField();
	int cursor = textField.getCursorPosition();
	textField.setCursorPosition(0);
	textField.setText(model.getText());
	textField.setCursorPosition(cursor);

	if (fireEvent) {
		ChangeListener.ChangeEvent changeEvent = Pools.obtain(ChangeListener.ChangeEvent.class);
		fire(changeEvent);
		Pools.free(changeEvent);
	}
}