mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
macOS 11: SF symbols for preference pane / use the right toolbar styles
Use SF symbols (only for macOS 11+ / Big Sur) for preference pane's toolbar to be consistent with rest of OS. Set toolbar style to be "preference" as otherwise it defaults to "unified" which is not correct for a preference pane. Set toolbar style for main MacVim window to be "unified compact", as the default "unified" is too larger and not useful for text editing. For example, Xcode also uses this.
This commit is contained in:
@@ -12,39 +12,6 @@
|
||||
#import "MMAppController.h"
|
||||
#import "Miscellaneous.h"
|
||||
|
||||
// On Leopard, we want to use the images provided by the OS for some of the
|
||||
// toolbar images (NSImageNamePreferencesGeneral and friends). We need to jump
|
||||
// through some hoops to do that in a way that MacVim still _compiles_ on Tiger
|
||||
// (life would be easier if we'd require Leopard for building). See
|
||||
// http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html
|
||||
// and http://developer.apple.com/technotes/tn2002/tn2064.html
|
||||
// for how you'd do it with a Leopard build system, and see
|
||||
// http://lists.cairographics.org/archives/cairo-bugs/2007-December/001818.html
|
||||
// for why this doesn't work here.
|
||||
// Using the system images gives us resolution independence and consistency
|
||||
// with other apps.
|
||||
|
||||
#import <dlfcn.h>
|
||||
|
||||
|
||||
NSString* nsImageNamePreferencesGeneral = nil;
|
||||
NSString* nsImageNamePreferencesAppearance = nil;
|
||||
NSString* nsImageNamePreferencesAdvanced = nil;
|
||||
|
||||
|
||||
static void loadSymbols()
|
||||
{
|
||||
// use dlfcn() instead of the deprecated NSModule api.
|
||||
void *ptr;
|
||||
if ((ptr = dlsym(RTLD_DEFAULT, "NSImageNamePreferencesGeneral")) != NULL)
|
||||
nsImageNamePreferencesGeneral = *(NSString**)ptr;
|
||||
if ((ptr = dlsym(RTLD_DEFAULT, "NSImageNameColorPanel")) != NULL) // Closest match for default icon for "appearance"
|
||||
nsImageNamePreferencesAppearance = *(NSString**)ptr;
|
||||
if ((ptr = dlsym(RTLD_DEFAULT, "NSImageNameAdvanced")) != NULL)
|
||||
nsImageNamePreferencesAdvanced = *(NSString**)ptr;
|
||||
}
|
||||
|
||||
|
||||
@implementation MMPreferenceController
|
||||
|
||||
- (void)windowDidLoad
|
||||
@@ -66,6 +33,15 @@ static void loadSymbols()
|
||||
}
|
||||
#endif
|
||||
[super windowDidLoad];
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
|
||||
if (@available(macos 11.0, *)) {
|
||||
// macOS 11 will default to a unified toolbar style unless you use the new
|
||||
// toolbarStyle to tell it to use a "preference" style, which makes it look nice
|
||||
// and centered.
|
||||
[self window].toolbarStyle = NSWindowToolbarStylePreference;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (IBAction)showWindow:(id)sender
|
||||
@@ -76,30 +52,35 @@ static void loadSymbols()
|
||||
|
||||
- (void)setupToolbar
|
||||
{
|
||||
loadSymbols();
|
||||
|
||||
if (nsImageNamePreferencesGeneral != NULL) {
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
|
||||
if (@available(macos 11.0, *)) {
|
||||
// Use SF Symbols for versions of the OS that supports it to be more unified with OS appearance.
|
||||
[self addView:generalPreferences
|
||||
label:@"General"
|
||||
image:[NSImage imageNamed:nsImageNamePreferencesGeneral]];
|
||||
} else {
|
||||
[self addView:generalPreferences label:@"General"];
|
||||
}
|
||||
image:[NSImage imageWithSystemSymbolName:@"gearshape" accessibilityDescription:nil]];
|
||||
|
||||
if (nsImageNamePreferencesAppearance != NULL) {
|
||||
[self addView:appearancePreferences
|
||||
label:@"Appearance"
|
||||
image:[NSImage imageNamed:nsImageNamePreferencesAppearance]];
|
||||
} else {
|
||||
[self addView:appearancePreferences label:@"Appearance"];
|
||||
}
|
||||
image:[NSImage imageWithSystemSymbolName:@"paintbrush" accessibilityDescription:nil]];
|
||||
|
||||
if (nsImageNamePreferencesAdvanced != NULL) {
|
||||
[self addView:advancedPreferences
|
||||
label:@"Advanced"
|
||||
image:[NSImage imageNamed:nsImageNamePreferencesAdvanced]];
|
||||
} else {
|
||||
[self addView:advancedPreferences label:@"Advanced"];
|
||||
image:[NSImage imageWithSystemSymbolName:@"gearshape.2" accessibilityDescription:nil]];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
[self addView:generalPreferences
|
||||
label:@"General"
|
||||
image:[NSImage imageNamed:NSImageNamePreferencesGeneral]];
|
||||
|
||||
[self addView:appearancePreferences
|
||||
label:@"Appearance"
|
||||
image:[NSImage imageNamed:NSImageNameColorPanel]];
|
||||
|
||||
[self addView:advancedPreferences
|
||||
label:@"Advanced"
|
||||
image:[NSImage imageNamed:NSImageNameAdvanced]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -222,6 +222,15 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
|
||||
if (@available(macos 11.0, *)) {
|
||||
// macOS 11 will default to a unified toolbar style unless you use the new
|
||||
// toolbarStyle to tell it to use a "preference" style, which makes it look nice
|
||||
// and centered.
|
||||
win.toolbarStyle = NSWindowToolbarStyleUnifiedCompact;
|
||||
}
|
||||
#endif
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(applicationDidChangeScreenParameters:)
|
||||
|
||||
Reference in New Issue
Block a user