nsbitmapimagerep from nsview subclass, obtaining and drawing
nsbitmapimagerep from nsview subclass, obtaining and drawing
- Subject: nsbitmapimagerep from nsview subclass, obtaining and drawing
- From: David Harper <email@hidden>
- Date: Wed, 1 Aug 2007 11:22:48 -0400 (EDT)
Hi,
I'm attempting to implement subview dragging, snapping etc. with transparency. I'm pretty sure the solution is not to create a temporary subview to be dragged (because there is no way to draw a subview with 50% transparency?), but I'd like the image of the view being dragged to appear over the other subviews.
Right now I've got something working, but there are 2 problems:
1. the nsbitmapimagerep I'm obtaining from the subview being dragged is being either stored or drawn improperly. It basically appears that although the memory space is retained, the contents of that memory is highly corrupt; the view usually contains the color black with random spots of white (consistent with a ton of 0x00000000 bytes and other garbage values). I'm obtaining the image rep by setting myImageRep = [self bitmapImageRectForCachingDisplayInRect:[self bounds]], then passing that image rep to the controller which passes it to the window's primary view so it can be displayed anchored to the mouse position in the window.
2. the imagerep is drawn below all the subviews in the window. my drawRect function looks like this (note, I'm not clear on exactly how bitmap image drawing works, whether I need to obtain some context or what - however, since a square is being drawn at the correct location in relation to the mouse, I suspect that it is the image itself that's corrupt, as described above):
-(void) drawRect:(NSRect)rect {
[super drawRect:rect];
if (viewBeingDragged) {
[myDragImage drawAtPoint:viewDragOrigin];
}
}
I called the super drawrect with the expectation that maybe the subviews would be drawn first, and then the dragimage drawn on top of everything else.
I have not yet tried to draw the image with 50% transparency. Is this done by first using [[NSColor colorWithRed:% green:% blue:% alpha:%] set] ? It doesn't seem to be the case that setting the nscolor has any effect.
Hopefully someone can provide some insight, I'd appreciate any response.
Thanks,
-Dave H.
_______________________________________________
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