mirror of
https://github.com/transmission/transmission
synced 2025-01-31 03:12:44 +00:00
create an addition to NSBezierClass to create a rectangle with rounded corners
This commit is contained in:
parent
16627cc209
commit
892d9bf156
5 changed files with 89 additions and 16 deletions
|
@ -48,6 +48,7 @@
|
|||
A200B9B60A22893D007BBB1E /* InfoWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = A200B9620A227FD0007BBB1E /* InfoWindow.nib */; };
|
||||
A20AB97B0A5C622A004F81FA /* SmallTurtle.png in Resources */ = {isa = PBXBuildFile; fileRef = A20AB97A0A5C622A004F81FA /* SmallTurtle.png */; };
|
||||
A21567ED0A9A5034004DECD6 /* MessageWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = A21567EB0A9A5034004DECD6 /* MessageWindow.nib */; };
|
||||
A215760B0C0D449A0057A26A /* BezierPathAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = A21576090C0D449A0057A26A /* BezierPathAdditions.m */; };
|
||||
A2173E1C0A33C1B300B0D8AB /* ActionButtonPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = A2173E1B0A33C1B300B0D8AB /* ActionButtonPressed.png */; };
|
||||
A21DFF100A292B2B007C5F76 /* Transfers.png in Resources */ = {isa = PBXBuildFile; fileRef = A21DFF0F0A292B2B007C5F76 /* Transfers.png */; };
|
||||
A21F5B890AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = A21F5B870AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.m */; };
|
||||
|
@ -308,6 +309,8 @@
|
|||
A200B9630A227FD0007BBB1E /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = macosx/English.lproj/InfoWindow.nib; sourceTree = "<group>"; };
|
||||
A20AB97A0A5C622A004F81FA /* SmallTurtle.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = SmallTurtle.png; path = macosx/Images/SmallTurtle.png; sourceTree = "<group>"; };
|
||||
A21567EC0A9A5034004DECD6 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = macosx/English.lproj/MessageWindow.nib; sourceTree = "<group>"; };
|
||||
A21576090C0D449A0057A26A /* BezierPathAdditions.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = BezierPathAdditions.m; path = macosx/BezierPathAdditions.m; sourceTree = "<group>"; };
|
||||
A215760A0C0D449A0057A26A /* BezierPathAdditions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = BezierPathAdditions.h; path = macosx/BezierPathAdditions.h; sourceTree = "<group>"; };
|
||||
A2173E1B0A33C1B300B0D8AB /* ActionButtonPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ActionButtonPressed.png; path = macosx/Images/ActionButtonPressed.png; sourceTree = "<group>"; };
|
||||
A21DFF0F0A292B2B007C5F76 /* Transfers.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Transfers.png; path = macosx/Images/Transfers.png; sourceTree = "<group>"; };
|
||||
A21F5B860AF25FB6008CE5CE /* ActionMenuRatioToDisplayRatioTransformer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ActionMenuRatioToDisplayRatioTransformer.h; path = macosx/ActionMenuRatioToDisplayRatioTransformer.h; sourceTree = "<group>"; };
|
||||
|
@ -556,6 +559,8 @@
|
|||
children = (
|
||||
A24D2A610C0A624600A0ED9F /* IPCController.h */,
|
||||
A24D2A620C0A624600A0ED9F /* IPCController.m */,
|
||||
A21576090C0D449A0057A26A /* BezierPathAdditions.m */,
|
||||
A215760A0C0D449A0057A26A /* BezierPathAdditions.h */,
|
||||
A2FB057C0BFEB6800095564D /* DragOverlayView.h */,
|
||||
A2FB057D0BFEB6800095564D /* DragOverlayView.m */,
|
||||
A2385DD20BFE06C800B24EF6 /* DragOverlayWindow.m */,
|
||||
|
@ -1214,6 +1219,7 @@
|
|||
E138A9780C04D88F00C5426C /* CTGradientAdditions.m in Sources */,
|
||||
A24D2A640C0A624600A0ED9F /* IPCController.m in Sources */,
|
||||
A24838820C0BA608005CC3FE /* FilterBarView.m in Sources */,
|
||||
A215760B0C0D449A0057A26A /* BezierPathAdditions.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
31
macosx/BezierPathAdditions.h
Normal file
31
macosx/BezierPathAdditions.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/******************************************************************************
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2007 Transmission authors and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*****************************************************************************/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface NSBezierPath (BezierPathAdditions)
|
||||
|
||||
+ (NSBezierPath *) bezierPathWithRoundedRect: (NSRect) rect radius: (float) radius;
|
||||
|
||||
@end
|
49
macosx/BezierPathAdditions.m
Normal file
49
macosx/BezierPathAdditions.m
Normal file
|
@ -0,0 +1,49 @@
|
|||
/******************************************************************************
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (c) 2007 Transmission authors and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*****************************************************************************/
|
||||
|
||||
#import "BezierPathAdditions.h"
|
||||
|
||||
@implementation NSBezierPath (BezierPathAdditions)
|
||||
|
||||
+ (NSBezierPath *) bezierPathWithRoundedRect: (NSRect) rect radius: (float) radius
|
||||
{
|
||||
float minX = NSMinX(rect),
|
||||
minY = NSMinY(rect),
|
||||
maxX = NSMaxX(rect),
|
||||
maxY = NSMaxY(rect),
|
||||
midX = NSMidX(rect),
|
||||
midY = NSMidY(rect);
|
||||
|
||||
NSBezierPath * bp = [NSBezierPath bezierPath];
|
||||
[bp moveToPoint: NSMakePoint(maxX, midY)];
|
||||
[bp appendBezierPathWithArcFromPoint: NSMakePoint(maxX, maxY) toPoint: NSMakePoint(midX, maxY) radius: radius];
|
||||
[bp appendBezierPathWithArcFromPoint: NSMakePoint(minX, maxY) toPoint: NSMakePoint(minX, midY) radius: radius];
|
||||
[bp appendBezierPathWithArcFromPoint: NSMakePoint(minX, minY) toPoint: NSMakePoint(midX, minY) radius: radius];
|
||||
[bp appendBezierPathWithArcFromPoint: NSMakePoint(maxX, minY) toPoint: NSMakePoint(maxX, midY) radius: radius];
|
||||
[bp closePath];
|
||||
|
||||
return bp;
|
||||
}
|
||||
|
||||
@end
|
|
@ -3039,6 +3039,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
[[NSWorkspace sharedWorkspace] selectFile: location inFileViewerRootedAtPath: nil];
|
||||
}
|
||||
|
||||
#warning move to additions
|
||||
- (NSString *) applicationSupportFolder
|
||||
{
|
||||
return [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) objectAtIndex: 0]
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#import "DragOverlayView.h"
|
||||
#import "BezierPathAdditions.h"
|
||||
|
||||
@implementation DragOverlayView
|
||||
|
||||
|
@ -32,22 +33,7 @@
|
|||
{
|
||||
//create badge
|
||||
NSRect badgeRect = NSMakeRect(0, 0, 325.0, 84.0);
|
||||
|
||||
float minX = NSMinX(badgeRect),
|
||||
minY = NSMinY(badgeRect),
|
||||
maxX = NSMaxX(badgeRect),
|
||||
maxY = NSMaxY(badgeRect),
|
||||
midX = NSMidX(badgeRect),
|
||||
midY = NSMidY(badgeRect),
|
||||
radius = 15.0;
|
||||
|
||||
NSBezierPath * bp = [NSBezierPath bezierPath];
|
||||
[bp moveToPoint: NSMakePoint(maxX, midY)];
|
||||
[bp appendBezierPathWithArcFromPoint: NSMakePoint(maxX, maxY) toPoint: NSMakePoint(midX, maxY) radius: radius];
|
||||
[bp appendBezierPathWithArcFromPoint: NSMakePoint(minX, maxY) toPoint: NSMakePoint(minX, midY) radius: radius];
|
||||
[bp appendBezierPathWithArcFromPoint: NSMakePoint(minX, minY) toPoint: NSMakePoint(midX, minY) radius: radius];
|
||||
[bp appendBezierPathWithArcFromPoint: NSMakePoint(maxX, minY) toPoint: NSMakePoint(maxX, midY) radius: radius];
|
||||
[bp closePath];
|
||||
NSBezierPath * bp = [NSBezierPath bezierPathWithRoundedRect: badgeRect radius: 15.0];
|
||||
|
||||
fBackBadge = [[NSImage alloc] initWithSize: badgeRect.size];
|
||||
[fBackBadge lockFocus];
|
||||
|
|
Loading…
Reference in a new issue