Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Button insets



This is a very interesting idea, and I've added it into the "focus ring insets: do not want!" bug. We currently use different border classes to rotate around the different styles, and we'll swap them when we receive a client property change notification - but it might be interesting to actually install the "painter" and the "insets" as their own client properties, and just let the "one magic Aqua border" pull those properties when it's asked to draw or calculate insets.

Naturally, I have concerns about the speed of painting or layout when every button is accessing the client property hash table - but that could be mitigated by caching caching an instance variable in the border instance itself, and ensuring the border is listening for client property changes. Hrm...

Thanks for the idea Werner,
Mike Swingler
Java Runtime Engineer
Apple Inc.

On Sep 30, 2008, at 10:31 AM, Werner Randelshofer wrote:

In case this is of interest: the Quaqua Look and Feel uses a client property named "Quaqua.Component.visualMargin" with a default value of Insets(3,3,3,3). 

With the insets of 3,3,3,3 the bounds of JComponent accommodate its visual bounds (the button border or the text field border), as well as cast shadows and focus ring.

By setting the insets to 0,0,0,0 the visual bounds of the component touch the bounds of the JComponent. Cast shadows and focus ring are cut off. This allows to place two components next to each other, so that their visual bounds touch.


Swing actually does support overlapping components by placing the components into a JLayeredPane, or by overriding method isOptimizedDrawing enabled of a JPanel (or whatever the parent JComponent is) so that it returns false.

This allows to use gaps between components which are smaller than 6 pixels, even if the visual margin insets is set to 3,3,3,3.


By providing the "Quaqua.Component.visualMargin" developers can choose whether they want to place components very close together by reducing the insets and cutting of some artwork, or by keeping the insets and letting the components slightly overlap.


With best regards,
Werner


On 30.09.2008, at 18:00, Mike Swingler wrote:

Yeah, I mean, we could adjust the borders in Aqua if the button were both setFocusPainted(false) and setFocusable(false), but that still might catch some people by surprise. I figure if you are opting into the special button styles using a client property, there isn't much harm in using another one to hint that the insets should change too.

Ideally, if focus indicators had their own dedicated layer they were drawn in, or a component could dirty outside of it's bounds without causing infinite loops, we wouldn't have to make the component big enough to accommodate both the control and it's focus area - but I digress.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden

References: 
 >Button insets (From: Ken Orr <email@hidden>)
 >Re: Button insets (From: Mike Swingler <email@hidden>)
 >Re: Button insets (From: Rob Ross <email@hidden>)
 >Re: Button insets (From: Ken Orr <email@hidden>)
 >Re: Button insets (From: Mike Swingler <email@hidden>)
 >Re: Button insets (From: Werner Randelshofer <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.