So I need to rotate back elements inside ListBox, but I have some problems here,
here I am trying to rotate back the first element (elemnts are lemur button) and resize it, but
Rotation works ok, but the button does not move or resize. (Seems like they are being controlled by listbox layout)
see the code :
for (int i = 1; i <= 2; i++) {
Texture icon = getApplication().getAssetManager().loadTexture(new TextureKey("/editor-128.png"));
InventoryItem invItem = new DefaultInventoryItem("Editor", icon);
((Button) invItem.getView()).setColor(ColorRGBA.Red);
//Add items to ListBox
systemTray.getModel().add(invItem);
}
// Grab first element in list box
Button cell = (Button) ((InventoryItem) systemTray.getModel().get(0)).getView();
//Rotation works fine (some how)
cell.getControl(GuiControl.class).getNode().rotate(new Quaternion().fromAngleNormalAxis(FastMath.HALF_PI, Vector3f.UNIT_Z.clone()));
//Transform not work
cell.getControl(GuiControl.class).getNode().move(0, -cell.getPreferredSize().y, 0);
//Setting PreferredSize not work
//swap height and width
cell.getControl(GuiControl.class).setPreferredSize(new Vector3f(cell.getPreferredSize().y, cell.getPreferredSize().x, cell.getPreferredSize().z));
There is another easy solution, to just hardcode the text on icon image using an Image editor, then rotate it 90 degree counter-clockwise. But I don’t like to hardcode it.
Yes, the list controls the placement. I’m not sure how else that could work. If you rotate the children it would need to be in such a way that positioning would still be the same… you can’t move() them because the list box will put them where it thinks they should be. None of the layouts take rotation into account… but neither do they set it.
I assume you’ve done this just by rotating the ListBox?
Given that list box is just a combination of a grid panel and a scroll bar, you might actually have an easier time forking list box and making it use a column based grid (just swap row for column, etc.) then a horizontal scroll bar. It may be that the row click calculation needs to be redone, too, but maybe not. I don’t know how hard it would be to make the base ListBox switchable.
Yes I am giving a HALF_PI rotation to the container which contains the listbox.
I will look into it to see If I can do something.
But it would be better to have this built in to ListBox, you know just for everybody to obey the same standards.
Calling it 3D because going to add 3D elements into cells, also going to add support for D&D stuffs.
Thanks for the help.
btw, this is not clear enough for me, can you please explain what this annotation is doing? @StyleAttribute(value = "visibleItems", lookupDefault = false)
It’s for the styling support. When you create a new element then it usually applies styles. (Yours doesn’t because you never call the super class.) You should take a look at things like ListBox to see how they call the protected super constructor and then apply styles. It will be nicer for you if you ever want to have styling on your container.
That line is specifically saying that when the “visibileStyles” attribute is set in styling that it will call that method to set it.