Couple of issues found with Window and Panel

Hello all,

I just wanted to say I’m really enjoying using this, but ran into a couple of errors.

  1. When I resize window to my screen size the title bar gets placed as shown in the picture here.

  2. When using setIsMovable(false); the corners of the window and panel are still able to be dragged and moved, this is all 4 corners dragging, as well as resizing the application vertically(haven’t gotten horizontally to work).

Is a window/panel the correct parent for buttons and such?

Thank you!

I forgot to post my code, so since I cannot edit…

[java]Screen screen = new Screen(this);
screen.initialize();
guiNode.addControl(screen);
Window panel = new Window(screen, new Vector2f(0,0));
panel.setDimensions(settings.getWidth(), settings.getHeight());
panel.setWindowIsMovable(false);
screen.addElement(panel);[/java]

I can also resize horizontally as well!

@KonradZuse said: I forgot to post my code, so since I cannot edit....

[java]Screen screen = new Screen(this);
screen.initialize();
guiNode.addControl(screen);
Window panel = new Window(screen, new Vector2f(0,0));
panel.setDimensions(settings.getWidth(), settings.getHeight());
panel.setWindowIsMovable(false);
screen.addElement(panel);[/java]

I can also resize horizontally as well!

Do me a favor and try adding the window prior to resizing it. Though, this shouldn’t be an issue. Out of curosity, what OS are you using?

For the other issue, is the window being dragged? Or is it resizing when you grab on of the corners? If it is resizing, just set win.setIsResizable(false);

You can add buttons or other controls to anything you like. The screen directly, a window, a panel, another element, a button (though, I’ve never tried adding a button to another button… it should work fine).

EDIT: Oh… I see an issue in the code you posted…

no need to call screen.initialize() anymore and… you need to add the screen as a control to the gui node:

[java]
guiNode.addControl(screen);
[/java]

EDIT 2: ignore the last bit… my eyes are apparently playing trikcs on me.

Also, try adding the dimensions as a parameter f the constructor of the window:

[java]
Window win = new Window(screen, new Vector2f(position), new Vector2f(dimensions));
[/java]

And see if that fixes the issue.

@t0neg0d said: Do me a favor and try adding the window prior to resizing it. Though, this shouldn't be an issue. Out of curosity, what OS are you using?

For the other issue, is the window being dragged? Or is it resizing when you grab on of the corners? If it is resizing, just set win.setIsResizable(false);

You can add buttons or other controls to anything you like. The screen directly, a window, a panel, another element, a button (though, I’ve never tried adding a button to another button… it should work fine).

EDIT: Oh… I see an issue in the code you posted…

no need to call screen.initialize() anymore and… you need to add the screen as a control to the gui node:

[java]
guiNode.addControl(screen);
[/java]

EDIT 2: ignore the last bit… my eyes are apparently playing trikcs on me.

Okay so here’s how we stand.

  1. I apparently didn’t realize what I was doing, so I guess it wasn’t moving, just re sizing itself (If I drag it all to one side it doesn’t disappear now but I thought it did before, weird…[yay fairies…])?

  2. setting the resize off works, but I noticed that when I add it to the screen beforehand another weird issue occurs.

[java] Window panel = new Window(screen, new Vector2f(0,0));
screen.addElement(panel);
panel.setDimensions(settings.getWidth(), settings.getHeight());
panel.setIsMovable(false);
panel.setIsResizable(false);
// screen.addElement(panel);[/java]

  1. When setting it in the constructor it works.

    [java] Window panel = new Window(screen, new Vector2f(0,0), new Vector2f(settings.getWidth(), settings.getHeight()));
    // screen.addElement(panel);
    // panel.setDimensions();
    panel.setIsMovable(false);
    panel.setIsResizable(false);
    screen.addElement(panel);[/java]

  2. I have another issue now where the button text isnt’ centered after I increase size.

[java]

    ButtonAdapter register = new ButtonAdapter(screen, new Vector2f((settings.getWidth()/2f), settings.getHeight() * 0.30f), new Vector2f(200,80))
    {
       @Override
       public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled)
       {
         
       }
       
    };
    register.setPosition(register.getPosition().x-register.getWidth()/2f, register.getPosition().y);
    register.setText("Open Plan");
    register.setFontSize(40);
    register.setTextPosition(register.getWidth()/2f, register.getHeight()/2f);[/java]

  1. OS is Windows 7 64-Bit, and initialize didn’t do anything regardless, but I did comment it out, so thank!

  2. Thanks for the awesome GUI regardless of the issues, I’m enjoying it so much more than nifty, and wish I didn’t spend the last few days messing with it… Oh wells :P.

EDIT:

  1. After trying to see if anything worked it seems as if [java]setTextPosition[/java] doesn’t do anything. After about font size 25 it starts to shift downwards.

I also tried

[java] register.setPosition(register.getPosition().x-register.getWidth()/2f, register.getPosition().y);
register.setText(“Register”);
register.setFontSize(35);
register.setTextVAlign(BitmapFont.VAlign.Center);
// register.setTextPosition(register.getWidth()/2f, (register.getHeight()/2f) + register.getFontSize());
// register.sizeToContent();[/java]

Setting the text align to “center” it moves the text past the button…

regular align doesn’t do anything, and there is no “horizontal Align” it’s just Align?

  1. For some reason clicking the title bar of my window allows it to be moved, everything else is off http://i1139.photobucket.com/albums/n551/ThekonradZuse/ToneIssue5_zps654f7c4a.jpg I guess I wasn’t going crazy :P.

Anything with children you should fill before attaching.

@KonradZuse
I somehow missed this post… and I’m REALLLLLY sorry about that.

Can you do me a favor and post the entire java file where you are setting all this up so I can see if I spot where/how/what/if there is an issue.

I know the documentation is somewhat (or more than somewhat) out of date and could be the reason all this is happening.

In the meantime, try running this test and see if all works ok:

[java]
import com.jme3.app.SimpleApplication;
import com.jme3.input.event.MouseButtonEvent;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector4f;
import com.jme3.system.AppSettings;
import java.util.ArrayList;
import java.util.List;

import tonegod.gui.controls.buttons.ButtonAdapter;
import tonegod.gui.controls.extras.Indicator;
import tonegod.gui.controls.windows.Window;
import tonegod.gui.core.Screen;

public class GUIComponentTest_Indicator extends SimpleApplication {
private static GUIComponentTest_Indicator app;
private Screen screen;
public int winCount = 0;
public int indicatorCount = 0;
private final List<Indicator> indicatorMap = new ArrayList();

public static void main(final String[] args) {
    app = new GUIComponentTest_Indicator();
    final AppSettings settings = new AppSettings(true);
    settings.setWidth(800);
    settings.setHeight(600);
    app.setSettings(settings);
    app.setShowSettings(false);
    app.setPauseOnLostFocus(false);
    app.start();
}

@Override
public void simpleInitApp() {
	flyCam.setEnabled(false);
    screen = new Screen(this);
    guiNode.addControl(screen);

    final Window win = new Window(screen, "win", new Vector2f(250, 15));
    final ButtonAdapter makeWindow = new ButtonAdapter(screen, "Btn1", new Vector2f(15, 55)) {
		{
			setText("New window");
		}
		@Override
		public void onButtonMouseLeftUp(final MouseButtonEvent evt, final boolean toggled) {
			createNewWindow("New Window " + winCount);
		}
	};

    win.addChild(makeWindow);
    screen.addElement(win);
}

@Override
public void simpleUpdate(final float tpf) {
	for (final Indicator indicator : indicatorMap) {
		indicator.setCurrentValue(((indicator.getCurrentValue() + tpf) % 1f));
	}
}

public final void createNewWindow(final String someWindowTitle) {
	final Window nWin = new Window(screen, "Window" + winCount,
			new Vector2f((screen.getWidth()/2)-175,
				(screen.getHeight() / 2) - 100));
	nWin.setWindowTitle(someWindowTitle);
	nWin.setToolTipText(nWin.getUID());

	final int rows = 3;
	for (int i = 0; i &lt; rows; i++) {
		for (int j = 0; j &lt; i + 1; j++) {
			final Vector2f dimension = new Vector2f(140, 40);
			final Vector2f position = new Vector2f(
					10 + (j * (dimension.getX() + 1)),
					40 + (i * (dimension.getY() + 1)));
			final Indicator ind = new Indicator(screen, position, dimension,
					Indicator.Orientation.HORIZONTAL) {
				@Override
				public void onChange(float currentValue, float currentPercentage) {  }
			};
			ColorRGBA color = ColorRGBA.randomColor();
			color.a = 1f;
			ind.setIndicatorColor(color);
			ind.setAlphaMap("tonegod/gui/style/def/Common/Extras/indicator_am_x.png");
			ind.setIndicatorPadding(new Vector4f(4,4,4,4));
			ind.setMaxValue(1f);
			ind.setDisplayPercentage();

			indicatorMap.add(ind);
			indicatorCount++;
			nWin.addChild(ind);
		}
	}
	nWin.setControlClippingLayer(nWin);
	screen.addElement(nWin);
	winCount++;
}

}
[/java]