mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 17:26:09 +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 */; };
|
A5E112952AF73E8A00C6E0C2 /* ClipboardConfirmationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E112942AF73E8A00C6E0C2 /* ClipboardConfirmationController.swift */; };
|
||||||
A5E112972AF7401B00C6E0C2 /* ClipboardConfirmationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E112962AF7401B00C6E0C2 /* ClipboardConfirmationView.swift */; };
|
A5E112972AF7401B00C6E0C2 /* ClipboardConfirmationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5E112962AF7401B00C6E0C2 /* ClipboardConfirmationView.swift */; };
|
||||||
A5FEB3002ABB69450068369E /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5FEB2FF2ABB69450068369E /* main.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 */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@ -123,6 +124,7 @@
|
|||||||
A5E112942AF73E8A00C6E0C2 /* ClipboardConfirmationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClipboardConfirmationController.swift; sourceTree = "<group>"; };
|
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>"; };
|
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>"; };
|
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 */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -187,6 +189,7 @@
|
|||||||
8503D7C62A549C66006CFF3D /* FullScreenHandler.swift */,
|
8503D7C62A549C66006CFF3D /* FullScreenHandler.swift */,
|
||||||
A59630962AEE163600D64628 /* HostingWindow.swift */,
|
A59630962AEE163600D64628 /* HostingWindow.swift */,
|
||||||
A59FB5D02AE0DEA7009128F3 /* MetalView.swift */,
|
A59FB5D02AE0DEA7009128F3 /* MetalView.swift */,
|
||||||
|
C159E81C2B66A06B00FDFE9C /* NSColor+Extension.swift */,
|
||||||
A5CEAFDA29B8005900646FDA /* SplitView */,
|
A5CEAFDA29B8005900646FDA /* SplitView */,
|
||||||
);
|
);
|
||||||
path = Helpers;
|
path = Helpers;
|
||||||
@ -489,6 +492,7 @@
|
|||||||
A5E112952AF73E8A00C6E0C2 /* ClipboardConfirmationController.swift in Sources */,
|
A5E112952AF73E8A00C6E0C2 /* ClipboardConfirmationController.swift in Sources */,
|
||||||
8503D7C72A549C66006CFF3D /* FullScreenHandler.swift in Sources */,
|
8503D7C72A549C66006CFF3D /* FullScreenHandler.swift in Sources */,
|
||||||
A596309E2AEE1D6C00D64628 /* TerminalView.swift in Sources */,
|
A596309E2AEE1D6C00D64628 /* TerminalView.swift in Sources */,
|
||||||
|
C159E81D2B66A06B00FDFE9C /* NSColor+Extension.swift in Sources */,
|
||||||
A5CEAFDE29B8058B00646FDA /* SplitView.Divider.swift in Sources */,
|
A5CEAFDE29B8058B00646FDA /* SplitView.Divider.swift in Sources */,
|
||||||
A5E112972AF7401B00C6E0C2 /* ClipboardConfirmationView.swift in Sources */,
|
A5E112972AF7401B00C6E0C2 /* ClipboardConfirmationView.swift in Sources */,
|
||||||
A514C8D82B54DC6800493A16 /* Ghostty.App.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
|
/// 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
|
/// 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.
|
/// 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
|
/// 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...
|
/// 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 {
|
extension SplitView {
|
||||||
/// The split divider that is rendered and can be used to resize a split view.
|
/// The split divider that is rendered and can be used to resize a split view.
|
||||||
struct Divider: View {
|
struct Divider: View {
|
||||||
|
@EnvironmentObject var ghostty: Ghostty.App
|
||||||
|
|
||||||
let direction: SplitViewDirection
|
let direction: SplitViewDirection
|
||||||
let visibleSize: CGFloat
|
let visibleSize: CGFloat
|
||||||
let invisibleSize: 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 {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color.clear
|
Color.clear
|
||||||
.frame(width: invisibleWidth, height: invisibleHeight)
|
.frame(width: invisibleWidth, height: invisibleHeight)
|
||||||
Rectangle()
|
Rectangle()
|
||||||
.fill(Color.gray)
|
.fill(color)
|
||||||
.frame(width: visibleWidth, height: visibleHeight)
|
.frame(width: visibleWidth, height: visibleHeight)
|
||||||
}
|
}
|
||||||
.onHover { isHovered in
|
.onHover { isHovered in
|
||||||
|
Reference in New Issue
Block a user