View unanswered posts | View active topics It is currently Thu Jun 20, 2013 5:59 am



Reply to topic  [ 5 posts ] 
 Visual Padding not implemented on OS X 
Author Message

Joined: Mon May 07, 2012 8:08 pm
Posts: 3
Post Visual Padding not implemented on OS X
I'm using Swing on OS X, and most controls have some visual padding that I want to be ignored during layout. For instance, JButtons have 3,3,3,3 extra insets for the focus ring. I'd like to specify the visual padding for components, but I cannot find a way to do so. I see that SwingComponentWrapper.getVisualPadding() always returns null except for when the component is Windows JTabbedPanes. There doesn't seem to be a way to create a custom ComponentWrapper class, nor a way to set the visual padding on a per-Component nor per-Class basis.

What's the best way to get MiGLayout to ignore the 3-pixel visual padding on OS X JButtons?


Mon May 07, 2012 8:14 pm
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: Visual Padding not implemented on OS X
Hello,

Yeah, that needs to be done in the source. So either I have to do it our you build your own version. If you change the code for the better on OS X, please send it to me and I'll integrate it into the next release.

Note that I'm not entirely sure how the padding is applied. It should be applied already in the preffered size stage but unfortunately I think it's in the final padding stage which will make the components have the right gap, but be too large. I don't remember and I don't have the code at hand right now. The code is in the class PlatformDefaults I think though.

Cheers,
Mikael


Mon May 07, 2012 9:19 pm
Profile WWW

Joined: Mon May 07, 2012 8:08 pm
Posts: 3
Post Re: Visual Padding not implemented on OS X
I've added support to specify the visual padding in three different ways:
1) As a UIDefault property. This allows developers to specify the default visual padding for all components of a specific type. For example, PlatformDefaults now has the following line:
Code:
UIManager.put( "TabbedPane.visualPadding", new int[] {-1, 0, 2, 2} );

2) As a client property on a JComponent. The value may be an int[] or an Insets instance. For example,
Code:
button.putClientProperty( "visualPadding", new Insets(3,3,3,3) );

3) As a component constraint, using the same format as "pad" - e.g. "visualpadding 3 3 3 3" or "vp 3 3 3 3"

That was the easy part. Now I'm trying to figure out how to adjust the layout. Do you have any suggestions on where to take the visual padding into account?
I'm thinking about putting it into Grid.CompWrap.getSize, but that method and class have no current way of knowing if the layout constraints included "novisualpadding" to toggle the behavior.
Do you have any suggestions?

Thanks,
-Tex


Mon May 14, 2012 3:07 am
Profile

Joined: Mon May 07, 2012 8:08 pm
Posts: 3
Post Re: Visual Padding not implemented on OS X
I now have it working.
It subtracts the visual padding in Grid.CompWrap.getSize.
But it adds the visual padding in Grid.CompWrap.transferBounds.

I haven't added all of the padding values for all of the component types into PlatformDefaults yet.

How would like for me to send you the changes?

-Tex


Tue May 15, 2012 8:50 pm
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: Visual Padding not implemented on OS X
Good job!

Either as annotated snippets in a text file or a patch. Whatever is most practical depending on the number of changes.

Send it to miglayout at miginfocom dot com.

Thanks,
Mikael


Tue May 15, 2012 11:09 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.