Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: make menu item height using default value #318

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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