Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ThemeKit/Demo/Demo/TitleBarOverlayView.swift
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
34 lines (29 sloc)
1.06 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TitleBarOverlayView.swift | |
// Demo | |
// | |
// Created by Nuno Grilo on 11/07/2017. | |
// Copyright © 2017 Paw & Nuno Grilo. All rights reserved. | |
// | |
import Cocoa | |
import ThemeKit | |
class TitleBarOverlayView: NSView { | |
/// Drawing code | |
override func draw(_ dirtyRect: NSRect) { | |
let theme = ThemeManager.shared.theme | |
let windowIsActive = window?.isKeyWindow ?? false | |
let isWindowInFullScreen = window?.styleMask.contains(NSWindow.StyleMask.fullScreen) ?? false | |
|| (window?.className ?? "") == "NSToolbarFullScreenWindow" | |
if (windowIsActive || isWindowInFullScreen), | |
let color = theme.themeAsset("windowTitleBarActiveColor") as? NSColor { | |
// Fill with 'active' color | |
color.set() | |
NSBezierPath(rect: bounds).fill() | |
} else if !windowIsActive, | |
let color = theme.themeAsset("windowTitleBarInactiveColor") as? NSColor { | |
// Fill with 'inactive' color | |
color.set() | |
NSBezierPath(rect: bounds).fill() | |
} | |
} | |
} |