fixed: levelindicator

This commit is contained in:
daboe01
2026-01-17 19:42:46 +01:00
parent 10989ada31
commit fb93d3dcf0
2 changed files with 40 additions and 9 deletions
+19 -8
View File
@@ -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];
}
}
+21 -1
View File
@@ -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];