use of com.talosvfx.talos.editor.widgets.ui.EditableLabel in project talos by rockbite.
the class ModuleWrapperGroup method init.
public void init(Skin skin) {
this.skin = skin;
frameImage = new Image(skin.getDrawable("group_frame"));
frameImage.setColor(44 / 255f, 140 / 255f, 209 / 255f, 1f);
addActor(frameImage);
topHit = new Actor();
topHit.setTouchable(Touchable.enabled);
addActor(topHit);
title = new EditableLabel("GROUP NAME", skin);
addActor(title);
settings = new ImageButton(skin, "settings");
settings.setSize(25, 25);
addActor(settings);
settings.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
final Vector2 vec = new Vector2(Gdx.input.getX(), Gdx.input.getY());
(TalosMain.Instance().UIStage().getStage().getViewport()).unproject(vec);
settingsPopup.showMenu(TalosMain.Instance().UIStage().getStage(), vec.x, vec.y);
}
});
settingsPopup = new PopupMenu();
MenuItem changeColorMenuItem = new MenuItem("Change Color");
MenuItem ungroupMenuItem = new MenuItem("Ungroup");
settingsPopup.addItem(changeColorMenuItem);
settingsPopup.addItem(ungroupMenuItem);
changeColorMenuItem.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
TalosMain.Instance().UIStage().showColorPicker(new ColorPickerAdapter() {
@Override
public void changed(Color newColor) {
super.changed(newColor);
frameImage.setColor(newColor);
}
});
}
});
ungroupMenuItem.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
TalosMain.Instance().NodeStage().moduleBoardWidget.removeGroup(ModuleWrapperGroup.this);
}
});
topHit.addListener(new ClickListener() {
Vector2 tmp = new Vector2();
Vector2 pos = new Vector2();
Vector2 diff = new Vector2();
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
pos.set(x, y);
topHit.localToStageCoordinates(pos);
TalosMain.Instance().NodeStage().moduleBoardWidget.setSelectedWrappers(wrappers);
return true;
}
@Override
public void touchDragged(InputEvent event, float x, float y, int pointer) {
tmp.set(x, y);
topHit.localToStageCoordinates(tmp);
diff.set(tmp).sub(pos);
moveGroupBy(diff.x, diff.y);
pos.set(tmp);
super.touchDragged(event, x, y, pointer);
}
});
setTouchable(Touchable.childrenOnly);
frameImage.setTouchable(Touchable.disabled);
}
use of com.talosvfx.talos.editor.widgets.ui.EditableLabel in project talos by rockbite.
the class ProjectExplorerWidget method traversePath.
private void traversePath(FileHandle path, int currDepth, int maxDepth, FilteredTree.Node node) {
if (path.isDirectory() && currDepth <= maxDepth) {
FileHandle[] list = path.list(fileFilter);
for (int i = 0; i < list.length; i++) {
FileHandle listItemHandle = list[i];
if (!listItemHandle.isDirectory())
continue;
RowWidget widget = new RowWidget(listItemHandle);
EditableLabel label = widget.getLabel();
final FilteredTree.Node newNode = new FilteredTree.Node(listItemHandle.path(), widget);
newNode.setObject(listItemHandle.path());
// newNode.draggable = true; // todo: for later file manipulation
node.add(newNode);
nodes.put(listItemHandle.path(), newNode);
if (listItemHandle.isDirectory()) {
traversePath(list[i], currDepth++, maxDepth, newNode);
}
label.setListener(new EditableLabel.EditableLabelChangeListener() {
@Override
public void changed(String newText) {
String path = (String) newNode.getObject();
FileHandle fileHandle = Gdx.files.absolute(path);
if (newText.isEmpty()) {
newText = fileHandle.nameWithoutExtension();
}
FileHandle newHandle = AssetImporter.renameFile(fileHandle, newText);
notifyRename(fileHandle, newHandle);
}
});
}
}
}
use of com.talosvfx.talos.editor.widgets.ui.EditableLabel in project talos by rockbite.
the class DynamicItemListWidget method makeDataArray.
private Array<ItemData> makeDataArray() {
Array<ItemData> arr = new Array<>();
Array<FilteredTree.Node<Object>> rootNodes = list.getRootNodes();
for (FilteredTree.Node<Object> node : rootNodes) {
EditableLabel label = (EditableLabel) node.getActor();
arr.add(new ItemData(node.name, label.getText()));
}
return arr;
}
use of com.talosvfx.talos.editor.widgets.ui.EditableLabel in project talos by rockbite.
the class DynamicItemListWidget method createNode.
private FilteredTree.Node createNode(ItemData itemData) {
Skin skin = TalosMain.Instance().getSkin();
EditableLabel editableLabel = new EditableLabel(itemData.text, skin);
editableLabel.setListener(new EditableLabel.EditableLabelChangeListener() {
@Override
public void changed(String newText) {
callValueChanged(makeDataArray());
}
});
FilteredTree.Node node = new FilteredTree.Node(itemData.id, editableLabel);
node.draggable = true;
node.draggableInLayerOnly = true;
node.setObject(itemData);
return node;
}
use of com.talosvfx.talos.editor.widgets.ui.EditableLabel in project talos by rockbite.
the class NodeGroup method init.
public void init(Skin skin) {
this.skin = skin;
frameImage = new Image(skin.getDrawable("group_frame"));
frameImage.setColor(44 / 255f, 140 / 255f, 209 / 255f, 1f);
addActor(frameImage);
topHit = new Actor();
topHit.setTouchable(Touchable.enabled);
addActor(topHit);
title = new EditableLabel("GROUP NAME", skin);
addActor(title);
settings = new ImageButton(skin, "settings");
settings.setSize(25, 25);
addActor(settings);
settings.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
final Vector2 vec = new Vector2(Gdx.input.getX(), Gdx.input.getY());
(TalosMain.Instance().UIStage().getStage().getViewport()).unproject(vec);
settingsPopup.showMenu(TalosMain.Instance().UIStage().getStage(), vec.x, vec.y);
}
});
settingsPopup = new PopupMenu();
MenuItem changeColorMenuItem = new MenuItem("Change Color");
MenuItem ungroupMenuItem = new MenuItem("Ungroup");
settingsPopup.addItem(changeColorMenuItem);
settingsPopup.addItem(ungroupMenuItem);
changeColorMenuItem.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
TalosMain.Instance().UIStage().showColorPicker(new ColorPickerAdapter() {
@Override
public void changed(Color newColor) {
super.changed(newColor);
frameImage.setColor(newColor);
}
});
}
});
ungroupMenuItem.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
nodeBoard.removeGroup(NodeGroup.this);
}
});
topHit.addListener(new ClickListener() {
Vector2 tmp = new Vector2();
Vector2 pos = new Vector2();
Vector2 diff = new Vector2();
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
pos.set(x, y);
topHit.localToStageCoordinates(pos);
nodeBoard.setSelectedNodes(nodes);
return true;
}
@Override
public void touchDragged(InputEvent event, float x, float y, int pointer) {
tmp.set(x, y);
topHit.localToStageCoordinates(tmp);
diff.set(tmp).sub(pos);
moveGroupBy(diff.x, diff.y);
pos.set(tmp);
super.touchDragged(event, x, y, pointer);
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
event.cancel();
}
});
setTouchable(Touchable.childrenOnly);
frameImage.setTouchable(Touchable.disabled);
}
Aggregations