From a2d3d8da2c94f78de4cc7387fd7179a21f7ccc32 Mon Sep 17 00:00:00 2001 From: phlpsong Date: Sun, 7 Jan 2024 22:43:11 +0800 Subject: [PATCH] bugfix: remove increaseMenuItemHeight func --- .../Feature/StatusItem/EZMenuItemManager.m | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/Easydict/Feature/StatusItem/EZMenuItemManager.m b/Easydict/Feature/StatusItem/EZMenuItemManager.m index ca784ad32..7f87b5103 100644 --- a/Easydict/Feature/StatusItem/EZMenuItemManager.m +++ b/Easydict/Feature/StatusItem/EZMenuItemManager.m @@ -98,7 +98,6 @@ - (void)setup { self.versionItem.title = self.versionTitle; NSArray *items = @[self.versionItem, self.settingsItem, self.checkForUpdateItem, self.helpItem, self.quitItem]; - [self increaseMenuItemsHeight:items lineHeightRatio:kTitleMenuItemHeightRatio]; [self updateVersionItem]; } @@ -308,8 +307,6 @@ - (void)menuWillOpen:(NSMenu *)menu { item.keyEquivalent = @""; item.keyEquivalentModifierMask = 0; } - - [self increaseMenuItemHeight:item lineHeightRatio:kImageMenuItemHeightRatio]; }; configItemShortcut(self.selectionItem, EZSelectionShortcutKey); @@ -319,24 +316,6 @@ - (void)menuWillOpen:(NSMenu *)menu { configItemShortcut(self.screenshotOCRItem, EZScreenshotOCRShortcutKey); } -#pragma mark - - -/// Increase menu item height. Ref: https://stackoverflow.com/questions/18031666/nsmenuitem-height -- (void)increaseMenuItemHeight:(NSMenuItem *)item lineHeightRatio:(CGFloat)lineHeightRatio { - NSFont *font = [NSFont systemFontOfSize:[NSFont systemFontSize]]; - CGFloat fontLineHeight = (font.ascender + fabs(font.descender)); - CGFloat lineHeight = fontLineHeight * lineHeightRatio; - // Ref stackoverflow: https://stackoverflow.com/a/18034142/8378840 - NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize(1, lineHeight)]; - [item setImage:image]; -} - -- (void)increaseMenuItemsHeight:(NSArray *)itmes lineHeightRatio:(CGFloat)lineHeightRatio { - for (NSMenuItem *item in itmes) { - [self increaseMenuItemHeight:item lineHeightRatio:lineHeightRatio]; - } -} - #pragma mark - Fetch Github Repo Info - (void)updateVersionItem { @@ -347,7 +326,6 @@ - (void)updateVersionItem { versionTitle = [NSString stringWithFormat:@"%@ (✨ %@)", self.versionTitle, lastestVersion]; } self.versionItem.title = versionTitle; - [self increaseMenuItemHeight:self.versionItem lineHeightRatio:kTitleMenuItemHeightRatio]; }]; }