From 6cae91705826e5feffac6f5fab28f10369b64972 Mon Sep 17 00:00:00 2001 From: Udo Schneider Date: Fri, 21 Feb 2014 08:43:00 +0100 Subject: [PATCH] New: Added bidirectional CPLevelIndicator behaviour Depending on whether min < max or max > min CPLevelIndicator changes the order of the normal/warning/critical color. This commit enables this behavior for both cases. --- AppKit/CPLevelIndicator.j | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/AppKit/CPLevelIndicator.j b/AppKit/CPLevelIndicator.j index 042b17e84..07ce720c3 100644 --- a/AppKit/CPLevelIndicator.j +++ b/AppKit/CPLevelIndicator.j @@ -105,10 +105,21 @@ CPRatingLevelIndicatorStyle = 3; var filledColor = [self valueForThemeAttribute:@"color-normal"], value = [self doubleValue]; - if (value <= _criticalValue) - filledColor = [self valueForThemeAttribute:@"color-critical"]; - else if (value <= _warningValue) - filledColor = [self valueForThemeAttribute:@"color-warning"]; + if (_warningValue < _criticalValue) + { + if (value >= _criticalValue) + filledColor = [self valueForThemeAttribute:@"color-critical"]; + else if (value >= _warningValue) + filledColor = [self valueForThemeAttribute:@"color-warning"]; + } + else + { + if (value <= _criticalValue) + filledColor = [self valueForThemeAttribute:@"color-critical"]; + else if (value <= _warningValue) + filledColor = [self valueForThemeAttribute:@"color-warning"]; + } + for (var i = 0; i < segmentCount; i++) {