Improve Items Tree UI
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 191 B After Width: | Height: | Size: 6.9 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 6.8 KiB |
+22
-22
@@ -90,7 +90,7 @@ animation-up
|
||||
index: -1
|
||||
border
|
||||
rotate: false
|
||||
xy: 712, 32
|
||||
xy: 656, 8
|
||||
size: 5, 5
|
||||
split: 2, 2, 2, 2
|
||||
pad: 1, 1, 1, 1
|
||||
@@ -296,7 +296,7 @@ color-picker-bar-selector
|
||||
index: -1
|
||||
color-picker-cross
|
||||
rotate: false
|
||||
xy: 674, 3
|
||||
xy: 663, 8
|
||||
size: 5, 5
|
||||
orig: 5, 5
|
||||
offset: 0, 0
|
||||
@@ -850,7 +850,7 @@ menu-bg-up
|
||||
index: -1
|
||||
menu-item
|
||||
rotate: false
|
||||
xy: 887, 47
|
||||
xy: 674, 54
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
@@ -858,7 +858,7 @@ menu-item
|
||||
index: -1
|
||||
menu-item-disabled
|
||||
rotate: false
|
||||
xy: 674, 59
|
||||
xy: 648, 2
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
@@ -866,7 +866,7 @@ menu-item-disabled
|
||||
index: -1
|
||||
menu-item-down
|
||||
rotate: false
|
||||
xy: 674, 54
|
||||
xy: 653, 2
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
@@ -874,7 +874,7 @@ menu-item-down
|
||||
index: -1
|
||||
menu-item-over
|
||||
rotate: false
|
||||
xy: 442, 9
|
||||
xy: 674, 59
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
@@ -889,7 +889,7 @@ origin-anchor
|
||||
index: -1
|
||||
padded-list-selection
|
||||
rotate: false
|
||||
xy: 658, 10
|
||||
xy: 692, 34
|
||||
size: 10, 3
|
||||
split: 4, 4, 1, 1
|
||||
pad: 4, 4, 0, 0
|
||||
@@ -973,7 +973,7 @@ scroll-horizontal
|
||||
index: -1
|
||||
scroll-knob-horizontal
|
||||
rotate: false
|
||||
xy: 666, 3
|
||||
xy: 929, 57
|
||||
size: 6, 5
|
||||
split: 2, 2, 0, 5
|
||||
pad: -1, -1, 2, 2
|
||||
@@ -1025,7 +1025,7 @@ selection
|
||||
index: -1
|
||||
selection-anchor
|
||||
rotate: false
|
||||
xy: 880, 52
|
||||
xy: 908, 53
|
||||
size: 9, 9
|
||||
orig: 9, 9
|
||||
offset: 0, 0
|
||||
@@ -1130,14 +1130,14 @@ splitpane-over
|
||||
index: -1
|
||||
splitpane-vertical
|
||||
rotate: false
|
||||
xy: 681, 4
|
||||
xy: 658, 2
|
||||
size: 1, 4
|
||||
orig: 1, 4
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
splitpane-vertical-over
|
||||
rotate: false
|
||||
xy: 684, 2
|
||||
xy: 661, 2
|
||||
size: 1, 4
|
||||
orig: 1, 4
|
||||
offset: 0, 0
|
||||
@@ -1239,7 +1239,7 @@ thumbnail-over
|
||||
index: -1
|
||||
tint-border
|
||||
rotate: false
|
||||
xy: 658, 2
|
||||
xy: 648, 7
|
||||
size: 6, 6
|
||||
split: 2, 2, 2, 2
|
||||
orig: 6, 6
|
||||
@@ -1320,7 +1320,7 @@ toolbar-normal
|
||||
index: -1
|
||||
toolbar-over
|
||||
rotate: false
|
||||
xy: 648, 4
|
||||
xy: 919, 53
|
||||
size: 8, 9
|
||||
split: 2, 2, 3, 3
|
||||
orig: 8, 9
|
||||
@@ -1328,7 +1328,7 @@ toolbar-over
|
||||
index: -1
|
||||
tooltip-bg
|
||||
rotate: false
|
||||
xy: 684, 8
|
||||
xy: 704, 34
|
||||
size: 3, 3
|
||||
split: 1, 1, 1, 1
|
||||
orig: 3, 3
|
||||
@@ -1343,21 +1343,21 @@ touchpad-knob
|
||||
index: -1
|
||||
tree-minus
|
||||
rotate: false
|
||||
xy: 692, 29
|
||||
size: 8, 8
|
||||
orig: 8, 8
|
||||
xy: 880, 49
|
||||
size: 12, 12
|
||||
orig: 12, 12
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
tree-plus
|
||||
rotate: false
|
||||
xy: 702, 29
|
||||
size: 8, 8
|
||||
orig: 8, 8
|
||||
xy: 894, 50
|
||||
size: 12, 12
|
||||
orig: 12, 12
|
||||
offset: 0, 0
|
||||
index: -1
|
||||
tree-selection
|
||||
rotate: false
|
||||
xy: 880, 45
|
||||
xy: 937, 57
|
||||
size: 5, 5
|
||||
split: 2, 2, 2, 2
|
||||
pad: 1, 1, 1, 1
|
||||
@@ -1450,7 +1450,7 @@ vis-red
|
||||
index: -1
|
||||
white
|
||||
rotate: false
|
||||
xy: 690, 24
|
||||
xy: 944, 59
|
||||
size: 3, 3
|
||||
orig: 3, 3
|
||||
offset: 0, 0
|
||||
|
||||
@@ -229,6 +229,10 @@
|
||||
font: default-font,
|
||||
fontColor: white
|
||||
},
|
||||
greyed: {
|
||||
font: default-font,
|
||||
fontColor: menuitem-grey
|
||||
},
|
||||
small: {
|
||||
font: small-font,
|
||||
fontColor: white
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
@@ -24,8 +24,10 @@ import com.badlogic.ashley.core.Family;
|
||||
import com.badlogic.ashley.core.PooledEngine;
|
||||
import com.badlogic.ashley.utils.ImmutableArray;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import com.kotcrab.vis.ui.VisUI;
|
||||
import games.rednblack.editor.renderer.SceneLoader;
|
||||
import games.rednblack.editor.renderer.components.*;
|
||||
import games.rednblack.editor.renderer.components.light.LightBodyComponent;
|
||||
@@ -53,31 +55,19 @@ public class EntityUtils {
|
||||
return mainItemComponent.itemIdentifier;
|
||||
} else {
|
||||
int type = EntityUtils.getType(entity);
|
||||
switch (type) {
|
||||
case EntityFactory.IMAGE_TYPE:
|
||||
return "Image";
|
||||
case EntityFactory.NINE_PATCH:
|
||||
return "9Patch Image";
|
||||
case EntityFactory.LABEL_TYPE:
|
||||
return "Label";
|
||||
case EntityFactory.COMPOSITE_TYPE:
|
||||
return "Composite Item";
|
||||
case EntityFactory.PARTICLE_TYPE:
|
||||
return "Particle Effect";
|
||||
case EntityFactory.LIGHT_TYPE:
|
||||
return "Light";
|
||||
case EntityFactory.SPINE_TYPE:
|
||||
return "Spine";
|
||||
case EntityFactory.SPRITE_TYPE:
|
||||
return "Sprite Animation";
|
||||
case EntityFactory.COLOR_PRIMITIVE:
|
||||
return "Primitive";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
if (EntityFactory.itemTypeMap.get(type) != null)
|
||||
return EntityFactory.itemTypeNameMap.get(EntityFactory.itemTypeMap.get(type));
|
||||
else
|
||||
return EntityFactory.itemTypeNameMap.get(EntityFactory.ItemType.unknown);
|
||||
}
|
||||
}
|
||||
|
||||
public static Drawable getItemIcon(Entity entity) {
|
||||
int type = EntityUtils.getType(entity);
|
||||
String icon = EntityFactory.itemTypeIconMap.get(EntityFactory.itemTypeMap.get(type));
|
||||
return VisUI.getSkin().getDrawable(icon);
|
||||
}
|
||||
|
||||
public static Integer getEntityId(Entity entity) {
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(entity, MainItemComponent.class);
|
||||
return mainItemComponent.uniqueId;
|
||||
|
||||
@@ -95,7 +95,7 @@ public class UIMainTable extends VisTable {
|
||||
//TreeView
|
||||
UIItemsTreeBoxMediator uiItemsTreeBoxMediator = facade.retrieveMediator(UIItemsTreeBoxMediator.NAME);
|
||||
UIItemsTreeBox itemsBox = uiItemsTreeBoxMediator.getViewComponent();
|
||||
leftBoxesPanel.add(itemsBox).expandX().fillX().maxHeight(600).top();
|
||||
leftBoxesPanel.add(itemsBox).width(184).fillX().maxHeight(600).top();
|
||||
middleTable.add(leftBoxesPanel).top().left().expand().padTop(15).padLeft(16);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Set;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Cell;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Tree;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.Selection;
|
||||
@@ -34,6 +35,7 @@ import com.kotcrab.vis.ui.widget.VisTree;
|
||||
import games.rednblack.editor.HyperLap2DFacade;
|
||||
import games.rednblack.editor.renderer.components.MainItemComponent;
|
||||
import games.rednblack.editor.renderer.components.NodeComponent;
|
||||
import games.rednblack.editor.renderer.components.ParentNodeComponent;
|
||||
import games.rednblack.editor.renderer.components.ZIndexComponent;
|
||||
import games.rednblack.editor.renderer.factory.EntityFactory;
|
||||
import games.rednblack.editor.renderer.utils.ComponentRetriever;
|
||||
@@ -53,7 +55,7 @@ public class UIItemsTreeBox extends UICollapsibleBox {
|
||||
Sandbox sandbox;
|
||||
|
||||
public UIItemsTreeBox() {
|
||||
super("Items Tree", 166);
|
||||
super("Items Tree", 180);
|
||||
setMovable(false);
|
||||
facade = HyperLap2DFacade.getInstance();
|
||||
treeTable = new VisTable();
|
||||
@@ -70,7 +72,7 @@ public class UIItemsTreeBox extends UICollapsibleBox {
|
||||
tree = new VisTree<>();
|
||||
VisScrollPane scroller = StandardWidgetsFactory.createScrollPane(tree);
|
||||
scroller.setFlickScroll(false);
|
||||
treeTable.add(scroller).width(166).maxHeight(570);
|
||||
treeTable.add(scroller).width(177).maxHeight(570);
|
||||
//
|
||||
rootTreeNode = addTreeRoot(rootScene, null);
|
||||
rootTreeNode.setExpanded(true);
|
||||
@@ -107,11 +109,39 @@ public class UIItemsTreeBox extends UICollapsibleBox {
|
||||
}
|
||||
|
||||
private UIItemsTreeNode addTreeNode(Entity item, UIItemsTreeNode parentNode) {
|
||||
UIItemsTreeNode node = new UIItemsTreeNode(new VisLabel(EntityUtils.getItemName(item)));
|
||||
String name, style;
|
||||
ParentNodeComponent parentNodeComponent = ComponentRetriever.get(item, ParentNodeComponent.class);
|
||||
MainItemComponent mainItemComponent = ComponentRetriever.get(item, MainItemComponent.class);
|
||||
|
||||
if (parentNodeComponent == null) {
|
||||
name = Sandbox.getInstance().sceneControl.getCurrentSceneVO().sceneName;
|
||||
style = "default";
|
||||
} else if (mainItemComponent.itemIdentifier != null && !mainItemComponent.itemIdentifier.isEmpty()) {
|
||||
name = mainItemComponent.itemIdentifier;
|
||||
style = "default";
|
||||
} else {
|
||||
style = "greyed";
|
||||
int type = EntityUtils.getType(item);
|
||||
if (EntityFactory.itemTypeMap.get(type) != null)
|
||||
name = EntityFactory.itemTypeNameMap.get(EntityFactory.itemTypeMap.get(type));
|
||||
else
|
||||
name = EntityFactory.itemTypeNameMap.get(EntityFactory.ItemType.unknown);
|
||||
}
|
||||
|
||||
VisTable label = new VisTable();
|
||||
Cell<VisLabel> lblCell = label.add(new VisLabel(name, style));
|
||||
UIItemsTreeNode node = new UIItemsTreeNode(label);
|
||||
ZIndexComponent zIndexComponent = ComponentRetriever.get(item, ZIndexComponent.class);
|
||||
|
||||
node.setValue(new UIItemsTreeValue(mainItemComponent.uniqueId, zIndexComponent.getGlobalZIndex()));
|
||||
if (mainItemComponent.entityType != EntityFactory.COMPOSITE_TYPE)
|
||||
lblCell.padBottom(4);
|
||||
else {
|
||||
lblCell.padTop(4);
|
||||
lblCell.padLeft(3);
|
||||
lblCell.padBottom(4);
|
||||
}
|
||||
node.setIcon(EntityUtils.getItemIcon(item));
|
||||
if (parentNode != null) {
|
||||
parentNode.add(node);
|
||||
} else {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package games.rednblack.editor.view.ui.box;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Tree;
|
||||
import com.kotcrab.vis.ui.widget.VisLabel;
|
||||
import com.kotcrab.vis.ui.widget.VisTable;
|
||||
|
||||
public class UIItemsTreeNode extends Tree.Node<UIItemsTreeNode, UIItemsTreeValue, VisLabel> {
|
||||
public class UIItemsTreeNode extends Tree.Node<UIItemsTreeNode, UIItemsTreeValue, VisTable> {
|
||||
|
||||
public UIItemsTreeNode(VisLabel actor) {
|
||||
public UIItemsTreeNode(VisTable actor) {
|
||||
super(actor);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-46
@@ -28,10 +28,13 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Scaling;
|
||||
import com.kotcrab.vis.ui.VisUI;
|
||||
import com.kotcrab.vis.ui.util.Validators;
|
||||
import com.kotcrab.vis.ui.widget.*;
|
||||
import games.rednblack.editor.event.ButtonToNotificationListener;
|
||||
import games.rednblack.editor.renderer.factory.EntityFactory;
|
||||
import games.rednblack.editor.renderer.factory.EntityFactory.ItemType;
|
||||
import games.rednblack.h2d.common.view.ui.widget.TintButton;
|
||||
import games.rednblack.editor.event.CheckBoxChangeListener;
|
||||
import games.rednblack.editor.event.KeyboardListener;
|
||||
@@ -50,22 +53,6 @@ public class UIBasicItemProperties extends UIItemProperties {
|
||||
public static final String ADD_COMPONENT_BUTTON_CLICKED = prefix + "ADD_COMPONENT_BUTTON_CLICKED";
|
||||
public static final String LINKING_CHANGED = prefix + ".LINKING_CHANGED";
|
||||
|
||||
public enum ItemType {
|
||||
multiple,
|
||||
composite,
|
||||
texture,
|
||||
spriteAnimation,
|
||||
spineAnimation,
|
||||
particle,
|
||||
text,
|
||||
light,
|
||||
patchImage,
|
||||
primitive
|
||||
}
|
||||
|
||||
private HashMap<ItemType, String> itemTypeIconMap = new HashMap<>();
|
||||
private HashMap<ItemType, String> itemTypeNameMap = new HashMap<>();
|
||||
|
||||
private Image itemTypeIcon;
|
||||
private VisLabel itemType;
|
||||
|
||||
@@ -93,10 +80,6 @@ public class UIBasicItemProperties extends UIItemProperties {
|
||||
private VisTextButton addComponentButton;
|
||||
|
||||
public UIBasicItemProperties() {
|
||||
super();
|
||||
|
||||
initMaps();
|
||||
|
||||
Validators.FloatValidator floatValidator = new Validators.FloatValidator();
|
||||
|
||||
itemType = new VisLabel("");
|
||||
@@ -207,8 +190,9 @@ public class UIBasicItemProperties extends UIItemProperties {
|
||||
}
|
||||
|
||||
public void setItemType(ItemType type, int itemUniqueId) {
|
||||
itemType.setText(itemTypeNameMap.get(type) + " ("+itemUniqueId+")");
|
||||
itemTypeIcon.setDrawable(VisUI.getSkin().getDrawable(itemTypeIconMap.get(type)));
|
||||
itemType.setText(EntityFactory.itemTypeNameMap.get(type) + " ("+itemUniqueId+")");
|
||||
itemTypeIcon.setDrawable(VisUI.getSkin().getDrawable(EntityFactory.itemTypeIconMap.get(type)));
|
||||
itemTypeIcon.setScaling(Scaling.fit);
|
||||
itemTypeIcon.setWidth(22);
|
||||
}
|
||||
|
||||
@@ -342,28 +326,4 @@ public class UIBasicItemProperties extends UIItemProperties {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initMaps() {
|
||||
itemTypeNameMap.put(ItemType.multiple, "Multiple Selection");
|
||||
itemTypeNameMap.put(ItemType.composite, "Composite item");
|
||||
itemTypeNameMap.put(ItemType.particle, "Particle Effect");
|
||||
itemTypeNameMap.put(ItemType.text, "Text");
|
||||
itemTypeNameMap.put(ItemType.texture, "Texture");
|
||||
itemTypeNameMap.put(ItemType.patchImage, "9Patch");
|
||||
itemTypeNameMap.put(ItemType.light, "Light");
|
||||
itemTypeNameMap.put(ItemType.spineAnimation, "Spine animation");
|
||||
itemTypeNameMap.put(ItemType.spriteAnimation, "Sprite Animation");
|
||||
itemTypeNameMap.put(ItemType.primitive, "Primitive");
|
||||
|
||||
itemTypeIconMap.put(ItemType.multiple, "icon-multiple");
|
||||
itemTypeIconMap.put(ItemType.composite, "icon-composite");
|
||||
itemTypeIconMap.put(ItemType.particle, "icon-particle-white");
|
||||
itemTypeIconMap.put(ItemType.text, "icon-label");
|
||||
itemTypeIconMap.put(ItemType.texture, "icon-image");
|
||||
itemTypeIconMap.put(ItemType.patchImage, "icon-image");
|
||||
itemTypeIconMap.put(ItemType.light, "icon-particle-white");
|
||||
itemTypeIconMap.put(ItemType.spineAnimation, "icon-spine");
|
||||
itemTypeIconMap.put(ItemType.spriteAnimation, "icon-animation");
|
||||
itemTypeIconMap.put(ItemType.primitive, "icon-image");
|
||||
}
|
||||
}
|
||||
|
||||
+1
-13
@@ -61,8 +61,6 @@ public class UIBasicItemPropertiesMediator extends UIItemPropertiesMediator<Enti
|
||||
private DimensionsComponent dimensionComponent;
|
||||
private TintComponent tintComponent;
|
||||
|
||||
final private HashMap<String, UIBasicItemProperties.ItemType> itemTypeMap = new HashMap<>();
|
||||
|
||||
public static final String POLYGON_COMPONENT_KEY = "Polygon";
|
||||
public static final String PHYSICS_COMPONENT_KEY = "Physics";
|
||||
public static final String SHADER_COMPONENT_KEY = "Shader";
|
||||
@@ -77,16 +75,6 @@ public class UIBasicItemPropertiesMediator extends UIItemPropertiesMediator<Enti
|
||||
|
||||
@Override
|
||||
public void onRegister() {
|
||||
itemTypeMap.put("ENTITY_"+EntityFactory.COMPOSITE_TYPE, UIBasicItemProperties.ItemType.composite);
|
||||
itemTypeMap.put("ENTITY_"+EntityFactory.IMAGE_TYPE, UIBasicItemProperties.ItemType.texture);
|
||||
itemTypeMap.put("ENTITY_"+EntityFactory.PARTICLE_TYPE, UIBasicItemProperties.ItemType.particle);
|
||||
itemTypeMap.put("ENTITY_"+EntityFactory.LABEL_TYPE, UIBasicItemProperties.ItemType.text);
|
||||
itemTypeMap.put("ENTITY_"+EntityFactory.SPRITE_TYPE, UIBasicItemProperties.ItemType.spriteAnimation);
|
||||
itemTypeMap.put("ENTITY_"+EntityFactory.SPINE_TYPE, UIBasicItemProperties.ItemType.spineAnimation);
|
||||
itemTypeMap.put("ENTITY_"+EntityFactory.LIGHT_TYPE, UIBasicItemProperties.ItemType.light);
|
||||
itemTypeMap.put("ENTITY_"+EntityFactory.NINE_PATCH, UIBasicItemProperties.ItemType.patchImage);
|
||||
itemTypeMap.put("ENTITY_"+EntityFactory.COLOR_PRIMITIVE, UIBasicItemProperties.ItemType.primitive);
|
||||
|
||||
componentClassMap.put(POLYGON_COMPONENT_KEY, PolygonComponent.class);
|
||||
componentClassMap.put(PHYSICS_COMPONENT_KEY, PhysicsBodyComponent.class);
|
||||
componentClassMap.put(SHADER_COMPONENT_KEY, ShaderComponent.class);
|
||||
@@ -190,7 +178,7 @@ public class UIBasicItemPropertiesMediator extends UIItemPropertiesMediator<Enti
|
||||
componentClassMap.remove(TYPING_LABEL_COMPONENT_KEY);
|
||||
}
|
||||
|
||||
viewComponent.setItemType(itemTypeMap.get("ENTITY_" + EntityUtils.getType(entity)), mainItemComponent.uniqueId);
|
||||
viewComponent.setItemType(EntityFactory.itemTypeMap.get(EntityUtils.getType(entity)), mainItemComponent.uniqueId);
|
||||
viewComponent.setIdBoxValue(mainItemComponent.itemIdentifier);
|
||||
viewComponent.setXValue(String.format(Locale.ENGLISH, "%.2f", transformComponent.x));
|
||||
viewComponent.setYValue(String.format(Locale.ENGLISH, "%.2f", transformComponent.y));
|
||||
|
||||
Reference in New Issue
Block a user