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

Allow themes to override [NSMenu _isVisible] #307

Merged
merged 1 commit into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions Headers/Additions/GNUstepGUI/GSTheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,12 @@ withRepeatedImage: (NSImage*)image
- (void) organizeMenu: (NSMenu *)menu
isHorizontal: (BOOL)horizontal;

/**
* Used by the theme to override the proposed menu visibility. The default
* implementation simply returns the proposed visibility unmodified.
*/
- (BOOL) proposedVisibility: (BOOL)visible
forMenu: (NSMenu *) menu;
@end

@interface GSTheme (OpenSavePanels)
Expand Down
6 changes: 6 additions & 0 deletions Source/GSThemeMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -418,5 +418,11 @@ - (void) organizeMenu: (NSMenu *)menu
[[menu menuRepresentation] update];
[menu sizeToFit];
}

- (BOOL) proposedVisibility: (BOOL)visible
forMenu: (NSMenu *) menu
{
return visible;
}
@end

3 changes: 2 additions & 1 deletion Source/NSMenu.m
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ - (void) _rightMouseDisplay: (NSEvent*)theEvent

- (BOOL) _isVisible
{
return [_aWindow isVisible] || [_bWindow isVisible];
BOOL isVisible = [_aWindow isVisible] || [_bWindow isVisible];
return [[GSTheme theme] proposedVisibility: isVisible forMenu: self];
}

- (BOOL) _isMain
Expand Down
Loading