From 77856a1334da44519834869d67944975da01fa8d Mon Sep 17 00:00:00 2001 From: mac Date: Wed, 4 Nov 2026 13:45:21 +0800 Subject: [PATCH] feat: add ice-blue relief UI with reflective button and module rims --- 大鱼调色/Plugin/DYCompactUIDiagnostics.inc.h | 17 ++++-- 大鱼调色/Plugin/DYInspector.mm | 38 +++++++----- 大鱼调色/Plugin/DYLUTBrowser.mm | 8 ++- 大鱼调色/Plugin/DYTheme.h | 3 + 大鱼调色/Plugin/DYTheme.mm | 62 ++++++++++++++++---- 大鱼调色/Plugin/Info.plist | 6 +- 大鱼调色/Wrapper Application/Info.plist | 4 +- 7 files changed, 99 insertions(+), 39 deletions(-) diff --git a/大鱼调色/Plugin/DYCompactUIDiagnostics.inc.h b/大鱼调色/Plugin/DYCompactUIDiagnostics.inc.h index 70174e7..0f42caa 100644 --- a/大鱼调色/Plugin/DYCompactUIDiagnostics.inc.h +++ b/大鱼调色/Plugin/DYCompactUIDiagnostics.inc.h @@ -15,17 +15,26 @@ for(NSNumber *width in @[@280,@320,@400]){ [view setFrameSize:NSMakeSize(width.doubleValue,780)];[view layoutSubtreeIfNeeded];NSArray *buttons=@[[view valueForKey:@"save"],[view valueForKey:@"load"],[view valueForKey:@"export"],settings];BOOL fit=YES; for(NSView *button in buttons){fit&=NSMinX(button.frame)>=0&&NSMaxX(button.frame)<=width.doubleValue&&button.frame.size.width>=66;for(NSView *other in buttons)if(button!=other)fit&=!NSIntersectsRect(button.frame,other.frame);} - NSArray *themes=[view valueForKey:@"themeButtons"];NSView *brand=[view valueForKey:@"brand"];fit&=themes.count==7&&NSMaxX(brand.frame)<=NSMinX([themes.firstObject frame]); + NSArray *themes=[view valueForKey:@"themeButtons"];NSView *brand=[view valueForKey:@"brand"];fit&=themes.count==8&&NSMaxX(brand.frame)<=NSMinX([themes.firstObject frame]); run.record([NSString stringWithFormat:@"compact-header-controls-fit-%@",width],fit); } DYDiagnosticManager *fresh=[[[DYDiagnosticManager alloc]init]autorelease];DYCreateParameters(fresh,nil);run.record(@"compact-new-host-stays-original-flow",!DYReadAssets(fresh,kCMTimeZero).colorManagement); NSInteger previous=DYThemeIndex();@try{ - BOOL colors=DYThemeNames().count==7&&[DYThemeNames()[5]isEqual:@"黑金渐变"]; - for(NSInteger i=0;i<7;i++){DYSetThemeIndex(i);colors&=DYThemeIndex()==i&&DYThemePalette()[@"background"]&&DYThemePalette()[@"text"];} - run.record(@"compact-six-stable-theme-choices",colors); + BOOL colors=DYThemeNames().count==8&&[DYThemeNames()[5]isEqual:@"黑金渐变"]; + for(NSInteger i=0;i<8;i++){DYSetThemeIndex(i);colors&=DYThemeIndex()==i&&DYThemePalette()[@"background"]&&DYThemePalette()[@"text"];} + run.record(@"compact-eight-stable-theme-choices",colors); DYSetThemeIndex(5);auto luminance=[](NSColor *color){NSColor *c=[color colorUsingColorSpace:NSColorSpace.sRGBColorSpace];auto linear=[](double x){return x<=.04045?x/12.92:pow((x+.055)/1.055,2.4);};return .2126*linear(c.redComponent)+.7152*linear(c.greenComponent)+.0722*linear(c.blueComponent);}; double minimum=100;for(NSString *text in @[@"text",@"secondary"])for(NSString *surface in @[@"background",@"backgroundEnd",@"card",@"cardEnd",@"field",@"headerTop"])minimum=std::min(minimum,(luminance(DYThemePalette()[text])+.05)/(luminance(DYThemePalette()[surface])+.05)); run.record(@"compact-gold-labels-have-readable-contrast",minimum>=4.5,@{@"minimumContrast":@(minimum)}); + NSDictionary *themeSnapshot=[view presetSnapshot];int themeUndo=host->_undoStarts; + DYSetThemeIndex(7);double lightMinimum=100; + for(NSString *text in @[@"text",@"secondary",@"slot15"])for(NSString *surface in @[@"background",@"backgroundEnd",@"card",@"cardEnd",@"field",@"headerTop",@"headerBottom"]) + lightMinimum=std::min(lightMinimum,(luminance(DYThemePalette()[surface])+.05)/(luminance(DYThemePalette()[text])+.05)); + run.record(@"soft-light-text-contrast-at-least-4.5",lightMinimum>=4.5,@{@"minimumContrast":@(lightMinimum)}); + [view performSelector:@selector(themeChanged:) withObject:nil]; + run.record(@"soft-native-controls-use-light-appearance",[view.appearance.name isEqual:NSAppearanceNameAqua]&&DYThemeTextShadow()==nil); + run.record(@"soft-theme-preserves-grade-and-undo",[themeSnapshot isEqual:[view presetSnapshot]]&&themeUndo==host->_undoStarts); + DYSetThemeIndex(5); DYThemePopUpButton *pullDown=[[[DYThemePopUpButton alloc]initWithFrame:NSMakeRect(0,0,240,28) pullsDown:YES]autorelease];[pullDown addItemWithTitle:@"+ 添加模块"];pullDown.font=[NSFont systemFontOfSize:11]; NSBitmapImageRep *bitmap=[[[NSBitmapImageRep alloc]initWithBitmapDataPlanes:NULL pixelsWide:240 pixelsHigh:28 bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace bytesPerRow:0 bitsPerPixel:0]autorelease]; [NSGraphicsContext saveGraphicsState];[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:bitmap]];[pullDown drawRect:pullDown.bounds];[NSGraphicsContext restoreGraphicsState];NSUInteger glyphPixels=0; diff --git a/大鱼调色/Plugin/DYInspector.mm b/大鱼调色/Plugin/DYInspector.mm index c250d08..2566e56 100644 --- a/大鱼调色/Plugin/DYInspector.mm +++ b/大鱼调色/Plugin/DYInspector.mm @@ -84,13 +84,15 @@ static NSString *DYNumber(double value,NSDictionary *d) { } - (void)drawBarInside:(NSRect)rect flipped:(BOOL)flipped { NSRect track=NSMakeRect(rect.origin.x,NSMidY(rect)-2.5,rect.size.width,5); + if(DYThemeIsLight())DYDrawSoftControl(NSInsetRect(track,-.5,-1),3.5,YES,NO,NO); NSArray *colors=[self trackColors];if(colors){NSGradient *g=[[[NSGradient alloc]initWithColors:colors]autorelease];[g drawInBezierPath:[NSBezierPath bezierPathWithRoundedRect:track xRadius:2.5 yRadius:2.5] angle:0];return;} - NSBezierPath *bar=[NSBezierPath bezierPathWithRoundedRect:track xRadius:2.5 yRadius:2.5];NSGradient *base=[[[NSGradient alloc]initWithStartingColor:DYThemePalette()[@"slot8"] endingColor:DYThemePalette()[@"slot9"]]autorelease];[base drawInBezierPath:bar angle:90];[[NSColor colorWithWhite:0 alpha:.28]setStroke];bar.lineWidth=.6;[bar stroke]; + NSBezierPath *bar=[NSBezierPath bezierPathWithRoundedRect:track xRadius:2.5 yRadius:2.5];NSGradient *base=[[[NSGradient alloc]initWithStartingColor:DYThemePalette()[@"slot8"] endingColor:DYThemePalette()[@"slot9"]]autorelease];[base drawInBezierPath:bar angle:90];[[(DYThemeIsLight()?DYAccent():NSColor.blackColor) colorWithAlphaComponent:DYThemeIsLight()?.20:.28]setStroke];bar.lineWidth=.6;[bar stroke]; double fraction=(self.doubleValue-self.minValue)/fmax(.000001,self.maxValue-self.minValue); - NSRect active=track;active.size.width*=fmax(0,fmin(1,fraction));NSGradient *g=[[[NSGradient alloc]initWithStartingColor:DYThemePalette()[@"activeTop"] endingColor:DYThemePalette()[@"activeBottom"]]autorelease];[g drawInBezierPath:[NSBezierPath bezierPathWithRoundedRect:active xRadius:2 yRadius:2] angle:DYThemeIndex()==6?0:90]; + NSRect active=track;active.size.width*=fmax(0,fmin(1,fraction));NSGradient *g=[[[NSGradient alloc]initWithStartingColor:DYThemePalette()[@"activeTop"] endingColor:DYThemePalette()[@"activeBottom"]]autorelease];[g drawInBezierPath:[NSBezierPath bezierPathWithRoundedRect:active xRadius:2 yRadius:2] angle:(DYThemeIndex()==6||DYThemeIsLight())?0:90]; } - (void)drawKnob:(NSRect)knobRect { NSRect circle=NSInsetRect(knobRect,1,1); + if(DYThemeIsLight()){DYDrawSoftControl(circle,MIN(circle.size.width,circle.size.height)/2,NO,NO,self.highlighted);return;} [DYThemeColor(@"knob") setFill];[[NSBezierPath bezierPathWithOvalInRect:circle] fill]; [DYAccent() setStroke];NSBezierPath *ring=[NSBezierPath bezierPathWithOvalInRect:circle];ring.lineWidth=.7;[ring stroke]; } @@ -100,7 +102,8 @@ static NSString *DYNumber(double value,NSDictionary *d) { @implementation DYNumberFieldCell - (void)drawWithFrame:(NSRect)frame inView:(NSView *)view { NSRect rect=NSInsetRect(frame,.5,.5);NSBezierPath *p=[NSBezierPath bezierPathWithRoundedRect:rect xRadius:2.5 yRadius:2.5]; - NSGradient *gradient=[[[NSGradient alloc]initWithStartingColor:DYThemePalette()[@"slot5"] endingColor:DYThemePalette()[@"slot4"]]autorelease];[gradient drawInBezierPath:p angle:90];[[DYThemePalette()[@"accent"]colorWithAlphaComponent:.65]setStroke];p.lineWidth=.9;[p stroke]; + if(DYThemeIsLight())DYDrawSoftControl(NSInsetRect(frame,1,2),5,YES,NO,NO); + else{NSGradient *gradient=[[[NSGradient alloc]initWithStartingColor:DYThemePalette()[@"slot5"] endingColor:DYThemePalette()[@"slot4"]]autorelease];[gradient drawInBezierPath:p angle:90];[[DYThemePalette()[@"accent"]colorWithAlphaComponent:.65]setStroke];p.lineWidth=.9;[p stroke];} [NSGraphicsContext saveGraphicsState];[DYThemeTextShadow()set];[self drawInteriorWithFrame:NSInsetRect(frame,4,3) inView:view];[NSGraphicsContext restoreGraphicsState]; } @end @@ -162,9 +165,9 @@ static NSArray *DYAccessibleSubviews(NSView *view, BOOL visibleOnly) { @implementation DYCard - (void)drawRect:(NSRect)rect { NSBezierPath *path=[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(self.bounds,.5,.5) xRadius:11 yRadius:11]; - DYDrawThemeSurface(path,YES);[DYThemeColor(@"border")setStroke]; - path.lineWidth=1; [path stroke]; - [[NSColor colorWithWhite:.52 alpha:1]setFill];[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(32,19,5,5)]fill]; + if(DYThemeIsLight())DYDrawSoftControl(NSInsetRect(self.bounds,3,3),12,NO,NO,NO); + else{DYDrawThemeSurface(path,YES);[DYThemeColor(@"border")setStroke];path.lineWidth=1;[path stroke];} + [(DYThemeIsLight()?DYThemeColor(@"secondary"):[NSColor colorWithWhite:.52 alpha:1])setFill];[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(32,19,5,5)]fill]; } @end @@ -175,7 +178,9 @@ static NSArray *DYAccessibleSubviews(NSView *view, BOOL visibleOnly) { - (void)drawRect:(NSRect)dirtyRect { NSRect r=NSInsetRect(self.bounds,.5,2); NSBezierPath *pill=[NSBezierPath bezierPathWithRoundedRect:r xRadius:7 yRadius:7]; - if(DYThemeIndex()==6){ + if(DYThemeIsLight()){ + BOOL expanded=self.state==NSControlStateValueOn;DYDrawSoftControl(NSInsetRect(self.bounds,2,3),7,expanded,NO,self.cell.highlighted); + }else if(DYThemeIndex()==6){ NSDictionary *palette=DYThemePalette();BOOL expanded=self.state==NSControlStateValueOn; NSColor *left=[palette[@"headerTop"]blendedColorWithFraction:expanded?.32:.22 ofColor:palette[@"activeTop"]]; NSColor *right=[palette[@"headerBottom"]blendedColorWithFraction:expanded?.26:.18 ofColor:palette[@"activeBottom"]]; @@ -201,7 +206,8 @@ static NSArray *DYAccessibleSubviews(NSView *view, BOOL visibleOnly) { - (void)dealloc {[_swatch release];[super dealloc];} - (void)drawRect:(NSRect)dirtyRect { NSRect r=NSInsetRect(self.bounds,3,3);[_swatch setFill];NSBezierPath *p=[NSBezierPath bezierPathWithRoundedRect:r xRadius:5 yRadius:5];[p fill]; - if([self.identifier isEqual:@"themeSwatch"]&&self.tag>=5){NSGradient *g=[[[NSGradient alloc]initWithStartingColor:self.tag==6?[NSColor colorWithSRGBRed:.8 green:.12 blue:1 alpha:1]:NSColor.blackColor endingColor:self.tag==6?NSColor.cyanColor:DYThemeSwatch(5)]autorelease];[g drawInBezierPath:p angle:45];} + if([self.identifier isEqual:@"themeSwatch"]&&self.tag==7){DYDrawSoftControl(r,5,NO,NO,NO);} + else if([self.identifier isEqual:@"themeSwatch"]&&self.tag>=5){NSGradient *g=[[[NSGradient alloc]initWithStartingColor:self.tag==6?[NSColor colorWithSRGBRed:.8 green:.12 blue:1 alpha:1]:NSColor.blackColor endingColor:self.tag==6?NSColor.cyanColor:DYThemeSwatch(5)]autorelease];[g drawInBezierPath:p angle:45];} if([self.identifier isEqual:@"customColorSwatch"]){NSGradient *g=[[[NSGradient alloc]initWithColors:@[NSColor.systemRedColor,NSColor.systemYellowColor,NSColor.systemGreenColor,NSColor.systemCyanColor,NSColor.systemBlueColor,NSColor.systemPurpleColor]]autorelease];[g drawInBezierPath:p angle:45];[@"⌾" drawInRect:NSInsetRect(r,3,1) withAttributes:@{NSFontAttributeName:[NSFont boldSystemFontOfSize:16],NSForegroundColorAttributeName:NSColor.whiteColor}];} if(self.state==NSControlStateValueOn){[DYInk() setStroke];p.lineWidth=2;[p stroke];} } @@ -297,12 +303,13 @@ static NSArray *DYPresentationSections(void) { } - (void)drawRect:(NSRect)dirtyRect { NSRect r=[self plotRect]; - [(DYThemeIndex()==6?[NSColor colorWithSRGBRed:.025 green:.02 blue:.06 alpha:1]:DYThemeIndex()==5?DYThemeColor(@"card"):[NSColor colorWithSRGBRed:.025 green:.085 blue:.13 alpha:1]) setFill];[[NSBezierPath bezierPathWithRoundedRect:r xRadius:4 yRadius:4] fill]; + if(DYThemeIsLight())DYDrawSoftControl(r,5,YES,NO,NO); + else{[(DYThemeIndex()==6?[NSColor colorWithSRGBRed:.025 green:.02 blue:.06 alpha:1]:DYThemeIndex()==5?DYThemeColor(@"card"):[NSColor colorWithSRGBRed:.025 green:.085 blue:.13 alpha:1]) setFill];[[NSBezierPath bezierPathWithRoundedRect:r xRadius:4 yRadius:4] fill];} if(_histogramToggle.state==NSControlStateValueOn){ const DYHistogram *h=_histogram.length==sizeof(DYHistogram)?(const DYHistogram*)_histogram.bytes:nullptr; if(h&&h->samples){ uint32_t peak=1;for(int c=0;c<4;c++)if(_channel==0||c==_channel)for(int b=0;b<256;b++)peak=MAX(peak,h->bins[c][b]); - NSArray *colors=@[NSColor.whiteColor,[NSColor colorWithSRGBRed:1 green:.23 blue:.37 alpha:1],[NSColor colorWithSRGBRed:.23 green:.94 blue:.50 alpha:1],[NSColor colorWithSRGBRed:.19 green:.51 blue:1 alpha:1]]; + NSArray *colors=DYThemeIsLight()?@[DYInk(),[NSColor colorWithSRGBRed:.78 green:.20 blue:.32 alpha:1],[NSColor colorWithSRGBRed:.13 green:.50 blue:.31 alpha:1],[NSColor colorWithSRGBRed:.18 green:.39 blue:.83 alpha:1]]:@[NSColor.whiteColor,[NSColor colorWithSRGBRed:1 green:.23 blue:.37 alpha:1],[NSColor colorWithSRGBRed:.23 green:.94 blue:.50 alpha:1],[NSColor colorWithSRGBRed:.19 green:.51 blue:1 alpha:1]]; [NSGraphicsContext saveGraphicsState];NSRectClip(r); for(int c=3;c>=0;c--){if(_channel!=0&&c!=_channel)continue; NSBezierPath *area=[NSBezierPath bezierPath],*line=[NSBezierPath bezierPath];[area moveToPoint:NSMakePoint(NSMinX(r),NSMaxY(r))]; @@ -311,7 +318,7 @@ static NSArray *DYPresentationSections(void) { }[NSGraphicsContext restoreGraphicsState]; }else [@"等待画面 · 请移动播放头" drawAtPoint:NSMakePoint(r.origin.x+8,NSMaxY(r)-20) withAttributes:@{NSFontAttributeName:[NSFont systemFontOfSize:10],NSForegroundColorAttributeName:DYThemeColor(@"secondary")}]; } - [[NSColor colorWithWhite:1 alpha:.1] setStroke];NSBezierPath *grid=[NSBezierPath bezierPath];grid.lineWidth=.5; + [[(DYThemeIsLight()?DYInk():NSColor.whiteColor) colorWithAlphaComponent:DYThemeIsLight()?.18:.1] setStroke];NSBezierPath *grid=[NSBezierPath bezierPath];grid.lineWidth=.5; for(int i=0;i<5;i++){CGFloat x=r.origin.x+r.size.width*i/4,y=r.origin.y+r.size.height*i/4;[grid moveToPoint:NSMakePoint(x,NSMinY(r))];[grid lineToPoint:NSMakePoint(x,NSMaxY(r))];[grid moveToPoint:NSMakePoint(NSMinX(r),y)];[grid lineToPoint:NSMakePoint(NSMaxX(r),y)];}[grid stroke]; std::vector p; p.push_back(NSMakePoint(0,0)); NSArray *points=[self activePoints];for(NSDictionary *point in points)p.push_back(NSMakePoint([point[@"x"] doubleValue],[point[@"y"] doubleValue]));p.push_back(NSMakePoint(1,1)); @@ -334,11 +341,11 @@ static NSArray *DYPresentationSections(void) { NSPoint q=NSMakePoint(r.origin.x+x*r.size.width,r.origin.y+(1-fmax(0,fmin(1,y)))*r.size.height); if(sample==0)[curve moveToPoint:q];else[curve lineToPoint:q]; } - NSColor *color=_channel==0?(DYThemeIndex()==6?NSColor.whiteColor:DYAccent()):_channel==1?[NSColor systemRedColor]:_channel==2?[NSColor systemGreenColor]:[NSColor systemBlueColor];[color setStroke];[curve stroke]; + NSColor *color=_channel==0?(DYThemeIsLight()?DYInk():DYThemeIndex()==6?NSColor.whiteColor:DYAccent()):_channel==1?[NSColor systemRedColor]:_channel==2?[NSColor systemGreenColor]:[NSColor systemBlueColor];[color setStroke];[curve stroke]; for(NSDictionary *point in points) {NSPoint q=[self positionOfPoint:point];[color setFill];[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(q.x-4,q.y-4,8,8)] fill];[DYInk() setStroke];[[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(q.x-4,q.y-4,8,8)] stroke];} NSDictionary *axis=@{NSFontAttributeName:[NSFont monospacedDigitSystemFontOfSize:8 weight:NSFontWeightRegular],NSForegroundColorAttributeName:DYThemeColor(@"secondary")}; [@"0" drawAtPoint:NSMakePoint(NSMinX(r),NSMaxY(r)+2) withAttributes:axis];[@"128" drawAtPoint:NSMakePoint(NSMidX(r)-7,NSMaxY(r)+2) withAttributes:axis];[@"255" drawAtPoint:NSMakePoint(NSMaxX(r)-14,NSMaxY(r)+2) withAttributes:axis]; - [@"点击添加 · 拖动调整 · 双击删除" drawAtPoint:NSMakePoint(16,self.bounds.size.height-16) withAttributes:@{NSFontAttributeName:[NSFont systemFontOfSize:9],NSForegroundColorAttributeName:[NSColor colorWithWhite:.7 alpha:1]}]; + [@"点击添加 · 拖动调整 · 双击删除" drawAtPoint:NSMakePoint(16,self.bounds.size.height-16) withAttributes:@{NSFontAttributeName:[NSFont systemFontOfSize:9],NSForegroundColorAttributeName:DYThemeColor(@"secondary")}]; } - (void)sendValues:(NSDictionary *)values { NSMutableDictionary *merged=[[_values mutableCopy] autorelease];[merged addEntriesFromDictionary:values];[self setValues:merged]; @@ -496,7 +503,7 @@ static NSImage *DYWheelImage(void) { self.clipsToBounds=YES; self.wantsLayer=YES; self.layer.masksToBounds=YES; self.layer.backgroundColor=[DYThemePalette()[@"background"] CGColor]; - self.appearance=[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]; + self.appearance=[NSAppearance appearanceNamed:DYThemeIsLight()?NSAppearanceNameAqua:NSAppearanceNameDarkAqua]; _brand=[DYLabel(@"◒ 大鱼调色",16) retain]; _brand.font=[NSFont boldSystemFontOfSize:16];_brand.textColor=DYInk(); _subtitle=[DYLabel([[NSBundle bundleForClass:self.class]objectForInfoDictionaryKey:@"CFBundleShortVersionString"]?:@"1.1.5",9) retain]; _subtitle.textColor=DYThemeColor(@"secondary"); _websiteLink=[[DYWebsiteLink alloc]initWithFrame:NSZeroRect];_websiteLink.title=@"更多插件访问 https://dayu.media"; @@ -577,6 +584,7 @@ static NSImage *DYWheelImage(void) { - (void)openWebsite:(id)sender {[[NSWorkspace sharedWorkspace]openURL:[NSURL URLWithString:@"https://dayu.media"]];} - (void)redrawTree:(NSView *)view { [view setNeedsDisplay:YES];for(NSView *child in view.subviews)[self redrawTree:child]; } - (void)themeChanged:(NSNotification *)notification { + self.appearance=[NSAppearance appearanceNamed:DYThemeIsLight()?NSAppearanceNameAqua:NSAppearanceNameDarkAqua]; for(NSDictionary *card in _cards){NSColor *accent=DYThemeIndex()==6?DYThemeColor(@"slot15"):DYAccent();for(NSString *key in @[@"enabled",@"maskButton",@"repeatButton",@"removeButton"])[card[key]setContentTintColor:accent];} self.layer.backgroundColor=[DYThemePalette()[@"background"] CGColor]; for(NSButton *b in _themeButtons)b.state=b.tag==DYThemeIndex()?NSControlStateValueOn:NSControlStateValueOff; @@ -752,7 +760,7 @@ static NSImage *DYWheelImage(void) { [super layout]; CGFloat w=MAX(280,self.bounds.size.width),h=self.bounds.size.height; _brand.frame=NSMakeRect(16,14,112,26);_subtitle.frame=NSMakeRect(130,21,40,13);_subtitle.hidden=_embedded||w<380; - for(NSInteger i=0;i<_themeButtons.count;i++)[_themeButtons[i]setFrame:NSMakeRect(w-147+i*16,17,16,22)]; + for(NSInteger i=0;i<_themeButtons.count;i++)[_themeButtons[i]setFrame:NSMakeRect(w-147+i*14,17,14,22)]; _resetAll.frame=NSMakeRect(w-33,16,23,24); _websiteLink.frame=NSMakeRect(16,41,w-32,20); CGFloat gap=7;BOOL compact=w<320;CGFloat bw=(w-32-gap*(compact?1:3))/(compact?2:4); diff --git a/大鱼调色/Plugin/DYLUTBrowser.mm b/大鱼调色/Plugin/DYLUTBrowser.mm index 02569a4..a506351 100644 --- a/大鱼调色/Plugin/DYLUTBrowser.mm +++ b/大鱼调色/Plugin/DYLUTBrowser.mm @@ -400,10 +400,12 @@ static NSButton *BrowserButton(NSString *title,id target,SEL action){NSButton *b - (void)updatePalette:(NSDictionary *)palette{ NSMutableDictionary *browserPalette=[NSMutableDictionary dictionaryWithDictionary:palette?:@{}]; - browserPalette[@"background"]=[NSColor colorWithCalibratedRed:.035 green:.08 blue:.12 alpha:1]; + NSColor *background=[palette[@"background"]colorUsingColorSpace:NSColorSpace.sRGBColorSpace]; + BOOL light=background&&background.redComponent>.7&&background.greenComponent>.7; + if(!light)browserPalette[@"background"]=[NSColor colorWithCalibratedRed:.035 green:.08 blue:.12 alpha:1]; [_palette release];_palette=[browserPalette copy];_root.palette=_palette;_folderDocument.palette=_palette;_gridDocument.palette=_palette; - self.window.backgroundColor=DYBrowserColor(_palette,@"background");self.window.appearance=[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]; - _root.appearance=[NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]; + self.window.backgroundColor=DYBrowserColor(_palette,@"background");self.window.appearance=[NSAppearance appearanceNamed:light?NSAppearanceNameAqua:NSAppearanceNameDarkAqua]; + _root.appearance=[NSAppearance appearanceNamed:light?NSAppearanceNameAqua:NSAppearanceNameDarkAqua]; for(NSTextField *label in @[_titleLabel,_countLabel,_statusLabel,_sizeLabel,_emptyLabel])label.textColor=DYBrowserColor(_palette,label==_titleLabel?@"text":@"secondary"); for(NSButton *button in @[_importFiles,_importFolder,_reveal,_refresh,_none,_done,_layoutMenu])button.contentTintColor=DYBrowserColor(_palette,@"accent"); _search.textColor=DYBrowserColor(_palette,@"text");_search.backgroundColor=DYBrowserColor(_palette,@"field"); diff --git a/大鱼调色/Plugin/DYTheme.h b/大鱼调色/Plugin/DYTheme.h index 1640999..5bce098 100644 --- a/大鱼调色/Plugin/DYTheme.h +++ b/大鱼调色/Plugin/DYTheme.h @@ -7,6 +7,9 @@ FOUNDATION_EXPORT void DYSetThemeIndex(NSInteger index); FOUNDATION_EXPORT NSDictionary *DYThemePalette(void); FOUNDATION_EXPORT NSColor *DYThemeColor(NSString *role); FOUNDATION_EXPORT NSColor *DYThemeSwatch(NSInteger index); +FOUNDATION_EXPORT BOOL DYThemeIsLight(void); +// Opaque relief with a directional reflective rim; native controls retain their actions. +FOUNDATION_EXPORT void DYDrawSoftControl(NSRect rect, CGFloat radius, BOOL recessed, BOOL emphasized, BOOL pressed); // Shared AppKit controls keep native actions, focus, and accessibility. FOUNDATION_EXPORT NSShadow *DYThemeTextShadow(void); diff --git a/大鱼调色/Plugin/DYTheme.mm b/大鱼调色/Plugin/DYTheme.mm index 659c070..b92ed62 100644 --- a/大鱼调色/Plugin/DYTheme.mm +++ b/大鱼调色/Plugin/DYTheme.mm @@ -11,7 +11,7 @@ static NSColor *rgb(double r,double g,double b){return [NSColor colorWithCalibra - (instancetype)init { if((self=[super init])) { _defaults=[[NSUserDefaults alloc]initWithSuiteName:preferenceDomain]; - [_defaults registerDefaults:@{@"themeIndex":@6}]; + [_defaults registerDefaults:@{@"themeIndex":@7}]; [[NSDistributedNotificationCenter defaultCenter]addObserver:self selector:@selector(externalChange:) name:distributedChange object:preferenceDomain suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately]; } return self; @@ -23,27 +23,29 @@ static NSColor *rgb(double r,double g,double b){return [NSColor colorWithCalibra } @end static DYThemeStore *store(void){static DYThemeStore *s;static dispatch_once_t once;dispatch_once(&once,^{s=[DYThemeStore new];});return s;} -NSArray *DYThemeNames(void){return @[@"深空灰",@"冰川蓝",@"薰衣草紫",@"翡翠绿",@"琥珀橙",@"黑金渐变",@"霓虹炫彩"];} -NSInteger DYThemeIndex(void){NSInteger i=[store().defaults integerForKey:@"themeIndex"];return i>=0&&i<7?i:6;} -static const double paletteRGB[7][17][3]={ +NSArray *DYThemeNames(void){return @[@"深空灰",@"冰川蓝",@"薰衣草紫",@"翡翠绿",@"琥珀橙",@"黑金渐变",@"霓虹炫彩",@"冰蓝柔光"];} +NSInteger DYThemeIndex(void){NSInteger i=[store().defaults integerForKey:@"themeIndex"];return i>=0&&i<8?i:7;} +static const double paletteRGB[8][17][3]={ {{0.11,0.12,0.14},{0.075,0.08,0.095},{0.17,0.18,0.21},{0.12,0.13,0.15},{0.27,0.29,0.33},{0.2,0.22,0.25},{0.36,0.39,0.44},{0.25,0.28,0.32},{0.21,0.23,0.26},{0.15,0.17,0.2},{0.78,0.83,0.9},{0.55,0.61,0.7},{1.0,1.0,1.0},{0.78,0.82,0.88},{0.96,0.97,0.98},{0.86,0.89,0.92},{0.67,0.72,0.77}}, {{0.031,0.086,0.148},{0.025,0.075,0.13},{0.07,0.155,0.235},{0.045,0.12,0.19},{0.115,0.22,0.33},{0.07,0.15,0.24},{0.15,0.33,0.5},{0.08,0.24,0.36},{0.23,0.32,0.41},{0.18,0.26,0.35},{0.38,0.76,1.0},{0.23,0.64,0.97},{0.96,0.98,1.0},{0.62,0.7,0.76},{0.88,0.96,1.0},{0.82,0.9,0.96},{0.58,0.7,0.78}}, {{0.11,0.09,0.17},{0.07,0.06,0.12},{0.18,0.14,0.28},{0.13,0.1,0.21},{0.27,0.22,0.42},{0.2,0.16,0.31},{0.43,0.34,0.68},{0.31,0.23,0.52},{0.22,0.18,0.31},{0.15,0.12,0.23},{0.78,0.71,1.0},{0.5,0.42,0.93},{0.95,0.9,1.0},{0.63,0.5,0.95},{0.98,0.95,1.0},{0.9,0.86,0.97},{0.7,0.66,0.82}}, {{0.08,0.17,0.1},{0.05,0.12,0.07},{0.12,0.27,0.15},{0.09,0.2,0.11},{0.16,0.35,0.2},{0.12,0.27,0.15},{0.21,0.57,0.31},{0.14,0.4,0.21},{0.14,0.27,0.16},{0.1,0.2,0.11},{0.54,0.96,0.64},{0.22,0.75,0.35},{0.91,1.0,0.93},{0.28,0.8,0.42},{0.95,1.0,0.96},{0.86,0.96,0.88},{0.66,0.8,0.68}}, {{0.23,0.15,0.08},{0.16,0.1,0.05},{0.35,0.22,0.11},{0.26,0.16,0.08},{0.45,0.28,0.14},{0.36,0.22,0.1},{0.72,0.44,0.18},{0.56,0.32,0.12},{0.29,0.18,0.09},{0.2,0.12,0.06},{0.98,0.67,0.31},{0.86,0.47,0.17},{1.0,0.86,0.57},{0.93,0.59,0.22},{1.0,0.96,0.9},{0.97,0.9,0.82},{0.8,0.7,0.58}}, {{.065,.060,.050},{.012,.012,.012},{.12,.105,.075},{.045,.042,.035},{.105,.092,.065},{.15,.125,.075},{.17,.14,.085},{.075,.065,.045},{.23,.20,.14},{.10,.09,.065},{.98,.82,.42},{.72,.51,.18},{1,.90,.65},{.88,.74,.43},{1,.86,.48},{.96,.82,.49},{.79,.70,.48}}, - {{.11,.10,.13},{.045,.040,.055},{.16,.14,.20},{.083,.073,.103},{.115,.104,.139},{.15,.135,.18},{.16,.145,.19},{.105,.10,.13},{.24,.22,.28},{.14,.125,.17},{.90,.20,.83},{.02,.79,.94},{.93,.97,1},{.75,.72,.82},{.95,.97,1},{.86,.86,.91},{.67,.64,.73}} + {{.11,.10,.13},{.045,.040,.055},{.16,.14,.20},{.083,.073,.103},{.115,.104,.139},{.15,.135,.18},{.16,.145,.19},{.105,.10,.13},{.24,.22,.28},{.14,.125,.17},{.90,.20,.83},{.02,.79,.94},{.93,.97,1},{.75,.72,.82},{.95,.97,1},{.86,.86,.91},{.67,.64,.73}}, + {{.89,.94,.97},{.84,.91,.95},{.94,.98,1},{.90,.95,.98},{.83,.90,.95},{.91,.96,.99},{.95,.985,1},{.83,.91,.96},{.74,.84,.90},{.88,.94,.97},{.52,.61,.89},{.29,.74,.80},{.96,.99,1},{.40,.55,.65},{.12,.28,.34},{.19,.36,.43},{.25,.39,.47}} }; -NSColor *DYThemeSwatch(NSInteger index){static const double values[7][3]={{.30,.33,.38},{.28,.72,1},{.58,.52,1},{.30,.86,.52},{1,.61,.28},{.96,.77,.36},{.65,.38,1}};index=MAX(0,MIN(6,index));return rgb(values[index][0],values[index][1],values[index][2]);} -void DYSetThemeIndex(NSInteger index){if(index<0||index>6)return;[store().defaults setInteger:index forKey:@"themeIndex"];[store().defaults synchronize];[[NSNotificationCenter defaultCenter]postNotificationName:DYThemeDidChange object:nil];[[NSDistributedNotificationCenter defaultCenter]postNotificationName:distributedChange object:preferenceDomain userInfo:nil deliverImmediately:YES];} +NSColor *DYThemeSwatch(NSInteger index){static const double values[8][3]={{.30,.33,.38},{.28,.72,1},{.58,.52,1},{.30,.86,.52},{1,.61,.28},{.96,.77,.36},{.65,.38,1},{.82,.93,.98}};index=MAX(0,MIN(7,index));return rgb(values[index][0],values[index][1],values[index][2]);} +void DYSetThemeIndex(NSInteger index){if(index<0||index>7)return;[store().defaults setInteger:index forKey:@"themeIndex"];[store().defaults synchronize];[[NSNotificationCenter defaultCenter]postNotificationName:DYThemeDidChange object:nil];[[NSDistributedNotificationCenter defaultCenter]postNotificationName:distributedChange object:preferenceDomain userInfo:nil deliverImmediately:YES];} NSDictionary *DYThemePalette(void){ static NSArray *palettes;static dispatch_once_t once;dispatch_once(&once,^{ NSMutableArray *all=[NSMutableArray array]; - for(NSInteger index=0;index<7;index++){ + for(NSInteger index=0;index<8;index++){ const double (*p)[3]=paletteRGB[index];NSMutableDictionary *d=[NSMutableDictionary dictionary]; for(int i=0;i<17;i++)d[[NSString stringWithFormat:@"slot%d",i]]=rgb(p[i][0],p[i][1],p[i][2]); - NSColor *accent=index==0?rgb(.72,.77,.84):index==1?rgb(.22,.67,1):index==6?rgb(.78,.75,.87):DYThemeSwatch(index); - [d addEntriesFromDictionary:@{@"background":d[@"slot1"],@"card":d[@"slot3"],@"border":[accent colorWithAlphaComponent:.38],@"text":d[@"slot14"],@"secondary":d[@"slot16"],@"accent":accent,@"field":d[@"slot4"],@"headerTop":d[@"slot6"],@"headerBottom":d[@"slot7"],@"track":d[@"slot8"],@"activeTop":d[@"slot10"],@"activeBottom":d[@"slot11"],@"knob":d[@"slot12"]}];d[@"backgroundEnd"]=index==5?rgb(.085,.078,.060):d[@"background"];d[@"cardEnd"]=index==5?rgb(.085,.075,.052):d[@"card"];if(index==6){d[@"backgroundEnd"]=rgb(.065,.060,.080);d[@"cardEnd"]=rgb(.093,.090,.110);d[@"border"]=[rgb(.36,.33,.43)colorWithAlphaComponent:.40];} [all addObject:[[d copy]autorelease]]; + NSColor *accent=index==0?rgb(.72,.77,.84):index==1?rgb(.22,.67,1):index==6?rgb(.78,.75,.87):index==7?rgb(.23,.42,.54):DYThemeSwatch(index); + [d addEntriesFromDictionary:@{@"background":d[@"slot1"],@"card":d[@"slot3"],@"border":[accent colorWithAlphaComponent:.38],@"text":d[@"slot14"],@"secondary":d[@"slot16"],@"accent":accent,@"field":d[@"slot4"],@"headerTop":d[@"slot6"],@"headerBottom":d[@"slot7"],@"track":d[@"slot8"],@"activeTop":d[@"slot10"],@"activeBottom":d[@"slot11"],@"knob":d[@"slot12"]}];d[@"backgroundEnd"]=index==5?rgb(.085,.078,.060):d[@"background"];d[@"cardEnd"]=index==5?rgb(.085,.075,.052):d[@"card"];if(index==6){d[@"backgroundEnd"]=rgb(.065,.060,.080);d[@"cardEnd"]=rgb(.093,.090,.110);d[@"border"]=[rgb(.36,.33,.43)colorWithAlphaComponent:.40];} if(index==7){d[@"backgroundEnd"]=rgb(.90,.95,.98);d[@"cardEnd"]=rgb(.86,.93,.97);d[@"border"]=rgb(.55,.70,.79);} + [all addObject:[[d copy]autorelease]]; }palettes=[all copy]; });return palettes[DYThemeIndex()]; } @@ -67,6 +69,40 @@ void DYDrawThemeSurface(NSBezierPath *path,BOOL card) { if(DYThemeIndex()>=5){NSGradient *gradient=[[[NSGradient alloc]initWithStartingColor:palette[role] endingColor:palette[card?@"cardEnd":@"backgroundEnd"]]autorelease];[gradient drawInBezierPath:path angle:35];} else {[palette[role]setFill];[path fill];} } +BOOL DYThemeIsLight(void) {return DYThemeIndex()==7;} +// Draw the rim as a filled ring, so the highlight follows the entire rounded +// outline rather than glowing around text or requiring additional view layers. +static void softGradient(NSBezierPath *path,NSArray *colors) { + NSRect r=path.bounds;BOOL flipped=NSGraphicsContext.currentContext.isFlipped; + NSGradient *gradient=[[[NSGradient alloc]initWithColors:colors]autorelease]; + [NSGraphicsContext saveGraphicsState];[path addClip]; + [gradient drawFromPoint:NSMakePoint(NSMinX(r),flipped?NSMinY(r):NSMaxY(r)) toPoint:NSMakePoint(NSMaxX(r),flipped?NSMaxY(r):NSMinY(r)) options:NSGradientDrawsBeforeStartingLocation|NSGradientDrawsAfterEndingLocation]; + [NSGraphicsContext restoreGraphicsState]; +} +void DYDrawSoftControl(NSRect rect,CGFloat radius,BOOL recessed,BOOL emphasized,BOOL pressed) { + BOOL strong=NSWorkspace.sharedWorkspace.accessibilityDisplayShouldIncreaseContrast; + BOOL quiet=strong||NSWorkspace.sharedWorkspace.accessibilityDisplayShouldReduceTransparency; + NSBezierPath *shape=[NSBezierPath bezierPathWithRoundedRect:rect xRadius:radius yRadius:radius]; + NSColor *top=recessed||pressed?rgb(.79,.87,.93):rgb(.96,.985,1); + NSColor *bottom=recessed||pressed?rgb(.91,.96,.99):rgb(.85,.92,.97); + if(emphasized){top=pressed?rgb(.66,.73,.90):rgb(.76,.77,.96);bottom=pressed?rgb(.50,.77,.83):rgb(.55,.85,.90);} + if(!quiet&&!recessed&&!pressed){ + BOOL flipped=NSGraphicsContext.currentContext.isFlipped; + for(int light=0;light<2;light++){ + [NSGraphicsContext saveGraphicsState];NSShadow *shadow=[[[NSShadow alloc]init]autorelease]; + shadow.shadowColor=light?[NSColor colorWithWhite:1 alpha:.90]:[rgb(.37,.55,.66)colorWithAlphaComponent:.28]; + CGFloat d=light?-1.5:2;shadow.shadowOffset=NSMakeSize(d,flipped?d:-d);shadow.shadowBlurRadius=light?2.5:3.5;[shadow set];[top setFill];[shape fill];[NSGraphicsContext restoreGraphicsState]; + } + } + softGradient(shape,@[top,bottom]); + NSBezierPath *rim=[NSBezierPath bezierPathWithRoundedRect:rect xRadius:radius yRadius:radius]; + CGFloat width=strong?1.3:1;[rim appendBezierPath:[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(rect,width,width) xRadius:MAX(0,radius-width) yRadius:MAX(0,radius-width)]];rim.windingRule=NSWindingRuleEvenOdd; + if(strong){[rgb(.33,.49,.60)setFill];[rim fill];} + else softGradient(rim,recessed||pressed?@[rgb(.56,.71,.81),rgb(.98,1,1)]:@[NSColor.whiteColor,rgb(.80,.89,.95),rgb(.55,.72,.83),rgb(.96,.99,1)]); + // The inner hairline gives a visible lower edge even with reduced effects. + NSBezierPath *inner=[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(rect,1.5,1.5) xRadius:MAX(0,radius-1.5) yRadius:MAX(0,radius-1.5)]; + [[rgb(.40,.60,.73)colorWithAlphaComponent:strong?.35:.12]setStroke];inner.lineWidth=.5;[inner stroke]; +} @implementation DYThemeLabel - (void)drawRect:(NSRect)rect {[NSGraphicsContext saveGraphicsState];[DYThemeTextShadow()set];[super drawRect:rect];[NSGraphicsContext restoreGraphicsState];} @end @@ -78,12 +114,14 @@ void DYDrawThemeSurface(NSBezierPath *path,BOOL card) { } - (void)drawBezelWithFrame:(NSRect)frame inView:(NSView*)view { if(DYThemeIndex()<5||!self.bordered){[super drawBezelWithFrame:frame inView:view];return;} + if(DYThemeIsLight()){DYDrawSoftControl(NSInsetRect(frame,2,3),7,NO,[view.identifier isEqual:@"primaryAction"],self.highlighted);return;} NSBezierPath *path=[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(frame,1,2) xRadius:6 yRadius:6];if(DYThemeIndex()==6&&[view.identifier isEqual:@"primaryAction"]){NSGradient *g=[[[NSGradient alloc]initWithColors:@[DYThemePalette()[@"activeTop"],DYThemePalette()[@"activeBottom"]]]autorelease];[g drawInBezierPath:path angle:0];}else DYDrawThemeSurface(path,YES);[[DYThemeColor(@"accent")colorWithAlphaComponent:self.highlighted?.8:.32]setStroke];path.lineWidth=self.highlighted?1.5:1;[path stroke]; } @end @implementation DYThemeButton + (Class)cellClass {return DYThemeButtonCell.class;} - (void)drawRect:(NSRect)rect { + if(DYThemeIsLight()&&[self.identifier isEqual:@"layerAction"])DYDrawSoftControl(NSInsetRect(self.bounds,2,2),6,NO,NO,self.cell.highlighted); if(DYThemeIndex()==6&&[self.identifier isEqual:@"layerAction"]){ NSBezierPath *plate=[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(self.bounds,1,1) xRadius:5 yRadius:5]; [[NSColor colorWithWhite:1 alpha:self.cell.highlighted?.12:.055]setFill];[plate fill]; @@ -95,8 +133,8 @@ void DYDrawThemeSurface(NSBezierPath *path,BOOL card) { @implementation DYThemePopUpButton - (void)drawRect:(NSRect)rect { if(DYThemeIndex()<5){[super drawRect:rect];return;} - NSRect bounds=NSInsetRect(self.bounds,1,2);NSBezierPath *path=[NSBezierPath bezierPathWithRoundedRect:bounds xRadius:6 yRadius:6];DYDrawThemeSurface(path,YES); - [[DYThemeColor(@"accent")colorWithAlphaComponent:self.enabled?.38:.18]setStroke];path.lineWidth=1;[path stroke]; + NSRect bounds=NSInsetRect(self.bounds,1,2);NSBezierPath *path=[NSBezierPath bezierPathWithRoundedRect:bounds xRadius:6 yRadius:6];if(DYThemeIsLight())DYDrawSoftControl(NSInsetRect(self.bounds,2,3),6,NO,NO,self.cell.highlighted);else DYDrawThemeSurface(path,YES); + if(!DYThemeIsLight()){[[DYThemeColor(@"accent")colorWithAlphaComponent:self.enabled?.38:.18]setStroke];path.lineWidth=1;[path stroke];} NSMutableDictionary *attributes=[NSMutableDictionary dictionaryWithDictionary:DYThemeTextAttributes(self.font?:[NSFont systemFontOfSize:11],[DYThemeColor(@"text")colorWithAlphaComponent:self.enabled?1:.45])];NSMutableParagraphStyle *paragraph=[[[NSMutableParagraphStyle alloc]init]autorelease];paragraph.lineBreakMode=NSLineBreakByTruncatingTail;attributes[NSParagraphStyleAttributeName]=paragraph; CGFloat y=NSMidY(self.bounds)-(self.font?:[NSFont systemFontOfSize:11]).pointSize*.62; [(self.pullsDown?[self itemAtIndex:0].title:(self.selectedItem.title?:@""))drawInRect:NSMakeRect(9,y,MAX(0,self.bounds.size.width-29),18) withAttributes:attributes]; diff --git a/大鱼调色/Plugin/Info.plist b/大鱼调色/Plugin/Info.plist index c08784d..8ab6d7b 100644 --- a/大鱼调色/Plugin/Info.plist +++ b/大鱼调色/Plugin/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 1.8.4 + 1.8.5 CFBundleVersion - 64 + 65 NSHumanReadableCopyright PlugInKit @@ -71,7 +71,7 @@ uuid 1C17B73B-F229-4C09-A434-EAF6DFF5F22A version - 1.8.4 + 1.8.5 className diff --git a/大鱼调色/Wrapper Application/Info.plist b/大鱼调色/Wrapper Application/Info.plist index 3b93813..1e75c4d 100644 --- a/大鱼调色/Wrapper Application/Info.plist +++ b/大鱼调色/Wrapper Application/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.8.4 + 1.8.5 CFBundleVersion - 64 + 65 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright