Slick Forums

Discuss the Slick 2D Library
It is currently Tue May 21, 2013 10:30 pm

All times are UTC




Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Tables and layout
PostPosted: Fri Aug 31, 2012 4:31 am 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1171
ColumnLayout is a subclass of DialogLayout. If you want you can easily add it to another DialogLayout, but then you need to add it to it's groups like any other widget.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: Tables and layout
PostPosted: Fri Aug 31, 2012 4:48 am 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
MatthiasM wrote:
ColumnLayout is a subclass of DialogLayout. If you want you can easily add it to another DialogLayout, but then you need to add it to it's groups like any other widget.


ok, thanks! This seems to work!

Code:
      ColumnLayout cl = new ColumnLayout();
      cl.setTheme("SoundSettings"); // ref=dialoglayout
      cl.addRow("label", "adjust", "label", "enable");
      Columns col = cl.getColumns("label", "adjuster", "label", "enable");
      cl.addRow(col).add(labelMusicVolume).add(musicVolumeAdjuster).add(labelMusicDisable).add(musicDisableCheckBox);
      cl.addRow(col).add(labelSoundVolume).add(soundVolumeAdjuster).add(labelSoundDisable).add(soundDisableCheckBox);
      
      setHorizontalGroup(createSequentialGroup(cl));
      setVerticalGroup(createParallelGroup(cl));


edit:

It seems to work the same if this is commented or not:
Code:
   //cl.addRow("label", "adjust", "label", "enable");


What exactly does that do?

edit 2:

How do I center or put these fields closer to right border? I'd also like to make vertical gaps smaller:
default:
Image

would like (bad photoshop):
Image


Top
 Profile  
 
 Post subject: Re: Tables and layout
PostPosted: Fri Aug 31, 2012 5:47 am 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1171
You should really try reading the javadoc.

As for adding a row without adding any widgets to it - it's kind of useless waste of CPU and memory.

Your screenshot shows only 2 widgets per row - so you should create a Columns object with only 2 fields: "label", "single-adjuster"
As they both start with "label" it will end up with a merged column - eg all labels are equal wide.
But as the 2nd column is different, it will take the same width as the other 3 columns.

Now you only need to make sure that your adjusters can be stretched (setting maxWidth to 32767 or the constant MAX).
Alternative you can use the widget alignment value FILL to force the widgets to take the whole space (but that might also stretch them vertically).

As for the vertical gap between rows - you can either change the default gap size, or you can add another vertical gap between rows (see getRootPanel).

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: Tables and layout
PostPosted: Mon Sep 10, 2012 2:44 am 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
MatthiasM wrote:
Now you only need to make sure that your adjusters can be stretched (setting maxWidth to 32767 or the constant MAX).
Alternative you can use the widget alignment value FILL to force the widgets to take the whole space (but that might also stretch them vertically).



I don't understand this part.

There is no setMaxWidth() or maxWidth variable, so I tried myWidget.setMaxSize(32767 ,myWidget.getHeight()) on the widget; but looks the same.

I don't see a alignment setting or variable in Widget.


Top
 Profile  
 
 Post subject: Re: Tables and layout
PostPosted: Mon Sep 10, 2012 5:12 am 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1171
The maxWidth must be set in the theme. It's default value is 0 which means "do not stretch and use preferred size" and a value > 0 sets the maximum width that widget can get.

The widget alignment is set in the DialogLayout / ColumnLayout class. Either using DialogLayout.setWidgetAlignment() after adding the widget or directly when adding it using eg with ColumnLayout .Row.add(Widget, Alignment).

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

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