Skip to content

Commit

Permalink
add source code
Browse files Browse the repository at this point in the history
  • Loading branch information
iMokhles authored and iMokhles committed May 31, 2016
1 parent 8137b8f commit 9f128e4
Show file tree
Hide file tree
Showing 35 changed files with 3,726 additions and 0 deletions.
354 changes: 354 additions & 0 deletions source code/IMSign.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions source code/IMSign/AppDelegate.h
@@ -0,0 +1,15 @@
//
// AppDelegate.h
// IMSign
//
// Created by iMokhles on 16/05/16.
// Copyright © 2016 iMokhles. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@interface AppDelegate : NSObject <NSApplicationDelegate>


@end

29 changes: 29 additions & 0 deletions source code/IMSign/AppDelegate.m
@@ -0,0 +1,29 @@
//
// AppDelegate.m
// IMSign
//
// Created by iMokhles on 16/05/16.
// Copyright © 2016 iMokhles. All rights reserved.
//

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
}

- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
}

- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication {
return YES;
}

@end
@@ -0,0 +1,68 @@
{
"images" : [
{
"size" : "16x16",
"idiom" : "mac",
"filename" : "icon_16x16.png",
"scale" : "1x"
},
{
"size" : "16x16",
"idiom" : "mac",
"filename" : "icon_32x32.png",
"scale" : "2x"
},
{
"size" : "32x32",
"idiom" : "mac",
"filename" : "icon_32x32-1.png",
"scale" : "1x"
},
{
"size" : "32x32",
"idiom" : "mac",
"filename" : "icon_32x32@2x.png",
"scale" : "2x"
},
{
"size" : "128x128",
"idiom" : "mac",
"filename" : "icon_128x128.png",
"scale" : "1x"
},
{
"size" : "128x128",
"idiom" : "mac",
"filename" : "icon_256x256.png",
"scale" : "2x"
},
{
"size" : "256x256",
"idiom" : "mac",
"filename" : "icon_256x256-1.png",
"scale" : "1x"
},
{
"size" : "256x256",
"idiom" : "mac",
"filename" : "icon_512x512.png",
"scale" : "2x"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "icon_512x512-1.png",
"scale" : "1x"
},
{
"size" : "512x512",
"idiom" : "mac",
"filename" : "icon_512x512@2x.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
926 changes: 926 additions & 0 deletions source code/IMSign/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions source code/IMSign/DJProgressHUD/DJActivityIndicator.h
@@ -0,0 +1,21 @@
//
// DJProgressIndicator.h
// Playground
//
// Created by Daniel Jackson on 5/11/14.
// Copyright (c) 2014 Daniel Jackson. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@interface DJActivityIndicator : NSView

@property BOOL isAnimating;

- (void)setColor:(NSColor *)value;
- (void)setBackgroundColor:(NSColor *)value;

- (void)stopAnimation:(id)sender;
- (void)startAnimation:(id)sender;

@end
208 changes: 208 additions & 0 deletions source code/IMSign/DJProgressHUD/DJActivityIndicator.m
@@ -0,0 +1,208 @@
//
// DJProgressIndicator.m
// Playground
//
// Created by Daniel Jackson on 5/11/14.
// Copyright (c) 2014 Daniel Jackson. All rights reserved.
//

#import "DJActivityIndicator.h"

#define kAlphaWhenStopped 0.15
#define kFadeMultiplier 0.85

@interface DJActivityIndicator ()
{
int position;
NSMutableArray* finColors;

BOOL isFadingOut;
NSTimer* animationTimer;

NSColor* foreColor;
NSColor* backColor;
}
@end

@implementation DJActivityIndicator

- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self) {
position = 0;
int numFins = 12;

finColors = [[NSMutableArray alloc] initWithCapacity:numFins];

_isAnimating = NO;
isFadingOut = NO;

foreColor = [NSColor blackColor];
backColor = [NSColor clearColor];

for(int i=0; i<numFins; i++)
{
[finColors addObject:foreColor];
}
}
return self;
}

- (void)drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];

NSSize size = [self bounds].size;
CGFloat theMaxSize;
if(size.width >= size.height)
theMaxSize = size.height;
else
theMaxSize = size.width;

[backColor set];
[NSBezierPath fillRect:[self bounds]];

CGContextRef currentContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
[NSGraphicsContext saveGraphicsState];

CGContextTranslateCTM(currentContext,[self bounds].size.width/2,[self bounds].size.height/2);

NSBezierPath *path = [[NSBezierPath alloc] init];
CGFloat lineWidth = 0.0859375 * theMaxSize;
CGFloat lineStart = 0.234375 * theMaxSize;
CGFloat lineEnd = 0.421875 * theMaxSize;
[path setLineWidth:lineWidth];
[path setLineCapStyle:NSRoundLineCapStyle];
[path moveToPoint:NSMakePoint(0,lineStart)];
[path lineToPoint:NSMakePoint(0,lineEnd)];

for (int i=0; i<finColors.count; i++) {
if(_isAnimating) {
[(NSColor*)finColors[i] set];
}
else {
[[foreColor colorWithAlphaComponent:kAlphaWhenStopped] set];
}

[path stroke];

CGContextRotateCTM(currentContext, 6.282185/finColors.count);
}
path = nil;

[NSGraphicsContext restoreGraphicsState];
}

- (void)startAnimation:(id)sender
{
if (_isAnimating && !isFadingOut) return;

[self actuallyStartAnimation];
}

- (void)stopAnimation:(id)sender
{
isFadingOut = YES;
}

- (void)setColor:(NSColor *)value
{
if (foreColor != value) {
foreColor = nil;
foreColor = value;

for (int i=0; i<finColors.count; i++) {
CGFloat alpha = [finColors[i] alphaComponent];
[finColors setObject:[foreColor colorWithAlphaComponent:alpha] atIndexedSubscript:i];
}

[self setNeedsDisplay:YES];
}
}

- (void)setBackgroundColor:(NSColor *)value
{
if (backColor != value) {
backColor = nil;
backColor = value;
[self setNeedsDisplay:YES];
}
}

- (void)updateFrame:(NSTimer *)timer
{
if(position > 0) {
position--;
}
else {
position = (int)finColors.count - 1;
}

CGFloat minAlpha = kAlphaWhenStopped;
for (int i=0; i<finColors.count; i++) {
CGFloat newAlpha = [finColors[i] alphaComponent] * kFadeMultiplier;
if (newAlpha < minAlpha)
newAlpha = minAlpha;

finColors[i] = [foreColor colorWithAlphaComponent:newAlpha];
}

if (isFadingOut) {
BOOL done = YES;
for (int i=0; i<finColors.count; i++) {
if (fabs([finColors[i] alphaComponent] - minAlpha) > 0.01) {
done = NO;
break;
}
}
if (done) {
[self actuallyStopAnimation];
}
}
else {
finColors[position] = foreColor;
}

[self setNeedsDisplay:YES];


}

- (void)actuallyStartAnimation
{
[self actuallyStopAnimation];

_isAnimating = YES;
isFadingOut = NO;

position = 1;

animationTimer = [NSTimer timerWithTimeInterval:(NSTimeInterval)0.05
target:self
selector:@selector(updateFrame:)
userInfo:nil
repeats:YES];

[[NSRunLoop currentRunLoop] addTimer:animationTimer forMode:NSRunLoopCommonModes];
[[NSRunLoop currentRunLoop] addTimer:animationTimer forMode:NSDefaultRunLoopMode];
[[NSRunLoop currentRunLoop] addTimer:animationTimer forMode:NSEventTrackingRunLoopMode];
}

- (void)actuallyStopAnimation
{
_isAnimating = NO;
isFadingOut = NO;

if (animationTimer) {
// we were using timer-based animation
[animationTimer invalidate];
animationTimer = nil;
}
//[self setNeedsDisplay:YES];
}




@end
15 changes: 15 additions & 0 deletions source code/IMSign/DJProgressHUD/DJBezierPath.h
@@ -0,0 +1,15 @@
//
// CPBezierPath.h
// Cloud Play OSX
//
// Created by Daniel Jackson on 5/11/14.
// Copyright (c) 2014 Daniel Jackson. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@interface DJBezierPath : NSBezierPath

- (CGPathRef)quartzPath;

@end

0 comments on commit 9f128e4

Please sign in to comment.