From: Adam M. <ama...@us...> - 2005-09-29 03:03:42
|
Update of /cvsroot/bibdesk/bibdesk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5152 Modified Files: Tag: BR_1x BDSKDragWindow.m Log Message: Draw circles only for spotlight effect. Index: BDSKDragWindow.m =================================================================== RCS file: /cvsroot/bibdesk/bibdesk/BDSKDragWindow.m,v retrieving revision 1.23.2.14 retrieving revision 1.23.2.15 diff -C2 -d -r1.23.2.14 -r1.23.2.15 *** BDSKDragWindow.m 20 Sep 2005 15:58:42 -0000 1.23.2.14 --- BDSKDragWindow.m 29 Sep 2005 03:03:34 -0000 1.23.2.15 *************** *** 278,329 **** float rectMax = MAX(NSHeight(highlightRect), NSWidth(highlightRect)); NSRect circleRect = NSMakeRect(highlightRect.origin.x, highlightRect.origin.y, rectMax, rectMax); ! ! if(NSHeight(highlightRect) <= 0.25 * NSHeight([self frame])){ ! // get the origin of the circle as (ctrX, ctrY) ! float ctrX = NSMidX(circleRect); ! float ctrY = NSMidY(circleRect); ! ! // here's our mouse location in the window ! NSPoint originPt = [[self window] mouseLocationOutsideOfEventStream]; ! ! // Here we define points tan1 and tan2 that are tangent to the circle on a line normal to a ray extending from the mouse location through the center of the circle. ! ! // Px defines the distance between the mouse and the origin of the circle in the horizontal direction ! float Px = ctrX - originPt.x; ! // Py defines the distance between the mouse and the origin of the circle in the vertical direction ! float Py = ctrY - originPt.y; ! // L1 is the distance between the mouse and the origin of the circle ! float L1 = sqrtf(Px * Px + Py * Py); ! // r is the radius of the circle ! float r = rectMax / 2; ! // deltaX is the horizontal distance between t1/t2 and the origin of the circle ! float deltaX = Py * r / L1; ! // deltaY is the vertical distance between t1/t2 and the origin of the circle ! float deltaY = sqrtf(r * r - deltaX * deltaX); ! ! // correct our delta value for other quadrants; this was derived with the mouse in quadrant IV (considering the circle center as origin) ! if(Py <= 0 && Px >= 0) ! deltaX *= -1; ! if(Px >= 0 && Py >= 0) ! deltaY *= -1; ! ! // Here we define our tangent points ! NSPoint tan1 = NSMakePoint(ctrX - deltaX, ctrY - deltaY); ! NSPoint tan2 = NSMakePoint(ctrX + deltaX, ctrY + deltaY); ! ! NSPoint points[3] = {tan2, originPt, tan1}; ! ! // create a point opposite the ray on the circle (fails when mouse is in quadrant II?) ! NSPoint farPoint = NSMakePoint(ctrX - deltaY, ctrY + deltaX); ! ! [NSBezierPath setDefaultWindingRule:NSEvenOddWindingRule]; ! NSBezierPath *conicalPath = [[NSBezierPath bezierPath] appendBezierPathWithPoints:points count:3]; ! [conicalPath appendBezierPathWithArcFromPoint:farPoint toPoint:tan2 radius:r]; ! [rectPath appendBezierPath:conicalPath]; ! } else { ! // if it's a large view, just highlight the entire view ! NSBezierPath *ovalPath = [NSBezierPath bezierPathWithOvalInRect:circleRect]; ! [rectPath appendBezierPath:[ovalPath bezierPathByReversingPath]]; ! } [[[NSColor blackColor] colorWithAlphaComponent:0.3] set]; --- 278,286 ---- float rectMax = MAX(NSHeight(highlightRect), NSWidth(highlightRect)); NSRect circleRect = NSMakeRect(highlightRect.origin.x, highlightRect.origin.y, rectMax, rectMax); ! ! [NSBezierPath setDefaultWindingRule:NSEvenOddWindingRule]; ! ! NSBezierPath *ovalPath = [NSBezierPath bezierPathWithOvalInRect:circleRect]; ! [rectPath appendBezierPath:[ovalPath bezierPathByReversingPath]]; [[[NSColor blackColor] colorWithAlphaComponent:0.3] set]; |