Skip navigation.
 
mlRe: Capsule-Style Toolbar Controls
FROM : Peter Ammon
DATE : Fri Apr 18 23:05:06 2008

Thanks Stefan,

From the screenshot, it looks to me like the test app is not using 
the unified title/toolbar metrics, but Mail is.  Try checking the 
unified title/toolbar checkbox in IB.

Your understanding of the NSToolbarItemGroup is correct.  However, the 
view will not be automatically resized to fit the labels.  For now, 
you will have to size the segments manually.

-Peter

On Apr 17, 2008, at 9:25 AM, Stefan Hafeneger wrote:
> Hi Peter,
>
> I uploaded two screenshots from Mail (in the background) and a demo 
> app (in the foreground) designed just in Interface Builder. The size 
> of the segmented control is exactly the same but there is a 
> difference in the baseline.
>
> http://homepage.mac.com/stefan.hafeneger/.cv/stefan.hafeneger/Sites/.Public/CapsuleToolbar1.png-zip.zip
> http://homepage.mac.com/stefan.hafeneger/.cv/stefan.hafeneger/Sites/.Public/CapsuleToolbar2.png-zip.zip
>
> Concerning NSToolbarItemGroup: So I create a NSToolbarItemGroup and 
> with three "dummy" items and label the three dummy items. Then I 
> create a segmented control cell with 3 segments and set it to the 
> view of NSToolbarItemGroup. Is this correct? Will the view then be 
> automatically resized if the user enables or disables the labels?
>
> With best wishes, Stefan
>
> Am 16.04.2008 um 23:29 schrieb Peter Ammon:
>

>>
>> On Apr 16, 2008, at 1:27 PM, Stefan Hafeneger wrote:
>>

>>> Hi,
>>>
>>> Has anyone tried to use the Capsule-Style Toolbar Controls in an 
>>> app so that it looks and behaves like Mail or Preview? When I add 
>>> them to my toolbar it looks like Mail. But if I compare them side 
>>> by side the ones in Mail and Preview there is a 2 pixel difference 
>>> of the baseline. And I think it looks better in Mail/Preview. When 
>>> I add a multi-segment control I only have one Label (not two or 
>>> more). In Mail and Preview it looks like there are as many labels 
>>> as segments. You can "fake" this by adding blanks. But there is 
>>> one more point: In Mail and Preview the size of the control is 
>>> adjusted (I think depending on the size of the label(s)). Well, in 
>>> the nib files from Mail and Preview there are no toolbars, so 
>>> Apple builds them via code. So the question is: If I code them as 
>>> well, is it possible to do the same that Apple does in Mail and 
>>> Preview via NSSegmentedCell or is this all done by hand?
>>>
>>> With best wishes, Stefan

>>
>> Hi Stefan,
>>
>> As of Leopard, this is all possible using standard AppKit controls, 
>> which Mail and Preview both use.
>>
>> Regarding the two pixel difference in the baseline, this may be 
>> because the segmented control is too short and so is clipped.  Try 
>> using sizeToFit.  You may also be referring to different window 
>> metrics; try giving the window a unified title/toolbar to see if 
>> that gives the appearance you expect.  It shouldn't affect the 
>> appearance much, but it does subtly change the toolbar 
>> positioning.  If these don't fix your issue, maybe you can provide 
>> a screenshot so I understand what you mean.
>>
>> To have multiple labels in a single toolbar item, make an 
>> NSToolbarItemGroup, and give it subitems.  If you set a view (but 
>> not a label) on the Group, the labels of the subitems will be 
>> arranged under the view.  If the view is a segmented control, the 
>> labels will be aligned with corresponding segments, assuming 
>> there's the same number of both. This is what Mail and Preview do.
>>
>> I hope that's clear,
>> -Peter
>>

>

Related mailsAuthorDate
mlCapsule-Style Toolbar Controls Stefan Hafeneger Apr 16, 22:27
mlRe: Capsule-Style Toolbar Controls Peter Ammon Apr 16, 23:29
mlRe: Capsule-Style Toolbar Controls Jim Puls Apr 17, 00:01
mlRe: Capsule-Style Toolbar Controls Stefan Hafeneger Apr 17, 18:25
mlRe: Capsule-Style Toolbar Controls Peter Ammon Apr 18, 23:05
mlRe: Capsule-Style Toolbar Controls Stefan Hafeneger Apr 19, 00:22
mlRe: Capsule-Style Toolbar Controls Peter Ammon Apr 19, 01:04
mlRe: Capsule-Style Toolbar Controls Stefan Hafeneger Apr 19, 12:19