Permalink
Browse files

april fools' day feature for beta version :)

  • Loading branch information...
Simone Manganelli Simone Manganelli
Simone Manganelli authored and Simone Manganelli committed Mar 31, 2010
1 parent e90cf11 commit cd3c1f34f81e33e39e7ec8e40a07d853a50ffcbc
Showing with 84 additions and 16 deletions.
  1. +10 −2 ClickToFlash.xcodeproj/project.pbxproj
  2. +74 −14 Plugin/CTFMainButton.m
  3. BIN flasher1.png
  4. BIN flasher2.png
@@ -73,6 +73,8 @@
A46A5E2B109700B400E1ABAA /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 79A060EB0FF1CBF50035F03A /* Sparkle.framework */; };
A486EE6D10A818560051FFD7 /* SparkleManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A486EE6C10A818560051FFD7 /* SparkleManager.m */; };
A494CC2C0F9F2446007D5EEB /* ctf.icns in Resources */ = {isa = PBXBuildFile; fileRef = A494CC2B0F9F2446007D5EEB /* ctf.icns */; };
+ A4C362441162CC760016E919 /* flasher1.png in Resources */ = {isa = PBXBuildFile; fileRef = A4C362421162CC760016E919 /* flasher1.png */; };
+ A4C362451162CC760016E919 /* flasher2.png in Resources */ = {isa = PBXBuildFile; fileRef = A4C362431162CC760016E919 /* flasher2.png */; };
A4D8074710A4129C0024454E /* ctf.icns in Resources */ = {isa = PBXBuildFile; fileRef = A494CC2B0F9F2446007D5EEB /* ctf.icns */; };
A4D808EE10A7D7870024454E /* ClickToFlash Updater.app in Resources */ = {isa = PBXBuildFile; fileRef = A46A59FE1096C2A700E1ABAA /* ClickToFlash Updater.app */; };
A4DEFC7A0FF33F7400CCB6A8 /* CTFPreferencesDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = A4DEFC770FF33F7400CCB6A8 /* CTFPreferencesDictionary.m */; };
@@ -236,6 +238,8 @@
A486EE6B10A818560051FFD7 /* SparkleManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SparkleManager.h; path = Plugin/SparkleManager.h; sourceTree = "<group>"; };
A486EE6C10A818560051FFD7 /* SparkleManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SparkleManager.m; path = Plugin/SparkleManager.m; sourceTree = "<group>"; };
A494CC2B0F9F2446007D5EEB /* ctf.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = ctf.icns; path = Plugin/ctf.icns; sourceTree = "<group>"; };
+ A4C362421162CC760016E919 /* flasher1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = flasher1.png; sourceTree = "<group>"; };
+ A4C362431162CC760016E919 /* flasher2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = flasher2.png; sourceTree = "<group>"; };
A4DEFC760FF33F7400CCB6A8 /* CTFPreferencesDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CTFPreferencesDictionary.h; path = Plugin/CTFPreferencesDictionary.h; sourceTree = "<group>"; };
A4DEFC770FF33F7400CCB6A8 /* CTFPreferencesDictionary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CTFPreferencesDictionary.m; path = Plugin/CTFPreferencesDictionary.m; sourceTree = "<group>"; };
A4DEFC780FF33F7400CCB6A8 /* CTFUserDefaultsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CTFUserDefaultsController.h; path = Plugin/CTFUserDefaultsController.h; sourceTree = "<group>"; };
@@ -340,6 +344,8 @@
A40485B210629B0E00FDC4E2 /* Credits.html */,
A40485B410629B0E00FDC4E2 /* InfoPlist.strings */,
A40485B610629B0E00FDC4E2 /* Localizable.strings */,
+ A4C362421162CC760016E919 /* flasher1.png */,
+ A4C362431162CC760016E919 /* flasher2.png */,
);
indentWidth = 4;
name = Plugin;
@@ -529,6 +535,8 @@
A40485BA10629B0E00FDC4E2 /* InfoPlist.strings in Resources */,
A40485BB10629B0E00FDC4E2 /* Localizable.strings in Resources */,
A4D808EE10A7D7870024454E /* ClickToFlash Updater.app in Resources */,
+ A4C362441162CC760016E919 /* flasher1.png in Resources */,
+ A4C362451162CC760016E919 /* flasher2.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -738,7 +746,7 @@
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_SIGN_COMPARE = YES;
- PRODUCT_VERSION = 1.6b8;
+ PRODUCT_VERSION = 1.6b9;
WARNING_CFLAGS = "-Wall";
};
name = Debug;
@@ -753,7 +761,7 @@
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_SIGN_COMPARE = YES;
- PRODUCT_VERSION = 1.6b8;
+ PRODUCT_VERSION = 1.6b9;
WARNING_CFLAGS = "-Wall";
};
name = Release;
View
@@ -11,6 +11,9 @@
#import "Plugin.h"
#import "CTFUtilities.h"
#import "NSBezierPath-RoundedRectangle.h"
+#import "CTFUserDefaultsController.h"
+
+static NSString *sAprilFoolsJokeKey = @"enableClickToFlashMascot";
@@ -47,24 +50,81 @@ @implementation CTFMainButtonCell
- (void) drawWithFrame: (NSRect) rect inView:(NSView *) controlView {
NSRect bounds = [[self controlView] bounds];
NSRect fillRect = NSInsetRect(bounds, 1.0, 1.0);
-
+
+ NSDate *todaysDate = [NSDate date];
+ NSCalendar *gregorianCal = [[NSCalendar alloc]
+ initWithCalendarIdentifier:NSGregorianCalendar];
+ unsigned componentFlags = NSMonthCalendarUnit | NSDayCalendarUnit;
+ NSDateComponents *todaysDateComponents = [gregorianCal components:componentFlags fromDate:todaysDate];
+
+ [gregorianCal release];
+
+ BOOL aprilFools = ( ([todaysDateComponents month] == 4) && ([todaysDateComponents day] == 1) );
+
[self drawGradientInRect: fillRect];
[self drawPreviewInRect: fillRect];
- // Draw stroke
- [[NSColor colorWithCalibratedWhite:0.0 alpha:0.50] set];
- [NSBezierPath setDefaultLineWidth:2.0];
- [NSBezierPath setDefaultLineCapStyle:NSSquareLineCapStyle];
- [[NSBezierPath bezierPathWithRect:bounds] stroke];
-
- // Draw label
- [self drawBadgeForBounds: bounds];
-
- // Draw 'glossy' overlay which can give some visual feedback on clicks when an preview image is set.
- if ([(CTFClickToFlashPlugin*)[controlView superview] previewImage] != nil) {
- [self drawGlossForBounds: bounds];
+ // Draw stroke
+ [[NSColor colorWithCalibratedWhite:0.0 alpha:0.50] set];
+ [NSBezierPath setDefaultLineWidth:2.0];
+ [NSBezierPath setDefaultLineCapStyle:NSSquareLineCapStyle];
+ [[NSBezierPath bezierPathWithRect:bounds] stroke];
+
+ if ([[CTFUserDefaultsController standardUserDefaults] boolForKey:sAprilFoolsJokeKey] || aprilFools) {
+ NSString *mascotImageFilename = nil;
+ if ([self isHighlighted]) {
+ mascotImageFilename = @"flasher2";
+ } else {
+ mascotImageFilename = @"flasher1";
+ }
+ NSBundle *CTFBundle = [NSBundle bundleWithIdentifier:@"com.github.rentzsch.clicktoflash"];
+ NSURL *fileURL = [NSURL fileURLWithPath:[CTFBundle pathForResource:mascotImageFilename ofType:@"png"]];
+ NSImage *mascotImage = [[NSImage alloc] initWithContentsOfURL:fileURL];
+
+ float smallestDimension = 130.0; // flasher image dimensions are 130x130
+ float boundsHeight = bounds.size.height;
+ float boundsWidth = bounds.size.width;
+ if (boundsHeight < boundsWidth) {
+ if (boundsHeight < smallestDimension) {
+ smallestDimension = boundsHeight;
+ }
+ } else {
+ if (boundsWidth < smallestDimension) {
+ smallestDimension = boundsWidth;
+ }
+ }
+ float marginHeight = (boundsHeight - smallestDimension)/2.0;
+ float marginWidth = (boundsWidth - smallestDimension)/2.0;
+ NSRect drawRect = NSMakeRect(bounds.origin.x + marginWidth, bounds.origin.y + marginHeight, smallestDimension, smallestDimension);
+
+ // first we need to draw a circular "spotlight" for the little mascot,
+ // otherwise he'll get lost on previews
+
+ /*CGFloat gearSize = [gearImage size].width; // assumes the gear to be square
+ CGFloat size = gearSize + 2.0 * padding;
+ CGFloat x = round(bounds.size.width * .5) - round(size * .5);
+ CGFloat y = round(bounds.size.height * .5 ) - round(size * .5);
+ NSRect backgroundFrame = NSMakeRect(x, y, size, size);*/
+
+ NSBezierPath * circle = [NSBezierPath bezierPathWithOvalInRect:drawRect];
+ CGFloat alpha = 1.0;
+ [[NSColor colorWithDeviceWhite:1.0 alpha:alpha] set];
+ [circle fill];
+
+
+ // now draw the little mascot!
+ NSRect imageRect = NSMakeRect(0,0,[mascotImage size].width,[mascotImage size].height);
+ [mascotImage drawInRect:drawRect fromRect:imageRect operation:NSCompositeSourceOver fraction:1.0];
+ [mascotImage release];
+ } else {
+ // Draw label
+ [self drawBadgeForBounds: bounds];
+
+ // Draw 'glossy' overlay which can give some visual feedback on clicks when an preview image is set.
+ if ([(CTFClickToFlashPlugin*)[controlView superview] previewImage] != nil) {
+ [self drawGlossForBounds: bounds];
+ }
}
-
}
View
Binary file not shown.
View
Binary file not shown.

0 comments on commit cd3c1f3

Please sign in to comment.