From 6e5326f91314c4da6faf25d256f09c9cffa61c9d Mon Sep 17 00:00:00 2001 From: relikd Date: Mon, 8 Dec 2025 16:32:39 +0100 Subject: [PATCH] feat: new menubar icon for Appearance settings --- baRSS/Constants.h | 20 +++++----- baRSS/Helper/DrawImage.m | 39 ++++++++++++++++++- .../Appearance Tab/SettingsAppearanceView.m | 2 +- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/baRSS/Constants.h b/baRSS/Constants.h index f8972c5..49663f7 100644 --- a/baRSS/Constants.h +++ b/baRSS/Constants.h @@ -21,21 +21,23 @@ static NSString* const auxiliaryAppURL = @"https://github.com/relikd/URL-Scheme- /// Default RSS icon (with border, with gradient, orange) -static NSImageName const RSSImageDefaultRSSIcon = @"RSSImageDefaultRSSIcon"; -/// Settings, global icon (menu bar, black) -static NSImageName const RSSImageSettingsGlobal = @"RSSImageSettingsGlobal"; +static NSImageName const RSSImageDefaultRSSIcon = @"RSSImageDefaultRSSIcon"; +/// Settings, global statusbar icon (rss icon with neighbor icons) +static NSImageName const RSSImageSettingsGlobalIcon = @"RSSImageSettingsGlobalIcon"; +/// Settings, global menu icon (menu bar, black) +static NSImageName const RSSImageSettingsGlobalMenu = @"RSSImageSettingsGlobalMenu"; /// Settings, group icon (folder, black) -static NSImageName const RSSImageSettingsGroup = @"RSSImageSettingsGroup"; +static NSImageName const RSSImageSettingsGroup = @"RSSImageSettingsGroup"; /// Settings, feed icon (RSS, no border, no gradient, black) -static NSImageName const RSSImageSettingsFeed = @"RSSImageSettingsFeed"; +static NSImageName const RSSImageSettingsFeed = @"RSSImageSettingsFeed"; /// Menu bar, bar icon (RSS, with border, no gradient, orange) -static NSImageName const RSSImageMenuBarIconActive = @"RSSImageMenuBarIconActive"; +static NSImageName const RSSImageMenuBarIconActive = @"RSSImageMenuBarIconActive"; /// Menu bar, bar icon (RSS, with border, no gradient, paused, orange) -static NSImageName const RSSImageMenuBarIconPaused = @"RSSImageMenuBarIconPaused"; +static NSImageName const RSSImageMenuBarIconPaused = @"RSSImageMenuBarIconPaused"; /// Menu item, unread state icon (blue dot) -static NSImageName const RSSImageMenuItemUnread = @"RSSImageMenuItemUnread"; +static NSImageName const RSSImageMenuItemUnread = @"RSSImageMenuItemUnread"; /// Feed edit, regex editor icon @c "(.*)" -static NSImageName const RSSImageRegexIcon = @"RSSImageRegexIcon"; +static NSImageName const RSSImageRegexIcon = @"RSSImageRegexIcon"; #pragma mark - NSNotificationName constants diff --git a/baRSS/Helper/DrawImage.m b/baRSS/Helper/DrawImage.m index 04919c6..a727cc0 100644 --- a/baRSS/Helper/DrawImage.m +++ b/baRSS/Helper/DrawImage.m @@ -172,6 +172,42 @@ static void DrawRoundedFrame(CGContextRef c, CGRect r, CGColorRef color, BOOL ba #pragma mark - Easy Icon Drawing Methods +/// Draw RSS icon in menu bar with neighbors +static void DrawMenubarIcon(CGRect r) { + const CGFloat size = ShorterSide(r.size); + CGContextRef c = NSGraphicsContext.currentContext.CGContext; + CGContextSetFillColorWithColor(c, [NSColor controlTextColor].CGColor); + + // menu bar + CGContextSetAlpha(c, .23); + const CGFloat barHeightInset = round(size*.06); + svgAddRect(c, 1, CGRectInset(r, 0, barHeightInset), 0); + CGContextFillPath(c); + + const CGFloat offset = round(size*.75); + const CGFloat iconInset = round(size*.2); + const CGFloat iconCorner = size*.12; + CGContextSetAlpha(c, .66); + + // left neighbor + CGContextTranslateCTM(c, -offset, 0); + svgAddRect(c, 1, CGRectInset(r, iconInset, iconInset), iconCorner); + CGContextFillPath(c); + + // right neighbor + CGContextTranslateCTM(c, +2*offset, 0); + svgAddRect(c, 1, CGRectInset(r, iconInset, iconInset), iconCorner); + CGContextFillPath(c); + + // main icon + CGContextSetAlpha(c, 1); + CGContextTranslateCTM(c, -offset, 0); + svgAddRect(c, 1, CGRectInset(r, iconInset, iconInset), iconCorner); + SetContentScale(c, r.size, .47); + AddRSSIconPath(c, size, YES); + CGContextEOFillPath(c); +} + /// Draw global icon (menu bar) static void DrawGlobalIcon(CGRect r, CGColorRef color, BOOL background) { CGContextRef c = NSGraphicsContext.currentContext.CGContext; @@ -277,7 +313,8 @@ static void Register(CGFloat size, NSImageName name, NSString *description, BOOL /// Register all icons that require custom drawing in @c ImageNamed cache void RegisterImageViewNames(void) { Register(16, RSSImageDefaultRSSIcon, NSLocalizedString(@"RSS icon", nil), ^(NSRect r) { DrawRSSGradientIcon(r, [NSColor rssOrange]); return YES; }); - Register(16, RSSImageSettingsGlobal, NSLocalizedString(@"Global settings", nil), ^(NSRect r) { DrawGlobalIcon(r, [NSColor controlTextColor].CGColor, NO); return YES; }); + Register(16, RSSImageSettingsGlobalIcon, NSLocalizedString(@"Global menu icon settings", nil), ^(NSRect r) { DrawMenubarIcon(r); return YES; }); + Register(16, RSSImageSettingsGlobalMenu, NSLocalizedString(@"Global settings", nil), ^(NSRect r) { DrawGlobalIcon(r, [NSColor controlTextColor].CGColor, NO); return YES; }); Register(16, RSSImageSettingsGroup, NSLocalizedString(@"Group settings", nil), ^(NSRect r) { DrawGroupIcon(r); return YES; }); Register(16, RSSImageSettingsFeed, NSLocalizedString(@"Feed settings", nil), ^(NSRect r) { DrawRSSIcon(r, [NSColor controlTextColor].CGColor, NO, YES); return YES; }); Register(16, RSSImageMenuBarIconActive, NSLocalizedString(@"RSS menu bar icon", nil), ^(NSRect r) { DrawRSSIcon(r, [NSColor menuBarIconColor].CGColor, YES, YES); return YES; }); diff --git a/baRSS/Preferences/Appearance Tab/SettingsAppearanceView.m b/baRSS/Preferences/Appearance Tab/SettingsAppearanceView.m index 957089c..5898595 100644 --- a/baRSS/Preferences/Appearance Tab/SettingsAppearanceView.m +++ b/baRSS/Preferences/Appearance Tab/SettingsAppearanceView.m @@ -18,7 +18,7 @@ - (instancetype)init { self = [super initWithFrame:NSMakeRect(0, 0, 320, 327)]; // Insert matrix header (icons above checkbox matrix) - ColumnIcon(self, X__, RSSImageSettingsGlobal); + ColumnIcon(self, X__, RSSImageSettingsGlobalMenu); ColumnIcon(self, _X_, RSSImageSettingsGroup); ColumnIcon(self, __X, RSSImageSettingsFeed); // Generate checkbox matrix