Skip to content

Commit

Permalink
bugfix: remove increaseMenuItemHeight func (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
phlpsong authored Jan 8, 2024
1 parent b336e30 commit 9433ee3
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions Easydict/Feature/StatusItem/EZMenuItemManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down Expand Up @@ -308,8 +307,6 @@ - (void)menuWillOpen:(NSMenu *)menu {
item.keyEquivalent = @"";
item.keyEquivalentModifierMask = 0;
}

[self increaseMenuItemHeight:item lineHeightRatio:kImageMenuItemHeightRatio];
};

configItemShortcut(self.selectionItem, EZSelectionShortcutKey);
Expand All @@ -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<NSMenuItem *> *)itmes lineHeightRatio:(CGFloat)lineHeightRatio {
for (NSMenuItem *item in itmes) {
[self increaseMenuItemHeight:item lineHeightRatio:lineHeightRatio];
}
}

#pragma mark - Fetch Github Repo Info

- (void)updateVersionItem {
Expand All @@ -347,7 +326,6 @@ - (void)updateVersionItem {
versionTitle = [NSString stringWithFormat:@"%@ (✨ %@)", self.versionTitle, lastestVersion];
}
self.versionItem.title = versionTitle;
[self increaseMenuItemHeight:self.versionItem lineHeightRatio:kTitleMenuItemHeightRatio];
}];
}

Expand Down

0 comments on commit 9433ee3

Please sign in to comment.