From ea47baa1fc0fcfc0e65f616c1fab17188d1652d7 Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Wed, 10 Feb 2010 16:19:51 +0100 Subject: [PATCH] implemented imageDimsWhenDisabled on CPButton --- AppKit/CPButton.j | 1 + AppKit/_CPImageAndTextView.j | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/AppKit/CPButton.j b/AppKit/CPButton.j index 57b15195b..2cbcbf519 100644 --- a/AppKit/CPButton.j +++ b/AppKit/CPButton.j @@ -554,6 +554,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 d5755c60d..85ba77333 100644 --- a/AppKit/_CPImageAndTextView.j +++ b/AppKit/_CPImageAndTextView.j @@ -68,6 +68,7 @@ var HORIZONTAL_MARGIN = 3.0, CPCellImagePosition _imagePosition; CPImageScaling _imageScaling; + BOOL _shouldDimImage; CPImage _image; CPString _text; @@ -216,6 +217,16 @@ var HORIZONTAL_MARGIN = 3.0, return _imageScaling; } +- (void)setDimsImage:(BOOL)shouldDimImage +{ + var shouldDimImage = !!shouldDimImage; + if (_shouldDimImage !== shouldDimImage) + { + _shouldDimImage = shouldDimImage; + [self setNeedsLayout]; + } +} + - (void)setTextColor:(CPColor)aTextColor { if (_textColor === aTextColor) @@ -577,6 +588,13 @@ var HORIZONTAL_MARGIN = 3.0, imageHeight *= scale; } +#if PLATFORM(DOM) + if (CPFeatureIsCompatible(CPOpacityRequiresFilterFeature)) + _DOMElement.style.filter = @"alpha(opacity=" + _shouldDimImage ? 50 : 100 + ")"; + else + _DOMElement.style.opacity = _shouldDimImage ? 0.5 : 1.0; +#endif + #if PLATFORM(DOM) _DOMImageElement.width = imageWidth; _DOMImageElement.height = imageHeight;