Skip to content

Commit

Permalink
Initial import.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcw committed Nov 17, 2013
0 parents commit b0a6797
Show file tree
Hide file tree
Showing 152 changed files with 8,188 additions and 0 deletions.
126 changes: 126 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#########################
# .gitignore file for Xcode4 / OS X Source projects
#
# NB: if you are storing "built" products, this WILL NOT WORK,
# and you should use a different .gitignore (or none at all)
# This file is for SOURCE projects, where there are many extra
# files that we want to exclude
#
# For updates, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#########################

#####
# OS X temporary files that should never be committed

.DS_Store
*.swp
*.lock
profile


####
# Xcode temporary files that should never be committed
#
# NB: NIB/XIB files still exist even on Storyboard projects, so we want this...

*~.nib


####
# Xcode build files -
#
# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "DerivedData"

DerivedData/

# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "build"

build/


#####
# Xcode private settings (window sizes, bookmarks, breakpoints, custom executables, smart groups)
#
# This is complicated:
#
# SOMETIMES you need to put this file in version control.
# Apple designed it poorly - if you use "custom executables", they are
# saved in this file.
# 99% of projects do NOT use those, so they do NOT want to version control this file.
# ..but if you're in the 1%, comment out the line "*.pbxuser"

*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
# NB: also, whitelist the default ones, some projects need to use these
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3


####
# Xcode 4 - semi-personal settings, often included in workspaces
#
# You can safely ignore the xcuserdata files - but do NOT ignore the files next to them
#

xcuserdata


####
# XCode 4 workspaces - more detailed
#
# Workspaces are important! They are a core feature of Xcode - don't exclude them :)
#
# Workspace layout is quite spammy. For reference:
#
# (root)/
# (project-name).xcodeproj/
# project.pbxproj
# project.xcworkspace/
# contents.xcworkspacedata
# xcuserdata/
# (your name)/xcuserdatad/
# xcuserdata/
# (your name)/xcuserdatad/
#
#
#
# Xcode 4 workspaces - SHARED
#
# This is UNDOCUMENTED (google: "developer.apple.com xcshareddata" - 0 results
# But if you're going to kill personal workspaces, at least keep the shared ones...
#
#
!xcshareddata


####
# Xcode 4 - Deprecated classes
#
# Allegedly, if you manually "deprecate" your classes, they get moved here.
#
# We're using source-control, so this is a "feature" that we do not want!

*.moved-aside


####
# UNKNOWN: recommended by others, but I can't discover what these files are
#
# ...none. Everything is now explained.
node_modules
dist/TwentyTwo.app
dist/template.dmg
dist/wc.dmg

####
# Xcode 5 - Source Control files
#
# Xcode 5 introduced a new file type .xccheckout. This files contains VCS metadata
# and should therefore not be checked into the VCS.

*.xccheckout
.codesign
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## 0.12 (November 8, 2013)
- Automatic updates yay!

## 0.11 (October 10, 2013)
- fixed closing window stops music in certain cases
- notifications support

## 0.10 (September 13, 2013)
- added reload menu item and Cmd+R shortcut
- added main window menu item and Cmd+1 shortcut

## 0.9.1 (August 1, 2013)
- distributed as .dmg package instead of Mac Installer
- compatible with OSX 10.7 Lion

## 0.9 (July 5, 2013)

- fixed ▶ media key
- support the new upload ui

## 0.8 (June 26, 2013)

- enabled Flash plugin which is required for playing certain sounds

## 0.7 (June 13, 2013)

- swipe for back/forward navigation
- fixed notifications and unread messages reappearing on every launch
- pause/start on spacebar even when the main window is not visible
- fixed restoring position and size on launch

## 0.6 (April 17, 2013)

- brought back the Edit menu, fixed lost copy&paste functionality
- one more shot on supporting pre Mt. Lion (should be confirmed)

## 0.5 (april 10, 2013)

- added basic full screen support
- close button hides main window without stopping play
- simplified menu bar
- introduced CHANGELOG :)
24 changes: 24 additions & 0 deletions DHSwipeWebView/DHSwipeClipView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#import <Cocoa/Cocoa.h>
#import "DHSwipeWebView.h"

@interface DHSwipeClipView : NSClipView {
CGFloat currentSum;
NSTimer *drawTimer;
BOOL canGoLeft;
BOOL canGoRight;
DHSwipeWebView *webView;
BOOL isHandlingEvent;
BOOL _haveAdditionalClip;
NSRect _additionalClip;
CGFloat scrollDeltaX;
CGFloat scrollDeltaY;
}

@property (retain) NSTimer *drawTimer;
@property (assign) CGFloat currentSum;
@property (retain) DHSwipeWebView *webView;
@property (assign) BOOL isHandlingEvent;

- (id)initWithFrame:(NSRect)frame webView:(DHSwipeWebView *)aWebView;

@end
186 changes: 186 additions & 0 deletions DHSwipeWebView/DHSwipeClipView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
#import "DHSwipeClipView.h"

// Some code taken from https://github.com/kgn/LinenClipView
@implementation DHSwipeClipView

@synthesize drawTimer;
@synthesize currentSum;
@synthesize webView;
@synthesize isHandlingEvent;

- (id)initWithFrame:(NSRect)frame webView:(DHSwipeWebView *)aWebView
{
if(!(self = [super initWithFrame:frame]))
{
return nil;
}
self.webView = aWebView;

// In WebHTMLView, we set a clip. This is not typical to do in an
// NSView, and while correct for any one invocation of drawRect:,
// it causes some bad problems if that clip is cached between calls.
// The cached graphics state, which clip views keep around, does
// cache the clip in this undesirable way. Consequently, we want to
// release the GState for all clip views for all views contained in
// a WebHTMLView. Here we do it for subframes, which use WebClipView.
// See these bugs for more information:
// <rdar://problem/3409315>: REGRESSSION (7B58-7B60)?: Safari draws blank frames on macosx.apple.com perf page
[self releaseGState];

return self;
}

- (void)resetAdditionalClip
{
_haveAdditionalClip = NO;
}

- (void)setAdditionalClip:(NSRect)additionalClip
{
_haveAdditionalClip = YES;
_additionalClip = additionalClip;
}

- (BOOL)hasAdditionalClip
{
return _haveAdditionalClip;
}

- (NSRect)additionalClip
{
return _additionalClip;
}

// From https://gist.github.com/b6bcb09a9fc0e9557c27
- (NSView *)hitTest:(NSPoint)aPoint
{
NSEvent *currentEvent = [NSApp currentEvent];
NSScrollView *scrollView = [self enclosingScrollView];
if([currentEvent type] == NSLeftMouseDown)
{
// if we have a vertical scroller and it accepts the current hit
if([scrollView hasVerticalScroller] && [[scrollView verticalScroller] hitTest:aPoint] != nil)
{
[[scrollView verticalScroller] mouseDown:currentEvent];
}
// if we have a horizontal scroller and it accepts the current hit
if([scrollView hasVerticalScroller] && [[scrollView horizontalScroller] hitTest:aPoint] != nil)
{
[[scrollView horizontalScroller] mouseDown:currentEvent];
}
}
return [super hitTest:aPoint];
}

- (void)scrollWheel:(NSEvent *)event
{
if(![NSEvent isSwipeTrackingFromScrollEventsEnabled])
{
[super scrollWheel:event];
return;
}
if([event phase] == NSEventPhaseBegan)
{
currentSum = 0;
NSScrollView *scrollView = [[[[webView mainFrame] frameView] documentView] enclosingScrollView];
NSRect bounds = [[scrollView contentView] bounds];
canGoLeft = canGoRight = NO;
if(bounds.origin.x <= 0)
{
canGoLeft = YES; // && [webView canGoBack]
}
if(bounds.origin.x + bounds.size.width >= [[scrollView documentView] bounds].size.width)
{
canGoRight = YES; // && [webView canGoForward]
}
scrollDeltaX = 0;
scrollDeltaY = 0;
isHandlingEvent = canGoLeft || canGoRight;
}
else if([event phase] == NSEventPhaseChanged)
{
if(!isHandlingEvent)
{
if(currentSum != 0)
{
currentSum = 0;
[self launchDrawTimer];
}
}
else
{
scrollDeltaX += [event scrollingDeltaX];
scrollDeltaY += [event scrollingDeltaY];

float absoluteSumX = fabsf(scrollDeltaX);
float absoluteSumY = fabsf(scrollDeltaY);
if((absoluteSumX < absoluteSumY && currentSum == 0))
{
isHandlingEvent = NO;
if(currentSum != 0)
{
currentSum = 0;
[self launchDrawTimer];
}
}
else
{
CGFloat flippedDeltaX = scrollDeltaX * -1;
if(flippedDeltaX == 0 || (flippedDeltaX < 0 && !canGoLeft) || (flippedDeltaX > 0 && !canGoRight))
{
if(currentSum != 0)
{
currentSum = 0;
[self launchDrawTimer];
}
}
else
{
// Draw the back/forward indicators
currentSum = flippedDeltaX/1000;
[self launchDrawTimer];
return;
}
}
}
}
else if([event phase] == NSEventPhaseEnded)
{
if(currentSum < -0.3 && canGoLeft && [self.webView canGoBack])
{
[self.webView goBack];
}
else if(currentSum >= 0.3 && canGoRight && [self.webView canGoForward])
{
[self.webView goForward];
}
isHandlingEvent = NO;
if(currentSum != 0)
{
currentSum = 0;
[self launchDrawTimer];
}
}
else if([event phase] == NSEventPhaseCancelled)
{
isHandlingEvent = NO;
if(currentSum != 0)
{
currentSum = 0;
[self launchDrawTimer];
}
}
[super scrollWheel:event];
}

- (void)launchDrawTimer
{
// a timer is needed because events are queued and processing and drawing
// takes longer than they are delivered, so the queue fills up
if(!drawTimer || ![drawTimer isValid])
{
self.drawTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f/25 target:webView.swipeIndicator selector:@selector(display) userInfo:nil repeats:NO];
}
}

@end
15 changes: 15 additions & 0 deletions DHSwipeWebView/DHSwipeIndicator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#import <Cocoa/Cocoa.h>
#import "DHSwipeWebView.h"
#import "DHSwipeClipView.h"

@interface DHSwipeIndicator : NSView {
DHSwipeWebView *webView;
DHSwipeClipView *clipView;
}

@property (retain) DHSwipeWebView *webView;
@property (retain) DHSwipeClipView *clipView;

- (id)initWithWebView:(DHSwipeWebView *)aWebView;

@end
Loading

0 comments on commit b0a6797

Please sign in to comment.