mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-05 10:23:39 +00:00
fixed: levelindicator
This commit is contained in:
@@ -91,32 +91,43 @@ CPRatingLevelIndicatorStyle = 3;
|
||||
var bezelView = [self layoutEphemeralSubviewNamed:"bezel"
|
||||
positioned:CPWindowBelow
|
||||
relativeToEphemeralSubviewNamed:nil];
|
||||
// TODO Make themable.
|
||||
[bezelView setBackgroundColor:[self valueForThemeAttribute:@"bezel-color"]];
|
||||
|
||||
// Explicitly retrieve the theme state.
|
||||
var themeState = [self themeState];
|
||||
|
||||
// Ensure HUD state is included if the window is HUD (robustness check)
|
||||
if ([[self window] styleMask] & CPHUDBackgroundWindowMask)
|
||||
themeState = themeState.and(CPThemeStateHUD);
|
||||
|
||||
// Use inState: explicitly
|
||||
[bezelView setBackgroundColor:[self valueForThemeAttribute:@"bezel-color" inState:themeState]];
|
||||
|
||||
var segmentCount = _maxValue - _minValue;
|
||||
|
||||
if (segmentCount <= 0)
|
||||
return;
|
||||
|
||||
var filledColor = [self valueForThemeAttribute:@"color-normal"],
|
||||
// Use inState: explicitly
|
||||
var filledColor = [self valueForThemeAttribute:@"color-normal" inState:themeState],
|
||||
value = [self doubleValue];
|
||||
|
||||
if (_warningValue < _criticalValue)
|
||||
{
|
||||
if (value >= _criticalValue)
|
||||
filledColor = [self valueForThemeAttribute:@"color-critical"];
|
||||
filledColor = [self valueForThemeAttribute:@"color-critical" inState:themeState];
|
||||
else if (value >= _warningValue)
|
||||
filledColor = [self valueForThemeAttribute:@"color-warning"];
|
||||
filledColor = [self valueForThemeAttribute:@"color-warning" inState:themeState];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value <= _criticalValue)
|
||||
filledColor = [self valueForThemeAttribute:@"color-critical"];
|
||||
filledColor = [self valueForThemeAttribute:@"color-critical" inState:themeState];
|
||||
else if (value <= _warningValue)
|
||||
filledColor = [self valueForThemeAttribute:@"color-warning"];
|
||||
filledColor = [self valueForThemeAttribute:@"color-warning" inState:themeState];
|
||||
}
|
||||
|
||||
// Use inState: explicitly for empty color too
|
||||
var emptyColor = [self valueForThemeAttribute:@"color-empty" inState:themeState];
|
||||
|
||||
for (var i = 0; i < segmentCount; i++)
|
||||
{
|
||||
@@ -124,7 +135,7 @@ CPRatingLevelIndicatorStyle = 3;
|
||||
positioned:CPWindowAbove
|
||||
relativeToEphemeralSubviewNamed:bezelView];
|
||||
|
||||
[segmentView setBackgroundColor:(_minValue + i) < value ? filledColor : [self valueForThemeAttribute:@"color-empty"]];
|
||||
[segmentView setBackgroundColor:(_minValue + i) < value ? filledColor : emptyColor];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1096,6 +1096,9 @@ var themedButtonValues = nil,
|
||||
[@"text-color", [CPColor whiteColor], [CPButtonStateBezelStyleRounded, CPThemeStateHUD, CPThemeStateBordered, CPThemeStateHighlighted]],
|
||||
[@"text-color", [CPColor whiteColor], [CPButtonStateBezelStyleRounded, CPThemeStateHUD, CPThemeStateBordered, CPThemeStateSelected]],
|
||||
|
||||
// High specificity rule for Disabled HUD buttons to prevent them from looking enabled (white)
|
||||
[@"text-color", [CPColor colorWithWhite:1 alpha:0.4], [CPButtonStateBezelStyleRounded, CPThemeStateHUD, CPThemeStateBordered, CPThemeStateDisabled]],
|
||||
|
||||
[@"text-color", [CPColor whiteColor], [CPButtonStateBezelStyleSmallSquare, CPThemeStateHUD]],
|
||||
[@"text-color", [CPColor whiteColor], [CPButtonStateBezelStyleSmallSquare, CPThemeStateHUD, CPThemeStateHighlighted]],
|
||||
|
||||
@@ -7772,6 +7775,19 @@ var themedButtonValues = nil,
|
||||
@"background-color": A3ColorActiveText
|
||||
}],
|
||||
|
||||
// --- HUD Styles ---
|
||||
hudBezelColor = [CPColor colorWithCSSDictionary:@{
|
||||
@"background-color": @"rgba(0, 0, 0, 0.2)",
|
||||
@"border": @"1px solid rgba(255, 255, 255, 0.2)",
|
||||
@"box-sizing": @"border-box",
|
||||
@"box-shadow": @"inset 0 1px 2px rgba(0,0,0,0.1)"
|
||||
}],
|
||||
|
||||
hudSegmentColor = [CPColor colorWithCSSDictionary:@{
|
||||
@"background-color": @"rgba(255, 255, 255, 0.9)",
|
||||
@"box-shadow": @"0 0 2px rgba(255, 255, 255, 0.4)"
|
||||
}],
|
||||
|
||||
themeValues =
|
||||
[
|
||||
[@"bezel-color", bezelColor],
|
||||
@@ -7779,7 +7795,11 @@ var themedButtonValues = nil,
|
||||
[@"color-normal", segmentColor],
|
||||
[@"color-warning", [CPColor orangeColor]],
|
||||
[@"color-critical", [CPColor redColor]],
|
||||
[@"spacing", 1.0]
|
||||
[@"spacing", 1.0],
|
||||
|
||||
// --- HUD Mappings ---
|
||||
[@"bezel-color", hudBezelColor, CPThemeStateHUD],
|
||||
[@"color-normal", hudSegmentColor, CPThemeStateHUD]
|
||||
];
|
||||
|
||||
[self registerThemeValues:themeValues forView:levelIndicator];
|
||||
|
||||
Reference in New Issue
Block a user