mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-28 01:12:03 +00:00
AppKit: Give Aristo3 colours names that follow appearance, add first dark set
- Add theme colour catalog "Theme" with values in CPColor attribute theme-colors - Accept colours and arrays in CSS dictionaries; convert each value at write time - Compare converted CSS of appearance-dependent CSS colours and images in setters - Skip dynamic values in theme load walks; fix resource paths in strings only - Rename CPView -_applyBackgroundColor to -_writeBackgroundColor (CPWebView clash) - Resolve event-time DOM writes in owning view appearance; reapply on change - Write _CPImageAndTextView text colour in layout - Define 104 Aristo3 constants as 98 theme colours; add dark table for DarkAqua - Add tests for CSS values, theme catalog, Aristo3 theme colours and audit sites
This commit is contained in:
1 parent
dadd5e5996
commit
fbd08705e9
23 files changed
+1982
-179
No files matched your search
+199
-8
@@ -77,6 +77,14 @@ var cachedBlackColor,
|
||||
*/
|
||||
var _CPColorSystemCatalogName = @"System";
|
||||
|
||||
/*
|
||||
The catalog that holds a theme's own colours: the colours that have no System name. The
|
||||
theme gives their values in the attribute "theme-colors" of CPColor (see
|
||||
_CPThemeColorValue). The catalog name does not contain a theme's name, so that a theme
|
||||
and a bundle that extends it resolve the same colour names.
|
||||
*/
|
||||
var _CPColorThemeCatalogName = @"Theme";
|
||||
|
||||
/*
|
||||
The colours of the System catalog, with each colour's value when the current theme gives
|
||||
it none. These are the names that Interface Builder writes into a XIB and that AppKit
|
||||
@@ -156,7 +164,9 @@ var _CPSystemColorDefaults = {
|
||||
"windowFrameTextColor": [0.0, 0.0, 0.0, 0.8471]
|
||||
},
|
||||
_CPSystemColors = {},
|
||||
_CPSystemColorDefaultValues = {};
|
||||
_CPSystemColorDefaultValues = {},
|
||||
_CPThemeColors = {},
|
||||
_CPThemeColorMissingNames = {};
|
||||
|
||||
/*
|
||||
Returns the theme attribute of CPColor that holds a theme's values for the system colour
|
||||
@@ -193,6 +203,47 @@ function _CPSystemColorValue(aName, anAppearance)
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the value of the theme colour aName for anAppearance. The attribute "theme-colors"
|
||||
of the current theme holds, for each appearance state, a dictionary from colour name to
|
||||
colour. The lookup takes the dictionaries in the order of -bestMatchFromAppearancesWithNames:
|
||||
for anAppearance and uses the first one that holds aName, then the dictionary for every
|
||||
appearance. A name that no dictionary holds is a defect of the theme: it logs one warning
|
||||
and gives the clear colour.
|
||||
*/
|
||||
function _CPThemeColorValue(aName, anAppearance)
|
||||
{
|
||||
var theme = [CPTheme defaultTheme],
|
||||
values = [[theme attributeWithName:@"theme-colors" forClass:[CPColor defaultThemeClass]] values];
|
||||
|
||||
if (values)
|
||||
{
|
||||
var matchingNames = _CPAppearanceMatchingNames([anAppearance name]);
|
||||
|
||||
for (var i = 0, count = matchingNames.length; i < count; i++)
|
||||
{
|
||||
var state = _CPThemeStateForAppearanceName(matchingNames[i]),
|
||||
value = state ? [[values objectForKey:String(state)] objectForKey:aName] : nil;
|
||||
|
||||
if (value)
|
||||
return value;
|
||||
}
|
||||
|
||||
var normalValue = [[values objectForKey:String(CPThemeStateNormal)] objectForKey:aName];
|
||||
|
||||
if (normalValue)
|
||||
return normalValue;
|
||||
}
|
||||
|
||||
if (!_CPThemeColorMissingNames.hasOwnProperty(aName))
|
||||
{
|
||||
_CPThemeColorMissingNames[aName] = YES;
|
||||
CPLog.warn("Theme colour: the theme " + [theme name] + " gives no value for \"" + aName + "\"");
|
||||
}
|
||||
|
||||
return [CPColor clearColor];
|
||||
}
|
||||
|
||||
/// @endcond
|
||||
|
||||
@class _CPCatalogColor
|
||||
@@ -225,7 +276,9 @@ function _CPSystemColorValue(aName, anAppearance)
|
||||
|
||||
/*
|
||||
Besides its own attributes, CPColor has one attribute for each system colour, which holds
|
||||
the theme's values for that colour (see _CPSystemColorValue).
|
||||
the theme's values for that colour (see _CPSystemColorValue), and the attribute
|
||||
"theme-colors", which holds the values of the theme's own colours (see
|
||||
_CPThemeColorValue).
|
||||
*/
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
@@ -234,7 +287,8 @@ function _CPSystemColorValue(aName, anAppearance)
|
||||
@"secondary-selected-control-color": [CPNull null],
|
||||
@"selected-text-background-color": [CPNull null],
|
||||
@"selected-text-inactive-background-color": [CPNull null],
|
||||
@"css-based": NO
|
||||
@"css-based": NO,
|
||||
@"theme-colors": [CPNull null]
|
||||
};
|
||||
|
||||
for (var colorName in _CPSystemColorDefaults)
|
||||
@@ -618,18 +672,35 @@ function _CPSystemColorValue(aName, anAppearance)
|
||||
value for the current drawing appearance (see
|
||||
+[CPAppearance currentDrawingAppearance]), or the colour's default when the theme gives
|
||||
none.
|
||||
|
||||
The catalog \c Theme holds a theme's own colours. For it, the method returns a colour
|
||||
for any name, because a theme's archive is decoded before the theme gives values. A
|
||||
name that the current theme does not give resolves to the clear colour.
|
||||
@param aCatalogName the name of the catalog
|
||||
@param aColorName the name of the colour
|
||||
@return the named colour, or \c nil
|
||||
*/
|
||||
+ (CPColor)colorWithCatalogName:(CPString)aCatalogName colorName:(CPString)aColorName
|
||||
{
|
||||
if (aCatalogName === _CPColorThemeCatalogName && aColorName)
|
||||
return [self _themeColorNamed:aColorName];
|
||||
|
||||
if (aCatalogName !== _CPColorSystemCatalogName || !_CPSystemColorDefaults.hasOwnProperty(aColorName))
|
||||
return nil;
|
||||
|
||||
return [self _systemColorNamed:aColorName];
|
||||
}
|
||||
|
||||
+ (CPColor)_themeColorNamed:(CPString)aColorName
|
||||
{
|
||||
var color = _CPThemeColors.hasOwnProperty(aColorName) ? _CPThemeColors[aColorName] : nil;
|
||||
|
||||
if (!color)
|
||||
color = _CPThemeColors[aColorName] = [[_CPCatalogColor alloc] _initWithCatalogName:_CPColorThemeCatalogName colorName:aColorName];
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
+ (CPColor)_systemColorNamed:(CPString)aColorName
|
||||
{
|
||||
var color = _CPSystemColors[aColorName];
|
||||
@@ -1482,6 +1553,118 @@ url("data:image/png;base64,BASE64ENCODEDDATA") // if there is a pattern image
|
||||
// Remark : +(void)restorePreviousCSSState and -(DOMElement)applyCSSColorForView are meant to be used by low level UI widgets (like CPView) to implement
|
||||
// CSS theme support.
|
||||
|
||||
/*
|
||||
A value in a CSS dictionary of a colour or an image is a string, a colour, or an array of
|
||||
strings and colours. A colour can be a named colour, so that the dictionary follows the
|
||||
appearance: [CPColor separatorColor], or @[@"0 0 0 3px ", aColor] for a value with more
|
||||
than a colour. The dictionary keeps the objects; each value is converted when it is
|
||||
written, in the current drawing appearance.
|
||||
*/
|
||||
|
||||
/*
|
||||
Returns the CSS text of aValue, a value of a CSS dictionary: a string gives itself; a
|
||||
colour gives its CSS string in the current drawing appearance; an array gives its members,
|
||||
each converted, joined with no separator. A number gives its decimal text, as the DOM
|
||||
writes it. Any other value is a defect of the dictionary and raises.
|
||||
*/
|
||||
function _CPCSSValueString(aValue)
|
||||
{
|
||||
if (typeof aValue === "string")
|
||||
return aValue;
|
||||
|
||||
if (typeof aValue === "number")
|
||||
return String(aValue);
|
||||
|
||||
if (aValue && aValue.isa)
|
||||
{
|
||||
if ([aValue isKindOfClass:CPColor])
|
||||
return [aValue cssString];
|
||||
|
||||
if ([aValue isKindOfClass:CPArray])
|
||||
{
|
||||
var text = "";
|
||||
|
||||
for (var i = 0, count = aValue.length; i < count; i++)
|
||||
text += _CPCSSValueString(aValue[i]);
|
||||
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
[CPException raise:CPInvalidArgumentException reason:"A CSS dictionary value must be a string, a colour or an array of these, not " + aValue];
|
||||
}
|
||||
|
||||
/*
|
||||
Returns YES when aValue, a value of a CSS dictionary, is a colour or an array that holds
|
||||
one.
|
||||
*/
|
||||
function _CPCSSValueHoldsColor(aValue)
|
||||
{
|
||||
if (!aValue || !aValue.isa || typeof aValue === "string")
|
||||
return NO;
|
||||
|
||||
if ([aValue isKindOfClass:CPColor])
|
||||
return YES;
|
||||
|
||||
if ([aValue isKindOfClass:CPArray])
|
||||
{
|
||||
for (var i = 0, count = aValue.length; i < count; i++)
|
||||
if (_CPCSSValueHoldsColor(aValue[i]))
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
function _CPCSSDictionaryHoldsColor(aDictionary)
|
||||
{
|
||||
var values = [aDictionary allValues];
|
||||
|
||||
for (var i = 0, count = [values count]; i < count; i++)
|
||||
if (_CPCSSValueHoldsColor(values[i]))
|
||||
return YES;
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
/*
|
||||
Returns YES when a CSS dictionary of anObject, a colour or an image, holds a colour. Such
|
||||
an object writes other CSS in another appearance, although it is the same object.
|
||||
|
||||
The result is computed at each call and not kept on the object, because a dictionary
|
||||
changes after the object is made: a theme replaces placeholder strings with the values of
|
||||
its dynamic set in place (see -[CPTheme applyDynamicSet:]).
|
||||
*/
|
||||
function _CPCSSObjectIsAppearanceDependent(anObject)
|
||||
{
|
||||
return _CPCSSDictionaryHoldsColor([anObject cssDictionary]) ||
|
||||
_CPCSSDictionaryHoldsColor([anObject cssBeforeDictionary]) ||
|
||||
_CPCSSDictionaryHoldsColor([anObject cssAfterDictionary]);
|
||||
}
|
||||
|
||||
function _CPCSSDictionaryText(aDictionary)
|
||||
{
|
||||
var text = "",
|
||||
keys = [aDictionary allKeys];
|
||||
|
||||
for (var i = 0, count = [keys count]; i < count; i++)
|
||||
text += keys[i] + ": " + _CPCSSValueString([aDictionary objectForKey:keys[i]]) + "; ";
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the CSS that anObject, a colour or an image, writes in the current drawing
|
||||
appearance: its three dictionaries with every value converted, as one string. A setter
|
||||
compares it with the text of its last write to decide whether to write again.
|
||||
*/
|
||||
function _CPCSSObjectText(anObject)
|
||||
{
|
||||
return _CPCSSDictionaryText([anObject cssDictionary]) +
|
||||
"::before { " + _CPCSSDictionaryText([anObject cssBeforeDictionary]) + "} " +
|
||||
"::after { " + _CPCSSDictionaryText([anObject cssAfterDictionary]) + "}";
|
||||
}
|
||||
|
||||
@implementation CPColor (CSSTheming)
|
||||
{
|
||||
CPDictionary _cssDictionary @accessors(property=cssDictionary);
|
||||
@@ -1548,6 +1731,10 @@ url("data:image/png;base64,BASE64ENCODEDDATA") // if there is a pattern image
|
||||
@deref(aPreviousStateRef) = @[];
|
||||
}
|
||||
|
||||
/*
|
||||
Writes the receiver's CSS into the DOM. Each value is converted with _CPCSSValueString in
|
||||
the current drawing appearance, which the caller sets to the view's appearance.
|
||||
*/
|
||||
- (DOMElement)applyCSSColorForView:(CPView)aView onDOMElement:(DOMElement)aDOMElement styleNode:(DOMElement)aStyleNode previousState:(CPArrayRef)aPreviousStateRef
|
||||
{
|
||||
var aPreviousState = @deref(aPreviousStateRef);
|
||||
@@ -1555,7 +1742,7 @@ url("data:image/png;base64,BASE64ENCODEDDATA") // if there is a pattern image
|
||||
[_cssDictionary enumerateKeysAndObjectsUsingBlock:function(aKey, anObject, stop)
|
||||
{
|
||||
[aPreviousState addObject:@[aKey, aDOMElement.style[aKey]]];
|
||||
aDOMElement.style[aKey] = anObject;
|
||||
aDOMElement.style[aKey] = _CPCSSValueString(anObject);
|
||||
}];
|
||||
|
||||
if ([self hasCSSBeforeDictionary] || [self hasCSSAfterDictionary])
|
||||
@@ -1571,7 +1758,7 @@ url("data:image/png;base64,BASE64ENCODEDDATA") // if there is a pattern image
|
||||
|
||||
[_cssBeforeDictionary enumerateKeysAndObjectsUsingBlock:function(aKey, anObject, stop)
|
||||
{
|
||||
styleContent += aKey + ": " + anObject + "; ";
|
||||
styleContent += aKey + ": " + _CPCSSValueString(anObject) + "; ";
|
||||
}];
|
||||
|
||||
styleContent += "} ";
|
||||
@@ -1583,7 +1770,7 @@ url("data:image/png;base64,BASE64ENCODEDDATA") // if there is a pattern image
|
||||
|
||||
[_cssAfterDictionary enumerateKeysAndObjectsUsingBlock:function(aKey, anObject, stop)
|
||||
{
|
||||
styleContent += aKey + ": " + anObject + "; ";
|
||||
styleContent += aKey + ": " + _CPCSSValueString(anObject) + "; ";
|
||||
}];
|
||||
|
||||
styleContent += "} ";
|
||||
@@ -1883,8 +2070,9 @@ var CPColorComponentsKey = @"CPColorComponentsKey",
|
||||
|
||||
|
||||
/*
|
||||
A colour of a catalog, such as the System catalog. It keeps its catalog name and colour
|
||||
name and takes its value from the current theme (see _CPSystemColorValue).
|
||||
A colour of a catalog: the System catalog or the theme catalog. It keeps its catalog name
|
||||
and colour name and takes its value from the current theme (see _CPSystemColorValue and
|
||||
_CPThemeColorValue).
|
||||
*/
|
||||
@implementation _CPCatalogColor : _CPDynamicColor
|
||||
{
|
||||
@@ -1907,6 +2095,9 @@ var CPColorComponentsKey = @"CPColorComponentsKey",
|
||||
|
||||
- (CPColor)_valueInAppearance:(CPAppearance)anAppearance
|
||||
{
|
||||
if (_catalogName === _CPColorThemeCatalogName)
|
||||
return _CPThemeColorValue(_colorName, anAppearance);
|
||||
|
||||
return _CPSystemColorValue(_colorName, anAppearance);
|
||||
}
|
||||
|
||||
|
||||
+9
-3
@@ -42,6 +42,7 @@
|
||||
@class _CPSystemImage
|
||||
@global document
|
||||
@global _CPRaiseInvalidAbstractInvocation
|
||||
@global _CPCSSValueString
|
||||
|
||||
@protocol CPImageDelegate <CPObject>
|
||||
|
||||
@@ -889,6 +890,11 @@ function _CPSystemImageValue(aName, anAppearance)
|
||||
return ([_cssAfterDictionary count] > 0);
|
||||
}
|
||||
|
||||
/*
|
||||
Writes the receiver's CSS into the DOM. Each value is converted with _CPCSSValueString (see
|
||||
CPColor.j) in the current drawing appearance, which the caller sets to the view's
|
||||
appearance.
|
||||
*/
|
||||
- (DOMElement)applyCSSImageForView:(CPView)aView onDOMElement:(DOMElement)aDOMElement styleNode:(DOMElement)aStyleNode previousState:(CPArrayRef)aPreviousStateRef
|
||||
{
|
||||
if (!CPDOMAvailable) return;
|
||||
@@ -907,7 +913,7 @@ function _CPSystemImageValue(aName, anAppearance)
|
||||
[_cssDictionary enumerateKeysAndObjectsUsingBlock:function(aKey, anObject, stop)
|
||||
{
|
||||
[aPreviousState addObject:@[aKey, aDOMElement.style[aKey]]];
|
||||
aDOMElement.style[aKey] = anObject;
|
||||
aDOMElement.style[aKey] = _CPCSSValueString(anObject);
|
||||
}];
|
||||
|
||||
if (_cssBeforeDictionary || _cssAfterDictionary)
|
||||
@@ -923,7 +929,7 @@ function _CPSystemImageValue(aName, anAppearance)
|
||||
|
||||
[_cssBeforeDictionary enumerateKeysAndObjectsUsingBlock:function(aKey, anObject, stop)
|
||||
{
|
||||
styleContent += aKey + ": " + anObject + "; ";
|
||||
styleContent += aKey + ": " + _CPCSSValueString(anObject) + "; ";
|
||||
}];
|
||||
|
||||
styleContent += "} ";
|
||||
@@ -935,7 +941,7 @@ function _CPSystemImageValue(aName, anAppearance)
|
||||
|
||||
[_cssAfterDictionary enumerateKeysAndObjectsUsingBlock:function(aKey, anObject, stop)
|
||||
{
|
||||
styleContent += aKey + ": " + anObject + "; ";
|
||||
styleContent += aKey + ": " + _CPCSSValueString(anObject) + "; ";
|
||||
}];
|
||||
|
||||
styleContent += "} ";
|
||||
|
||||
@@ -48,6 +48,10 @@ var CPImageViewEmptyPlaceholderImage = nil;
|
||||
/*
|
||||
Returns a record of what the image gives in the current drawing appearance: its file name
|
||||
and its CSS dictionaries. A dynamic image gives other values in another appearance.
|
||||
|
||||
A CSS image whose dictionaries hold a colour gives other CSS in another appearance with
|
||||
the same dictionaries, so a record of the dictionaries alone kept the old appearance's
|
||||
CSS. The record also holds the CSS that such an image writes.
|
||||
*/
|
||||
function _CPImageViewRecordForImage(anImage)
|
||||
{
|
||||
@@ -58,7 +62,8 @@ function _CPImageViewRecordForImage(anImage)
|
||||
filename: isCSSBased ? nil : [image filename],
|
||||
cssDictionary: isCSSBased ? [image cssDictionary] : nil,
|
||||
cssBeforeDictionary: isCSSBased ? [image cssBeforeDictionary] : nil,
|
||||
cssAfterDictionary: isCSSBased ? [image cssAfterDictionary] : nil
|
||||
cssAfterDictionary: isCSSBased ? [image cssAfterDictionary] : nil,
|
||||
cssText: isCSSBased && _CPCSSObjectIsAppearanceDependent(image) ? _CPCSSObjectText(image) : nil
|
||||
};
|
||||
}
|
||||
|
||||
@@ -68,7 +73,8 @@ function _CPImageViewRecordsAreSame(aRecord, anotherRecord)
|
||||
aRecord.filename === anotherRecord.filename &&
|
||||
aRecord.cssDictionary === anotherRecord.cssDictionary &&
|
||||
aRecord.cssBeforeDictionary === anotherRecord.cssBeforeDictionary &&
|
||||
aRecord.cssAfterDictionary === anotherRecord.cssAfterDictionary;
|
||||
aRecord.cssAfterDictionary === anotherRecord.cssAfterDictionary &&
|
||||
aRecord.cssText === anotherRecord.cssText;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
+27
-2
@@ -811,6 +811,25 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
_DOMElement.style[CPBrowserStyleProperty(@"user-select")] = shouldEnable ? @"text" : @"none";
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the CSS string of the text colour for the shared input element, in the receiver's
|
||||
effective appearance and current theme state. The shared element is styled when it moves
|
||||
into a field, which can happen outside layout, so the method sets the appearance itself.
|
||||
*/
|
||||
- (CPString)_inputElementTextColorCSSString
|
||||
{
|
||||
var previousAppearance = _CPAppearanceBeginDrawing([self effectiveAppearance]);
|
||||
|
||||
try
|
||||
{
|
||||
return [[self currentValueForThemeAttribute:@"text-color"] cssString];
|
||||
}
|
||||
finally
|
||||
{
|
||||
_CPAppearanceEndDrawing(previousAppearance);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the css style for the input element of the textField
|
||||
@ignore
|
||||
@@ -846,8 +865,14 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
break;
|
||||
}
|
||||
|
||||
// Use currentValueForThemeAttribute to respect all current states (HUD, Placeholder, Editing, etc.)
|
||||
element.style.color = [[self currentValueForThemeAttribute:@"text-color"] cssString];
|
||||
/*
|
||||
The text colour resolved in the current drawing appearance. The method also runs when
|
||||
the field becomes first responder and from -[CPComboBox takeStringValueFromList],
|
||||
outside layout, where the drawing appearance is the application's. A named colour
|
||||
then took the application's value in a field of another appearance. The colour now
|
||||
resolves in the field's appearance.
|
||||
*/
|
||||
element.style.color = [self _inputElementTextColorCSSString];
|
||||
|
||||
switch ([self alignment])
|
||||
{
|
||||
|
||||
+64
-4
@@ -31,6 +31,8 @@
|
||||
@class CPImage
|
||||
@class CPColor
|
||||
@class CPApplication
|
||||
@class _CPDynamicColor
|
||||
@class _CPDynamicImage
|
||||
|
||||
var CPThemesByName = { },
|
||||
CPThemeDefaultTheme = nil,
|
||||
@@ -430,6 +432,44 @@ var CPThemeNameKey = @"CPThemeNameKey",
|
||||
|
||||
var _savedThemesByName = { };
|
||||
|
||||
/*
|
||||
Returns YES when aValue, a value of a theme attribute, is a colour or an image with CSS
|
||||
dictionaries of its own. A dynamic colour or image, such as a named colour or a System
|
||||
image, has none: it resolves to another object when it is asked for them.
|
||||
*/
|
||||
function _CPThemeValueHasOwnCSSDictionaries(aValue)
|
||||
{
|
||||
if (!aValue || !aValue.isa)
|
||||
return NO;
|
||||
|
||||
if (!([aValue isKindOfClass:CPImage] || [aValue isKindOfClass:CPColor]))
|
||||
return NO;
|
||||
|
||||
if ([aValue isKindOfClass:_CPDynamicImage] || [aValue isKindOfClass:_CPDynamicColor])
|
||||
return NO;
|
||||
|
||||
return !![aValue cssDictionary];
|
||||
}
|
||||
|
||||
/*
|
||||
Returns aValue, a value of a CSS dictionary, with "%%" replaced by aPath in a string and in
|
||||
each string member of an array, which gives a new array. A colour has no path and stays
|
||||
as it is.
|
||||
*/
|
||||
function _CPThemeCSSValueWithResourcesPath(aValue, aPath)
|
||||
{
|
||||
if (typeof aValue === "string")
|
||||
return [aValue stringByReplacingOccurrencesOfString:@"%%" withString:aPath];
|
||||
|
||||
if (aValue && aValue.isa && [aValue isKindOfClass:CPArray])
|
||||
return aValue.map(function(aMember)
|
||||
{
|
||||
return _CPThemeCSSValueWithResourcesPath(aMember, aPath);
|
||||
});
|
||||
|
||||
return aValue;
|
||||
}
|
||||
|
||||
@implementation CPTheme (CSSTheming)
|
||||
|
||||
- (void)_initializeDynamicAttributesAndResourcesPathWithBundle:(CPBundle)aBundle
|
||||
@@ -499,9 +539,15 @@ var _savedThemesByName = { };
|
||||
{
|
||||
// anObject2 is now a _CPThemeAttribute
|
||||
|
||||
/*
|
||||
The walk asked every colour and image for its CSS dictionaries. A named
|
||||
colour resolves when asked, against the default theme, which at theme load
|
||||
is not yet this theme, so each theme colour logged a missing value. A
|
||||
dynamic value holds no dictionaries of its own, so the walk skips it.
|
||||
*/
|
||||
[[anObject2 values] enumerateKeysAndObjectsUsingBlock:function(aKey3, anObject3, stop3)
|
||||
{
|
||||
if (anObject3.isa && ([anObject3 isKindOfClass:CPImage] || [anObject3 isKindOfClass:CPColor]) && [anObject3 cssDictionary])
|
||||
if (_CPThemeValueHasOwnCSSDictionaries(anObject3))
|
||||
{
|
||||
// We have a CSS defined image or color
|
||||
[self _fixPathInCSSDictionary:[anObject3 cssDictionary] withPathToResources:pathToResources];
|
||||
@@ -513,11 +559,16 @@ var _savedThemesByName = { };
|
||||
}];
|
||||
}
|
||||
|
||||
/*
|
||||
The method sent -stringByReplacingOccurrencesOfString:withString: to every value. A value
|
||||
can also be a colour or an array (see _CPCSSValueString in CPColor.j), and a colour does
|
||||
not respond to it, so theme load raised. Only strings, also inside arrays, hold paths.
|
||||
*/
|
||||
- (void)_fixPathInCSSDictionary:(CPDictionary)aDictionary withPathToResources:(CPString)pathToResources
|
||||
{
|
||||
[aDictionary enumerateKeysAndObjectsUsingBlock:function(aKey, anObject, stop)
|
||||
{
|
||||
[aDictionary setObject:[anObject stringByReplacingOccurrencesOfString:@"%%" withString:pathToResources] forKey:aKey];
|
||||
[aDictionary setObject:_CPThemeCSSValueWithResourcesPath(anObject, pathToResources) forKey:aKey];
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -529,11 +580,15 @@ var _savedThemesByName = { };
|
||||
{
|
||||
var anObject2Values = [anObject2 values];
|
||||
|
||||
/*
|
||||
As in -setCSSResourcesPath:, a dynamic colour or image resolved here against
|
||||
the previous default theme. The walk skips it.
|
||||
*/
|
||||
[anObject2Values enumerateKeysAndObjectsUsingBlock:function(aKey3, anObject3, stop3)
|
||||
{
|
||||
if (anObject3.isa)
|
||||
{
|
||||
if (([anObject3 isKindOfClass:CPImage] || [anObject3 isKindOfClass:CPColor]) && [anObject3 cssDictionary])
|
||||
if (_CPThemeValueHasOwnCSSDictionaries(anObject3))
|
||||
{
|
||||
// We have a CSS defined image or color
|
||||
[self _applyDynamicSet:dynamicSet toCSSDictionary:[anObject3 cssDictionary]];
|
||||
@@ -552,11 +607,16 @@ var _savedThemesByName = { };
|
||||
}];
|
||||
}
|
||||
|
||||
/*
|
||||
The method compared every value with the names of the set. A value can also be a colour
|
||||
or an array, which is never a placeholder; -containsKey: compared its description as a
|
||||
key. Only a string is a placeholder.
|
||||
*/
|
||||
- (void)_applyDynamicSet:(CPDictionary)dynamicSet toCSSDictionary:(CPDictionary)aDictionary
|
||||
{
|
||||
[aDictionary enumerateKeysAndObjectsUsingBlock:function(aKey, anObject, stop)
|
||||
{
|
||||
if ([dynamicSet containsKey:anObject])
|
||||
if (typeof anObject === "string" && [dynamicSet containsKey:anObject])
|
||||
[aDictionary setObject:[dynamicSet objectForKey:anObject] forKey:aKey];
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -426,8 +426,13 @@ CPTokenFieldDeleteButtonType = 1;
|
||||
element = [self _inputElement],
|
||||
font = [self currentValueForThemeAttribute:@"font"];
|
||||
|
||||
/*
|
||||
The text colour resolved in the current drawing appearance, which outside layout
|
||||
is the application's, so a named colour took the application's value in a field
|
||||
of another appearance. It now resolves in the field's appearance.
|
||||
*/
|
||||
element.value = nil;
|
||||
element.style.color = [[self currentValueForThemeAttribute:@"text-color"] cssString];
|
||||
element.style.color = [self _inputElementTextColorCSSString];
|
||||
element.style.font = [font cssString];
|
||||
element.style.zIndex = 1000;
|
||||
|
||||
|
||||
+59
-11
@@ -227,6 +227,7 @@ function _CPViewResolvedColorsAreSame(aColor, anotherColor)
|
||||
float _opacity;
|
||||
CPColor _backgroundColor;
|
||||
CPColor _backgroundColorResolved;
|
||||
CPString _backgroundColorCSSText;
|
||||
|
||||
BOOL _autoresizesSubviews;
|
||||
unsigned _autoresizingMask;
|
||||
@@ -2063,18 +2064,44 @@ function _CPViewResolvedColorsAreSame(aColor, anotherColor)
|
||||
after an appearance change left the old value in the DOM. The setter now skips only
|
||||
when the object and its resolved value are both unchanged.
|
||||
*/
|
||||
var resolvedColor = [self _resolvedBackgroundColor:aColor];
|
||||
var resolvedColor = [self _resolvedBackgroundColor:aColor],
|
||||
cssText = [self _backgroundCSSTextForResolvedColor:resolvedColor];
|
||||
|
||||
if (_backgroundColor === aColor && _CPViewResolvedColorsAreSame(resolvedColor, _backgroundColorResolved))
|
||||
if (_backgroundColor === aColor && _CPViewResolvedColorsAreSame(resolvedColor, _backgroundColorResolved) && cssText === _backgroundColorCSSText)
|
||||
return;
|
||||
|
||||
_backgroundColor = aColor;
|
||||
_backgroundColorResolved = resolvedColor;
|
||||
_backgroundColorCSSText = cssText;
|
||||
|
||||
if (!CPDOMAvailable)
|
||||
return;
|
||||
|
||||
[self _applyBackgroundColor];
|
||||
[self _writeBackgroundColor];
|
||||
}
|
||||
|
||||
/*
|
||||
A CSS colour whose dictionaries hold a colour writes other CSS in another appearance,
|
||||
although it is the same object. The setter and the reapplication skipped the write for the
|
||||
same object, so the old appearance's CSS stayed in the DOM. They now also compare the CSS
|
||||
that such a colour writes in the receiver's effective appearance. Returns that text, or
|
||||
nil for every other colour.
|
||||
*/
|
||||
- (CPString)_backgroundCSSTextForResolvedColor:(CPColor)aResolvedColor
|
||||
{
|
||||
if (![aResolvedColor isCSSBased] || !_CPCSSObjectIsAppearanceDependent(aResolvedColor))
|
||||
return nil;
|
||||
|
||||
var previousAppearance = _CPAppearanceBeginDrawing([self effectiveAppearance]);
|
||||
|
||||
try
|
||||
{
|
||||
return _CPCSSObjectText(aResolvedColor);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_CPAppearanceEndDrawing(previousAppearance);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2107,21 +2134,27 @@ function _CPViewResolvedColorsAreSame(aColor, anotherColor)
|
||||
*/
|
||||
- (void)_reapplyBackgroundColorIfNeeded
|
||||
{
|
||||
var resolvedColor = [self _resolvedBackgroundColor:_backgroundColor];
|
||||
var resolvedColor = [self _resolvedBackgroundColor:_backgroundColor],
|
||||
cssText = [self _backgroundCSSTextForResolvedColor:resolvedColor];
|
||||
|
||||
if (_CPViewResolvedColorsAreSame(resolvedColor, _backgroundColorResolved))
|
||||
if (_CPViewResolvedColorsAreSame(resolvedColor, _backgroundColorResolved) && cssText === _backgroundColorCSSText)
|
||||
return;
|
||||
|
||||
_backgroundColorResolved = resolvedColor;
|
||||
_backgroundColorCSSText = cssText;
|
||||
|
||||
if (CPDOMAvailable)
|
||||
[self _applyBackgroundColor];
|
||||
[self _writeBackgroundColor];
|
||||
}
|
||||
|
||||
/*
|
||||
Writes the resolved background colour into the DOM.
|
||||
|
||||
The method was named -_applyBackgroundColor, which is the name of an older private method
|
||||
of CPWebView that styles the web view's iframe. The web view's method replaced this one,
|
||||
so a web view's own element got no background. The method now has a name of its own.
|
||||
*/
|
||||
- (void)_applyBackgroundColor
|
||||
- (void)_writeBackgroundColor
|
||||
{
|
||||
var color = _backgroundColorResolved;
|
||||
|
||||
@@ -2208,10 +2241,25 @@ function _CPViewResolvedColorsAreSame(aColor, anotherColor)
|
||||
|
||||
if (_backgroundType === BackgroundCSSStyling)
|
||||
{
|
||||
_cssStyleNode = [color applyCSSColorForView:self
|
||||
onDOMElement:_DOMElement
|
||||
styleNode:_cssStyleNode
|
||||
previousState:@ref(_cssStylePreviousState)];
|
||||
/*
|
||||
The setter resolved the colour in the receiver's appearance, but wrote its CSS in
|
||||
the current drawing appearance, which outside layout is the application's. A
|
||||
named colour inside the CSS dictionaries then took the application's value. The
|
||||
write now runs in the receiver's effective appearance.
|
||||
*/
|
||||
var previousAppearance = _CPAppearanceBeginDrawing([self effectiveAppearance]);
|
||||
|
||||
try
|
||||
{
|
||||
_cssStyleNode = [color applyCSSColorForView:self
|
||||
onDOMElement:_DOMElement
|
||||
styleNode:_cssStyleNode
|
||||
previousState:@ref(_cssStylePreviousState)];
|
||||
}
|
||||
finally
|
||||
{
|
||||
_CPAppearanceEndDrawing(previousAppearance);
|
||||
}
|
||||
}
|
||||
else if (_backgroundType === BackgroundTrivialColor || _backgroundType === BackgroundTransparentColor)
|
||||
{
|
||||
|
||||
+30
-3
@@ -794,16 +794,43 @@ CPWebViewAppKitScrollMaxPollCount = 3;
|
||||
[self _applyBackgroundColor];
|
||||
}
|
||||
|
||||
/*
|
||||
The method resolved the background colour in the current drawing appearance, which
|
||||
outside layout is the application's, so a named colour took the application's value in a
|
||||
web view of another appearance; and nothing applied it again after a change of
|
||||
appearance. It now resolves in the receiver's effective appearance, and
|
||||
-_effectiveAppearanceDidChange calls it.
|
||||
*/
|
||||
- (void)_applyBackgroundColor
|
||||
{
|
||||
if (_iframe)
|
||||
{
|
||||
var bgColor = [self backgroundColor] || [CPColor whiteColor];
|
||||
_iframe.allowtransparency = !_drawsBackground;
|
||||
_iframe.style.backgroundColor = _drawsBackground ? [bgColor cssString] : "transparent";
|
||||
var bgColor = [self backgroundColor] || [CPColor whiteColor],
|
||||
previousAppearance = _CPAppearanceBeginDrawing([self effectiveAppearance]);
|
||||
|
||||
try
|
||||
{
|
||||
_iframe.allowtransparency = !_drawsBackground;
|
||||
_iframe.style.backgroundColor = _drawsBackground ? [bgColor cssString] : "transparent";
|
||||
}
|
||||
finally
|
||||
{
|
||||
_CPAppearanceEndDrawing(previousAppearance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Applies the iframe's background again in the new appearance. The iframe has no layout of
|
||||
its own that would write it.
|
||||
*/
|
||||
- (void)_effectiveAppearanceDidChange
|
||||
{
|
||||
[super _effectiveAppearanceDidChange];
|
||||
|
||||
[self _applyBackgroundColor];
|
||||
}
|
||||
|
||||
// IBActions
|
||||
|
||||
/*!
|
||||
|
||||
@@ -1442,6 +1442,32 @@ CPTexturedBackgroundWindowMask
|
||||
return _hasShadow;
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the CSS of the window's shadow under a CSS theme: the window view's attribute
|
||||
"window-shadow-color" in the theme, converted in the window's effective appearance (see
|
||||
_CPCSSValueString). The shadow is a property of the window, written outside the layout of
|
||||
any view, so the method sets the appearance itself. A theme that gives no value gives no
|
||||
shadow, as the DOM took the nil value before.
|
||||
*/
|
||||
- (CPString)_windowShadowCSSString
|
||||
{
|
||||
var value = [_windowView actualValueForThemeAttribute:@"window-shadow-color"];
|
||||
|
||||
if (value === nil || value === undefined)
|
||||
return "";
|
||||
|
||||
var previousAppearance = _CPAppearanceBeginDrawing([self effectiveAppearance]);
|
||||
|
||||
try
|
||||
{
|
||||
return _CPCSSValueString(value);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_CPAppearanceEndDrawing(previousAppearance);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_updateShadow
|
||||
{
|
||||
if ([self _sharesChromeWithPlatformWindow])
|
||||
@@ -1471,16 +1497,17 @@ CPTexturedBackgroundWindowMask
|
||||
// _setSharesChromeWithPlatformWindow whereas _windowView is not yet created
|
||||
if (_windowView && _windowView._DOMElement)
|
||||
{
|
||||
var currentBoxShadow = _windowView._DOMElement.style.boxShadow;
|
||||
|
||||
if (_hasShadow && (currentBoxShadow.length == 0))
|
||||
{
|
||||
_windowView._DOMElement.style.boxShadow = [_windowView actualValueForThemeAttribute:@"window-shadow-color"];
|
||||
}
|
||||
else if (!_hasShadow && (currentBoxShadow.length > 0))
|
||||
{
|
||||
/*
|
||||
The method wrote the shadow only when the element had none, so the value
|
||||
of a new appearance never reached the DOM. It wrote the attribute's value
|
||||
as it was, so a value that holds a named colour, in the array form of a
|
||||
CSS value, could not be written. The shadow is now converted in the
|
||||
window's appearance and written whenever the window has one.
|
||||
*/
|
||||
if (_hasShadow)
|
||||
_windowView._DOMElement.style.boxShadow = [self _windowShadowCSSString];
|
||||
else if (_windowView._DOMElement.style.boxShadow.length > 0)
|
||||
_windowView._DOMElement.style.boxShadow = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1069,6 +1069,17 @@ function _CPWindowViewSetCornerRadii(aDOMElement, someRadii)
|
||||
return MIN(myWidth, parentWidth);
|
||||
}
|
||||
|
||||
/*
|
||||
Applies the window's shadow again in the new appearance. Under a CSS theme the shadow is
|
||||
written on the receiver's element outside any layout, so nothing else writes it again.
|
||||
*/
|
||||
- (void)_effectiveAppearanceDidChange
|
||||
{
|
||||
[super _effectiveAppearanceDidChange];
|
||||
|
||||
[[self window] _updateShadow];
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
|
||||
@@ -6,6 +6,29 @@
|
||||
var DEFAULT_CSS_PROPERTIES = nil,
|
||||
FRAME_UPDATERS = {};
|
||||
|
||||
/*
|
||||
Returns a value function that calls aFunction in the effective appearance of aView. The
|
||||
keyframes of an animation are built outside layout, where the drawing appearance is the
|
||||
application's, so a named colour took the application's value in a view of another
|
||||
appearance.
|
||||
*/
|
||||
function _CPViewAnimatorValueFunctionInAppearance(aFunction, aView)
|
||||
{
|
||||
return function(aStartValue, aValue)
|
||||
{
|
||||
var previousAppearance = _CPAppearanceBeginDrawing([aView effectiveAppearance]);
|
||||
|
||||
try
|
||||
{
|
||||
return aFunction(aStartValue, aValue);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_CPAppearanceEndDrawing(previousAppearance);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@implementation CPViewAnimator : _CPObjectAnimator
|
||||
{
|
||||
BOOL _wantsPeriodicFrameUpdates @accessors(property=wantsPeriodicFrameUpdates);
|
||||
@@ -160,6 +183,14 @@ var DEFAULT_CSS_PROPERTIES = nil,
|
||||
property = [aDict objectForKey:@"property"],
|
||||
getter = [aDict objectForKey:@"value"];
|
||||
|
||||
/*
|
||||
The value function of backgroundColor resolved the colour in the current drawing
|
||||
appearance, which here is the application's. It now runs in the animated view's
|
||||
appearance.
|
||||
*/
|
||||
if (getter)
|
||||
getter = _CPViewAnimatorValueFunctionInAppearance(getter, anAction.object);
|
||||
|
||||
animation.addPropertyAnimation(property, getter, anAction.duration, anAction.keytimes, anAction.values, timingFunctions, completionFunction);
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -20,144 +20,232 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
A3CPColorActiveText = [CPColor colorWithRed:0 green:0 blue:0 alpha:0.85];
|
||||
A3CPColorActiveTextHighlighted = [CPColor colorWithRed:255 green:255 blue:255 alpha:0.90];
|
||||
A3CPColorInactiveText = [CPColor colorWithRed:0 green:0 blue:0 alpha:0.30];
|
||||
A3CPColorInactiveWhiteText = [CPColor colorWithRed: 255 green:255 blue:255 alpha:0.6];
|
||||
A3CPColorDefaultText = [CPColor colorWithHexString:@"FFFFFF"];
|
||||
A3CPColorActiveText65 = [CPColor colorWithRed:0 green:0 blue:0 alpha:0.65];
|
||||
/*
|
||||
Aristo3's theme colours: the colours that have no System name. Each constant is a named
|
||||
colour of the theme catalog. It resolves at use to the value that the current theme gives
|
||||
for the current appearance, so a CSS dictionary that holds it follows the appearance.
|
||||
|
||||
A3CPColorBlack50 = [CPColor colorWithRed:0 green:0 blue:0 alpha:0.50];
|
||||
A3CPColorBlack85 = [CPColor colorWithRed:0 green:0 blue:0 alpha:0.85];
|
||||
A3CPColorBlack25 = [CPColor colorWithRed:0 green:0 blue:0 alpha:0.25];
|
||||
This file is the table of the values for every appearance (A3ThemeColorValues).
|
||||
Aristo3DarkColors.j gives the values for the dark appearance (A3DarkThemeColorValues), and
|
||||
the dark values of System colours that Aristo3 uses (A3DarkSystemColorValues).
|
||||
+[Aristo3ThemeDescriptor themedColor] registers the tables.
|
||||
|
||||
A3CPColorActiveBorder = [CPColor colorWithRed:0 green:0 blue:0 alpha:0.20];
|
||||
A3ColorActiveBorder = @"rgba(0,0,0,0.20)";
|
||||
A3CPColorInactiveBorder = [CPColor colorWithRed:0 green:0 blue:0 alpha:0.10];
|
||||
A3ColorInactiveBorder = @"rgba(0,0,0,0.10)";
|
||||
A3ColorInactiveDarkBorder = @"rgba(0,0,0,0.25)";
|
||||
A3ColorNotKeyDarkBorder = @"rgba(0,0,0,0.85)";
|
||||
A3ColorTransparent = @"rgba(0,0,0,0)";
|
||||
A3ColorLightBackground = @"rgba(255,255,255,0.5)";
|
||||
A constant's colour name is its identifier without A3Color or A3CPColor, with a lower-case
|
||||
first letter and Color added: A3ColorBorderBlue is borderBlueColor. The two forms of one
|
||||
colour (A3Color... and A3CPColor...) are one name, and both constants hold one object.
|
||||
*/
|
||||
A3ThemeColorValues = @{};
|
||||
A3DarkThemeColorValues = @{};
|
||||
A3DarkSystemColorValues = @{};
|
||||
|
||||
A3ColorBorderLight = @"rgb(230,230,230)";
|
||||
A3ColorBorderMedium = @"rgb(213,213,213)";
|
||||
A3ColorBorderDark = @"rgb(205,205,205)";
|
||||
A3ColorBorderBlue = @"rgb(23,128,251)";
|
||||
A3CPColorBorderBlue = [CPColor colorWithHexString:@"1780FB"];
|
||||
A3CPColorBorderBlueInactive = [CPColor colorWithHexString:@"DCDCDC"];
|
||||
A3ColorBorderBlueLight = @"rgb(150,200,250)";
|
||||
A3ColorBorderBlueHighlighted = @"rgb(0,103,216)";
|
||||
A3ColorBackground = @"rgb(236,236,236)";
|
||||
A3ColorBackgroundInactive = @"rgb(240,240,240)";
|
||||
A3ColorBackgroundHighlighted = @"rgb(231,231,231)";
|
||||
A3ColorBackgroundWhite = @"rgb(255,255,255)";
|
||||
A3ColorBackgroundDark = @"rgb(159,159,159)";
|
||||
A3ColorBackgroundDarkened = @"rgba(0,0,0,0.15)";
|
||||
A3ColorBackgroundLightlyDarkened = @"rgba(0,0,0,0.05)";
|
||||
A3ColorButtonBackgroundHighlighted = @"rgb(191,191,191)";
|
||||
A3ColorBackground90 = @"rgba(236,236,236,0.90)";
|
||||
A3ColorBackground50 = @"rgba(236,236,236,0.50)";
|
||||
A3ColorButtonBackgroundHighlighted80= @"rgba(191,191,191,0.80)";
|
||||
A3ColorButtonBackgroundHighlighted50= @"rgba(191,191,191,0.50)";
|
||||
A3ColorBackgroundDark35 = @"rgba(159,159,159,0.35)";
|
||||
A3ColorBackgroundBlack50 = @"rgba(0,0,0,0.50)";
|
||||
A3ColorBackgroundBlack35 = @"rgba(0,0,0,0.35)";
|
||||
A3ColorBackgroundBlack20 = @"rgba(0,0,0,0.20)";
|
||||
A3ColorBackgroundBlack14 = @"rgba(0,0,0,0.14)";
|
||||
/*
|
||||
Returns YES when two values of a table give the same colour. A channel above 1, as
|
||||
[CPColor colorWithRed:255 green:255 blue:255 alpha:0.35] has, gives the same colour as 1,
|
||||
because the browser clamps it.
|
||||
*/
|
||||
function A3ThemeColorValuesAreEqual(aColor, anotherColor)
|
||||
{
|
||||
if ([aColor isKindOfClass:_CPDynamicColor] || [anotherColor isKindOfClass:_CPDynamicColor])
|
||||
return [aColor isEqual:anotherColor];
|
||||
|
||||
A3ColorBorderRed = @"rgb(192,26,25)";
|
||||
A3ColorBorderRedLight = @"rgb(239,102,103)";
|
||||
A3ColorBorderRedHighlighted = @"rgb(144,19,19)";
|
||||
var components = [aColor components],
|
||||
otherComponents = [anotherColor components];
|
||||
|
||||
for (var i = 0; i < 3; i++)
|
||||
if (ROUND(MIN(MAX(components[i], 0.0), 1.0) * 255.0) !== ROUND(MIN(MAX(otherComponents[i], 0.0), 1.0) * 255.0))
|
||||
return NO;
|
||||
|
||||
return components[3] === otherComponents[3];
|
||||
}
|
||||
|
||||
/*
|
||||
Puts aValue into aTable under aName. A name defined twice with different values is a defect
|
||||
of the table, so the blend build stops.
|
||||
*/
|
||||
function A3PutThemeColorValue(aTable, aName, aValue)
|
||||
{
|
||||
var previousValue = [aTable objectForKey:aName];
|
||||
|
||||
if (!previousValue)
|
||||
[aTable setObject:aValue forKey:aName];
|
||||
else if (!A3ThemeColorValuesAreEqual(previousValue, aValue))
|
||||
[CPException raise:CPInvalidArgumentException reason:"Aristo3 defines the theme colour " + aName + " twice with different values"];
|
||||
}
|
||||
|
||||
/*
|
||||
Defines the theme colour aName with aValue for every appearance, and returns the named
|
||||
colour.
|
||||
*/
|
||||
function A3DefineThemeColor(aName, aValue)
|
||||
{
|
||||
A3PutThemeColorValue(A3ThemeColorValues, aName, aValue);
|
||||
|
||||
return [CPColor colorWithCatalogName:@"Theme" colorName:aName];
|
||||
}
|
||||
|
||||
/*
|
||||
Defines the value of the theme colour aName in the dark appearance.
|
||||
*/
|
||||
function A3DefineDarkThemeColor(aName, aValue)
|
||||
{
|
||||
A3PutThemeColorValue(A3DarkThemeColorValues, aName, aValue);
|
||||
}
|
||||
|
||||
/*
|
||||
Defines the value of the System colour aName in the dark appearance.
|
||||
*/
|
||||
function A3DefineDarkSystemColor(aName, aValue)
|
||||
{
|
||||
A3PutThemeColorValue(A3DarkSystemColorValues, aName, aValue);
|
||||
}
|
||||
|
||||
A3CPColorActiveText = A3DefineThemeColor(@"activeTextColor", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.85]);
|
||||
A3CPColorActiveTextHighlighted = A3DefineThemeColor(@"activeTextHighlightedColor", [CPColor colorWithRed:255 green:255 blue:255 alpha:0.90]);
|
||||
A3CPColorInactiveText = A3DefineThemeColor(@"inactiveTextColor", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.30]);
|
||||
A3CPColorInactiveWhiteText = A3DefineThemeColor(@"inactiveWhiteTextColor", [CPColor colorWithRed: 255 green:255 blue:255 alpha:0.6]);
|
||||
A3CPColorDefaultText = A3DefineThemeColor(@"defaultTextColor", [CPColor colorWithHexString:@"FFFFFF"]);
|
||||
A3CPColorActiveText65 = A3DefineThemeColor(@"activeText65Color", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.65]);
|
||||
|
||||
A3CPColorBlack50 = A3DefineThemeColor(@"black50Color", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.50]);
|
||||
A3CPColorBlack85 = A3DefineThemeColor(@"black85Color", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.85]);
|
||||
A3CPColorBlack25 = A3DefineThemeColor(@"black25Color", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.25]);
|
||||
|
||||
A3CPColorActiveBorder = A3DefineThemeColor(@"activeBorderColor", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.20]);
|
||||
A3ColorActiveBorder = A3DefineThemeColor(@"activeBorderColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.20)"]);
|
||||
A3CPColorInactiveBorder = A3DefineThemeColor(@"inactiveBorderColor", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.10]);
|
||||
A3ColorInactiveBorder = A3DefineThemeColor(@"inactiveBorderColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.10)"]);
|
||||
A3ColorInactiveDarkBorder = A3DefineThemeColor(@"inactiveDarkBorderColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.25)"]);
|
||||
A3ColorNotKeyDarkBorder = A3DefineThemeColor(@"notKeyDarkBorderColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.85)"]);
|
||||
A3ColorTransparent = @"rgba(0,0,0,0)"; // A fully clear colour has no name.
|
||||
A3ColorLightBackground = A3DefineThemeColor(@"lightBackgroundColor", [CPColor colorWithCSSString:@"rgba(255,255,255,0.5)"]);
|
||||
|
||||
A3ColorBorderLight = A3DefineThemeColor(@"borderLightColor", [CPColor colorWithCSSString:@"rgb(230,230,230)"]);
|
||||
A3ColorBorderMedium = A3DefineThemeColor(@"borderMediumColor", [CPColor colorWithCSSString:@"rgb(213,213,213)"]);
|
||||
A3ColorBorderDark = A3DefineThemeColor(@"borderDarkColor", [CPColor colorWithCSSString:@"rgb(205,205,205)"]);
|
||||
A3ColorBorderBlue = A3DefineThemeColor(@"borderBlueColor", [CPColor colorWithCSSString:@"rgb(23,128,251)"]);
|
||||
A3CPColorBorderBlue = A3DefineThemeColor(@"borderBlueColor", [CPColor colorWithHexString:@"1780FB"]);
|
||||
A3CPColorBorderBlueInactive = A3DefineThemeColor(@"borderBlueInactiveColor", [CPColor colorWithHexString:@"DCDCDC"]);
|
||||
A3ColorBorderBlueLight = A3DefineThemeColor(@"borderBlueLightColor", [CPColor colorWithCSSString:@"rgb(150,200,250)"]);
|
||||
A3ColorBorderBlueHighlighted = A3DefineThemeColor(@"borderBlueHighlightedColor", [CPColor colorWithCSSString:@"rgb(0,103,216)"]);
|
||||
A3ColorBackground = A3DefineThemeColor(@"backgroundColor", [CPColor colorWithCSSString:@"rgb(236,236,236)"]);
|
||||
A3ColorBackgroundInactive = A3DefineThemeColor(@"backgroundInactiveColor", [CPColor colorWithCSSString:@"rgb(240,240,240)"]);
|
||||
A3ColorBackgroundHighlighted = A3DefineThemeColor(@"backgroundHighlightedColor", [CPColor colorWithCSSString:@"rgb(231,231,231)"]);
|
||||
A3ColorBackgroundWhite = A3DefineThemeColor(@"backgroundWhiteColor", [CPColor colorWithCSSString:@"rgb(255,255,255)"]);
|
||||
A3ColorBackgroundDark = A3DefineThemeColor(@"backgroundDarkColor", [CPColor colorWithCSSString:@"rgb(159,159,159)"]);
|
||||
A3ColorBackgroundDarkened = A3DefineThemeColor(@"backgroundDarkenedColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.15)"]);
|
||||
A3ColorBackgroundLightlyDarkened = A3DefineThemeColor(@"backgroundLightlyDarkenedColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.05)"]);
|
||||
A3ColorButtonBackgroundHighlighted = A3DefineThemeColor(@"buttonBackgroundHighlightedColor", [CPColor colorWithCSSString:@"rgb(191,191,191)"]);
|
||||
A3ColorBackground90 = A3DefineThemeColor(@"background90Color", [CPColor colorWithCSSString:@"rgba(236,236,236,0.90)"]);
|
||||
A3ColorBackground50 = A3DefineThemeColor(@"background50Color", [CPColor colorWithCSSString:@"rgba(236,236,236,0.50)"]);
|
||||
A3ColorButtonBackgroundHighlighted80= A3DefineThemeColor(@"buttonBackgroundHighlighted80Color", [CPColor colorWithCSSString:@"rgba(191,191,191,0.80)"]);
|
||||
A3ColorButtonBackgroundHighlighted50= A3DefineThemeColor(@"buttonBackgroundHighlighted50Color", [CPColor colorWithCSSString:@"rgba(191,191,191,0.50)"]);
|
||||
A3ColorBackgroundDark35 = A3DefineThemeColor(@"backgroundDark35Color", [CPColor colorWithCSSString:@"rgba(159,159,159,0.35)"]);
|
||||
A3ColorBackgroundBlack50 = A3DefineThemeColor(@"backgroundBlack50Color", [CPColor colorWithCSSString:@"rgba(0,0,0,0.50)"]);
|
||||
A3ColorBackgroundBlack35 = A3DefineThemeColor(@"backgroundBlack35Color", [CPColor colorWithCSSString:@"rgba(0,0,0,0.35)"]);
|
||||
A3ColorBackgroundBlack20 = A3DefineThemeColor(@"backgroundBlack20Color", [CPColor colorWithCSSString:@"rgba(0,0,0,0.20)"]);
|
||||
A3ColorBackgroundBlack14 = A3DefineThemeColor(@"backgroundBlack14Color", [CPColor colorWithCSSString:@"rgba(0,0,0,0.14)"]);
|
||||
|
||||
A3ColorBorderRed = A3DefineThemeColor(@"borderRedColor", [CPColor colorWithCSSString:@"rgb(192,26,25)"]);
|
||||
A3ColorBorderRedLight = A3DefineThemeColor(@"borderRedLightColor", [CPColor colorWithCSSString:@"rgb(239,102,103)"]);
|
||||
A3ColorBorderRedHighlighted = A3DefineThemeColor(@"borderRedHighlightedColor", [CPColor colorWithCSSString:@"rgb(144,19,19)"]);
|
||||
|
||||
// Windows
|
||||
|
||||
A3ColorWindowHeadActive = @"rgb(216,216,216)";
|
||||
A3ColorWindowHeadInactive = @"rgb(246,246,246)";
|
||||
A3ColorWindowButtonClose = @"rgb(252,96,92)";
|
||||
A3ColorWindowButtonCloseDark = @"rgb(223,72,69)";
|
||||
A3ColorWindowButtonCloseLight = @"rgb(254,176,174)";
|
||||
A3ColorWindowButtonMin = @"rgb(253,188,64)";
|
||||
A3ColorWindowButtonMinDark = @"rgb(222,160,52)";
|
||||
A3ColorWindowButtonMinLight = @"rgb(254,222,160)";
|
||||
A3ColorWindowButtonZoom = @"rgb(52,200,74)";
|
||||
A3ColorWindowButtonZoomDark = @"rgb(40,171,53)";
|
||||
A3ColorWindowButtonZoomLight = @"rgb(154,227,164)";
|
||||
A3ColorWindowButtonUnsaved = @"rgba(50,50,50,0.65)";
|
||||
A3ColorWindowButtonUnsavedLight = @"rgb(100,100,100)";
|
||||
A3ColorWindowButtonBackground = @"rgb(128,128,128)";
|
||||
A3ColorWindowButtonBackgroundLight = @"rgb(192,192,192)";
|
||||
A3ColorWindowButtonBackgroundDark = @"rgb(96,96,96)";
|
||||
A3ColorWindowBorder = @"rgb(189,189,189)";
|
||||
A3ColorWindowHeadActive = A3DefineThemeColor(@"windowHeadActiveColor", [CPColor colorWithCSSString:@"rgb(216,216,216)"]);
|
||||
A3ColorWindowHeadInactive = A3DefineThemeColor(@"windowHeadInactiveColor", [CPColor colorWithCSSString:@"rgb(246,246,246)"]);
|
||||
A3ColorWindowButtonClose = A3DefineThemeColor(@"windowButtonCloseColor", [CPColor colorWithCSSString:@"rgb(252,96,92)"]);
|
||||
A3ColorWindowButtonCloseDark = A3DefineThemeColor(@"windowButtonCloseDarkColor", [CPColor colorWithCSSString:@"rgb(223,72,69)"]);
|
||||
A3ColorWindowButtonCloseLight = A3DefineThemeColor(@"windowButtonCloseLightColor", [CPColor colorWithCSSString:@"rgb(254,176,174)"]);
|
||||
A3ColorWindowButtonMin = A3DefineThemeColor(@"windowButtonMinColor", [CPColor colorWithCSSString:@"rgb(253,188,64)"]);
|
||||
A3ColorWindowButtonMinDark = A3DefineThemeColor(@"windowButtonMinDarkColor", [CPColor colorWithCSSString:@"rgb(222,160,52)"]);
|
||||
A3ColorWindowButtonMinLight = A3DefineThemeColor(@"windowButtonMinLightColor", [CPColor colorWithCSSString:@"rgb(254,222,160)"]);
|
||||
A3ColorWindowButtonZoom = A3DefineThemeColor(@"windowButtonZoomColor", [CPColor colorWithCSSString:@"rgb(52,200,74)"]);
|
||||
A3ColorWindowButtonZoomDark = A3DefineThemeColor(@"windowButtonZoomDarkColor", [CPColor colorWithCSSString:@"rgb(40,171,53)"]);
|
||||
A3ColorWindowButtonZoomLight = A3DefineThemeColor(@"windowButtonZoomLightColor", [CPColor colorWithCSSString:@"rgb(154,227,164)"]);
|
||||
A3ColorWindowButtonUnsaved = A3DefineThemeColor(@"windowButtonUnsavedColor", [CPColor colorWithCSSString:@"rgba(50,50,50,0.65)"]);
|
||||
A3ColorWindowButtonUnsavedLight = A3DefineThemeColor(@"windowButtonUnsavedLightColor", [CPColor colorWithCSSString:@"rgb(100,100,100)"]);
|
||||
A3ColorWindowButtonBackground = A3DefineThemeColor(@"windowButtonBackgroundColor", [CPColor colorWithCSSString:@"rgb(128,128,128)"]);
|
||||
A3ColorWindowButtonBackgroundLight = A3DefineThemeColor(@"windowButtonBackgroundLightColor", [CPColor colorWithCSSString:@"rgb(192,192,192)"]);
|
||||
A3ColorWindowButtonBackgroundDark = A3DefineThemeColor(@"windowButtonBackgroundDarkColor", [CPColor colorWithCSSString:@"rgb(96,96,96)"]);
|
||||
A3ColorWindowBorder = A3DefineThemeColor(@"windowBorderColor", [CPColor colorWithCSSString:@"rgb(189,189,189)"]);
|
||||
|
||||
// Menus
|
||||
|
||||
A3ColorMenuLightBackground = @"rgb(246,246,246)";
|
||||
A3ColorMenuBackground = @"rgb(206,206,206)";
|
||||
A3ColorMenuCheckmark = @"rgba(0,0,0,0.85)";
|
||||
A3ColorMenuBorder = @"rgba(0,0,0,0.20)";
|
||||
A3ColorMenuLightBackground = A3DefineThemeColor(@"menuLightBackgroundColor", [CPColor colorWithCSSString:@"rgb(246,246,246)"]);
|
||||
A3ColorMenuBackground = A3DefineThemeColor(@"menuBackgroundColor", [CPColor colorWithCSSString:@"rgb(206,206,206)"]);
|
||||
A3ColorMenuCheckmark = A3DefineThemeColor(@"menuCheckmarkColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.85)"]);
|
||||
A3ColorMenuBorder = A3DefineThemeColor(@"menuBorderColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.20)"]);
|
||||
|
||||
// Textfields
|
||||
|
||||
A3ColorTextfieldActiveBorder = @"rgba(0,0,0,0.25)";
|
||||
A3ColorTextfieldInactiveBorder = @"rgba(0,0,0,0.20)";
|
||||
A3ColorTextfieldActiveBorder = A3DefineThemeColor(@"textfieldActiveBorderColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.25)"]);
|
||||
A3ColorTextfieldInactiveBorder = A3DefineThemeColor(@"textfieldInactiveBorderColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.20)"]);
|
||||
|
||||
// Tables
|
||||
|
||||
A3CPColorTableRow = [CPColor whiteColor];
|
||||
A3CPColorTableAlternateRow = [CPColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0];
|
||||
A3CPColorTableDivider = [CPColor colorWithRed:214.0/255.0 green:214.0/255.0 blue:214.0/255.0 alpha:1.0];
|
||||
A3ColorTableDivider = @"rgb(214,214,214)";
|
||||
A3ColorTableHeaderSeparator = @"rgb(229,229,229)";
|
||||
A3CPColorTableHeaderText = [CPColor colorWithRed:0 green:0 blue:0 alpha:0.40];
|
||||
A3CPColorSelectedTableHeaderText = [CPColor colorWithRed:0 green:0 blue:0 alpha:0.70];
|
||||
A3ColorTableColumnHeaderPressed = @"rgba(0,0,0,0.10)";
|
||||
/*
|
||||
The first of the table's alternating row colours is the background of the table view,
|
||||
which has a System name. Aristo3 gives no value for it under Aqua, so it keeps CPColor's
|
||||
default, which is white.
|
||||
*/
|
||||
A3CPColorTableRow = [CPColor controlBackgroundColor];
|
||||
A3CPColorTableAlternateRow = A3DefineThemeColor(@"tableAlternateRowColor", [CPColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0]);
|
||||
A3CPColorTableDivider = A3DefineThemeColor(@"tableDividerColor", [CPColor colorWithRed:214.0/255.0 green:214.0/255.0 blue:214.0/255.0 alpha:1.0]);
|
||||
A3ColorTableDivider = A3DefineThemeColor(@"tableDividerColor", [CPColor colorWithCSSString:@"rgb(214,214,214)"]);
|
||||
A3ColorTableHeaderSeparator = A3DefineThemeColor(@"tableHeaderSeparatorColor", [CPColor colorWithCSSString:@"rgb(229,229,229)"]);
|
||||
A3CPColorTableHeaderText = A3DefineThemeColor(@"tableHeaderTextColor", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.40]);
|
||||
A3CPColorSelectedTableHeaderText = A3DefineThemeColor(@"selectedTableHeaderTextColor", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.70]);
|
||||
A3ColorTableColumnHeaderPressed = A3DefineThemeColor(@"tableColumnHeaderPressedColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.10)"]);
|
||||
|
||||
// Scrollers
|
||||
|
||||
A3ColorScrollerDark = @"rgba(0,0,0,0.50)";
|
||||
A3ColorScrollerLight = @"rgba(255,255,255,0.5)";
|
||||
A3ColorScrollerLegacy = @"rgba(0,0,0,0.20)";
|
||||
A3ColorScrollerBackground = @"rgb(250,250,250)";
|
||||
A3ColorScrollerBorder = @"rgb(232,232,232)";
|
||||
A3ColorScrollerDark = A3DefineThemeColor(@"scrollerDarkColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.50)"]);
|
||||
A3ColorScrollerLight = A3DefineThemeColor(@"scrollerLightColor", [CPColor colorWithCSSString:@"rgba(255,255,255,0.5)"]);
|
||||
A3ColorScrollerLegacy = A3DefineThemeColor(@"scrollerLegacyColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.20)"]);
|
||||
A3ColorScrollerBackground = A3DefineThemeColor(@"scrollerBackgroundColor", [CPColor colorWithCSSString:@"rgb(250,250,250)"]);
|
||||
A3ColorScrollerBorder = A3DefineThemeColor(@"scrollerBorderColor", [CPColor colorWithCSSString:@"rgb(232,232,232)"]);
|
||||
|
||||
// Sliders
|
||||
|
||||
A3ColorCircularSliderKnob = @"rgba(0,0,0,0.5)";
|
||||
A3ColorSliderDisabledKnob = @"rgb(251,251,251)";
|
||||
A3ColorSliderDisabledTrack = @"rgb(140,140,140)";
|
||||
A3ColorCircularSliderKnob = A3DefineThemeColor(@"circularSliderKnobColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.5)"]);
|
||||
A3ColorSliderDisabledKnob = A3DefineThemeColor(@"sliderDisabledKnobColor", [CPColor colorWithCSSString:@"rgb(251,251,251)"]);
|
||||
A3ColorSliderDisabledTrack = A3DefineThemeColor(@"sliderDisabledTrackColor", [CPColor colorWithCSSString:@"rgb(140,140,140)"]);
|
||||
|
||||
// Steppers
|
||||
|
||||
A3ColorStepperArrow = @"rgba(0,0,0,0.65)";
|
||||
A3ColorHighlightedStepperArrow = @"rgba(255,255,255,1)";
|
||||
A3ColorStepperArrow = A3DefineThemeColor(@"stepperArrowColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.65)"]);
|
||||
A3ColorHighlightedStepperArrow = A3DefineThemeColor(@"highlightedStepperArrowColor", [CPColor colorWithCSSString:@"rgba(255,255,255,1)"]);
|
||||
|
||||
// Split views
|
||||
|
||||
A3ColorSplitPaneDividerBackground = @"rgb(253,253,253)";
|
||||
A3ColorSplitPaneDividerBorder = @"rgb(213,213,213)";
|
||||
A3ColorSplitPaneDividerBackground = A3DefineThemeColor(@"splitPaneDividerBackgroundColor", [CPColor colorWithCSSString:@"rgb(253,253,253)"]);
|
||||
A3ColorSplitPaneDividerBorder = A3DefineThemeColor(@"splitPaneDividerBorderColor", [CPColor colorWithCSSString:@"rgb(213,213,213)"]);
|
||||
|
||||
// Calendar
|
||||
|
||||
A3ColorCalendarButtons = @"rgb(50,50,50)";
|
||||
A3ColorCalendarHighlightedButtons = @"rgb(165,165,165)";
|
||||
A3CPColorCalendarDark = [CPColor colorWithRed:0 green:0 blue:0 alpha:0.35];
|
||||
A3ColorCalendarDark = @"rgba(0,0,0,0.35)";
|
||||
A3ColorCalendarActive = A3ColorBorderBlue;
|
||||
A3ColorCalendarActiveNotKey = @"rgba(0,0,0,0.15)";
|
||||
A3CPColorCalendarTitle = [CPColor colorWithRed:65/255 green:65/255 blue:65/255 alpha:1];
|
||||
A3CPColorCalendarTile = A3CPColorActiveText; // [CPColor colorWithRed:40/255 green:40/255 blue:40/255 alpha:1];
|
||||
A3CPColorCalendarCurrentDayTile = A3CPColorBorderBlue;
|
||||
A3CPColorCalendarOutOfRangeTile = A3CPColorInactiveText;
|
||||
A3CPColorCalendarSelectedTile = [CPColor whiteColor];
|
||||
A3ColorCalendarBackground = @"rgb(255,255,255)";
|
||||
A3ColorCalendarButtons = A3DefineThemeColor(@"calendarButtonsColor", [CPColor colorWithCSSString:@"rgb(50,50,50)"]);
|
||||
A3ColorCalendarHighlightedButtons = A3DefineThemeColor(@"calendarHighlightedButtonsColor", [CPColor colorWithCSSString:@"rgb(165,165,165)"]);
|
||||
A3CPColorCalendarDark = A3DefineThemeColor(@"calendarDarkColor", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.35]);
|
||||
A3ColorCalendarDark = A3DefineThemeColor(@"calendarDarkColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.35)"]);
|
||||
A3ColorCalendarActive = A3DefineThemeColor(@"calendarActiveColor", [CPColor colorWithCSSString:@"rgb(23,128,251)"]);
|
||||
A3ColorCalendarActiveNotKey = A3DefineThemeColor(@"calendarActiveNotKeyColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.15)"]);
|
||||
A3CPColorCalendarTitle = A3DefineThemeColor(@"calendarTitleColor", [CPColor colorWithRed:65/255 green:65/255 blue:65/255 alpha:1]);
|
||||
A3CPColorCalendarTile = A3DefineThemeColor(@"calendarTileColor", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.85]); // [CPColor colorWithRed:40/255 green:40/255 blue:40/255 alpha:1];
|
||||
A3CPColorCalendarCurrentDayTile = A3DefineThemeColor(@"calendarCurrentDayTileColor", [CPColor colorWithHexString:@"1780FB"]);
|
||||
A3CPColorCalendarOutOfRangeTile = A3DefineThemeColor(@"calendarOutOfRangeTileColor", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.30]);
|
||||
A3CPColorCalendarSelectedTile = A3DefineThemeColor(@"calendarSelectedTileColor", [CPColor whiteColor]);
|
||||
A3ColorCalendarBackground = A3DefineThemeColor(@"calendarBackgroundColor", [CPColor colorWithCSSString:@"rgb(255,255,255)"]);
|
||||
|
||||
// Disclosure triangle
|
||||
|
||||
A3ColorDisclosure = @"rgb(140,140,140)";
|
||||
A3ColorDisclosureDisabled = @"rgb(191,191,191)";
|
||||
A3ColorDisclosurePushed = @"rgb(115,115,115)";
|
||||
A3ColorDisclosure = A3DefineThemeColor(@"disclosureColor", [CPColor colorWithCSSString:@"rgb(140,140,140)"]);
|
||||
A3ColorDisclosureDisabled = A3DefineThemeColor(@"disclosureDisabledColor", [CPColor colorWithCSSString:@"rgb(191,191,191)"]);
|
||||
A3ColorDisclosurePushed = A3DefineThemeColor(@"disclosurePushedColor", [CPColor colorWithCSSString:@"rgb(115,115,115)"]);
|
||||
|
||||
// Square buttons
|
||||
|
||||
A3ColorSquareButtonBackground = @"rgb(248,248,248)";
|
||||
A3ColorSquareButtonBackground = A3DefineThemeColor(@"squareButtonBackgroundColor", [CPColor colorWithCSSString:@"rgb(248,248,248)"]);
|
||||
|
||||
// Window shadow
|
||||
|
||||
A3ColorWindowViewWindowShadow = A3DefineThemeColor(@"windowViewWindowShadowColor", [CPColor colorWithCSSString:@"rgba(0, 0, 0, 0.25)"]);
|
||||
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Aristo3DarkColors.j
|
||||
* AppKit
|
||||
*
|
||||
* Modified for Dark Grey Structural Theme
|
||||
*/
|
||||
|
||||
/*
|
||||
The values of Aristo3's theme colours in the dark appearance: for each colour of
|
||||
Aristo3Colors.j, its value under DarkAqua. +[Aristo3ThemeDescriptor themedColor] registers
|
||||
the table keyed by CPThemeStateAppearanceDarkAqua; the vibrant and high-contrast dark
|
||||
appearances find it through -bestMatchFromAppearancesWithNames:. A colour that is not in
|
||||
this table keeps its value for every appearance.
|
||||
|
||||
The set is a first, rudimentary one, so that dark mode shows which parts follow the
|
||||
appearance. Descriptor refinement comes after theme packaging.
|
||||
*/
|
||||
|
||||
A3DefineDarkThemeColor(@"activeTextColor", [CPColor colorWithRed:255 green:255 blue:255 alpha:0.85]);
|
||||
A3DefineDarkThemeColor(@"activeTextHighlightedColor", [CPColor colorWithRed:255 green:255 blue:255 alpha:1.00]);
|
||||
A3DefineDarkThemeColor(@"inactiveTextColor", [CPColor colorWithRed:255 green:255 blue:255 alpha:0.40]);
|
||||
A3DefineDarkThemeColor(@"inactiveWhiteTextColor", [CPColor colorWithRed:255 green:255 blue:255 alpha:0.25]);
|
||||
A3DefineDarkThemeColor(@"defaultTextColor", [CPColor colorWithHexString:@"DEDEDE"]);
|
||||
A3DefineDarkThemeColor(@"activeText65Color", [CPColor colorWithRed:255 green:255 blue:255 alpha:0.65]);
|
||||
|
||||
A3DefineDarkThemeColor(@"black50Color", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.50]);
|
||||
A3DefineDarkThemeColor(@"black85Color", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.85]);
|
||||
A3DefineDarkThemeColor(@"black25Color", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.25]);
|
||||
|
||||
A3DefineDarkThemeColor(@"activeBorderColor", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.60]);
|
||||
A3DefineDarkThemeColor(@"activeBorderColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.60)"]);
|
||||
A3DefineDarkThemeColor(@"inactiveBorderColor", [CPColor colorWithRed:0 green:0 blue:0 alpha:0.30]);
|
||||
A3DefineDarkThemeColor(@"inactiveBorderColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.30)"]);
|
||||
A3DefineDarkThemeColor(@"inactiveDarkBorderColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.50)"]);
|
||||
A3DefineDarkThemeColor(@"notKeyDarkBorderColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.40)"]);
|
||||
A3DefineDarkThemeColor(@"lightBackgroundColor", [CPColor colorWithCSSString:@"rgba(255,255,255,0.10)"]);
|
||||
|
||||
A3DefineDarkThemeColor(@"borderLightColor", [CPColor colorWithCSSString:@"rgb(85,85,85)"]);
|
||||
A3DefineDarkThemeColor(@"borderMediumColor", [CPColor colorWithCSSString:@"rgb(45,45,45)"]);
|
||||
A3DefineDarkThemeColor(@"borderDarkColor", [CPColor colorWithCSSString:@"rgb(25,25,25)"]);
|
||||
A3DefineDarkThemeColor(@"borderBlueColor", [CPColor colorWithCSSString:@"rgb(10,100,210)"]);
|
||||
A3DefineDarkThemeColor(@"borderBlueColor", [CPColor colorWithHexString:@"0A64D2"]);
|
||||
A3DefineDarkThemeColor(@"borderBlueInactiveColor", [CPColor colorWithHexString:@"444444"]);
|
||||
A3DefineDarkThemeColor(@"borderBlueLightColor", [CPColor colorWithCSSString:@"rgb(60,130,220)"]);
|
||||
A3DefineDarkThemeColor(@"borderBlueHighlightedColor", [CPColor colorWithCSSString:@"rgb(40,150,255)"]);
|
||||
A3DefineDarkThemeColor(@"backgroundColor", [CPColor colorWithCSSString:@"rgb(45,45,45)"]);
|
||||
A3DefineDarkThemeColor(@"backgroundInactiveColor", [CPColor colorWithCSSString:@"rgb(38,38,38)"]);
|
||||
A3DefineDarkThemeColor(@"backgroundHighlightedColor", [CPColor colorWithCSSString:@"rgb(65,65,65)"]);
|
||||
A3DefineDarkThemeColor(@"backgroundWhiteColor", [CPColor colorWithCSSString:@"rgb(30,30,30)"]); // Inset base
|
||||
A3DefineDarkThemeColor(@"backgroundDarkColor", [CPColor colorWithCSSString:@"rgb(25,25,25)"]);
|
||||
A3DefineDarkThemeColor(@"backgroundDarkenedColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.35)"]);
|
||||
A3DefineDarkThemeColor(@"backgroundLightlyDarkenedColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.15)"]);
|
||||
A3DefineDarkThemeColor(@"buttonBackgroundHighlightedColor", [CPColor colorWithCSSString:@"rgb(75,75,75)"]);
|
||||
A3DefineDarkThemeColor(@"background90Color", [CPColor colorWithCSSString:@"rgba(45,45,45,0.90)"]);
|
||||
A3DefineDarkThemeColor(@"background50Color", [CPColor colorWithCSSString:@"rgba(45,45,45,0.50)"]);
|
||||
A3DefineDarkThemeColor(@"buttonBackgroundHighlighted80Color", [CPColor colorWithCSSString:@"rgba(75,75,75,0.80)"]);
|
||||
A3DefineDarkThemeColor(@"buttonBackgroundHighlighted50Color", [CPColor colorWithCSSString:@"rgba(75,75,75,0.50)"]);
|
||||
A3DefineDarkThemeColor(@"backgroundDark35Color", [CPColor colorWithCSSString:@"rgba(25,25,25,0.35)"]);
|
||||
A3DefineDarkThemeColor(@"backgroundBlack50Color", [CPColor colorWithCSSString:@"rgba(0,0,0,0.50)"]);
|
||||
A3DefineDarkThemeColor(@"backgroundBlack35Color", [CPColor colorWithCSSString:@"rgba(0,0,0,0.35)"]);
|
||||
A3DefineDarkThemeColor(@"backgroundBlack20Color", [CPColor colorWithCSSString:@"rgba(0,0,0,0.20)"]);
|
||||
A3DefineDarkThemeColor(@"backgroundBlack14Color", [CPColor colorWithCSSString:@"rgba(0,0,0,0.14)"]);
|
||||
|
||||
A3DefineDarkThemeColor(@"borderRedColor", [CPColor colorWithCSSString:@"rgb(205,50,50)"]);
|
||||
A3DefineDarkThemeColor(@"borderRedLightColor", [CPColor colorWithCSSString:@"rgb(235,90,90)"]);
|
||||
A3DefineDarkThemeColor(@"borderRedHighlightedColor", [CPColor colorWithCSSString:@"rgb(255,80,80)"]);
|
||||
|
||||
// Windows
|
||||
|
||||
A3DefineDarkThemeColor(@"windowHeadActiveColor", [CPColor colorWithCSSString:@"rgb(54,54,54)"]);
|
||||
A3DefineDarkThemeColor(@"windowHeadInactiveColor", [CPColor colorWithCSSString:@"rgb(38,38,38)"]);
|
||||
A3DefineDarkThemeColor(@"windowButtonCloseColor", [CPColor colorWithCSSString:@"rgb(252,96,92)"]);
|
||||
A3DefineDarkThemeColor(@"windowButtonCloseDarkColor", [CPColor colorWithCSSString:@"rgb(223,72,69)"]);
|
||||
A3DefineDarkThemeColor(@"windowButtonCloseLightColor", [CPColor colorWithCSSString:@"rgb(254,176,174)"]);
|
||||
A3DefineDarkThemeColor(@"windowButtonMinColor", [CPColor colorWithCSSString:@"rgb(253,188,64)"]);
|
||||
A3DefineDarkThemeColor(@"windowButtonMinDarkColor", [CPColor colorWithCSSString:@"rgb(222,160,52)"]);
|
||||
A3DefineDarkThemeColor(@"windowButtonMinLightColor", [CPColor colorWithCSSString:@"rgb(254,222,160)"]);
|
||||
A3DefineDarkThemeColor(@"windowButtonZoomColor", [CPColor colorWithCSSString:@"rgb(52,200,74)"]);
|
||||
A3DefineDarkThemeColor(@"windowButtonZoomDarkColor", [CPColor colorWithCSSString:@"rgb(40,171,53)"]);
|
||||
A3DefineDarkThemeColor(@"windowButtonZoomLightColor", [CPColor colorWithCSSString:@"rgb(154,227,164)"]);
|
||||
A3DefineDarkThemeColor(@"windowButtonUnsavedColor", [CPColor colorWithCSSString:@"rgba(200,200,200,0.65)"]);
|
||||
A3DefineDarkThemeColor(@"windowButtonUnsavedLightColor", [CPColor colorWithCSSString:@"rgb(150,150,150)"]);
|
||||
A3DefineDarkThemeColor(@"windowButtonBackgroundColor", [CPColor colorWithCSSString:@"rgb(75,75,75)"]);
|
||||
A3DefineDarkThemeColor(@"windowButtonBackgroundLightColor", [CPColor colorWithCSSString:@"rgb(90,90,90)"]);
|
||||
A3DefineDarkThemeColor(@"windowButtonBackgroundDarkColor", [CPColor colorWithCSSString:@"rgb(40,40,40)"]);
|
||||
A3DefineDarkThemeColor(@"windowBorderColor", [CPColor colorWithCSSString:@"rgb(20,20,20)"]);
|
||||
|
||||
// Menus
|
||||
|
||||
A3DefineDarkThemeColor(@"menuLightBackgroundColor", [CPColor colorWithCSSString:@"rgb(55,55,55)"]);
|
||||
A3DefineDarkThemeColor(@"menuBackgroundColor", [CPColor colorWithCSSString:@"rgb(45,45,45)"]);
|
||||
A3DefineDarkThemeColor(@"menuCheckmarkColor", [CPColor colorWithCSSString:@"rgba(255,255,255,0.85)"]);
|
||||
A3DefineDarkThemeColor(@"menuBorderColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.60)"]);
|
||||
|
||||
// Textfields
|
||||
|
||||
A3DefineDarkThemeColor(@"textfieldActiveBorderColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.70)"]);
|
||||
A3DefineDarkThemeColor(@"textfieldInactiveBorderColor", [CPColor colorWithCSSString:@"rgba(0,0,0,0.40)"]);
|
||||
|
||||
// Tables
|
||||
|
||||
/*
|
||||
The background of the table view, the first of its alternating row colours, has the
|
||||
System name controlBackgroundColor (see A3CPColorTableRow in Aristo3Colors.j).
|
||||
*/
|
||||
A3DefineDarkSystemColor(@"controlBackgroundColor", [CPColor colorWithRed:45.0/255.0 green:45.0/255.0 blue:45.0/255.0 alpha:1.0]);
|
||||
A3DefineDarkThemeColor(@"tableAlternateRowColor", [CPColor colorWithRed:38.0/255.0 green:38.0/255.0 blue:38.0/255.0 alpha:1.0]);
|
||||
A3DefineDarkThemeColor(@"tableDividerColor", [CPColor colorWithRed:25.0/255.0 green:25.0/255.0 blue:25.0/255.0 alpha:1.0]);
|
||||
A3DefineDarkThemeColor(@"tableDividerColor", [CPColor colorWithCSSString:@"rgb(25,25,25)"]);
|
||||
A3DefineDarkThemeColor(@"tableHeaderSeparatorColor", [CPColor colorWithCSSString:@"rgb(20,20,20)"]);
|
||||
A3DefineDarkThemeColor(@"tableHeaderTextColor", [CPColor colorWithRed:255 green:255 blue:255 alpha:0.60]);
|
||||
A3DefineDarkThemeColor(@"selectedTableHeaderTextColor", [CPColor colorWithRed:255 green:255 blue:255 alpha:0.85]);
|
||||
A3DefineDarkThemeColor(@"tableColumnHeaderPressedColor", [CPColor colorWithCSSString:@"rgba(255,255,255,0.10)"]);
|
||||
|
||||
// Scrollers
|
||||
|
||||
A3DefineDarkThemeColor(@"scrollerDarkColor", [CPColor colorWithCSSString:@"rgba(255,255,255,0.50)"]);
|
||||
A3DefineDarkThemeColor(@"scrollerLightColor", [CPColor colorWithCSSString:@"rgba(255,255,255,0.25)"]);
|
||||
A3DefineDarkThemeColor(@"scrollerLegacyColor", [CPColor colorWithCSSString:@"rgba(255,255,255,0.30)"]);
|
||||
A3DefineDarkThemeColor(@"scrollerBackgroundColor", [CPColor colorWithCSSString:@"rgb(35,35,35)"]);
|
||||
A3DefineDarkThemeColor(@"scrollerBorderColor", [CPColor colorWithCSSString:@"rgb(20,20,20)"]);
|
||||
|
||||
// Sliders
|
||||
|
||||
A3DefineDarkThemeColor(@"circularSliderKnobColor", [CPColor colorWithCSSString:@"rgba(255,255,255,0.80)"]);
|
||||
A3DefineDarkThemeColor(@"sliderDisabledKnobColor", [CPColor colorWithCSSString:@"rgb(60,60,60)"]);
|
||||
A3DefineDarkThemeColor(@"sliderDisabledTrackColor", [CPColor colorWithCSSString:@"rgb(40,40,40)"]);
|
||||
|
||||
// Steppers
|
||||
|
||||
A3DefineDarkThemeColor(@"stepperArrowColor", [CPColor colorWithCSSString:@"rgba(255,255,255,0.65)"]);
|
||||
A3DefineDarkThemeColor(@"highlightedStepperArrowColor", [CPColor colorWithCSSString:@"rgba(255,255,255,1)"]);
|
||||
|
||||
// Split views
|
||||
|
||||
A3DefineDarkThemeColor(@"splitPaneDividerBackgroundColor", [CPColor colorWithCSSString:@"rgb(30,30,30)"]);
|
||||
A3DefineDarkThemeColor(@"splitPaneDividerBorderColor", [CPColor colorWithCSSString:@"rgb(20,20,20)"]);
|
||||
|
||||
// Calendar
|
||||
|
||||
A3DefineDarkThemeColor(@"calendarButtonsColor", [CPColor colorWithCSSString:@"rgb(150,150,150)"]);
|
||||
A3DefineDarkThemeColor(@"calendarHighlightedButtonsColor", [CPColor colorWithCSSString:@"rgb(200,200,200)"]);
|
||||
A3DefineDarkThemeColor(@"calendarDarkColor", [CPColor colorWithRed:255 green:255 blue:255 alpha:0.35]);
|
||||
A3DefineDarkThemeColor(@"calendarDarkColor", [CPColor colorWithCSSString:@"rgba(255,255,255,0.35)"]);
|
||||
A3DefineDarkThemeColor(@"calendarActiveColor", [CPColor colorWithCSSString:@"rgb(10,100,210)"]);
|
||||
A3DefineDarkThemeColor(@"calendarActiveNotKeyColor", [CPColor colorWithCSSString:@"rgba(255,255,255,0.15)"]);
|
||||
A3DefineDarkThemeColor(@"calendarTitleColor", [CPColor colorWithRed:200/255 green:200/255 blue:200/255 alpha:1]);
|
||||
A3DefineDarkThemeColor(@"calendarTileColor", [CPColor colorWithRed:255 green:255 blue:255 alpha:0.85]);
|
||||
A3DefineDarkThemeColor(@"calendarCurrentDayTileColor", [CPColor colorWithHexString:@"0A64D2"]);
|
||||
A3DefineDarkThemeColor(@"calendarOutOfRangeTileColor", [CPColor colorWithRed:255 green:255 blue:255 alpha:0.40]);
|
||||
A3DefineDarkThemeColor(@"calendarSelectedTileColor", [CPColor colorWithRed:60/255 green:60/255 blue:60/255 alpha:1]);
|
||||
A3DefineDarkThemeColor(@"calendarBackgroundColor", [CPColor colorWithCSSString:@"rgb(45,45,45)"]);
|
||||
|
||||
// Disclosure triangle
|
||||
|
||||
A3DefineDarkThemeColor(@"disclosureColor", [CPColor colorWithCSSString:@"rgb(160,160,160)"]);
|
||||
A3DefineDarkThemeColor(@"disclosureDisabledColor", [CPColor colorWithCSSString:@"rgb(80,80,80)"]);
|
||||
A3DefineDarkThemeColor(@"disclosurePushedColor", [CPColor colorWithCSSString:@"rgb(220,220,220)"]);
|
||||
|
||||
// Square buttons
|
||||
|
||||
A3DefineDarkThemeColor(@"squareButtonBackgroundColor", [CPColor colorWithCSSString:@"rgb(55,55,55)"]);
|
||||
|
||||
// Window shadow: the light value, until descriptor refinement.
|
||||
|
||||
A3DefineDarkThemeColor(@"windowViewWindowShadowColor", [CPColor colorWithCSSString:@"rgba(0, 0, 0, 0.25)"]);
|
||||
@@ -56,11 +56,15 @@
|
||||
@import <AppKit/CPImage.j>
|
||||
|
||||
@import "Aristo3Colors.j"
|
||||
@import "Aristo3DarkColors.j"
|
||||
|
||||
var A3ColorActiveText = [A3CPColorActiveText cssString],
|
||||
A3ColorInactiveText = [A3CPColorInactiveText cssString],
|
||||
A3ColorWhite = [[CPColor whiteColor] cssString],
|
||||
A3ColorBlack = [[CPColor blackColor] cssString];
|
||||
/*
|
||||
The string forms of the two text colours hold the named colours, so that a CSS value
|
||||
follows the appearance. A3ColorWhite waits for names of its own (SPEC-4 part 4e).
|
||||
*/
|
||||
var A3ColorActiveText = A3CPColorActiveText,
|
||||
A3ColorInactiveText = A3CPColorInactiveText,
|
||||
A3ColorWhite = [[CPColor whiteColor] cssString];
|
||||
|
||||
// SVGs
|
||||
var svgArrowDown = "url('data:image/svg+xml;charset=utf-8;base64,PHN2ZyB3aWR0aD0iNjQiIGhlaWdodD0iNjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cGF0aCBkPSJNNyAxMEwxMiAxNUwxNyAxMEg3WiIgZmlsbD0iIzQ1NDU0NSIvPgo8L3N2Zz4=')",
|
||||
@@ -245,9 +249,16 @@ function A3MaskIcon(aMaskImage, aColor)
|
||||
[@"alternate-selected-control-color", [[CPColor alloc] _initWithRGBA:[0.22, 0.46, 0.84, 1.0]]],
|
||||
[@"secondary-selected-control-color", [[CPColor alloc] _initWithRGBA:[0.83, 0.83, 0.83, 1.0]]],
|
||||
[@"selected-text-background-color", [CPColor colorWithHexString:"99CCFF"]],
|
||||
[@"selected-text-inactive-background-color", [CPColor colorWithHexString:"CCCCCC"]]
|
||||
[@"selected-text-inactive-background-color", [CPColor colorWithHexString:"CCCCCC"]],
|
||||
[@"theme-colors", A3ThemeColorValues],
|
||||
[@"theme-colors", A3DarkThemeColorValues, CPThemeStateAppearanceDarkAqua]
|
||||
];
|
||||
|
||||
[A3DarkSystemColorValues enumerateKeysAndObjectsUsingBlock:function(aName, aValue, stop)
|
||||
{
|
||||
themedColorValues.push([_CPThemeAttributeForSystemColorName(aName), aValue, CPThemeStateAppearanceDarkAqua]);
|
||||
}];
|
||||
|
||||
[self registerThemeValues:themedColorValues forObject:color];
|
||||
|
||||
return color;
|
||||
@@ -7064,7 +7075,7 @@ function A3MaskIcon(aMaskImage, aColor)
|
||||
// Standard Background
|
||||
background = [CPColor colorWithCSSDictionary:@{
|
||||
@"background-color": A3ColorBackgroundWhite,
|
||||
@"border-bottom": @"1px solid " + A3ColorTableDivider,
|
||||
@"border-bottom": @[@"1px solid ", A3ColorTableDivider],
|
||||
@"box-sizing": @"border-box"
|
||||
}
|
||||
beforeDictionary:nil
|
||||
@@ -7362,12 +7373,12 @@ function A3MaskIcon(aMaskImage, aColor)
|
||||
// Replaced PatternImage
|
||||
horizontalDividerColor = [CPColor colorWithCSSDictionary:@{
|
||||
@"background-color": A3ColorBackground,
|
||||
@"border-top": @"1px solid " + A3ColorBorderLight
|
||||
@"border-top": @[@"1px solid ", A3ColorBorderLight]
|
||||
}],
|
||||
|
||||
verticalDividerColor = [CPColor colorWithCSSDictionary:@{
|
||||
@"background-color": A3ColorBackground,
|
||||
@"border-left": @"1px solid " + A3ColorBorderLight
|
||||
@"border-left": @[@"1px solid ", A3ColorBorderLight]
|
||||
}],
|
||||
|
||||
thinDividerCssColor = [CPColor colorWithCSSDictionary:@{
|
||||
@@ -8584,7 +8595,7 @@ function A3MaskIcon(aMaskImage, aColor)
|
||||
|
||||
// --- Standard Colors ---
|
||||
var bezelColor = [CPColor colorWithCSSDictionary:@{
|
||||
@"border": @"1px solid " + A3ColorBorderDark,
|
||||
@"border": @[@"1px solid ", A3ColorBorderDark],
|
||||
@"background-color": A3ColorBackgroundWhite,
|
||||
@"border-radius": @"3px",
|
||||
@"box-sizing": @"border-box"
|
||||
@@ -8640,7 +8651,7 @@ function A3MaskIcon(aMaskImage, aColor)
|
||||
|
||||
// --- Standard Colors (Blue with White Stripes) ---
|
||||
var bezelColor = [CPColor colorWithCSSDictionary:@{
|
||||
@"border": @"1px solid " + A3ColorBorderDark,
|
||||
@"border": @[@"1px solid ", A3ColorBorderDark],
|
||||
@"background-color": A3ColorBackgroundWhite,
|
||||
@"border-radius": @"3px",
|
||||
@"box-sizing": @"border-box"
|
||||
@@ -8823,7 +8834,7 @@ function A3MaskIcon(aMaskImage, aColor)
|
||||
var levelIndicator = [[CPLevelIndicator alloc] initWithFrame:CGRectMake(0, 0, 100, 100)],
|
||||
|
||||
bezelColor = [CPColor colorWithCSSDictionary:@{
|
||||
@"border": @"1px solid " + A3ColorBorderDark
|
||||
@"border": @[@"1px solid ", A3ColorBorderDark]
|
||||
}],
|
||||
|
||||
// --- Standard Colors (Traffic Light) ---
|
||||
@@ -8990,7 +9001,7 @@ function A3MaskIcon(aMaskImage, aColor)
|
||||
// Using pure CSS window frame
|
||||
var bezelColor = [CPColor colorWithCSSDictionary:@{
|
||||
@"background-color": A3ColorBackground,
|
||||
@"border": @"1px solid " + A3ColorWindowBorder,
|
||||
@"border": @[@"1px solid ", A3ColorWindowBorder],
|
||||
@"border-radius": @"6px",
|
||||
@"box-shadow": @"0 5px 15px rgba(0,0,0,0.5)"
|
||||
}],
|
||||
@@ -9025,7 +9036,7 @@ function A3MaskIcon(aMaskImage, aColor)
|
||||
[
|
||||
[@"shadow-inset", CGInsetMake(0, 0, 0, 0)],
|
||||
[@"shadow-distance", 5],
|
||||
[@"window-shadow-color", @"0px 5px 10px 0px rgba(0, 0, 0, 0.25)"],
|
||||
[@"window-shadow-color", @[@"0px 5px 10px 0px ", A3ColorWindowViewWindowShadow]],
|
||||
[@"resize-indicator", resizeIndicator],
|
||||
[@"attached-sheet-shadow-color", sheetShadow, CPThemeStateNormal],
|
||||
[@"shadow-height", 5],
|
||||
@@ -9260,7 +9271,7 @@ function A3MaskIcon(aMaskImage, aColor)
|
||||
[@"border-top-right-radius", @"6px"],
|
||||
[@"border-bottom-left-radius", @"7px"],
|
||||
[@"border-bottom-right-radius", @"7px"],
|
||||
[@"frame-border-color", [CPColor colorWithCSSString:A3ColorWindowBorder]],
|
||||
[@"frame-border-color", A3ColorWindowBorder],
|
||||
[@"frame-border-width", 1],
|
||||
|
||||
// --- REGISTER BUTTON IMAGES ---
|
||||
@@ -9329,7 +9340,7 @@ function A3MaskIcon(aMaskImage, aColor)
|
||||
// Apply the same styling as the standard Modal Window to cover the background
|
||||
var bezelColor = [CPColor colorWithCSSDictionary:@{
|
||||
@"background-color": A3ColorBackgroundWhite,
|
||||
@"border": @"1px solid " + A3ColorWindowBorder,
|
||||
@"border": @[@"1px solid ", A3ColorWindowBorder],
|
||||
@"border-radius": @"6px",
|
||||
@"box-shadow": @"0 5px 15px rgba(0,0,0,0.5)"
|
||||
}];
|
||||
@@ -9353,7 +9364,7 @@ function A3MaskIcon(aMaskImage, aColor)
|
||||
// Standard Theme Toolbar
|
||||
toolbarBackgroundColor = [CPColor colorWithCSSDictionary:@{
|
||||
@"background-color": A3ColorBackground,
|
||||
@"border-bottom": @"1px solid " + A3ColorBorderLight
|
||||
@"border-bottom": @[@"1px solid ", A3ColorBorderLight]
|
||||
}],
|
||||
|
||||
// HUD Theme Window Background (Dark/Translucent)
|
||||
@@ -9400,7 +9411,7 @@ function A3MaskIcon(aMaskImage, aColor)
|
||||
toolbarExtraItemsAlternateImage = toolbarExtraItemsImage,
|
||||
|
||||
toolbarSeparatorColor = [CPColor colorWithCSSDictionary:@{
|
||||
@"border-left": @"1px solid " + A3ColorBorderLight
|
||||
@"border-left": @[@"1px solid ", A3ColorBorderLight]
|
||||
}],
|
||||
|
||||
themeValues =
|
||||
|
||||
@@ -247,19 +247,21 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
|
||||
The early return compared only the object. A dynamic colour is the same object in every
|
||||
appearance, so a control that set it again after a change of appearance kept the CSS of
|
||||
the old one. The CSS string now takes part in the comparison.
|
||||
|
||||
The setter wrote the colour at once, in the current drawing appearance. Called outside
|
||||
layout, as from an event handler, it wrote the application's value of a named colour in a
|
||||
view of another appearance. The setter now marks the colour for layout, which writes it in
|
||||
the view's appearance (see -_layoutTextColor).
|
||||
*/
|
||||
- (void)setTextColor:(CPColor)aTextColor
|
||||
{
|
||||
var cssString = [aTextColor cssString];
|
||||
|
||||
if (_textColor === aTextColor && _textColorCSSString === cssString)
|
||||
if (_textColor === aTextColor && _textColorCSSString === [aTextColor cssString])
|
||||
return;
|
||||
|
||||
_textColor = aTextColor;
|
||||
_textColorCSSString = cssString;
|
||||
_flags |= _CPImageAndTextViewTextColorChangedFlag;
|
||||
|
||||
if (CPDOMAvailable)
|
||||
_DOMElement.style.color = cssString;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (CPColor)textColor
|
||||
@@ -268,19 +270,31 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
|
||||
}
|
||||
|
||||
/*
|
||||
Writes the text colour again and marks the text shadow and the image as changed, so that
|
||||
the next layout resolves them in the new appearance.
|
||||
Writes the text colour when it changed: when it was set, or when it gives another CSS
|
||||
string in the current drawing appearance, which layout sets to the view's appearance.
|
||||
*/
|
||||
- (void)_layoutTextColor
|
||||
{
|
||||
var cssString = [_textColor cssString];
|
||||
|
||||
if (!(_flags & _CPImageAndTextViewTextColorChangedFlag) && cssString === _textColorCSSString)
|
||||
return;
|
||||
|
||||
_textColorCSSString = cssString;
|
||||
|
||||
if (CPDOMAvailable)
|
||||
_DOMElement.style.color = cssString;
|
||||
}
|
||||
|
||||
/*
|
||||
Marks the text colour, the text shadow and the image as changed, so that the next layout
|
||||
resolves them in the new appearance.
|
||||
*/
|
||||
- (void)_effectiveAppearanceDidChange
|
||||
{
|
||||
[super _effectiveAppearanceDidChange];
|
||||
|
||||
_textColorCSSString = [_textColor cssString];
|
||||
|
||||
if (CPDOMAvailable)
|
||||
_DOMElement.style.color = _textColorCSSString;
|
||||
|
||||
_flags |= _CPImageAndTextViewTextShadowColorChangedFlag | _CPImageAndTextViewImageChangedFlag;
|
||||
_flags |= _CPImageAndTextViewTextColorChangedFlag | _CPImageAndTextViewTextShadowColorChangedFlag | _CPImageAndTextViewImageChangedFlag;
|
||||
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
@@ -463,6 +477,8 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[self _layoutTextColor];
|
||||
|
||||
if (CPDOMAvailable)
|
||||
{
|
||||
var needsDOMTextElement = _imagePosition !== CPImageOnly && ([_text length] > 0),
|
||||
@@ -503,7 +519,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
|
||||
{
|
||||
[[_textShadowColor cssDictionary] enumerateKeysAndObjectsUsingBlock:function(aKey, anObject, stop)
|
||||
{
|
||||
_DOMTextElement.style[aKey] = anObject;
|
||||
_DOMTextElement.style[aKey] = _CPCSSValueString(anObject);
|
||||
}];
|
||||
}
|
||||
else
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
* Aristo3ThemeColorsTest.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by David Richardson on 2026-11-11.
|
||||
* Copyright David Richardson 2026.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import "BuiltThemes.j"
|
||||
|
||||
/*
|
||||
Aristo3 gives its own colours as names of the theme catalog. Each name takes its value from
|
||||
the attribute "theme-colors" of CPColor: a table for every appearance and a table for the
|
||||
dark appearance. A value in a CSS dictionary is a string, a colour or an array of these,
|
||||
and it is converted when it is written.
|
||||
|
||||
These tests read the built Aristo3 theme, so they need the themes built first, as
|
||||
`npx jake build` does.
|
||||
*/
|
||||
var Aristo3ThemeColorsTestObjectDescriptions = ["Catalog color", "Asset color", "[object"];
|
||||
|
||||
@implementation Aristo3ThemeColorsTest : OJTestCase
|
||||
{
|
||||
CPTheme _previousTheme;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
// This will init the global var CPApp which are used internally in the AppKit
|
||||
[[CPApplication alloc] init];
|
||||
|
||||
_previousTheme = [CPTheme defaultTheme];
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
{
|
||||
[CPTheme setDefaultTheme:_previousTheme];
|
||||
[CPAppearance setCurrentAppearance:nil];
|
||||
}
|
||||
|
||||
- (CPTheme)aristo3
|
||||
{
|
||||
var theme = BuiltThemeNamed(@"Aristo3");
|
||||
|
||||
[self assertNotNull:theme message:@"The built blends hold no Aristo3 theme. Build the themes first."];
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the table of theme colours that aTheme gives for the theme state aState.
|
||||
*/
|
||||
- (CPDictionary)themeColorsOf:(CPTheme)aTheme inState:(CPThemeState)aState
|
||||
{
|
||||
return [[[aTheme attributeWithName:@"theme-colors" forClass:@"color"] values] objectForKey:String(aState)];
|
||||
}
|
||||
|
||||
/*
|
||||
Calls aFunction(aValue, aLocation) for each value inside aValue: aValue itself, the members
|
||||
of an array or a dictionary, and the values of the CSS dictionaries of a CSS colour or
|
||||
image. A named colour or a System image is not opened: it resolves to another object.
|
||||
*/
|
||||
- (void)visit:(id)aValue at:(CPString)aLocation with:(Function)aFunction
|
||||
{
|
||||
if (aValue === nil || aValue === undefined)
|
||||
return;
|
||||
|
||||
aFunction(aValue, aLocation);
|
||||
|
||||
if (typeof aValue === "string" || !aValue.isa)
|
||||
return;
|
||||
|
||||
if ([aValue isKindOfClass:[CPArray class]])
|
||||
{
|
||||
for (var i = 0; i < aValue.length; i++)
|
||||
[self visit:aValue[i] at:aLocation + "[" + i + "]" with:aFunction];
|
||||
}
|
||||
else if ([aValue isKindOfClass:[CPDictionary class]])
|
||||
{
|
||||
var keys = [aValue allKeys];
|
||||
|
||||
for (var i = 0; i < keys.length; i++)
|
||||
[self visit:[aValue objectForKey:keys[i]] at:aLocation + "." + keys[i] with:aFunction];
|
||||
}
|
||||
else if (([aValue isKindOfClass:[CPColor class]] && ![aValue isKindOfClass:[_CPDynamicColor class]]) ||
|
||||
([aValue isKindOfClass:[CPImage class]] && ![aValue isKindOfClass:[_CPDynamicImage class]]))
|
||||
{
|
||||
[self visit:[aValue cssDictionary] at:aLocation + " (CSS)" with:aFunction];
|
||||
[self visit:[aValue cssBeforeDictionary] at:aLocation + " (::before)" with:aFunction];
|
||||
[self visit:[aValue cssAfterDictionary] at:aLocation + " (::after)" with:aFunction];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Calls aFunction(aValue, aLocation) for each value inside every attribute value of aTheme.
|
||||
*/
|
||||
- (void)visitTheme:(CPTheme)aTheme with:(Function)aFunction
|
||||
{
|
||||
var classNames = [[aTheme classNames] sortedArrayUsingSelector:@selector(compare:)];
|
||||
|
||||
for (var i = 0; i < classNames.length; i++)
|
||||
{
|
||||
var attributes = [aTheme attributesForClass:classNames[i]],
|
||||
names = [[attributes allKeys] sortedArrayUsingSelector:@selector(compare:)];
|
||||
|
||||
for (var j = 0; j < names.length; j++)
|
||||
{
|
||||
var values = [[attributes objectForKey:names[j]] values],
|
||||
states = [values allKeys];
|
||||
|
||||
for (var k = 0; k < states.length; k++)
|
||||
[self visit:[values objectForKey:states[k]] at:classNames[i] + " " + names[j] + " (" + states[k] + ")" with:aFunction];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isThemeColor:(id)aValue
|
||||
{
|
||||
return !!aValue && !!aValue.isa && [aValue isKindOfClass:[_CPCatalogColor class]] && [aValue catalogNameComponent] === @"Theme";
|
||||
}
|
||||
|
||||
- (void)testEveryThemeColorThatAristo3NamesHasALightAndADarkValue
|
||||
{
|
||||
var theme = [self aristo3],
|
||||
lightColors = [self themeColorsOf:theme inState:CPThemeStateNormal],
|
||||
darkColors = [self themeColorsOf:theme inState:CPThemeStateAppearanceDarkAqua],
|
||||
missing = [],
|
||||
count = 0;
|
||||
|
||||
[self assertNotNull:lightColors message:@"Aristo3 gives no theme colours for every appearance"];
|
||||
[self assertNotNull:darkColors message:@"Aristo3 gives no theme colours for DarkAqua"];
|
||||
|
||||
[self visitTheme:theme with:function(aValue, aLocation)
|
||||
{
|
||||
if (![self isThemeColor:aValue])
|
||||
return;
|
||||
|
||||
var name = [aValue colorNameComponent];
|
||||
|
||||
count++;
|
||||
|
||||
if (![lightColors containsKey:name])
|
||||
missing.push(aLocation + ": " + name + " has no value for every appearance");
|
||||
|
||||
if (![darkColors containsKey:name])
|
||||
missing.push(aLocation + ": " + name + " has no value for DarkAqua");
|
||||
}];
|
||||
|
||||
[self assertTrue:count > 0 message:@"Aristo3 names no theme colour"];
|
||||
[self assertTrue:missing.length === 0 message:missing.join("\n")];
|
||||
}
|
||||
|
||||
- (void)testTheLightAndTheDarkTableNameTheSameColors
|
||||
{
|
||||
var theme = [self aristo3],
|
||||
lightNames = [[[self themeColorsOf:theme inState:CPThemeStateNormal] allKeys] sortedArrayUsingSelector:@selector(compare:)],
|
||||
darkNames = [[[self themeColorsOf:theme inState:CPThemeStateAppearanceDarkAqua] allKeys] sortedArrayUsingSelector:@selector(compare:)];
|
||||
|
||||
[self assert:lightNames.join(", ") equals:darkNames.join(", ")];
|
||||
}
|
||||
|
||||
- (void)testATableValueIsAFixedOrASystemColor
|
||||
{
|
||||
var theme = [self aristo3],
|
||||
violations = [];
|
||||
|
||||
[CPThemeStateNormal, CPThemeStateAppearanceDarkAqua].forEach(function(aState)
|
||||
{
|
||||
var colors = [self themeColorsOf:theme inState:aState],
|
||||
names = [colors allKeys];
|
||||
|
||||
for (var i = 0; i < names.length; i++)
|
||||
{
|
||||
var value = [colors objectForKey:names[i]];
|
||||
|
||||
if (![value isKindOfClass:[CPColor class]] || [self isThemeColor:value] || [value isCSSBased] || [value patternImage])
|
||||
violations.push(String(aState) + " " + names[i] + ": " + [value description]);
|
||||
}
|
||||
});
|
||||
|
||||
[self assertTrue:violations.length === 0 message:violations.join("\n")];
|
||||
}
|
||||
|
||||
/*
|
||||
A site that joins a named colour into a string with + writes the colour's description.
|
||||
Every CSS value converts in Aqua and in DarkAqua, and no text holds the description of
|
||||
an object.
|
||||
*/
|
||||
- (void)testNoConvertedValueHoldsTheDescriptionOfAnObject
|
||||
{
|
||||
var theme = [self aristo3],
|
||||
violations = [];
|
||||
|
||||
[CPTheme setDefaultTheme:theme];
|
||||
|
||||
[CPAppearanceNameAqua, CPAppearanceNameDarkAqua].forEach(function(anAppearanceName)
|
||||
{
|
||||
[[CPAppearance appearanceNamed:anAppearanceName] performAsCurrentDrawingAppearance:function()
|
||||
{
|
||||
[self visitTheme:theme with:function(aValue, aLocation)
|
||||
{
|
||||
var text = nil;
|
||||
|
||||
if (typeof aValue === "string")
|
||||
text = aValue;
|
||||
else if (aValue.isa && ([aValue isKindOfClass:[CPColor class]] || [aValue isKindOfClass:[CPImage class]]) &&
|
||||
![aValue isKindOfClass:[_CPDynamicColor class]] && ![aValue isKindOfClass:[_CPDynamicImage class]] && [aValue isCSSBased])
|
||||
{
|
||||
try
|
||||
{
|
||||
text = _CPCSSObjectText(aValue);
|
||||
}
|
||||
catch (anException)
|
||||
{
|
||||
violations.push(anAppearanceName + " " + aLocation + ": " + anException);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (text === nil)
|
||||
return;
|
||||
|
||||
for (var i = 0; i < Aristo3ThemeColorsTestObjectDescriptions.length; i++)
|
||||
if (text.indexOf(Aristo3ThemeColorsTestObjectDescriptions[i]) !== -1)
|
||||
violations.push(anAppearanceName + " " + aLocation + ": " + text);
|
||||
}];
|
||||
}];
|
||||
});
|
||||
|
||||
[self assertTrue:violations.length === 0 message:violations.join("\n")];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -327,4 +327,43 @@
|
||||
[self assert:0 equals:[button showsStateBy]];
|
||||
}
|
||||
|
||||
/*
|
||||
A text colour set outside layout, as from an event handler, is written by layout, which
|
||||
resolves it in the view's appearance. The setter wrote it at once, in the application's
|
||||
appearance.
|
||||
*/
|
||||
- (void)testATextColorSetOutsideLayoutIsWrittenByLayoutInTheViewAppearance
|
||||
{
|
||||
var view = [[_CPImageAndTextView alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 20.0)];
|
||||
|
||||
[view setAppearance:[CPAppearance appearanceNamed:CPAppearanceNameDarkAqua]];
|
||||
[view layoutIfNeeded];
|
||||
|
||||
[view setTextColor:[[CPButtonTestDynamicColor alloc] _initDynamicColor]];
|
||||
|
||||
[self assertTrue:[view needsLayout] message:@"-setTextColor: marks the view for layout"];
|
||||
[self assertNull:view._textColorCSSString message:@"-setTextColor: writes nothing"];
|
||||
|
||||
[view layoutIfNeeded];
|
||||
|
||||
[self assert:[[CPColor whiteColor] cssString] equals:view._textColorCSSString];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
A colour that is white in a dark appearance and black in every other.
|
||||
*/
|
||||
@implementation CPButtonTestDynamicColor : _CPDynamicColor
|
||||
|
||||
- (CPColor)_valueInAppearance:(CPAppearance)anAppearance
|
||||
{
|
||||
return [anAppearance name] === CPAppearanceNameDarkAqua ? [CPColor whiteColor] : [CPColor blackColor];
|
||||
}
|
||||
|
||||
- (_CPDynamicColor)_dynamicCopy
|
||||
{
|
||||
return [[CPButtonTestDynamicColor alloc] _initDynamicColor];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,396 @@
|
||||
/*
|
||||
* CPColorCSSValueTest.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by David Richardson on 2026-11-11.
|
||||
* Copyright David Richardson 2026.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import <AppKit/AppKit.j>
|
||||
|
||||
/*
|
||||
A value in a CSS dictionary of a colour or an image is a string, a colour, or an array of
|
||||
strings and colours. Each value is converted when it is written, in the current drawing
|
||||
appearance, so a dictionary that holds a named colour follows the appearance.
|
||||
*/
|
||||
|
||||
var CPColorCSSValueTestPlaceholder = @"CPColorCSSValueTestPlaceholder";
|
||||
|
||||
/*
|
||||
A view that counts the writes of its background into the DOM. Node has no DOM, so the view
|
||||
turns the DOM on while CPView applies its background again after a change of appearance;
|
||||
that path writes nothing else.
|
||||
*/
|
||||
@implementation CPColorCSSValueTestView : CPView
|
||||
{
|
||||
int writeCount;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
if (self = [super initWithFrame:aFrame])
|
||||
writeCount = 0;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)_writeBackgroundColor
|
||||
{
|
||||
writeCount++;
|
||||
}
|
||||
|
||||
- (void)_effectiveAppearanceDidChange
|
||||
{
|
||||
var savedDOMAvailable = CPDOMAvailable;
|
||||
|
||||
CPDOMAvailable = YES;
|
||||
|
||||
try
|
||||
{
|
||||
[super _effectiveAppearanceDidChange];
|
||||
}
|
||||
finally
|
||||
{
|
||||
CPDOMAvailable = savedDOMAvailable;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
A themed class whose theme gives a CSS colour with a placeholder of the dynamic set.
|
||||
*/
|
||||
@implementation CPColorCSSValueTestThemedView : CPView
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
{
|
||||
return @"css-value-test-view";
|
||||
}
|
||||
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{ @"test-background": [CPNull null] };
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPColorCSSValueTest : OJTestCase
|
||||
{
|
||||
CPTheme _previousTheme;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
// This will init the global var CPApp which are used internally in the AppKit
|
||||
[[CPApplication alloc] init];
|
||||
|
||||
_previousTheme = [CPTheme defaultTheme];
|
||||
[CPTheme setDefaultTheme:[self themeWithFillColor]];
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
{
|
||||
[CPTheme setDefaultTheme:_previousTheme];
|
||||
[CPApp setAppearance:nil];
|
||||
[CPAppearance setCurrentAppearance:nil];
|
||||
}
|
||||
|
||||
/*
|
||||
A theme that gives the theme colour cssValueTestFillColor red for every appearance and blue
|
||||
for DarkAqua.
|
||||
*/
|
||||
- (CPTheme)themeWithFillColor
|
||||
{
|
||||
var theme = [[CPTheme alloc] initWithName:@"CPColorCSSValueTestTheme"],
|
||||
template = [CPColor colorWithWhite:0.0 alpha:1.0];
|
||||
|
||||
[template setValue:@{ @"cssValueTestFillColor": [CPColor redColor] } forThemeAttribute:@"theme-colors"];
|
||||
[template setValue:@{ @"cssValueTestFillColor": [CPColor blueColor] } forThemeAttribute:@"theme-colors" inState:CPThemeStateAppearanceDarkAqua];
|
||||
[theme takeThemeFromObject:template];
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
- (CPColor)fillColor
|
||||
{
|
||||
return [CPColor colorWithCatalogName:@"Theme" colorName:@"cssValueTestFillColor"];
|
||||
}
|
||||
|
||||
- (CPAppearance)appearance:(CPString)aName
|
||||
{
|
||||
return [CPAppearance appearanceNamed:aName];
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the result of aFunction, called with the appearance named aName as the current
|
||||
drawing appearance.
|
||||
*/
|
||||
- (id)in:(CPString)aName perform:(Function)aFunction
|
||||
{
|
||||
var result = nil;
|
||||
|
||||
[[self appearance:aName] performAsCurrentDrawingAppearance:function()
|
||||
{
|
||||
result = aFunction();
|
||||
}];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (CPColor)appearanceDependentCSSColor
|
||||
{
|
||||
return [CPColor colorWithCSSDictionary:@{
|
||||
@"background-color": [self fillColor],
|
||||
@"border": @[@"1px solid ", [self fillColor]]
|
||||
}];
|
||||
}
|
||||
|
||||
- (CPColorCSSValueTestView)newView
|
||||
{
|
||||
return [[CPColorCSSValueTestView alloc] initWithFrame:CGRectMake(0.0, 0.0, 40.0, 40.0)];
|
||||
}
|
||||
|
||||
// MARK: Conversion
|
||||
|
||||
- (void)testAStringConvertsToItself
|
||||
{
|
||||
[self assert:@"1px solid rgb(1, 2, 3)" equals:_CPCSSValueString(@"1px solid rgb(1, 2, 3)")];
|
||||
}
|
||||
|
||||
- (void)testAColorConvertsToItsCSSStringInTheCurrentAppearance
|
||||
{
|
||||
var fillColor = [self fillColor];
|
||||
|
||||
[self assert:[[CPColor redColor] cssString] equals:[self in:CPAppearanceNameAqua perform:function() { return _CPCSSValueString(fillColor); }]];
|
||||
[self assert:[[CPColor blueColor] cssString] equals:[self in:CPAppearanceNameDarkAqua perform:function() { return _CPCSSValueString(fillColor); }]];
|
||||
[self assert:[[CPColor greenColor] cssString] equals:_CPCSSValueString([CPColor greenColor])];
|
||||
}
|
||||
|
||||
- (void)testAnArrayConvertsToItsMembersJoined
|
||||
{
|
||||
var value = @[@"0 0 0 3px ", [self fillColor], @", inset ", @[@"0 1px ", [CPColor greenColor]]],
|
||||
text = [self in:CPAppearanceNameDarkAqua perform:function() { return _CPCSSValueString(value); }];
|
||||
|
||||
[self assert:@"0 0 0 3px " + [[CPColor blueColor] cssString] + @", inset 0 1px " + [[CPColor greenColor] cssString] equals:text];
|
||||
}
|
||||
|
||||
- (void)testANumberConvertsToItsText
|
||||
{
|
||||
[self assert:@"300" equals:_CPCSSValueString(300)];
|
||||
[self assert:@"0.5" equals:_CPCSSValueString(0.5)];
|
||||
}
|
||||
|
||||
- (void)testAnotherKindRaises
|
||||
{
|
||||
[self assertThrows:function() { _CPCSSValueString(@{ @"a": @"b" }); }];
|
||||
[self assertThrows:function() { _CPCSSValueString([CPNull null]); }];
|
||||
[self assertThrows:function() { _CPCSSValueString(nil); }];
|
||||
[self assertThrows:function() { _CPCSSValueString(@[@"1px solid ", [CPNull null]]); }];
|
||||
}
|
||||
|
||||
- (void)testANamedColorWithAnAlphaConvertsWithThatAlpha
|
||||
{
|
||||
var fillColor = [[self fillColor] colorWithAlphaComponent:0.5];
|
||||
|
||||
[self assert:[[[CPColor redColor] colorWithAlphaComponent:0.5] cssString] equals:[self in:CPAppearanceNameAqua perform:function() { return _CPCSSValueString(fillColor); }]];
|
||||
[self assert:[[[CPColor blueColor] colorWithAlphaComponent:0.5] cssString] equals:[self in:CPAppearanceNameDarkAqua perform:function() { return _CPCSSValueString(fillColor); }]];
|
||||
}
|
||||
|
||||
- (void)testAnObjectIsAppearanceDependentWhenADictionaryHoldsAColor
|
||||
{
|
||||
[self assertTrue:_CPCSSObjectIsAppearanceDependent([self appearanceDependentCSSColor])];
|
||||
[self assertTrue:_CPCSSObjectIsAppearanceDependent([CPColor colorWithCSSDictionary:@{} beforeDictionary:nil afterDictionary:@{ @"border": @[@"1px solid ", [self fillColor]] }])];
|
||||
[self assertFalse:_CPCSSObjectIsAppearanceDependent([CPColor colorWithCSSDictionary:@{ @"background-color": @"rgb(1, 2, 3)" }])];
|
||||
}
|
||||
|
||||
/*
|
||||
Node has no DOM, so the test gives the method an element, a style node and a document that
|
||||
record what it writes.
|
||||
*/
|
||||
- (void)testTheMainAndBeforeValuesConvertIntoTheElementAndTheStyleText
|
||||
{
|
||||
var view = [[CPView alloc] initWithFrame:CGRectMake(0.0, 0.0, 10.0, 10.0)],
|
||||
cssColor = [CPColor colorWithCSSDictionary:@{ @"border": @[@"1px solid ", [self fillColor]] }
|
||||
beforeDictionary:@{ @"background-color": [self fillColor] }
|
||||
afterDictionary:nil],
|
||||
element = { style: {} },
|
||||
styleNode = { firstChild: { data: "" }, replaceChild: function(aNewChild, anOldChild) { this.firstChild = aNewChild; } },
|
||||
previousState = @[],
|
||||
hadDocument = global.hasOwnProperty("document"),
|
||||
savedDocument = global.document;
|
||||
|
||||
global.document = { createTextNode: function(aText) { return { data: aText }; } };
|
||||
|
||||
try
|
||||
{
|
||||
[self in:CPAppearanceNameDarkAqua perform:function()
|
||||
{
|
||||
[cssColor applyCSSColorForView:view onDOMElement:element styleNode:styleNode previousState:@ref(previousState)];
|
||||
}];
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (hadDocument)
|
||||
global.document = savedDocument;
|
||||
else
|
||||
delete global.document;
|
||||
}
|
||||
|
||||
var blue = [[CPColor blueColor] cssString];
|
||||
|
||||
[self assert:@"1px solid " + blue equals:element.style["border"]];
|
||||
[self assertTrue:styleNode.firstChild.data.indexOf(@"::before { background-color: " + blue + @"; }") !== -1 message:styleNode.firstChild.data];
|
||||
}
|
||||
|
||||
// MARK: Comparison in the background setter
|
||||
|
||||
- (void)testAnAppearanceChangeRewritesAnAppearanceDependentCSSBackground
|
||||
{
|
||||
var view = [self newView],
|
||||
cssColor = [self appearanceDependentCSSColor];
|
||||
|
||||
[view setAppearance:[self appearance:CPAppearanceNameAqua]];
|
||||
[view setBackgroundColor:cssColor];
|
||||
|
||||
[self assertTrue:view._backgroundColorCSSText.indexOf([[CPColor redColor] cssString]) !== -1 message:view._backgroundColorCSSText];
|
||||
|
||||
[view setAppearance:[self appearance:CPAppearanceNameDarkAqua]];
|
||||
|
||||
[self assert:cssColor same:view._backgroundColorResolved message:@"the resolved colour is the same object"];
|
||||
[self assert:1 equals:view.writeCount];
|
||||
[self assertTrue:view._backgroundColorCSSText.indexOf([[CPColor blueColor] cssString]) !== -1 message:view._backgroundColorCSSText];
|
||||
}
|
||||
|
||||
/*
|
||||
VibrantLight finds no value of its own and takes the value for every appearance, as Aqua
|
||||
does, so the CSS is the same.
|
||||
*/
|
||||
- (void)testNoRewriteWhenTheNewAppearanceGivesTheSameCSS
|
||||
{
|
||||
var view = [self newView];
|
||||
|
||||
[view setAppearance:[self appearance:CPAppearanceNameAqua]];
|
||||
[view setBackgroundColor:[self appearanceDependentCSSColor]];
|
||||
[view setAppearance:[self appearance:CPAppearanceNameVibrantLight]];
|
||||
|
||||
[self assert:0 equals:view.writeCount];
|
||||
}
|
||||
|
||||
- (void)testASecondSetWithTheSameColorAndAppearanceDoesNotWriteAgain
|
||||
{
|
||||
var view = [self newView],
|
||||
cssColor = [self appearanceDependentCSSColor],
|
||||
savedDOMAvailable = CPDOMAvailable;
|
||||
|
||||
[view setAppearance:[self appearance:CPAppearanceNameDarkAqua]];
|
||||
|
||||
CPDOMAvailable = YES;
|
||||
|
||||
try
|
||||
{
|
||||
[view setBackgroundColor:cssColor];
|
||||
[view setBackgroundColor:cssColor];
|
||||
}
|
||||
finally
|
||||
{
|
||||
CPDOMAvailable = savedDOMAvailable;
|
||||
}
|
||||
|
||||
[self assert:1 equals:view.writeCount];
|
||||
}
|
||||
|
||||
- (void)testACSSColorWithStringsOnlyKeepsTheComparisonOfTheSameObject
|
||||
{
|
||||
var view = [self newView];
|
||||
|
||||
[view setAppearance:[self appearance:CPAppearanceNameAqua]];
|
||||
[view setBackgroundColor:[CPColor colorWithCSSDictionary:@{ @"background-color": @"rgb(1, 2, 3)" }]];
|
||||
[view setAppearance:[self appearance:CPAppearanceNameDarkAqua]];
|
||||
|
||||
[self assertNull:view._backgroundColorCSSText];
|
||||
[self assert:0 equals:view.writeCount];
|
||||
}
|
||||
|
||||
// MARK: Archiving
|
||||
|
||||
- (void)testAnArchiveRoundTripKeepsColorsAndArraysInADictionary
|
||||
{
|
||||
var fillColor = [self fillColor],
|
||||
cssColor = [CPColor colorWithCSSDictionary:@{ @"background-color": fillColor, @"border": @[@"1px solid ", fillColor] }
|
||||
beforeDictionary:@{ @"color": fillColor }
|
||||
afterDictionary:nil],
|
||||
decodedColor = [CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:cssColor]],
|
||||
border = [[decodedColor cssDictionary] objectForKey:@"border"];
|
||||
|
||||
[self assert:fillColor same:[[decodedColor cssDictionary] objectForKey:@"background-color"]];
|
||||
[self assert:2 equals:[border count]];
|
||||
[self assert:@"1px solid " equals:border[0]];
|
||||
[self assert:fillColor same:border[1]];
|
||||
[self assert:fillColor same:[[decodedColor cssBeforeDictionary] objectForKey:@"color"]];
|
||||
}
|
||||
|
||||
// MARK: Theme load
|
||||
|
||||
- (void)testTheResourcesPathReplacesStringsAndLeavesColorsAlone
|
||||
{
|
||||
var fillColor = [self fillColor],
|
||||
theme = [[CPTheme alloc] initWithName:@"CPColorCSSValueTestPaths"],
|
||||
dictionary = @{
|
||||
@"background-image": @"url(%%packed.png)",
|
||||
@"mask-image": @[@"url(%%mask.svg) ", fillColor],
|
||||
@"color": fillColor
|
||||
};
|
||||
|
||||
[theme _fixPathInCSSDictionary:dictionary withPathToResources:@"Resources/"];
|
||||
|
||||
var maskImage = [dictionary objectForKey:@"mask-image"];
|
||||
|
||||
[self assert:@"url(Resources/packed.png)" equals:[dictionary objectForKey:@"background-image"]];
|
||||
[self assert:@"url(Resources/mask.svg) " equals:maskImage[0]];
|
||||
[self assert:fillColor same:maskImage[1]];
|
||||
[self assert:fillColor same:[dictionary objectForKey:@"color"]];
|
||||
}
|
||||
|
||||
- (void)testAPlaceholderTakesAStringFromAnApplicationSet
|
||||
{
|
||||
var fillColor = [self fillColor],
|
||||
theme = [[CPTheme alloc] initWithName:@"CPColorCSSValueTestPlaceholders"],
|
||||
dictionary = @{ @"background-color": CPColorCSSValueTestPlaceholder, @"color": fillColor };
|
||||
|
||||
[theme _applyDynamicSet:[CPDictionary dictionaryWithObject:@"rgb(1, 2, 3)" forKey:CPColorCSSValueTestPlaceholder] toCSSDictionary:dictionary];
|
||||
|
||||
[self assert:@"rgb(1, 2, 3)" equals:[dictionary objectForKey:@"background-color"]];
|
||||
[self assert:fillColor same:[dictionary objectForKey:@"color"]];
|
||||
}
|
||||
|
||||
- (void)testTheDefaultDynamicSetOfAThemeGivesANamedColor
|
||||
{
|
||||
var fillColor = [self fillColor],
|
||||
theme = [[CPTheme alloc] initWithName:@"CPColorCSSValueTestDynamicSet"],
|
||||
template = [[CPColorCSSValueTestThemedView alloc] initWithFrame:CGRectMakeZero()],
|
||||
themedClass = [CPColorCSSValueTestThemedView class];
|
||||
|
||||
[template setValue:[CPColor colorWithCSSDictionary:@{ @"background-color": CPColorCSSValueTestPlaceholder }] forThemeAttribute:@"test-background"];
|
||||
[template setValue:[CPDictionary dictionaryWithObject:fillColor forKey:CPColorCSSValueTestPlaceholder] forThemeAttribute:@"dynamic-set"];
|
||||
[theme takeThemeFromObject:template];
|
||||
|
||||
[theme applyDynamicSet:[theme valueForAttributeWithName:@"dynamic-set" forClass:themedClass]];
|
||||
|
||||
[self assert:fillColor same:[[[theme valueForAttributeWithName:@"test-background" forClass:themedClass] cssDictionary] objectForKey:@"background-color"]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* CPColorThemeCatalogTest.j
|
||||
* AppKit
|
||||
*
|
||||
* Created by David Richardson on 2026-11-11.
|
||||
* Copyright David Richardson 2026.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
@import <AppKit/CPColor.j>
|
||||
@import <AppKit/CPAppearance.j>
|
||||
@import <AppKit/CPTheme.j>
|
||||
|
||||
/*
|
||||
A theme's own colours are in the theme catalog "Theme". The theme gives their values in
|
||||
the attribute "theme-colors" of CPColor: for each appearance state, a dictionary from colour
|
||||
name to colour. A theme colour resolves at use against the default theme, as a System colour
|
||||
does.
|
||||
*/
|
||||
@implementation CPColorThemeCatalogTest : OJTestCase
|
||||
{
|
||||
CPTheme _previousTheme;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
_previousTheme = [CPTheme defaultTheme];
|
||||
[CPTheme setDefaultTheme:[self themeWithFillColors]];
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
{
|
||||
[CPTheme setDefaultTheme:_previousTheme];
|
||||
[CPAppearance setCurrentAppearance:nil];
|
||||
}
|
||||
|
||||
/*
|
||||
A theme that gives fillColor a value for every appearance, one for DarkAqua and one for
|
||||
high-contrast DarkAqua, and strokeColor a value for every appearance only.
|
||||
*/
|
||||
- (CPTheme)themeWithFillColors
|
||||
{
|
||||
var theme = [[CPTheme alloc] initWithName:@"CPColorThemeCatalogTestFillColors"],
|
||||
template = [CPColor colorWithWhite:0.0 alpha:1.0];
|
||||
|
||||
[template setValue:@{ @"fillColor": [CPColor redColor], @"strokeColor": [CPColor greenColor] } forThemeAttribute:@"theme-colors"];
|
||||
[template setValue:@{ @"fillColor": [CPColor blueColor] } forThemeAttribute:@"theme-colors" inState:CPThemeStateAppearanceDarkAqua];
|
||||
[template setValue:@{ @"fillColor": [CPColor yellowColor] } forThemeAttribute:@"theme-colors" inState:CPThemeStateAppearanceAccessibilityHighContrastDarkAqua];
|
||||
[theme takeThemeFromObject:template];
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
- (CPColor)themeColorNamed:(CPString)aName
|
||||
{
|
||||
return [CPColor colorWithCatalogName:@"Theme" colorName:aName];
|
||||
}
|
||||
|
||||
/*
|
||||
Returns aColor resolved in the appearance named anAppearanceName.
|
||||
*/
|
||||
- (CPColor)resolve:(CPColor)aColor in:(CPString)anAppearanceName
|
||||
{
|
||||
var resolvedColor = nil;
|
||||
|
||||
[[CPAppearance appearanceNamed:anAppearanceName] performAsCurrentDrawingAppearance:function()
|
||||
{
|
||||
resolvedColor = [aColor colorUsingColorSpaceName:nil];
|
||||
}];
|
||||
|
||||
return resolvedColor;
|
||||
}
|
||||
|
||||
// MARK: Names
|
||||
|
||||
- (void)testTheThemeCatalogGivesAColorForAnyName
|
||||
{
|
||||
var color = [self themeColorNamed:@"fillColor"];
|
||||
|
||||
[self assertNotNull:color];
|
||||
[self assert:@"Theme" equals:[color catalogNameComponent]];
|
||||
[self assert:@"fillColor" equals:[color colorNameComponent]];
|
||||
[self assertNotNull:[self themeColorNamed:@"aNameThatNoThemeGives"]];
|
||||
}
|
||||
|
||||
- (void)testTheThemeCatalogGivesOneObjectPerName
|
||||
{
|
||||
[self assert:[self themeColorNamed:@"fillColor"] same:[self themeColorNamed:@"fillColor"]];
|
||||
}
|
||||
|
||||
- (void)testTwoColorsOfOneNameAreEqual
|
||||
{
|
||||
var color = [self themeColorNamed:@"fillColor"],
|
||||
firstColor = [color colorWithAlphaComponent:0.5],
|
||||
secondColor = [color colorWithAlphaComponent:0.5];
|
||||
|
||||
[self assertFalse:firstColor === secondColor];
|
||||
[self assertTrue:[firstColor isEqual:secondColor]];
|
||||
}
|
||||
|
||||
- (void)testAThemeColorAndASystemColorOfTheSameNameAreNotEqual
|
||||
{
|
||||
[self assertFalse:[[self themeColorNamed:@"labelColor"] isEqual:[CPColor labelColor]]];
|
||||
[self assertFalse:[[CPColor labelColor] isEqual:[self themeColorNamed:@"labelColor"]]];
|
||||
}
|
||||
|
||||
// MARK: Resolution
|
||||
|
||||
- (void)testResolutionPerAppearanceWithTheFallbackOrder
|
||||
{
|
||||
var color = [self themeColorNamed:@"fillColor"];
|
||||
|
||||
[self assertTrue:[[self resolve:color in:CPAppearanceNameAqua] isEqual:[CPColor redColor]]];
|
||||
[self assertTrue:[[self resolve:color in:CPAppearanceNameDarkAqua] isEqual:[CPColor blueColor]]];
|
||||
[self assertTrue:[[self resolve:color in:CPAppearanceNameAccessibilityHighContrastDarkAqua] isEqual:[CPColor yellowColor]]];
|
||||
[self assertTrue:[[self resolve:color in:CPAppearanceNameVibrantDark] isEqual:[CPColor blueColor]] message:@"VibrantDark falls back to DarkAqua"];
|
||||
[self assertTrue:[[self resolve:color in:CPAppearanceNameAccessibilityHighContrastVibrantDark] isEqual:[CPColor yellowColor]] message:@"high-contrast VibrantDark falls back to high-contrast DarkAqua"];
|
||||
[self assertTrue:[[self resolve:color in:CPAppearanceNameVibrantLight] isEqual:[CPColor redColor]] message:@"VibrantLight falls back to the value for every appearance"];
|
||||
}
|
||||
|
||||
- (void)testANameMissingFromTheDarkDictionaryTakesTheValueForEveryAppearance
|
||||
{
|
||||
var color = [self themeColorNamed:@"strokeColor"];
|
||||
|
||||
[self assertTrue:[[self resolve:color in:CPAppearanceNameDarkAqua] isEqual:[CPColor greenColor]]];
|
||||
[self assertTrue:[[self resolve:color in:CPAppearanceNameAccessibilityHighContrastDarkAqua] isEqual:[CPColor greenColor]]];
|
||||
}
|
||||
|
||||
/*
|
||||
The warning is logged once per name for the whole run, so the name is used by this test
|
||||
only.
|
||||
*/
|
||||
- (void)testAMissingNameGivesTheClearColorAndOneWarning
|
||||
{
|
||||
var warnings = [],
|
||||
logger = function(aMessage) { warnings.push(aMessage); },
|
||||
color = [self themeColorNamed:@"CPColorThemeCatalogTestMissingColor"];
|
||||
|
||||
CPLogRegisterSingle(logger, "warn");
|
||||
|
||||
try
|
||||
{
|
||||
[self assertTrue:[[self resolve:color in:CPAppearanceNameAqua] isEqual:[CPColor clearColor]]];
|
||||
[self assertTrue:[[self resolve:color in:CPAppearanceNameDarkAqua] isEqual:[CPColor clearColor]]];
|
||||
}
|
||||
finally
|
||||
{
|
||||
CPLogUnregister(logger);
|
||||
}
|
||||
|
||||
[self assert:1 equals:warnings.length message:warnings.join("\n")];
|
||||
[self assertTrue:warnings[0].indexOf("CPColorThemeCatalogTestMissingColor") !== -1];
|
||||
}
|
||||
|
||||
- (void)testAThemeWithoutTheAttributeGivesTheClearColor
|
||||
{
|
||||
[CPTheme setDefaultTheme:[[CPTheme alloc] initWithName:@"CPColorThemeCatalogTestEmpty"]];
|
||||
|
||||
[self assertTrue:[[self resolve:[self themeColorNamed:@"fillColor"] in:CPAppearanceNameAqua] isEqual:[CPColor clearColor]]];
|
||||
}
|
||||
|
||||
- (void)testAnAlphaOnAThemeColor
|
||||
{
|
||||
var color = [[self themeColorNamed:@"fillColor"] colorWithAlphaComponent:0.5];
|
||||
|
||||
[self assertTrue:[[self resolve:color in:CPAppearanceNameAqua] isEqual:[[CPColor redColor] colorWithAlphaComponent:0.5]]];
|
||||
[self assertTrue:[[self resolve:color in:CPAppearanceNameDarkAqua] isEqual:[[CPColor blueColor] colorWithAlphaComponent:0.5]]];
|
||||
}
|
||||
|
||||
- (void)testAThemeSwitchChangesTheValueOfOneName
|
||||
{
|
||||
var color = [self themeColorNamed:@"fillColor"],
|
||||
otherTheme = [[CPTheme alloc] initWithName:@"CPColorThemeCatalogTestOtherColors"],
|
||||
template = [CPColor colorWithWhite:0.0 alpha:1.0];
|
||||
|
||||
[template setValue:@{ @"fillColor": [CPColor purpleColor] } forThemeAttribute:@"theme-colors"];
|
||||
[otherTheme takeThemeFromObject:template];
|
||||
|
||||
[self assertTrue:[[self resolve:color in:CPAppearanceNameAqua] isEqual:[CPColor redColor]]];
|
||||
|
||||
[CPTheme setDefaultTheme:otherTheme];
|
||||
|
||||
[self assertTrue:[[self resolve:color in:CPAppearanceNameAqua] isEqual:[CPColor purpleColor]]];
|
||||
}
|
||||
|
||||
// MARK: Archiving
|
||||
|
||||
- (void)testArchiveByCatalogAndName
|
||||
{
|
||||
var color = [self themeColorNamed:@"fillColor"],
|
||||
decodedColor = [CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:color]];
|
||||
|
||||
[self assert:color same:decodedColor];
|
||||
}
|
||||
|
||||
- (void)testArchiveOfAThemeColorWithAnAlpha
|
||||
{
|
||||
var color = [[self themeColorNamed:@"fillColor"] colorWithAlphaComponent:0.25],
|
||||
decodedColor = [CPKeyedUnarchiver unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:color]];
|
||||
|
||||
[self assert:@"Theme" equals:[decodedColor catalogNameComponent]];
|
||||
[self assert:@"fillColor" equals:[decodedColor colorNameComponent]];
|
||||
[self assertTrue:[[self resolve:decodedColor in:CPAppearanceNameDarkAqua] isEqual:[[CPColor blueColor] colorWithAlphaComponent:0.25]]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -53,6 +53,41 @@
|
||||
[self assert:@"12" equals:[control objectValue]];
|
||||
}
|
||||
|
||||
/*
|
||||
The shared input element takes the field's text colour when it moves into the field, which
|
||||
can happen outside layout, where the drawing appearance is the application's. The colour
|
||||
resolves in the field's appearance. The field holds text: an empty field holds the
|
||||
placeholder state, which takes the placeholder's colour.
|
||||
*/
|
||||
- (void)testTheInputElementTextColorResolvesInTheFieldAppearance
|
||||
{
|
||||
var field = [[CPTextField alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 24.0)];
|
||||
|
||||
[field setStringValue:@"Text"];
|
||||
[field setAppearance:[CPAppearance appearanceNamed:CPAppearanceNameDarkAqua]];
|
||||
[field setTextColor:[[CPTextFieldTestDynamicColor alloc] _initDynamicColor]];
|
||||
|
||||
[self assert:CPAppearanceNameAqua equals:[[CPAppearance currentDrawingAppearance] name]];
|
||||
[self assert:[[CPColor whiteColor] cssString] equals:[field _inputElementTextColorCSSString]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
A colour that is white in a dark appearance and black in every other.
|
||||
*/
|
||||
@implementation CPTextFieldTestDynamicColor : _CPDynamicColor
|
||||
|
||||
- (CPColor)_valueInAppearance:(CPAppearance)anAppearance
|
||||
{
|
||||
return [anAppearance name] === CPAppearanceNameDarkAqua ? [CPColor whiteColor] : [CPColor blackColor];
|
||||
}
|
||||
|
||||
- (_CPDynamicColor)_dynamicCopy
|
||||
{
|
||||
return [[CPTextFieldTestDynamicColor alloc] _initDynamicColor];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPTextFieldSubclass : CPTextField
|
||||
|
||||
@@ -91,6 +91,42 @@
|
||||
[self assert:[_delegate representedObjects] equals:[@"Alexandre", @"Antoine"]];
|
||||
}
|
||||
|
||||
// MARK: -
|
||||
// MARK: Appearance
|
||||
|
||||
/*
|
||||
The shared input element takes the token field's text colour when the field becomes first
|
||||
responder, outside layout, where the drawing appearance is the application's. The colour
|
||||
resolves in the field's appearance. The field holds a token: an empty field holds the
|
||||
placeholder state, which takes the placeholder's colour.
|
||||
*/
|
||||
- (void)testTheInputElementTextColorResolvesInTheFieldAppearance
|
||||
{
|
||||
[_tokenField setObjectValue:[@"Alexandre"]];
|
||||
[_tokenField setAppearance:[CPAppearance appearanceNamed:CPAppearanceNameDarkAqua]];
|
||||
[_tokenField setTextColor:[[CPTokenFieldTestDynamicColor alloc] _initDynamicColor]];
|
||||
|
||||
[self assert:CPAppearanceNameAqua equals:[[CPAppearance currentDrawingAppearance] name]];
|
||||
[self assert:[[CPColor whiteColor] cssString] equals:[_tokenField _inputElementTextColorCSSString]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
A colour that is white in a dark appearance and black in every other.
|
||||
*/
|
||||
@implementation CPTokenFieldTestDynamicColor : _CPDynamicColor
|
||||
|
||||
- (CPColor)_valueInAppearance:(CPAppearance)anAppearance
|
||||
{
|
||||
return [anAppearance name] === CPAppearanceNameDarkAqua ? [CPColor whiteColor] : [CPColor blackColor];
|
||||
}
|
||||
|
||||
- (_CPDynamicColor)_dynamicCopy
|
||||
{
|
||||
return [[CPTokenFieldTestDynamicColor alloc] _initDynamicColor];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation TestDelegateTokenField : CPObject <CPTokenFieldDelegate>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@import <AppKit/CPView.j>
|
||||
@import <AppKit/CPApplication.j>
|
||||
@import <AppKit/CPWebView.j>
|
||||
|
||||
var methodCalled;
|
||||
var updateTrackingAreasCalls,
|
||||
@@ -1707,6 +1708,43 @@ var updateTrackingAreasCalls,
|
||||
[self assertFalse:windowPropertyWasNilInViewDidAppear message:@"The view's window property should be set before -[CPViewController viewDidAppear] is called."];
|
||||
}
|
||||
|
||||
/*
|
||||
The background of a web view's iframe has no layout of its own that would write it, so a
|
||||
change of appearance applies it again.
|
||||
*/
|
||||
- (void)testAnAppearanceChangeAppliesTheWebViewBackgroundAgain
|
||||
{
|
||||
var webView = [[CPViewTestWebView alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 100.0)];
|
||||
|
||||
webView.applyCount = 0;
|
||||
|
||||
[webView setAppearance:[CPAppearance appearanceNamed:CPAppearanceNameDarkAqua]];
|
||||
|
||||
[self assert:1 equals:webView.applyCount];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
A web view that counts the applications of its iframe's background. Node has no DOM, so the
|
||||
web view makes no iframe.
|
||||
*/
|
||||
@implementation CPViewTestWebView : CPWebView
|
||||
{
|
||||
int applyCount;
|
||||
}
|
||||
|
||||
- (id)_initDOMWithFrame:(CGRect)aFrame
|
||||
{
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)_applyBackgroundColor
|
||||
{
|
||||
applyCount++;
|
||||
[super _applyBackgroundColor];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPTrackingAreaView : CPView
|
||||
|
||||
@@ -324,4 +324,79 @@
|
||||
[self assert:1 equals:subview.hookCount];
|
||||
}
|
||||
|
||||
// MARK: Window shadow
|
||||
|
||||
/*
|
||||
Under a CSS theme the window shadow is a property of the window, written outside the layout
|
||||
of any view. The shadow converts the array form of a CSS value in the window's appearance.
|
||||
The window reads the value from the window view's theme (-actualValueForThemeAttribute:),
|
||||
so the test gives the window view a theme that holds it.
|
||||
*/
|
||||
- (void)testTheWindowShadowConvertsInTheWindowAppearance
|
||||
{
|
||||
var window = [self window],
|
||||
windowView = [window _windowView],
|
||||
theme = [[CPTheme alloc] initWithName:@"CPWindowAppearanceTestShadowTheme"];
|
||||
|
||||
[windowView setValue:@[@"0px 5px 10px 0px ", [[CPWindowAppearanceTestDynamicColor alloc] _initDynamicColor]] forThemeAttribute:@"window-shadow-color"];
|
||||
[theme takeThemeFromObject:windowView];
|
||||
[windowView setTheme:theme];
|
||||
[window setAppearance:[self appearance:CPAppearanceNameDarkAqua]];
|
||||
|
||||
[self assert:CPAppearanceNameAqua equals:[[CPAppearance currentDrawingAppearance] name]];
|
||||
[self assert:@"0px 5px 10px 0px " + [[CPColor whiteColor] cssString] equals:[window _windowShadowCSSString]];
|
||||
}
|
||||
|
||||
- (void)testAThemeWithoutAWindowShadowGivesNoShadow
|
||||
{
|
||||
var window = [self window];
|
||||
|
||||
[[window _windowView] setTheme:[[CPTheme alloc] initWithName:@"CPWindowAppearanceTestEmptyTheme"]];
|
||||
|
||||
[self assert:@"" equals:[window _windowShadowCSSString]];
|
||||
}
|
||||
|
||||
- (void)testAnAppearanceChangeUpdatesTheWindowShadowAgain
|
||||
{
|
||||
var window = [[CPWindowAppearanceTestWindow alloc] initWithContentRect:CGRectMake(0.0, 0.0, 300.0, 200.0) styleMask:CPTitledWindowMask];
|
||||
|
||||
window.shadowUpdateCount = 0;
|
||||
[window setAppearance:[self appearance:CPAppearanceNameDarkAqua]];
|
||||
|
||||
[self assert:1 equals:window.shadowUpdateCount];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
A window that counts the updates of its shadow.
|
||||
*/
|
||||
@implementation CPWindowAppearanceTestWindow : CPWindow
|
||||
{
|
||||
int shadowUpdateCount;
|
||||
}
|
||||
|
||||
- (void)_updateShadow
|
||||
{
|
||||
shadowUpdateCount++;
|
||||
[super _updateShadow];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
A colour that is white in a dark appearance and black in every other.
|
||||
*/
|
||||
@implementation CPWindowAppearanceTestDynamicColor : _CPDynamicColor
|
||||
|
||||
- (CPColor)_valueInAppearance:(CPAppearance)anAppearance
|
||||
{
|
||||
return [anAppearance name] === CPAppearanceNameDarkAqua ? [CPColor whiteColor] : [CPColor blackColor];
|
||||
}
|
||||
|
||||
- (_CPDynamicColor)_dynamicCopy
|
||||
{
|
||||
return [[CPWindowAppearanceTestDynamicColor alloc] _initDynamicColor];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user