From 192b6ecfc4b8bd5de4b76aa5648438b5b5fe26ea Mon Sep 17 00:00:00 2001 From: daboe01 Date: Thu, 19 Feb 2026 19:44:11 +0100 Subject: [PATCH] fixed: rule editor selection --- .../CPRuleEditor/_CPRuleEditorViewSliceRow.j | 22 +++-- AppKit/Themes/Aristo3/ThemeDescriptors.j | 94 ++++++++++++++----- 2 files changed, 85 insertions(+), 31 deletions(-) diff --git a/AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j b/AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j index 6a2019332..f0146dc39 100644 --- a/AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j +++ b/AppKit/CPRuleEditor/_CPRuleEditorViewSliceRow.j @@ -67,15 +67,21 @@ [self setAutoresizingMask:CPViewWidthSizable]; } +- (void)_setSelected:(BOOL)isSelected +{ + [super _setSelected:isSelected]; + [self _updateButtonImages]; +} + - (void)_updateButtonImages { - // Re-fetch images from RuleEditor. This ensures we get the HUD images - // if the RuleEditor is in HUD state. - [_addButton setValue:[_ruleEditor _imageAdd] forThemeAttribute:@"image" inState:CPThemeStateNormal]; - [_addButton setValue:[_ruleEditor _imageAddHighlighted] forThemeAttribute:@"image" inState:CPThemeStateHighlighted]; + var rowState = [self themeState]; - [_subtractButton setValue:[_ruleEditor _imageRemove] forThemeAttribute:@"image" inState:CPThemeStateNormal]; - [_subtractButton setValue:[_ruleEditor _imageRemoveHighlighted] forThemeAttribute:@"image" inState:CPThemeStateHighlighted]; + if ([self _isSelected]) + rowState = rowState.and(CPThemeStateSelected); + + [_addButton setImage:[_ruleEditor valueForThemeAttribute:@"add-image" inState:rowState]]; + [_subtractButton setImage:[_ruleEditor valueForThemeAttribute:@"remove-image" inState:rowState]]; } - (CPButton)_createRowButton @@ -100,6 +106,8 @@ var button = [self _createRowButton]; [button setToolTip:[_ruleEditor _toolTipForAddSimpleRowButton]]; + + // Initial setup, _updateButtonImages will be called later to set correct state-based images [button setValue:[_ruleEditor _imageAdd] forThemeAttribute:@"image" inState:CPThemeStateNormal]; [button setValue:[_ruleEditor _imageAddHighlighted] forThemeAttribute:@"image" inState:CPThemeStateHighlighted]; @@ -114,6 +122,8 @@ var button = [self _createRowButton]; [button setToolTip:[_ruleEditor _toolTipForDeleteRowButton]]; + + // Initial setup [button setValue:[_ruleEditor _imageRemove] forThemeAttribute:@"image" inState:CPThemeStateNormal]; [button setValue:[_ruleEditor _imageRemoveHighlighted] forThemeAttribute:@"image" inState:CPThemeStateHighlighted]; diff --git a/AppKit/Themes/Aristo3/ThemeDescriptors.j b/AppKit/Themes/Aristo3/ThemeDescriptors.j index 73a07dffc..d31de427b 100644 --- a/AppKit/Themes/Aristo3/ThemeDescriptors.j +++ b/AppKit/Themes/Aristo3/ThemeDescriptors.j @@ -8332,28 +8332,29 @@ var themedButtonValues = nil, + (CPRuleEditor)themedRuleEditor { var ruleEditor = [[CPRuleEditor alloc] initWithFrame:CGRectMake(0.0, 0.0, 400.0, 300.0)], - + // --- Standard Colors --- backgroundColors = [[CPColor whiteColor], [CPColor colorWithRed:235 / 255 green:239 / 255 blue:252 / 255 alpha:1]], - selectedActiveRowColor = [CPColor colorWithHexString:@"5f83b9"], - selectedInactiveRowColor = [CPColor colorWithWhite:0.83 alpha:1], + + // Selection Colors + selectedActiveRowColor = @"A3CPColorBorderBlue", // Active (Blue) + selectedInactiveRowColor = A3CPColorBorderBlueInactive, // Inactive (Light Gray) + sliceTopBorderColor = [CPColor colorWithWhite:0.9 alpha:1.0], sliceBottomBorderColor = [CPColor colorWithWhite:0.729412 alpha:1.0], sliceLastBottomBorderColor = [CPColor colorWithWhite:0.6 alpha:1.0], - fontColor = [CPColor colorWithWhite:150 / 255 alpha:1], - + + // Standard Font Color + fontColor = A3CPColorActiveText, + // --- HUD Colors --- - // Matches themedTableView: Clear + Very Faint White (5%) hudBackgroundColors = [[CPColor clearColor], [CPColor colorWithWhite:1.0 alpha:0.05]], - - // Selection: Semi-transparent white (20%) hudSelectedRowColor = [CPColor colorWithWhite:1.0 alpha:0.2], - - // Borders: Very faint white lines (10%) to prevent "bright stripes" effect hudSliceBorderColor = [CPColor colorWithWhite:1.0 alpha:0.1], hudFontColor = [CPColor whiteColor], - // --- Standard Images --- + // --- Standard Images (Dark) --- + // Used for: Normal rows AND Inactive Selection (Gray background) buttonAddImage = [CPImage imageWithCSSDictionary:@{ "-webkit-mask-image": svgPlus, "mask-image": svgPlus, @@ -8378,7 +8379,33 @@ var themedButtonValues = nil, "mask-position": "center" } size:CGSizeMake(12, 12)], - // --- HUD Images (White Icons) --- + // --- Selected Images (White) --- + // Used for: Active Selection (Blue background) + buttonAddImageSelected = [CPImage imageWithCSSDictionary:@{ + "-webkit-mask-image": svgPlus, + "mask-image": svgPlus, + "background-color": @"#FFFFFF", // Force White + "-webkit-mask-size": "contain", + "mask-size": "contain", + "-webkit-mask-repeat": "no-repeat", + "mask-repeat": "no-repeat", + "-webkit-mask-position": "center", + "mask-position": "center" + } size:CGSizeMake(12, 12)], + + buttonRemoveImageSelected = [CPImage imageWithCSSDictionary:@{ + "-webkit-mask-image": svgMinus, + "mask-image": svgMinus, + "background-color": @"#FFFFFF", // Force White + "-webkit-mask-size": "contain", + "mask-size": "contain", + "-webkit-mask-repeat": "no-repeat", + "mask-repeat": "no-repeat", + "-webkit-mask-position": "center", + "mask-position": "center" + } size:CGSizeMake(12, 12)], + + // --- HUD Images (Always White) --- buttonAddImageHUD = [CPImage imageWithCSSDictionary:@{ "-webkit-mask-image": svgPlus, "mask-image": svgPlus, @@ -8407,34 +8434,51 @@ var themedButtonValues = nil, [ // --- Standard Theme --- [@"alternating-row-colors", backgroundColors], - [@"selected-color", selectedActiveRowColor, CPThemeStateNormal], + + // Selection Backgrounds + [@"selected-color", selectedInactiveRowColor, CPThemeStateNormal], + [@"selected-color", selectedActiveRowColor, CPThemeStateFirstResponder], [@"selected-color", selectedInactiveRowColor, CPThemeStateDisabled], + + // Borders [@"slice-top-border-color", sliceTopBorderColor], [@"slice-bottom-border-color", sliceBottomBorderColor], [@"slice-last-bottom-border-color", sliceLastBottomBorderColor], + [@"font", [CPFont systemFontOfSize:10.0]], - [@"font-color", fontColor], - [@"add-image", buttonAddImage, CPThemeStateNormal], - [@"remove-image", buttonRemoveImage, CPThemeStateNormal], [@"vertical-alignment", CPCenterVerticalTextAlignment], + // --- Text Color --- + // Normal & Inactive Selection (Gray) -> Black Text + [@"font-color", fontColor], + [@"font-color", fontColor, CPThemeStateSelected], + // Active Selection (Blue) -> White Text + [@"font-color", [CPColor whiteColor], [CPThemeStateSelected, CPThemeStateFirstResponder]], + + // --- Button Icons --- + // 1. Normal State -> Dark + [@"add-image", buttonAddImage, CPThemeStateNormal], + [@"remove-image", buttonRemoveImage, CPThemeStateNormal], + + // 2. Selected (Inactive/Gray) -> Dark (to contrast with light gray) + [@"add-image", buttonAddImage, CPThemeStateSelected], + [@"remove-image", buttonRemoveImage, CPThemeStateSelected], + + // 3. Selected (Active/Blue) -> White (Highest Specificity) + // [@"add-image", buttonAddImageSelected, [CPThemeStateSelected, CPThemeStateKeyWindow]], + // [@"remove-image", buttonRemoveImageSelected, [CPThemeStateSelected, CPThemeStateKeyWindow]], + // --- HUD Mappings --- - // Alternating Row Colors (Zebra) [@"alternating-row-colors", hudBackgroundColors, CPThemeStateHUD], - - // Selection Color [@"selected-color", hudSelectedRowColor, [CPThemeStateHUD, CPThemeStateNormal]], [@"selected-color", hudSelectedRowColor, [CPThemeStateHUD, CPThemeStateDisabled]], - - // Row Dividers (Borders) - Must be dimmed for HUD + [@"slice-top-border-color", hudSliceBorderColor, CPThemeStateHUD], [@"slice-bottom-border-color", hudSliceBorderColor, CPThemeStateHUD], [@"slice-last-bottom-border-color", hudSliceBorderColor, CPThemeStateHUD], - - // Font Color + [@"font-color", hudFontColor, CPThemeStateHUD], - - // Buttons + [@"add-image", buttonAddImageHUD, [CPThemeStateHUD, CPThemeStateNormal]], [@"remove-image", buttonRemoveImageHUD, [CPThemeStateHUD, CPThemeStateNormal]] ];