From 9eab2071dced51194b698fab408c2055b13bf21e Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Tue, 9 Mar 2010 11:49:36 -0800 Subject: [PATCH 1/3] In CPImageView, performDragOperation: should return a BOOL --- AppKit/CPImageView.j | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AppKit/CPImageView.j b/AppKit/CPImageView.j index 234f74ceb..7d365f71f 100644 --- a/AppKit/CPImageView.j +++ b/AppKit/CPImageView.j @@ -365,7 +365,7 @@ var LEFT_SHADOW_INSET = 3.0, return _isEditable; } -- (void)performDragOperation:(CPDraggingInfo)aSender +- (BOOL)performDragOperation:(CPDraggingInfo)aSender { var images = [CPKeyedUnarchiver unarchiveObjectWithData:[[aSender draggingPasteboard] dataForType:CPImagesPboardType]]; @@ -374,6 +374,8 @@ var LEFT_SHADOW_INSET = 3.0, [self setImage:images[0]]; [self sendAction:[self action] to:[self target]]; } + + return YES; } @end From ee2f3614250b48b4e0821c0f66b2ec09c003ec60 Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Tue, 16 Feb 2010 14:33:12 +0100 Subject: [PATCH 2/3] Reimplemented setImageDimsWhenDisabled: on CPButton to only dim the image instead of the entire button --- AppKit/CPButton.j | 1 + AppKit/_CPImageAndTextView.j | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/AppKit/CPButton.j b/AppKit/CPButton.j index 8a602a607..00b898233 100644 --- a/AppKit/CPButton.j +++ b/AppKit/CPButton.j @@ -530,6 +530,7 @@ CPButtonStateMixed = CPThemeState("mixed"); [contentView setTextShadowOffset:[self currentValueForThemeAttribute:@"text-shadow-offset"]]; [contentView setImagePosition:[self currentValueForThemeAttribute:@"image-position"]]; [contentView setImageScaling:[self currentValueForThemeAttribute:@"image-scaling"]]; + [contentView setDimsImage:[self hasThemeState:CPThemeStateDisabled] && _imageDimsWhenDisabled]; } } diff --git a/AppKit/_CPImageAndTextView.j b/AppKit/_CPImageAndTextView.j index 695598a4d..cee931360 100644 --- a/AppKit/_CPImageAndTextView.j +++ b/AppKit/_CPImageAndTextView.j @@ -63,6 +63,7 @@ var HORIZONTAL_MARGIN = 3.0, CPCellImagePosition _imagePosition; CPImageScaling _imageScaling; + BOOL _shouldDimImage; CPImage _image; CPString _text; @@ -211,6 +212,17 @@ var HORIZONTAL_MARGIN = 3.0, return _imageScaling; } +- (void)setDimsImage:(BOOL)shouldDim +{ + var shouldDimImage = !!shouldDimImage; + + if (_shouldDimImage !== shouldDimImage) + { + _shouldDimImage = shouldDim; + [self setNeedsLayout]; + } +} + - (void)setTextColor:(CPColor)aTextColor { if (_textColor === aTextColor) @@ -572,6 +584,11 @@ var HORIZONTAL_MARGIN = 3.0, imageHeight *= scale; } + if (CPFeatureIsCompatible(CPOpacityRequiresFilterFeature)) + imageStyle.filter = @"alpha(opacity=" + _shouldDimImage ? 35 : 100 + ")"; + else + imageStyle.opacity = _shouldDimImage ? 0.35 : 1.0; + _DOMImageElement.width = imageWidth; _DOMImageElement.height = imageHeight; imageStyle.width = MAX(imageWidth, 0) + "px"; From 13a5c7f215f220533e9bd4f4a8129f6110d68304 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Wed, 12 May 2010 16:50:58 -0700 Subject: [PATCH 3/3] indexOf is not a safe operation on arrays. --- Foundation/CPRunLoop.j | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Foundation/CPRunLoop.j b/Foundation/CPRunLoop.j index c5fde7b54..95ea272bd 100644 --- a/Foundation/CPRunLoop.j +++ b/Foundation/CPRunLoop.j @@ -271,7 +271,7 @@ var CPRunLoopLastNativeRunLoop = 0; // FIXME: Hack for not doing this in CommonJS - if (CFBundle.environments().indexOf("Browser") !== -1) + if ([CFBundle.environments() indexOfObject:("Browser")] !== CPNotFound) { if (!_runLoopInsuranceTimer) _runLoopInsuranceTimer = window.setNativeTimeout(function() @@ -293,7 +293,7 @@ var CPRunLoopLastNativeRunLoop = 0; _runLoopLock = YES; // FIXME: Hack for not doing this in CommonJS - if (CFBundle.environments().indexOf("Browser") !== -1) + if ([CFBundle.environments() indexOfObject:("Browser")] !== CPNotFound) { if (_runLoopInsuranceTimer) {