You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public static void setPosition(Panel panel, Position position, Camera cam) {
// Apply standard scale
float scale = getStandardScale(cam);
panel.setLocalScale(1.2f * scale);
int width = cam.getWidth();
int height = cam.getHeight();
Vector3f prefSize = new Vector3f(panel.getPreferredSize());
prefSize.multLocal(1.2f * scale);
// Position window to selected gui pos
switch (position) {
case CENTER:
panel.setLocalTranslation((width - prefSize.x) / 2, (height + prefSize.y) / 2, 0);
break;
case RIGHT:
panel.setLocalTranslation((width - prefSize.x), (height + prefSize.y) / 2, 0);
break;
case LEFT:
panel.setLocalTranslation(0, (height + prefSize.y) / 2, 0);
break;
case TOP:
panel.setLocalTranslation((width - prefSize.x) / 2, height, 0);
break;
case BOTTOM:
panel.setLocalTranslation((width - prefSize.x) / 2, prefSize.y, 0);
break;
}
}
Would be something similar useful to add in GuiGlobals ?
The text was updated successfully, but these errors were encountered:
Ali-RS
changed the title
Feature Request: Add a handy method in GuiGlobals to position Panel
Proposal: Add a handy method in GuiGlobals to position Panel
Apr 7, 2019
Ali-RS
changed the title
Proposal: Add a handy method in GuiGlobals to position Panel
Proposal: A handy method in GuiGlobals to position Panel
Apr 7, 2019
I don't think it belongs on GuiGlobals as it isn't really what it's for and also "which camera" becomes a critial question centrally. On something lilke PopupState it probably makes sense because that both is already tied to one camera/root and has a concept of a scaling that is different than Camera by itself. (Useful for resolution independent UIs.)
Wherever the method goes, it doesn't need its own position enum, though. It can just combine HAlignment and VAlignment... which would make that method a bit simpler anyway.
I feel the right way to achieve this would be put the target panel in a fullscreen container and let the layout do the positioning. However, this currently isn't a panacea: from what I gather in Lemur's code, it would prevent you from animating translations (due to a clash in layout vs animation mechanisms both intervening on the panel's local translation).
But I may be wrong, having only a fairly recent interest in Lemur 😛.
I have a GuiManager with a static method to position a Panel on gui (ex: Center, Left, Right, Up, Bottom)
GuiManager.setPosition(panel, GuiManager.Position.CENTER, getApplication().getCamera());
Would be something similar useful to add in GuiGlobals ?
The text was updated successfully, but these errors were encountered: