mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: add macos-icon-frame and some custom frame styles
This commit is contained in:
Before Width: | Height: | Size: 145 KiB After Width: | Height: | Size: 145 KiB |
15
macos/Assets.xcassets/Custom Icon/CustomIconBaseBeige.imageset/Contents.json
vendored
Normal file
15
macos/Assets.xcassets/Custom Icon/CustomIconBaseBeige.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "beige.png",
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"template-rendering-intent" : "original"
|
||||||
|
}
|
||||||
|
}
|
BIN
macos/Assets.xcassets/Custom Icon/CustomIconBaseBeige.imageset/beige.png
vendored
Normal file
BIN
macos/Assets.xcassets/Custom Icon/CustomIconBaseBeige.imageset/beige.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 349 KiB |
15
macos/Assets.xcassets/Custom Icon/CustomIconBaseChrome.imageset/Contents.json
vendored
Normal file
15
macos/Assets.xcassets/Custom Icon/CustomIconBaseChrome.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "chrome.png",
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"template-rendering-intent" : "original"
|
||||||
|
}
|
||||||
|
}
|
BIN
macos/Assets.xcassets/Custom Icon/CustomIconBaseChrome.imageset/chrome.png
vendored
Normal file
BIN
macos/Assets.xcassets/Custom Icon/CustomIconBaseChrome.imageset/chrome.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 124 KiB |
15
macos/Assets.xcassets/Custom Icon/CustomIconBasePlastic.imageset/Contents.json
vendored
Normal file
15
macos/Assets.xcassets/Custom Icon/CustomIconBasePlastic.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "plastic.png",
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
},
|
||||||
|
"properties" : {
|
||||||
|
"template-rendering-intent" : "original"
|
||||||
|
}
|
||||||
|
}
|
BIN
macos/Assets.xcassets/Custom Icon/CustomIconBasePlastic.imageset/plastic.png
vendored
Normal file
BIN
macos/Assets.xcassets/Custom Icon/CustomIconBasePlastic.imageset/plastic.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 97 KiB |
@ -532,12 +532,13 @@ class AppDelegate: NSObject,
|
|||||||
self.appIcon = nil
|
self.appIcon = nil
|
||||||
break
|
break
|
||||||
|
|
||||||
case .customColor:
|
case .customStyle:
|
||||||
guard let ghostColor = config.macosIconGhostColor else { break }
|
guard let ghostColor = config.macosIconGhostColor else { break }
|
||||||
guard let screenColors = config.macosIconScreenColor else { break }
|
guard let screenColors = config.macosIconScreenColor else { break }
|
||||||
guard let icon = ColorizedGhosttyIcon(
|
guard let icon = ColorizedGhosttyIcon(
|
||||||
screenColors: screenColors,
|
screenColors: screenColors,
|
||||||
ghostColor: ghostColor
|
ghostColor: ghostColor,
|
||||||
|
frame: config.macosIconFrame
|
||||||
).makeImage() else { break }
|
).makeImage() else { break }
|
||||||
self.appIcon = icon
|
self.appIcon = icon
|
||||||
}
|
}
|
||||||
|
@ -7,16 +7,26 @@ struct ColorizedGhosttyIcon {
|
|||||||
/// The color of the ghost.
|
/// The color of the ghost.
|
||||||
let ghostColor: NSColor
|
let ghostColor: NSColor
|
||||||
|
|
||||||
|
/// The frame type to use
|
||||||
|
let frame: Ghostty.MacOSIconFrame
|
||||||
|
|
||||||
/// Make a custom colorized ghostty icon.
|
/// Make a custom colorized ghostty icon.
|
||||||
func makeImage() -> NSImage? {
|
func makeImage() -> NSImage? {
|
||||||
// All of our layers (in order)
|
// All of our layers (not in order)
|
||||||
guard let base = NSImage(named: "CustomIconBase") else { return nil }
|
|
||||||
guard let screen = NSImage(named: "CustomIconScreen") else { return nil }
|
guard let screen = NSImage(named: "CustomIconScreen") else { return nil }
|
||||||
guard let screenMask = NSImage(named: "CustomIconScreenMask") else { return nil }
|
guard let screenMask = NSImage(named: "CustomIconScreenMask") else { return nil }
|
||||||
guard let ghost = NSImage(named: "CustomIconGhost") else { return nil }
|
guard let ghost = NSImage(named: "CustomIconGhost") else { return nil }
|
||||||
guard let crt = NSImage(named: "CustomIconCRT") else { return nil }
|
guard let crt = NSImage(named: "CustomIconCRT") else { return nil }
|
||||||
guard let gloss = NSImage(named: "CustomIconGloss") else { return nil }
|
guard let gloss = NSImage(named: "CustomIconGloss") else { return nil }
|
||||||
|
|
||||||
|
let baseName = switch (frame) {
|
||||||
|
case .aluminum: "CustomIconBaseAluminum"
|
||||||
|
case .beige: "CustomIconBaseBeige"
|
||||||
|
case .chrome: "CustomIconBaseChrome"
|
||||||
|
case .plastic: "CustomIconBasePlastic"
|
||||||
|
}
|
||||||
|
guard let base = NSImage(named: baseName) else { return nil }
|
||||||
|
|
||||||
// Apply our color in various ways to our layers.
|
// Apply our color in various ways to our layers.
|
||||||
// NOTE: These functions are not built-in, they're implemented as an extension
|
// NOTE: These functions are not built-in, they're implemented as an extension
|
||||||
// to NSImage in NSImage+Extension.swift.
|
// to NSImage in NSImage+Extension.swift.
|
||||||
|
@ -6,7 +6,8 @@ struct ColorizedGhosttyIconView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
Image(nsImage: ColorizedGhosttyIcon(
|
Image(nsImage: ColorizedGhosttyIcon(
|
||||||
screenColors: [.purple, .blue],
|
screenColors: [.purple, .blue],
|
||||||
ghostColor: .yellow
|
ghostColor: .yellow,
|
||||||
|
frame: .aluminum
|
||||||
).makeImage()!)
|
).makeImage()!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,6 +263,17 @@ extension Ghostty {
|
|||||||
return MacOSIcon(rawValue: str) ?? defaultValue
|
return MacOSIcon(rawValue: str) ?? defaultValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var macosIconFrame: MacOSIconFrame {
|
||||||
|
let defaultValue = MacOSIconFrame.aluminum
|
||||||
|
guard let config = self.config else { return defaultValue }
|
||||||
|
var v: UnsafePointer<Int8>? = nil
|
||||||
|
let key = "macos-icon-frame"
|
||||||
|
guard ghostty_config_get(config, &v, key, UInt(key.count)) else { return defaultValue }
|
||||||
|
guard let ptr = v else { return defaultValue }
|
||||||
|
let str = String(cString: ptr)
|
||||||
|
return MacOSIconFrame(rawValue: str) ?? defaultValue
|
||||||
|
}
|
||||||
|
|
||||||
var macosIconGhostColor: OSColor? {
|
var macosIconGhostColor: OSColor? {
|
||||||
guard let config = self.config else { return nil }
|
guard let config = self.config else { return nil }
|
||||||
var v: ghostty_config_color_s = .init()
|
var v: ghostty_config_color_s = .init()
|
||||||
|
@ -198,7 +198,15 @@ extension Ghostty {
|
|||||||
/// macos-icon
|
/// macos-icon
|
||||||
enum MacOSIcon: String {
|
enum MacOSIcon: String {
|
||||||
case official
|
case official
|
||||||
case customColor = "custom-color"
|
case customStyle = "custom-style"
|
||||||
|
}
|
||||||
|
|
||||||
|
/// macos-icon-frame
|
||||||
|
enum MacOSIconFrame: String {
|
||||||
|
case aluminum
|
||||||
|
case beige
|
||||||
|
case plastic
|
||||||
|
case chrome
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enum for the macos-titlebar-proxy-icon config option
|
/// Enum for the macos-titlebar-proxy-icon config option
|
||||||
|
@ -16,7 +16,6 @@ const build_config = @import("../build_config.zig");
|
|||||||
const assert = std.debug.assert;
|
const assert = std.debug.assert;
|
||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
const ArenaAllocator = std.heap.ArenaAllocator;
|
const ArenaAllocator = std.heap.ArenaAllocator;
|
||||||
const build_config = @import("../build_config.zig");
|
|
||||||
const global_state = &@import("../global.zig").state;
|
const global_state = &@import("../global.zig").state;
|
||||||
const fontpkg = @import("../font/main.zig");
|
const fontpkg = @import("../font/main.zig");
|
||||||
const inputpkg = @import("../input.zig");
|
const inputpkg = @import("../input.zig");
|
||||||
@ -1688,11 +1687,11 @@ keybind: Keybinds = .{},
|
|||||||
/// Valid values:
|
/// Valid values:
|
||||||
///
|
///
|
||||||
/// * `official` - Use the official Ghostty icon.
|
/// * `official` - Use the official Ghostty icon.
|
||||||
/// * `custom-color` - Use the official Ghostty icon but with custom
|
/// * `custom-style` - Use the official Ghostty icon but with custom
|
||||||
/// colors applied to various layers. The custom colors must be
|
/// styles applied to various layers. The custom styles must be
|
||||||
/// specified using the additional `macos-icon-x-color` configurations.
|
/// specified using the additional `macos-icon`-prefixed configurations.
|
||||||
/// Note that all colors are required. If any are missing, the icon
|
/// The `macos-icon-ghost-color` and `macos-icon-screen-color`
|
||||||
/// will not be changed.
|
/// configurations are required for this style.
|
||||||
///
|
///
|
||||||
/// Other caveats:
|
/// Other caveats:
|
||||||
///
|
///
|
||||||
@ -1703,12 +1702,27 @@ keybind: Keybinds = .{},
|
|||||||
///
|
///
|
||||||
@"macos-icon": MacAppIcon = .official,
|
@"macos-icon": MacAppIcon = .official,
|
||||||
|
|
||||||
|
/// The material to use for the frame of the macOS app icon.
|
||||||
|
///
|
||||||
|
/// Valid values:
|
||||||
|
///
|
||||||
|
/// * `aluminum` - A brushed aluminum frame. This is the default.
|
||||||
|
/// * `beige` - A classic 90's computer beige frame.
|
||||||
|
/// * `plastic` - A glossy, dark plastic frame.
|
||||||
|
/// * `chrome` - A shiny chrome frame.
|
||||||
|
///
|
||||||
|
/// This only has an effect when `macos-icon` is set to `custom-style`.
|
||||||
|
@"macos-icon-frame": MacAppIconFrame = .aluminum,
|
||||||
|
|
||||||
/// The color of the ghost in the macOS app icon.
|
/// The color of the ghost in the macOS app icon.
|
||||||
///
|
///
|
||||||
/// The format of the color is the same as the `background` configuration;
|
/// The format of the color is the same as the `background` configuration;
|
||||||
/// see that for more information.
|
/// see that for more information.
|
||||||
///
|
///
|
||||||
/// This only has an effect when `macos-icon` is set to `custom-color`.
|
/// Note: This configuration is required when `macos-icon` is set to
|
||||||
|
/// `custom-style`.
|
||||||
|
///
|
||||||
|
/// This only has an effect when `macos-icon` is set to `custom-style`.
|
||||||
@"macos-icon-ghost-color": ?Color = null,
|
@"macos-icon-ghost-color": ?Color = null,
|
||||||
|
|
||||||
/// The color of the screen in the macOS app icon.
|
/// The color of the screen in the macOS app icon.
|
||||||
@ -1718,7 +1732,10 @@ keybind: Keybinds = .{},
|
|||||||
/// format of the color is the same as the `background` configuration;
|
/// format of the color is the same as the `background` configuration;
|
||||||
/// see that for more information.
|
/// see that for more information.
|
||||||
///
|
///
|
||||||
/// This only has an effect when `macos-icon` is set to `custom-color`.
|
/// Note: This configuration is required when `macos-icon` is set to
|
||||||
|
/// `custom-style`.
|
||||||
|
///
|
||||||
|
/// This only has an effect when `macos-icon` is set to `custom-style`.
|
||||||
@"macos-icon-screen-color": ?ColorList = null,
|
@"macos-icon-screen-color": ?ColorList = null,
|
||||||
|
|
||||||
/// Put every surface (tab, split, window) into a dedicated Linux cgroup.
|
/// Put every surface (tab, split, window) into a dedicated Linux cgroup.
|
||||||
@ -5107,7 +5124,15 @@ pub const MacTitlebarProxyIcon = enum {
|
|||||||
/// format at all.
|
/// format at all.
|
||||||
pub const MacAppIcon = enum {
|
pub const MacAppIcon = enum {
|
||||||
official,
|
official,
|
||||||
@"custom-color",
|
@"custom-style",
|
||||||
|
};
|
||||||
|
|
||||||
|
/// See macos-icon-frame
|
||||||
|
pub const MacAppIconFrame = enum {
|
||||||
|
aluminum,
|
||||||
|
beige,
|
||||||
|
plastic,
|
||||||
|
chrome,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// See gtk-single-instance
|
/// See gtk-single-instance
|
||||||
|
Reference in New Issue
Block a user