Slick Forums

Discuss the Slick 2D Library
It is currently Fri May 24, 2013 3:11 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Jan 04, 2012 7:40 pm 
Offline

Joined: Sun Dec 25, 2011 4:51 pm
Posts: 22
Hello, Matthias,

Is there any tutorial about using DialogLayout (with pictures =) )? It is quite confusing, here is a part from LoginDemo.java

Code:
        DialogLayout.Group hLabels = loginPanel.createParallelGroup(lName, lPassword);
        DialogLayout.Group hFields = loginPanel.createParallelGroup(efName, efPassword);
        DialogLayout.Group hBtn = loginPanel.createSequentialGroup()
                .addGap()   // right align the button by using a variable gap
                .addWidget(btnLogin);
       
        loginPanel.setHorizontalGroup(loginPanel.createParallelGroup()
                .addGroup(loginPanel.createSequentialGroup(hLabels, hFields))
                .addGroup(hBtn));
        loginPanel.setVerticalGroup(loginPanel.createSequentialGroup()
                .addGroup(loginPanel.createParallelGroup(lName, efName))
                .addGroup(loginPanel.createParallelGroup(lPassword, efPassword))
                .addWidget(btnLogin));


Why we add to the same group both labels? Further it is even more confusing.

Thanks in advance.


Top
 Profile  
 
PostPosted: Wed Jan 04, 2012 9:00 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1173
DialogLayout uses 2 trees of groups - one which controls the horizontal axis (X) and one which controls the vertical axis (Y).
So you need to add every widget to both trees so that it's X and Y positions and size are defined.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Thu Jan 05, 2012 8:41 pm 
Offline

Joined: Sun Dec 25, 2011 4:51 pm
Posts: 22
Matthias,

How should be done next configuration:
| 0 |
--------
| 0|0 |
--------
| 0|0 |
--------
| 0 0|

4 rows:
- the first row consists of one widget aligned to center
- the second one have two widgets: one aligned to right and has gap in the beggining, the second to the left
- the third row is the clone of second one with different widgets
-the last one has two widgets placd sequencely around right border

Thanks.


Top
 Profile  
 
PostPosted: Thu Jan 05, 2012 10:03 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1173
Ok try this:
Code:
setVerticalGroup(createSequentialGroup()
   .addWidget(widgetRow1)
   .addGroup(createParallelGroup(widgetRow2left, widgetRow2right))
   .addGroup(createParallelGroup(widgetRow3left, widgetRow3right))
   .addGroup(createParallelGroup(widgetRow4left, widgetRow4right)));

Group col1 = createParallelGroup()
   .addGroup(createSequentialGroup().addGap().addWidget(widgetRow2left))
   .addGroup(createSequentialGroup().addGap().addWidget(widgetRow3left));

Group col2 = createParallelGroup()
   .addGroup(createSequentialGroup().addWidget(widgetRow2right).addGap())
   .addGroup(createSequentialGroup().addWidget(widgetRow3right).addGap());

setHorizontalGroup(createParallelGroup()
   .addGroup(createSequentialGroup().addGap().addWidget(widgetRow1).addGap())
   .addGroup(createSequentialGroup().addGroup(col1).addGroup(col2))
   .addGroup(createSequentialGroup().addGap().addWidget(widgetRow4left).addWidget(widgetRow4right)));

(untested code - only typed in forum editor)

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
PostPosted: Fri Jan 06, 2012 7:33 pm 
Offline

Joined: Sun Dec 25, 2011 4:51 pm
Posts: 22
It worked out,thanks!


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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