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";