Re: NSDrawThreePartImage - Strange scaling behavior, is it supposed to do that?
Re: NSDrawThreePartImage - Strange scaling behavior, is it supposed to do that?
- Subject: Re: NSDrawThreePartImage - Strange scaling behavior, is it supposed to do that?
- From: aaron smith <email@hidden>
- Date: Fri, 14 May 2010 17:08:30 -0700
AH. I can't believe I missed that. Thanks!
On Fri, May 14, 2010 at 4:39 PM, Ken Ferry <email@hidden> wrote:
> Yes, this is the intended behavior. See the header for details.
> You seem to be looking for the nine part draw.
>
> /* Draw an image from two end caps and a fill. The end caps are scaled
> proportionally to match the thickness of the destination frame. In the
> horizontal case, the startCap is drawn into the left part of the
> destination, the endCap is drawn into the right part of the destination, and
> the fill is tiled over the remaining area. The caps and the fill should all
> be the same height. The vertical case is similar.
>
>
>
> This is an appropriate way to draw the bezel of a button that can be
> resized in one dimension.
>
> */
>
> APPKIT_EXTERN void NSDrawThreePartImage(NSRect frame, NSImage *startCap,
> NSImage *centerFill, NSImage *endCap, BOOL vertical, NSCompositingOperation
> op, CGFloat alphaFraction, BOOL flipped) NS_AVAILABLE_MAC(10_5);
>
> /* Draw an image from nine pieces. When drawn, the destination rect is
> partitioned into nine rectangular regions: the corner pieces are the natural
> size of the corner images, the edge pieces are the natural size of the edge
> fill images in the direction perpendicular to the edge and flush with the
> corners. The center rect fills the remaining space. The supplied images
> and fills are drawn into the corresponding regions, with fill images tiled
> at their natural dimensions. Images that share a border should have the
> same thickness in that dimension.
>
>
>
> This method is appropriate for the bezel of a control, like a box, that can
> be resized in both dimensions.
>
> */
>
> APPKIT_EXTERN void NSDrawNinePartImage(NSRect frame, NSImage *topLeftCorner,
> NSImage *topEdgeFill, NSImage *topRightCorner, NSImage *leftEdgeFill,
> NSImage *centerFill, NSImage *rightEdgeFill, NSImage *bottomLeftCorner,
> NSImage *bottomEdgeFill, NSImage *bottomRightCorner, NSCompositingOperation
> op, CGFloat alphaFraction, BOOL flipped) NS_AVAILABLE_MAC(10_5);
>
> Like Graham says, consider something like a standard aqua button. Scaling
> should always respect the aspect ratio of the caps - they'd look totally
> wrong otherwise.
> -Ken
> On Fri, May 14, 2010 at 3:58 PM, Graham Cox <email@hidden> wrote:
>>
>> I haven't used this function but its behaviour seems logical to me. If the
>> height changes it has to scale the ends to fill that height and if they were
>> the end caps of a button (I guess its main intended use) then it would be
>> necessary to preserve the aspect ratio in order that, e.g. round end caps
>> remain round. The same is not true of a width change, where the round end
>> caps are the same regardless and do not have to be scaled.
>>
>> --Graham
>>
>>
>> On 15/05/2010, at 6:53 AM, aaron smith wrote:
>>
>> > http://i.imgur.com/cikiL.png - as soon as the height is changed, it's
>> > scaling everything. This can't be right?
>> >
>> > When the view draws, it's using [self bounds] as the frame for
>> > NSDrawThreePartImage.
>> >
>> > Here's my code that slices up the image for scale three:
>> > http://pastebin.com/HgVGyLEp
>> >
>> > I've put a bunch of logging in this method, and all of the rects are
>> > always the same size, which is correct. So i'm not sure where the
>> > scaling of the image is being introduced.
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden