Slick Forums

Discuss the Slick 2D Library
It is currently Sat Dec 14, 2019 10:02 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sat Oct 05, 2013 6:36 am 
Offline

Joined: Fri Sep 27, 2013 7:46 pm
Posts: 7
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 10512 times ]
File comment: Positioning Label in Edit Panel (the grey block).
scr_tdgame_IssuePositionLabel.jpg
scr_tdgame_IssuePositionLabel.jpg [ 173.19 KiB | Viewed 10513 times ]
Top
 Profile  
 
PostPosted: Sun Oct 06, 2013 7:17 am 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1242
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.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group