-
Notifications
You must be signed in to change notification settings - Fork 0
/
RoundDot.m
executable file
·77 lines (63 loc) · 1.78 KB
/
RoundDot.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// RoundDot.m
// App Pie
//
// Created by Giacomo Trezzi on 17/04/09.
// Copyright 2009 __MyCompanyName__. All rights reserved.
//
#import "RoundDot.h"
@implementation RoundDot
@synthesize dark, appcontrol;
- (void)mouseDown:(NSEvent *)theEvent{
dark =0.1;
[self setNeedsDisplay:YES];
}
- (void)mouseUp:(NSEvent *)theEvent{
dark=0;
[self setNeedsDisplay:YES];
[appcontrol loadTransparentWindow];
}
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
dark= 0;
}
return self;
}
//
// drawRect:
//
// Draws the frame of the window.
//
- (void)drawRect:(NSRect)rect
{
//CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
//quadrato trasparente
[[NSColor clearColor] set];
NSRectFill(rect);
//cerchio
int windowWidth = [super frame].size.width / 2;
int windowHeight = [super frame].size.height;
NSRect circleRect;
circleRect.origin.x = windowWidth - CIRCLE_RADIUS;
circleRect.origin.y = windowHeight - 2*CIRCLE_RADIUS;
circleRect.size.width = 2 * CIRCLE_RADIUS;
circleRect.size.height = 2 * CIRCLE_RADIUS;
NSBezierPath * circlePath = [NSBezierPath bezierPathWithOvalInRect:circleRect];
//Gradiente da grigio chiaro a scuro verso l'alto
NSGradient* aGradient =
[[[NSGradient alloc]
initWithColorsAndLocations:
[NSColor colorWithDeviceCyan:0.46+dark magenta:0.38+dark yellow:0.39+dark black:0.03+dark alpha:.8], (CGFloat)0.0,
[NSColor colorWithDeviceCyan:0.24+dark magenta:0.19+dark yellow:0.19+dark black:0+dark alpha:.8], (CGFloat)1.0,
nil]
autorelease];
[aGradient drawInBezierPath:circlePath angle:90];
//contorno del cerchio bianco
[[[NSColor whiteColor] colorWithAlphaComponent:0.6] set];
//[circlePath stroke];
}
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent{
return YES;
}
@end