summaryrefslogtreecommitdiff
path: root/cocoa/PSMTabBarControl/PSMTabDragWindowController.m
diff options
context:
space:
mode:
authorSven Weidauer <sven.weidauer@gmail.com>2011-01-26 10:52:13 +0000
committerSven Weidauer <sven.weidauer@gmail.com>2011-01-26 10:52:13 +0000
commit7b2694e9f6c35d9f50c3fb3cf38b0fc766478162 (patch)
treec4e3d07a6bb51de884f53312a96d05849f072db1 /cocoa/PSMTabBarControl/PSMTabDragWindowController.m
parenta663cf8f84942e1147d1d2f3db292308639c7fa5 (diff)
downloadnetsurf-7b2694e9f6c35d9f50c3fb3cf38b0fc766478162.tar.gz
netsurf-7b2694e9f6c35d9f50c3fb3cf38b0fc766478162.tar.bz2
Updated PSMTabBarControl source code to version from https://github.com/dergraf83/PSMTabBarControl
svn path=/trunk/netsurf/; revision=11490
Diffstat (limited to 'cocoa/PSMTabBarControl/PSMTabDragWindowController.m')
-rw-r--r--cocoa/PSMTabBarControl/PSMTabDragWindowController.m66
1 files changed, 29 insertions, 37 deletions
diff --git a/cocoa/PSMTabBarControl/PSMTabDragWindowController.m b/cocoa/PSMTabBarControl/PSMTabDragWindowController.m
index 018bca172..3a6e8c663 100644
--- a/cocoa/PSMTabBarControl/PSMTabDragWindowController.m
+++ b/cocoa/PSMTabBarControl/PSMTabDragWindowController.m
@@ -12,104 +12,96 @@
@implementation PSMTabDragWindowController
-- (id)initWithImage:(NSImage *)image styleMask:(NSUInteger)styleMask tearOffStyle:(PSMTabBarTearOffStyle)tearOffStyle
-{
+- (id)initWithImage:(NSImage *)image styleMask:(NSUInteger)styleMask tearOffStyle:(PSMTabBarTearOffStyle)tearOffStyle {
PSMTabDragWindow *window = [PSMTabDragWindow dragWindowWithImage:image styleMask:styleMask];
- if ( (self = [super initWithWindow:window]) ) {
+ if((self = [super initWithWindow:window])) {
_view = [[window dragView] retain];
_tearOffStyle = tearOffStyle;
-
- if (tearOffStyle == PSMTabBarTearOffMiniwindow) {
+
+ if(tearOffStyle == PSMTabBarTearOffMiniwindow) {
[window setBackgroundColor:[NSColor clearColor]];
[window setHasShadow:YES];
}
-
+
[window setAlphaValue:kPSMTabDragWindowAlpha];
}
return self;
}
-- (void)dealloc
-{
- if (_timer) {
+- (void)dealloc {
+ if(_timer) {
[_timer invalidate];
}
-
- if (_animation) {
+
+ if(_animation) {
[_animation release];
}
-
+
[_view release];
[super dealloc];
}
-- (NSImage *)image
-{
+- (NSImage *)image {
return [_view image];
}
-- (NSImage *)alternateImage
-{
+- (NSImage *)alternateImage {
return [_view alternateImage];
}
-- (void)setAlternateImage:(NSImage *)image
-{
+- (void)setAlternateImage:(NSImage *)image {
[_view setAlternateImage:image];
}
-- (BOOL)isAnimating
-{
+- (BOOL)isAnimating {
return _animation != nil;
}
-- (void)switchImages
-{
- if (_tearOffStyle != PSMTabBarTearOffMiniwindow || ![_view alternateImage]) {
+- (void)switchImages {
+ if(_tearOffStyle != PSMTabBarTearOffMiniwindow || ![_view alternateImage]) {
return;
}
-
+
CGFloat progress = 0;
_showingAlternate = !_showingAlternate;
-
- if (_animation) {
+
+ if(_animation) {
//An animation already exists, get the current progress
progress = 1.0f - [_animation currentProgress];
[_animation stopAnimation];
[_animation release];
}
-
+
//begin animating
_animation = [[NSAnimation alloc] initWithDuration:0.25 animationCurve:NSAnimationEaseInOut];
[_animation setAnimationBlockingMode:NSAnimationNonblocking];
[_animation setCurrentProgress:progress];
[_animation startAnimation];
-
+
_originalWindowFrame = [[self window] frame];
-
- if (_timer) {
+
+ if(_timer) {
[_timer invalidate];
}
_timer = [NSTimer scheduledTimerWithTimeInterval:1.0f / 30.0f target:self selector:@selector(animateTimer:) userInfo:nil repeats:YES];
}
-- (void)animateTimer:(NSTimer *)timer
-{
+- (void)animateTimer:(NSTimer *)timer {
NSRect frame = _originalWindowFrame;
- NSImage *currentImage = _showingAlternate ? [_view alternateImage] : [_view image];
+ NSImage *currentImage = _showingAlternate ?[_view alternateImage] :[_view image];
NSSize size = [currentImage size];
NSPoint mousePoint = [NSEvent mouseLocation];
CGFloat animationValue = [_animation currentValue];
-
+
frame.size.width = _originalWindowFrame.size.width + (size.width - _originalWindowFrame.size.width) * animationValue;
frame.size.height = _originalWindowFrame.size.height + (size.height - _originalWindowFrame.size.height) * animationValue;
frame.origin.x = mousePoint.x - (frame.size.width / 2);
frame.origin.y = mousePoint.y - (frame.size.height / 2);
-
+
[_view setFadeValue:_showingAlternate ? 1.0f - animationValue : animationValue];
[[self window] setFrame:frame display:YES];
-
- if (![_animation isAnimating]) {
+
+ if(![_animation isAnimating]) {
[_animation release], _animation = nil;
[timer invalidate];
_timer = nil;