mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
Support appearance
This commit is contained in:
parent
644655662e
commit
1872672d0c
3 changed files with 47 additions and 4 deletions
|
|
@ -40,8 +40,9 @@ func main() {
|
|||
},
|
||||
StartState: options.WindowStateMaximised,
|
||||
Mac: &options.MacWindow{
|
||||
Backdrop: options.MacBackdropTranslucent,
|
||||
TitleBar: options.TitleBarHiddenInset(),
|
||||
Backdrop: options.MacBackdropTranslucent,
|
||||
TitleBar: options.TitleBarHiddenInset(),
|
||||
Appearance: options.NSAppearanceNameDarkAqua,
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -373,6 +373,21 @@ void windowSetHideToolbarSeparator(void* nsWindow, bool hideSeparator) {
|
|||
});
|
||||
}
|
||||
|
||||
// Set Window appearance type
|
||||
void windowSetAppearanceTypeByName(void* nsWindow, const char *appearanceName) {
|
||||
// Set window appearance type on main thread
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// get main window
|
||||
NSWindow* window = (NSWindow*)nsWindow;
|
||||
// set window appearance type by name
|
||||
// Convert appearance name to NSString
|
||||
NSString* appearanceNameString = [NSString stringWithUTF8String:appearanceName];
|
||||
// Set appearance
|
||||
[window setAppearance:[NSAppearance appearanceNamed:appearanceNameString]];
|
||||
|
||||
free((void*)appearanceName);
|
||||
});
|
||||
}
|
||||
|
||||
*/
|
||||
import "C"
|
||||
|
|
@ -498,6 +513,10 @@ func (w *macosWindow) run() error {
|
|||
C.windowSetHideToolbarSeparator(w.nsWindow, C.bool(titleBarOptions.HideToolbarSeparator))
|
||||
}
|
||||
|
||||
if macOptions.Appearance != "" {
|
||||
C.windowSetAppearanceTypeByName(w.nsWindow, C.CString(string(macOptions.Appearance)))
|
||||
}
|
||||
|
||||
switch w.options.StartState {
|
||||
case options.WindowStateMaximised:
|
||||
w.setMaximised()
|
||||
|
|
|
|||
|
|
@ -60,8 +60,9 @@ const (
|
|||
|
||||
// MacWindow contains macOS specific options
|
||||
type MacWindow struct {
|
||||
Backdrop MacBackdrop
|
||||
TitleBar *TitleBar
|
||||
Backdrop MacBackdrop
|
||||
TitleBar *TitleBar
|
||||
Appearance MacAppearanceType
|
||||
}
|
||||
|
||||
// TitleBar contains options for the Mac titlebar
|
||||
|
|
@ -116,3 +117,25 @@ func TitleBarHiddenInset() *TitleBar {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
// MacAppearanceType is a type of Appearance for Cocoa windows
|
||||
type MacAppearanceType string
|
||||
|
||||
const (
|
||||
// DefaultAppearance uses the default system value
|
||||
DefaultAppearance MacAppearanceType = ""
|
||||
// NSAppearanceNameAqua - The standard light system appearance.
|
||||
NSAppearanceNameAqua MacAppearanceType = "NSAppearanceNameAqua"
|
||||
// NSAppearanceNameDarkAqua - The standard dark system appearance.
|
||||
NSAppearanceNameDarkAqua MacAppearanceType = "NSAppearanceNameDarkAqua"
|
||||
// NSAppearanceNameVibrantLight - The light vibrant appearance
|
||||
NSAppearanceNameVibrantLight MacAppearanceType = "NSAppearanceNameVibrantLight"
|
||||
// NSAppearanceNameAccessibilityHighContrastAqua - A high-contrast version of the standard light system appearance.
|
||||
NSAppearanceNameAccessibilityHighContrastAqua MacAppearanceType = "NSAppearanceNameAccessibilityHighContrastAqua"
|
||||
// NSAppearanceNameAccessibilityHighContrastDarkAqua - A high-contrast version of the standard dark system appearance.
|
||||
NSAppearanceNameAccessibilityHighContrastDarkAqua MacAppearanceType = "NSAppearanceNameAccessibilityHighContrastDarkAqua"
|
||||
// NSAppearanceNameAccessibilityHighContrastVibrantLight - A high-contrast version of the light vibrant appearance.
|
||||
NSAppearanceNameAccessibilityHighContrastVibrantLight MacAppearanceType = "NSAppearanceNameAccessibilityHighContrastVibrantLight"
|
||||
// NSAppearanceNameAccessibilityHighContrastVibrantDark - A high-contrast version of the dark vibrant appearance.
|
||||
NSAppearanceNameAccessibilityHighContrastVibrantDark MacAppearanceType = "NSAppearanceNameAccessibilityHighContrastVibrantDark"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue