• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Flipped NSView + scaled NSAffineTransform = confusion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Flipped NSView + scaled NSAffineTransform = confusion


  • Subject: Flipped NSView + scaled NSAffineTransform = confusion
  • From: Ken Tozier <email@hidden>
  • Date: Fri, 1 Oct 2010 02:28:33 -0400

Hi

I have a custom view, which contains a number of subviews, where it is much more intuitive to the user if items appear from the upper left corner than the bottom left corner. Normally, I would just flip the view and the placement of subviews is what I expect. When I apply a scaled affine transform to the subviews however, poof. The subviews vanish and no amount of resizing the window makes them reappear.

Here's a simple example of what I'm doing

Containing view:

- (BOOL) isFlipped { return YES; }

- (id) initWithFrame:(NSRect) inFrame
{
	self = [super initWithFrame: inFrame];
	if (self)
	{
		NSRect				*subFrame		= NSMakeRect(10, 10, 500, 1000);
		MySubView			*subview		= [[MySubView alloc] initWithFrame: subFrame];
		NSAffineTransform	*subTransform	= [[NSAffineTransform transform] retain];
		float					vertPadding		= 20;

		[transform scaleBy: (inFrame.size.height - vertPadding) / subFrame.size.height];

		[self addSubview: subview];
	}

	return self;
}

- (void) drawRect:(NSRect) inDirtyRect
{
	[[NSColor blackColor] set];
	NSRectFillUsingOperation(inDirtyRect, NSCompositeSourceOver);
}

- (NSAffineTransform *) subTransform
{
	return subTransform;
}

MySubView

- (void) drawRect:(NSRect) inDirtyRect
{
	[[[self superview] subTransform] concat];
	[[NSColor greenColor] set];
	NSRectFillUsingOperation(inDirtyRect, NSCompositeSourceOver);
}

What do I need to do to scale a subview using an NSAffineTransform and have it's upper left stay put? Or at least not move it off into the aether?

Thanks for any help._______________________________________________

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

  • Prev by Date: Continuously running daemon process CFConstantStringRefs build up over time
  • Next by Date: Re: Acquiring an NSConnection otherwise than by registered name?
  • Previous by thread: Continuously running daemon process CFConstantStringRefs build up over time
  • Index(es):
    • Date
    • Thread