use of com.talosvfx.talos.editor.widgets.ui.EditableLabel in project talos by rockbite.
the class NodeWidget method init.
public void init(Skin skin, NodeBoard nodeBoard) {
super.init(skin);
initMaps();
this.nodeBoard = nodeBoard;
Stack mainStack = new Stack();
Table backgroundTable = new Table();
Table contentTable = new Table();
mainStack.add(backgroundTable);
mainStack.add(contentTable);
headerTable = new Table();
Table bodyTable = new Table();
headerTable.setBackground(ColorLibrary.obtainBackground(getSkin(), "node-header", ColorLibrary.BackgroundColor.RED));
bodyTable.setBackground(ColorLibrary.obtainBackground(getSkin(), "node-body", ColorLibrary.BackgroundColor.WHITE));
setBackground(ColorLibrary.obtainBackground(getSkin(), "node-shadow-border", ColorLibrary.BackgroundColor.WHITE));
backgroundTable.add(headerTable).growX().height(32).row();
backgroundTable.add(bodyTable).grow().row();
title = new EditableLabel("Node Title", skin);
headerTable.add(title).expandX().top().left().padLeft(12).height(15);
contentTable.add(widgetContainer).padLeft(16).padRight(16).grow().top().padTop(32);
contentTable.row();
addAdditionalContent(contentTable);
contentTable.add().height(15).row();
contentTable.add().growY();
add(mainStack).width(266).pad(15);
setModal(false);
setMovable(true);
setResizable(false);
addCaptureListener(new InputListener() {
Vector2 tmp = new Vector2();
Vector2 prev = new Vector2();
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
prev.set(x, y);
NodeWidget.this.localToStageCoordinates(prev);
if (nodeBoard != null) {
nodeBoard.nodeClicked(NodeWidget.this);
}
return true;
}
@Override
public void touchDragged(InputEvent event, float x, float y, int pointer) {
tmp.set(x, y);
NodeWidget.this.localToStageCoordinates(tmp);
super.touchDragged(event, x, y, pointer);
if (nodeBoard != null) {
nodeBoard.wrapperMovedBy(NodeWidget.this, tmp.x - prev.x, tmp.y - prev.y);
}
prev.set(tmp);
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
super.touchUp(event, x, y, pointer, button);
if (nodeBoard != null) {
nodeBoard.nodeClickedUp(NodeWidget.this);
}
event.cancel();
}
});
}
use of com.talosvfx.talos.editor.widgets.ui.EditableLabel in project talos by rockbite.
the class DynamicItemListWidget method getSubWidget.
@Override
public Actor getSubWidget() {
Table table = new Table();
Skin skin = TalosMain.Instance().getSkin();
Table topBar = new Table();
topBar.setBackground(ColorLibrary.obtainBackground(getSkin(), ColorLibrary.BackgroundColor.DARK_GRAY));
SquareButton newBtn = new SquareButton(skin, skin.getDrawable("timeline-btn-icon-new"));
SquareButton deleteBtn = new SquareButton(skin, skin.getDrawable("timeline-btn-icon-delete"));
topBar.add().expandX();
topBar.add(newBtn).padRight(2);
topBar.add(deleteBtn).padRight(2);
list = new FilteredTree<>(skin, "modern");
list.draggable = true;
list.setItemListener(new FilteredTree.ItemListener() {
@Override
public void onNodeMove(FilteredTree.Node parentToMoveTo, FilteredTree.Node childThatHasMoved, int indexInParent, int indexOfPayloadInPayloadBefore) {
callValueChanged(makeDataArray());
}
@Override
public void delete(Array<FilteredTree.Node> nodes) {
deleteSelection();
}
});
table.add(list).growX();
table.row();
table.add(topBar).growX().padLeft(-10).padRight(-10);
newBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
ItemData newItemData = new ItemData(defaultItemName, defaultItemName);
Selection<FilteredTree.Node<Object>> selection = list.getSelection();
FilteredTree.Node node;
if (selection.size() > 0) {
int index = 0;
Array<FilteredTree.Node<Object>> rootNodes = list.getRootNodes();
for (index = 0; index < rootNodes.size; index++) {
if (rootNodes.get(index) == selection.first()) {
break;
}
}
node = addNode(newItemData, index + 1);
} else {
node = addNode(newItemData);
}
callValueChanged(makeDataArray());
EditableLabel label = (EditableLabel) node.getActor();
label.setEditMode();
}
});
deleteBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
deleteSelection();
}
});
return table;
}
use of com.talosvfx.talos.editor.widgets.ui.EditableLabel in project talos by rockbite.
the class EditableLabelWidget method getSubWidget.
@Override
public Actor getSubWidget() {
propertyValue = new EditableLabel("", TalosMain.Instance().getSkin());
propertyValue.setAlignment(Align.right);
propertyValue.setListener(new EditableLabel.EditableLabelChangeListener() {
@Override
public void changed(String newText) {
callValueChanged(newText);
}
});
return propertyValue;
}
use of com.talosvfx.talos.editor.widgets.ui.EditableLabel in project talos by rockbite.
the class HierarchyWidget method traverseEntityContainer.
private void traverseEntityContainer(GameObjectContainer entityContainer, FilteredTree.Node node) {
Array<GameObject> gameObjects = entityContainer.getGameObjects();
if (gameObjects == null)
return;
for (int i = 0; i < gameObjects.size; i++) {
final GameObject gameObject = gameObjects.get(i);
EditableLabel editableLabel = new EditableLabel(gameObject.getName(), TalosMain.Instance().getSkin());
FilteredTree.Node newNode = new FilteredTree.Node(gameObject.getName(), editableLabel);
newNode.draggable = true;
node.add(newNode);
editableLabel.setListener(new EditableLabel.EditableLabelChangeListener() {
@Override
public void changed(String newText) {
SceneEditorAddon.get().workspace.changeGOName(gameObject, newText);
}
});
objectMap.put(gameObject.getName(), gameObject);
nodeMap.put(gameObject, newNode);
if (gameObject.getGameObjects() != null) {
traverseEntityContainer(gameObject, newNode);
}
}
}
use of com.talosvfx.talos.editor.widgets.ui.EditableLabel in project talos by rockbite.
the class HierarchyWidget method select.
private void select(GameObject gameObject) {
if (gameObject == null)
return;
tree.getSelection().clear();
tree.getSelection().add(nodeMap.get(gameObject));
Actor actor = nodeMap.get(gameObject).getActor();
if (actor instanceof EditableLabel) {
EditableLabel editableLabel = (EditableLabel) actor;
if (!editableLabel.isEditMode()) {
getStage().setKeyboardFocus(nodeMap.get(gameObject).getActor());
}
} else {
getStage().setKeyboardFocus(nodeMap.get(gameObject).getActor());
}
}
Aggregations