Revision: 2981
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2981&view=rev
Author:   hofman
Date:     2007-09-23 05:12:47 -0700 (Sun, 23 Sep 2007)

Log Message:
-----------
Draw partially rounded rects in side windows.

Modified Paths:
--------------
    trunk/NSBezierPath_BDSKExtensions.h
    trunk/NSBezierPath_BDSKExtensions.m
    trunk/SKSideWindow.m

Modified: trunk/NSBezierPath_BDSKExtensions.h
===================================================================
--- trunk/NSBezierPath_BDSKExtensions.h 2007-09-22 17:25:06 UTC (rev 2980)
+++ trunk/NSBezierPath_BDSKExtensions.h 2007-09-23 12:12:47 UTC (rev 2981)
@@ -42,7 +42,19 @@
 
 + (void)fillRoundRectInRect:(NSRect)rect radius:(float)radius;
 + (void)strokeRoundRectInRect:(NSRect)rect radius:(float)radius;
-+ (NSBezierPath*)bezierPathWithRoundRectInRect:(NSRect)rect 
radius:(float)radius;
++ (NSBezierPath *)bezierPathWithRoundRectInRect:(NSRect)rect 
radius:(float)radius;
++ (void)fillLeftRoundRectInRect:(NSRect)rect radius:(float)radius;
++ (void)strokeLeftRoundRectInRect:(NSRect)rect radius:(float)radius;
++ (NSBezierPath *)bezierPathWithLeftRoundRectInRect:(NSRect)rect 
radius:(float)radius;
++ (void)fillRightRoundRectInRect:(NSRect)rect radius:(float)radius;
++ (void)strokeRightRoundRectInRect:(NSRect)rect radius:(float)radius;
++ (NSBezierPath *)bezierPathWithRightRoundRectInRect:(NSRect)rect 
radius:(float)radius;
++ (void)fillTopRoundRectInRect:(NSRect)rect radius:(float)radius;
++ (void)strokeTopRoundRectInRect:(NSRect)rect radius:(float)radius;
++ (NSBezierPath *)bezierPathWithTopRoundRectInRect:(NSRect)rect 
radius:(float)radius;
++ (void)fillBottomRoundRectInRect:(NSRect)rect radius:(float)radius;
++ (void)strokeBottomRoundRectInRect:(NSRect)rect radius:(float)radius;
++ (NSBezierPath *)bezierPathWithBottomRoundRectInRect:(NSRect)rect 
radius:(float)radius;
 
 + (void)drawHighlightInRect:(NSRect)rect radius:(float)radius 
lineWidth:(float)lineWidth color:(NSColor *)color;
 

Modified: trunk/NSBezierPath_BDSKExtensions.m
===================================================================
--- trunk/NSBezierPath_BDSKExtensions.m 2007-09-22 17:25:06 UTC (rev 2980)
+++ trunk/NSBezierPath_BDSKExtensions.m 2007-09-23 12:12:47 UTC (rev 2981)
@@ -57,7 +57,7 @@
     [p stroke];
 }
 
-+ (NSBezierPath*)bezierPathWithRoundRectInRect:(NSRect)rect 
radius:(float)radius
++ (NSBezierPath *)bezierPathWithRoundRectInRect:(NSRect)rect 
radius:(float)radius
 {
     // Make sure radius doesn't exceed a maximum size to avoid artifacts:
     radius = fminf(radius, 0.5f * fminf(NSHeight(rect), NSWidth(rect)));
@@ -80,7 +80,7 @@
     [path appendBezierPathWithArcWithCenter:NSMakePoint(NSMinX(innerRect), 
NSMinY(innerRect)) radius:radius startAngle:180.0 endAngle:270.0];
     // Bottom edge and bottom right:
     [path appendBezierPathWithArcWithCenter:NSMakePoint(NSMaxX(innerRect), 
NSMinY(innerRect)) radius:radius startAngle:270.0 endAngle:360.0];
-    // Left edge and top right:
+    // Right edge and top right:
     [path appendBezierPathWithArcWithCenter:NSMakePoint(NSMaxX(innerRect), 
NSMaxY(innerRect)) radius:radius startAngle:0.0  endAngle:90.0 ];
     // Top edge and top left:
     [path appendBezierPathWithArcWithCenter:NSMakePoint(NSMinX(innerRect), 
NSMaxY(innerRect)) radius:radius startAngle:90.0  endAngle:180.0];
@@ -90,6 +90,186 @@
     return path;
 }
 
++ (void)fillLeftRoundRectInRect:(NSRect)rect radius:(float)radius
+{
+    NSBezierPath *p = [self bezierPathWithLeftRoundRectInRect:rect 
radius:radius];
+    [p fill];
+}
+
+
++ (void)strokeLeftRoundRectInRect:(NSRect)rect radius:(float)radius
+{
+    NSBezierPath *p = [self bezierPathWithLeftRoundRectInRect:rect 
radius:radius];
+    [p stroke];
+}
+
++ (NSBezierPath *)bezierPathWithLeftRoundRectInRect:(NSRect)rect 
radius:(float)radius
+{
+    // Make sure radius doesn't exceed a maximum size to avoid artifacts:
+    radius = fminf(radius, fminf(0.5f * NSHeight(rect), NSWidth(rect)));
+    
+    // Make sure silly values simply lead to un-rounded corners:
+    if( radius <= 0 )
+        return [self bezierPathWithRect:rect];
+    
+    NSRect ignored, innerRect;
+    NSDivideRect(NSInsetRect(rect, 0.0, radius), &ignored, &innerRect, radius, 
NSMinXEdge); // Make rect with corners being centers of the corner circles.
+       static NSBezierPath *path = nil;
+    if(path == nil)
+        path = [[self bezierPath] retain];
+    
+    [path removeAllPoints];    
+    
+    // Now draw our rectangle:
+    [path moveToPoint: NSMakePoint(NSMaxX(rect), NSMinY(rect))];
+    
+    // Right edge:
+    [path lineToPoint:NSMakePoint(NSMaxX(rect), NSMaxY(rect))];
+    // Top edge and top left:
+    [path appendBezierPathWithArcWithCenter:NSMakePoint(NSMinX(innerRect), 
NSMaxY(innerRect)) radius:radius startAngle:90.0  endAngle:180.0];
+    // Left edge and bottom left:
+    [path appendBezierPathWithArcWithCenter:NSMakePoint(NSMinX(innerRect), 
NSMinY(innerRect)) radius:radius startAngle:180.0  endAngle:270.0 ];
+    // Bottom edge:
+    [path closePath];
+    
+    return path;
+}
+
++ (void)fillRightRoundRectInRect:(NSRect)rect radius:(float)radius
+{
+    NSBezierPath *p = [self bezierPathWithRightRoundRectInRect:rect 
radius:radius];
+    [p fill];
+}
+
+
++ (void)strokeRightRoundRectInRect:(NSRect)rect radius:(float)radius
+{
+    NSBezierPath *p = [self bezierPathWithRightRoundRectInRect:rect 
radius:radius];
+    [p stroke];
+}
+
++ (NSBezierPath *)bezierPathWithRightRoundRectInRect:(NSRect)rect 
radius:(float)radius
+{
+    // Make sure radius doesn't exceed a maximum size to avoid artifacts:
+    radius = fminf(radius, fminf(0.5f * NSHeight(rect), NSWidth(rect)));
+    
+    // Make sure silly values simply lead to un-rounded corners:
+    if( radius <= 0 )
+        return [self bezierPathWithRect:rect];
+    
+    NSRect ignored, innerRect;
+    NSDivideRect(NSInsetRect(rect, 0.0, radius), &ignored, &innerRect, radius, 
NSMaxXEdge); // Make rect with corners being centers of the corner circles.
+       static NSBezierPath *path = nil;
+    if(path == nil)
+        path = [[self bezierPath] retain];
+    
+    [path removeAllPoints];    
+    
+    // Now draw our rectangle:
+    [path moveToPoint: NSMakePoint(NSMinX(rect), NSMaxY(rect))];
+    
+    // Left edge:
+    [path lineToPoint:NSMakePoint(NSMinX(rect), NSMinY(rect))];
+    // Bottom edge and bottom right:
+    [path appendBezierPathWithArcWithCenter:NSMakePoint(NSMaxX(innerRect), 
NSMinY(innerRect)) radius:radius startAngle:270.0 endAngle:360.0];
+    // Right edge and top right:
+    [path appendBezierPathWithArcWithCenter:NSMakePoint(NSMaxX(innerRect), 
NSMaxY(innerRect)) radius:radius startAngle:0.0  endAngle:90.0 ];
+    // Top edge:
+    [path closePath];
+    
+    return path;
+}
+
++ (void)fillTopRoundRectInRect:(NSRect)rect radius:(float)radius
+{
+    NSBezierPath *p = [self bezierPathWithTopRoundRectInRect:rect 
radius:radius];
+    [p fill];
+}
+
+
++ (void)strokeTopRoundRectInRect:(NSRect)rect radius:(float)radius
+{
+    NSBezierPath *p = [self bezierPathWithTopRoundRectInRect:rect 
radius:radius];
+    [p stroke];
+}
+
++ (NSBezierPath *)bezierPathWithTopRoundRectInRect:(NSRect)rect 
radius:(float)radius
+{
+    // Make sure radius doesn't exceed a maximum size to avoid artifacts:
+    radius = fminf(radius, fminf(NSHeight(rect), 0.5f * NSWidth(rect)));
+    
+    // Make sure silly values simply lead to un-rounded corners:
+    if( radius <= 0 )
+        return [self bezierPathWithRect:rect];
+    
+    NSRect ignored, innerRect;
+    NSDivideRect(NSInsetRect(rect, radius, 0.0), &ignored, &innerRect, radius, 
NSMaxYEdge); // Make rect with corners being centers of the corner circles.
+       static NSBezierPath *path = nil;
+    if(path == nil)
+        path = [[self bezierPath] retain];
+    
+    [path removeAllPoints];    
+    
+    // Now draw our rectangle:
+    [path moveToPoint: NSMakePoint(NSMinX(rect), NSMinY(rect))];
+    
+    // Bottom edge:
+    [path lineToPoint:NSMakePoint(NSMaxX(rect), NSMinY(rect))];
+    // Right edge and top right:
+    [path appendBezierPathWithArcWithCenter:NSMakePoint(NSMaxX(innerRect), 
NSMaxY(innerRect)) radius:radius startAngle:0.0  endAngle:90.0 ];
+    // Top edge and top left:
+    [path appendBezierPathWithArcWithCenter:NSMakePoint(NSMinX(innerRect), 
NSMaxY(innerRect)) radius:radius startAngle:90.0  endAngle:180.0];
+    // Left edge:
+    [path closePath];
+    
+    return path;
+}
+
++ (void)fillBottomRoundRectInRect:(NSRect)rect radius:(float)radius
+{
+    NSBezierPath *p = [self bezierPathWithBottomRoundRectInRect:rect 
radius:radius];
+    [p fill];
+}
+
+
++ (void)strokeBottomRoundRectInRect:(NSRect)rect radius:(float)radius
+{
+    NSBezierPath *p = [self bezierPathWithBottomRoundRectInRect:rect 
radius:radius];
+    [p stroke];
+}
+
++ (NSBezierPath *)bezierPathWithBottomRoundRectInRect:(NSRect)rect 
radius:(float)radius
+{
+    // Make sure radius doesn't exceed a maximum size to avoid artifacts:
+    radius = fminf(radius, 0.5f * fminf(NSHeight(rect), NSWidth(rect)));
+    
+    // Make sure silly values simply lead to un-rounded corners:
+    if( radius <= 0 )
+        return [self bezierPathWithRect:rect];
+    
+    NSRect ignored, innerRect;
+    NSDivideRect(NSInsetRect(rect, radius, 0.0), &ignored, &innerRect, radius, 
NSMinYEdge); // Make rect with corners being centers of the corner circles.
+       static NSBezierPath *path = nil;
+    if(path == nil)
+        path = [[self bezierPath] retain];
+    
+    [path removeAllPoints];    
+    
+    // Now draw our rectangle:
+    [path moveToPoint: NSMakePoint(NSMaxX(rect), NSMaxY(rect))];
+    
+    // Top edge:
+    [path lineToPoint:NSMakePoint(NSMinX(rect), NSMaxY(rect))];
+    // Left edge and bottom left:
+    [path appendBezierPathWithArcWithCenter:NSMakePoint(NSMinX(innerRect), 
NSMinY(innerRect)) radius:radius startAngle:180.0 endAngle:270.0];
+    // Bottom edge and bottom right:
+    [path appendBezierPathWithArcWithCenter:NSMakePoint(NSMaxX(innerRect), 
NSMinY(innerRect)) radius:radius startAngle:270.0 endAngle:360.0];
+    // Left edge:
+    [path closePath];
+    
+    return path;
+}
+
 + (void)drawHighlightInRect:(NSRect)rect radius:(float)radius 
lineWidth:(float)lineWidth color:(NSColor *)color
 {
     NSBezierPath *path = [NSBezierPath 
bezierPathWithRoundRectInRect:NSInsetRect(rect, 0.5 * lineWidth, 0.5 * 
lineWidth) radius:radius];
@@ -113,7 +293,7 @@
     [p stroke];
 }
 
-+ (NSBezierPath*)bezierPathWithHorizontalOvalAroundRect:(NSRect)rect
++ (NSBezierPath *)bezierPathWithHorizontalOvalAroundRect:(NSRect)rect
 {
     float radius = 0.5f * rect.size.height;
     

Modified: trunk/SKSideWindow.m
===================================================================
--- trunk/SKSideWindow.m        2007-09-22 17:25:06 UTC (rev 2980)
+++ trunk/SKSideWindow.m        2007-09-23 12:12:47 UTC (rev 2981)
@@ -289,21 +289,29 @@
 }
 
 - (void)drawRect:(NSRect)aRect {
-    NSRect ignored, topRect, bottomRect, rect;
+    NSRect ignored, topRect, bottomRect, rect = [self bounds];
     NSPoint startPoint, endPoint;
     
-    NSDivideRect([self bounds], &ignored, &rect, -CONTENT_INSET, edge);
     NSDivideRect(rect, &topRect, &ignored, 2.0 * CORNER_RADIUS, NSMaxYEdge);
     NSDivideRect(rect, &bottomRect, &ignored, 2.0 * CORNER_RADIUS, NSMinYEdge);
     
     [NSGraphicsContext saveGraphicsState];
     
-    [[NSColor colorWithCalibratedWhite:0.9 alpha:1.0] set];
-    [NSBezierPath fillRoundRectInRect:topRect radius:CORNER_RADIUS];
-    [[NSColor colorWithCalibratedWhite:0.4 alpha:1.0] set];
-    [NSBezierPath fillRoundRectInRect:bottomRect radius:CORNER_RADIUS];
-    [[NSColor colorWithCalibratedWhite:0.8 alpha:1.0] set];
-    [NSBezierPath fillRoundRectInRect:NSInsetRect(rect, 0.0, 1.5) 
radius:CORNER_RADIUS];
+    if (edge == NSMinXEdge) {
+        [[NSColor colorWithCalibratedWhite:0.9 alpha:1.0] set];
+        [NSBezierPath fillRightRoundRectInRect:topRect radius:CORNER_RADIUS];
+        [[NSColor colorWithCalibratedWhite:0.4 alpha:1.0] set];
+        [NSBezierPath fillRightRoundRectInRect:bottomRect 
radius:CORNER_RADIUS];
+        [[NSColor colorWithCalibratedWhite:0.8 alpha:1.0] set];
+        [NSBezierPath fillRightRoundRectInRect:NSInsetRect(rect, 0.0, 1.5) 
radius:CORNER_RADIUS];
+    } else {
+        [[NSColor colorWithCalibratedWhite:0.9 alpha:1.0] set];
+        [NSBezierPath fillLeftRoundRectInRect:topRect radius:CORNER_RADIUS];
+        [[NSColor colorWithCalibratedWhite:0.4 alpha:1.0] set];
+        [NSBezierPath fillLeftRoundRectInRect:bottomRect radius:CORNER_RADIUS];
+        [[NSColor colorWithCalibratedWhite:0.8 alpha:1.0] set];
+        [NSBezierPath fillLeftRoundRectInRect:NSInsetRect(rect, 0.0, 1.5) 
radius:CORNER_RADIUS];
+    }
     
     rect = [self resizeHandleRect];
     startPoint = NSMakePoint(NSMidX(rect) - 1.5, NSMidY(rect) - 10.0);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to