Slick Forums
http://slick.ninjacave.com/forum/

Issue with relative position of children widgets
http://slick.ninjacave.com/forum/viewtopic.php?f=18&t=6739
Page 1 of 1

Author:  Cartman34 [ Sat Oct 05, 2013 6:36 am ]
Post subject:  Issue with relative position of children widgets

Hi,

I got some trouble by positioning children of my EditPanel class (a simple Widget), the children elements are positioned in an absolute way (relative to root pane, the window...).
This problem seems to occur with all children of this panel, i have a Label and a TabbedPanel in it, I will keep only the Label for demos.

So, i'm doing:
Code:
public class EditPanel extends Widget {

   private final Label cellInfosLabel;

   public EditPanel() {
      super();
      setTheme("panel");
      
      cellInfosLabel = new Label("No selection");
      add(cellInfosLabel);
   }
   @Override
   protected void layout() {
      super.layout();
      setInnerSize(250, 627);// 640 - 10 - 3 ??
      
      cellInfosLabel.setSize(getInnerWidth(), getInnerHeight());
      cellInfosLabel.setPosition(30, -220);

   }
}

I'm using the layout() method to resize element and to set its position...

Which is stupid I already had this issue with my map grid but i'm unable to remember how i resolved it.

Thank you in advance for your help.

EDIT: I made a mistake, The TabbedPane is positioned in an absolute way but for the Label, it's more complex, X is absolute but Y is relative to an illogic point (the middle ? not quite)
I added the screen of the Label and the Tabbedpane, you could see there is another issue with the Tabbox of the TabbedPane...

I think i'm doing something wrong...

Attachments:
File comment: Positioning TabbedPane in Edit Panel (the grey block).
scr_tdgame_IssuePositionTabbedPane.jpg
scr_tdgame_IssuePositionTabbedPane.jpg [ 173.31 KiB | Viewed 5198 times ]
File comment: Positioning Label in Edit Panel (the grey block).
scr_tdgame_IssuePositionLabel.jpg
scr_tdgame_IssuePositionLabel.jpg [ 173.19 KiB | Viewed 5199 times ]

Author:  MatthiasM [ Sun Oct 06, 2013 7:17 am ]
Post subject:  Re: Issue with relative position of children widgets

Widget positions are specified relative to the root (when the root is GUI it is absolute coordinates). hat is why layout() should use getX() or getInnerX() as a reference.
Adding a Widget to another Widget changes the coordinate system of the added Widget.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/