implemented imageDimsWhenDisabled on CPButton

This commit is contained in:
Klaas Pieter Annema committed 2010-02-10 16:19:51 +01:00
1 parent 90cd519916
commit ea47baa1fc
2 files changed
+19

No files matched your search

+1
View File
@@ -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];
}
}
+18
View File
@@ -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;