mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 09:16:11 +03:00
Tint split view divider based on theme background
This commit is contained in:
@ -65,6 +65,7 @@
|
||||
A5E112952AF73E8A00C6E0C2 /* ClipboardConfirmationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E112942AF73E8A00C6E0C2 /* ClipboardConfirmationController.swift */; };
|
||||
A5E112972AF7401B00C6E0C2 /* ClipboardConfirmationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E112962AF7401B00C6E0C2 /* ClipboardConfirmationView.swift */; };
|
||||
A5FEB3002ABB69450068369E /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5FEB2FF2ABB69450068369E /* main.swift */; };
|
||||
C159E81D2B66A06B00FDFE9C /* NSColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C159E81C2B66A06B00FDFE9C /* NSColor+Extension.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@ -123,6 +124,7 @@
|
||||
A5E112942AF73E8A00C6E0C2 /* ClipboardConfirmationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClipboardConfirmationController.swift; sourceTree = "<group>"; };
|
||||
A5E112962AF7401B00C6E0C2 /* ClipboardConfirmationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClipboardConfirmationView.swift; sourceTree = "<group>"; };
|
||||
A5FEB2FF2ABB69450068369E /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
|
||||
C159E81C2B66A06B00FDFE9C /* NSColor+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSColor+Extension.swift"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -187,6 +189,7 @@
|
||||
8503D7C62A549C66006CFF3D /* FullScreenHandler.swift */,
|
||||
A59630962AEE163600D64628 /* HostingWindow.swift */,
|
||||
A59FB5D02AE0DEA7009128F3 /* MetalView.swift */,
|
||||
C159E81C2B66A06B00FDFE9C /* NSColor+Extension.swift */,
|
||||
A5CEAFDA29B8005900646FDA /* SplitView */,
|
||||
);
|
||||
path = Helpers;
|
||||
@ -489,6 +492,7 @@
|
||||
A5E112952AF73E8A00C6E0C2 /* ClipboardConfirmationController.swift in Sources */,
|
||||
8503D7C72A549C66006CFF3D /* FullScreenHandler.swift in Sources */,
|
||||
A596309E2AEE1D6C00D64628 /* TerminalView.swift in Sources */,
|
||||
C159E81D2B66A06B00FDFE9C /* NSColor+Extension.swift in Sources */,
|
||||
A5CEAFDE29B8058B00646FDA /* SplitView.Divider.swift in Sources */,
|
||||
A5E112972AF7401B00C6E0C2 /* ClipboardConfirmationView.swift in Sources */,
|
||||
A514C8D82B54DC6800493A16 /* Ghostty.App.swift in Sources */,
|
||||
|
@ -30,7 +30,7 @@ extension Ghostty {
|
||||
/// The global app configuration. This defines the app level configuration plus any behavior
|
||||
/// for new windows, tabs, etc. Note that when creating a new window, it may inherit some
|
||||
/// configuration (i.e. font size) from the previously focused window. This would override this.
|
||||
private(set) var config: Config
|
||||
@Published private(set) var config: Config
|
||||
|
||||
/// The ghostty app instance. We only have one of these for the entire app, although I guess
|
||||
/// in theory you can have multiple... I don't know why you would...
|
||||
|
21
macos/Sources/Helpers/NSColor+Extension.swift
Normal file
21
macos/Sources/Helpers/NSColor+Extension.swift
Normal file
@ -0,0 +1,21 @@
|
||||
//
|
||||
// NSColor+Extension.swift
|
||||
// Ghostty
|
||||
//
|
||||
// Created by Pete Schaffner on 28/01/2024.
|
||||
//
|
||||
|
||||
import AppKit
|
||||
|
||||
extension NSColor {
|
||||
var isLightColor: Bool {
|
||||
var r: CGFloat = 0
|
||||
var g: CGFloat = 0
|
||||
var b: CGFloat = 0
|
||||
var a: CGFloat = 0
|
||||
|
||||
self.getRed(&r, green: &g, blue: &b, alpha: &a)
|
||||
let luminance = (0.299 * r) + (0.587 * g) + (0.114 * b)
|
||||
return luminance > 0.5
|
||||
}
|
||||
}
|
@ -3,6 +3,8 @@ import SwiftUI
|
||||
extension SplitView {
|
||||
/// The split divider that is rendered and can be used to resize a split view.
|
||||
struct Divider: View {
|
||||
@EnvironmentObject var ghostty: Ghostty.App
|
||||
|
||||
let direction: SplitViewDirection
|
||||
let visibleSize: CGFloat
|
||||
let invisibleSize: CGFloat
|
||||
@ -43,12 +45,20 @@ extension SplitView {
|
||||
}
|
||||
}
|
||||
|
||||
private var color: Color {
|
||||
let backgroundColor = NSColor(ghostty.config.backgroundColor)
|
||||
let isLightBackground = backgroundColor.isLightColor
|
||||
let newColor = isLightBackground ? backgroundColor.shadow(withLevel: 0.1) : backgroundColor.shadow(withLevel: 0.4)
|
||||
|
||||
return Color(nsColor: newColor ?? .gray.withAlphaComponent(0.5))
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Color.clear
|
||||
.frame(width: invisibleWidth, height: invisibleHeight)
|
||||
Rectangle()
|
||||
.fill(Color.gray)
|
||||
.fill(color)
|
||||
.frame(width: visibleWidth, height: visibleHeight)
|
||||
}
|
||||
.onHover { isHovered in
|
||||
|
Reference in New Issue
Block a user