mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Fix line number view background with fullscreen (fix #672)
Previous backgroundColor trick is no more needd on OS X 10.10 and later.
This commit is contained in:
parent
46e037e50f
commit
d7f16e5ff3
@ -17,6 +17,7 @@ develop
|
||||
- Fix an issue where the application crashed by the Highlight command under the condition when the find string is a invalid regular expression pattern even the regular expression is turned off.
|
||||
- Fix an issue on the text search where the single text search couldn't find the word intersects with the current selection.
|
||||
- Fix an issue where the metadata of a custom theme cannot be edited.
|
||||
- Fix an issue where the background of the line number view was drawn with wrong color when entered to the fullscreen mode.
|
||||
|
||||
|
||||
|
||||
|
@ -43,11 +43,6 @@ final class AlphaWindow: NSWindow {
|
||||
var backgroundAlpha: CGFloat = 1.0
|
||||
{
|
||||
didSet {
|
||||
// window must be opaque on version browsing
|
||||
if self.windowController?.document?.isInViewingMode ?? false {
|
||||
backgroundAlpha = 1.0
|
||||
}
|
||||
|
||||
backgroundAlpha = backgroundAlpha.within(min: 0.2, max: 1.0)
|
||||
self.backgroundColor = self.backgroundColor.withAlphaComponent(backgroundAlpha)
|
||||
self.isOpaque = (backgroundAlpha == 1.0)
|
||||
@ -58,11 +53,11 @@ final class AlphaWindow: NSWindow {
|
||||
|
||||
// MARK: Private Properties
|
||||
|
||||
private var storedBackgroundColor: NSColor?
|
||||
private var storedBackgroundAlpha: CGFloat?
|
||||
|
||||
|
||||
|
||||
// MARK:
|
||||
// MARK: -
|
||||
// MARK: Lifecycle
|
||||
|
||||
override init(contentRect: NSRect, styleMask style: NSWindowStyleMask, backing bufferingType: NSBackingStoreType, defer flag: Bool) {
|
||||
@ -76,10 +71,6 @@ final class AlphaWindow: NSWindow {
|
||||
windowTitleView.layer?.backgroundColor = NSColor.windowBackgroundColor.cgColor
|
||||
}
|
||||
|
||||
// observe toggling fullscreen
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(willEnterOpaqueMode), name: .NSWindowWillEnterFullScreen, object: self)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(willExitOpaqueMode), name: .NSWindowWillExitFullScreen, object: self)
|
||||
|
||||
// observe toggling Versions browsing
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(willEnterOpaqueMode), name: .NSWindowWillEnterVersionBrowser, object: self)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(willExitOpaqueMode), name: .NSWindowWillExitVersionBrowser, object: self)
|
||||
@ -117,21 +108,21 @@ final class AlphaWindow: NSWindow {
|
||||
|
||||
// MARK: Notifications
|
||||
|
||||
/// notify entering fullscreen or Versions
|
||||
/// entering Versions
|
||||
func willEnterOpaqueMode(_ notification: Notification) {
|
||||
|
||||
self.storedBackgroundColor = self.backgroundColor
|
||||
self.backgroundColor = nil // restore window background to default (affect to the toolbar's background)
|
||||
self.isOpaque = true // set opaque flag expressly in order to let textView which observes opaque update its background color
|
||||
self.storedBackgroundAlpha = self.backgroundAlpha
|
||||
self.backgroundAlpha = 1.0
|
||||
}
|
||||
|
||||
|
||||
/// notify exit fullscreen or Versions
|
||||
/// exiting Versions
|
||||
func willExitOpaqueMode(_ notification: Notification) {
|
||||
|
||||
self.backgroundColor = self.storedBackgroundColor
|
||||
self.isOpaque = (self.backgroundAlpha == 1.0)
|
||||
self.invalidateShadow()
|
||||
if let backgroundAlpha = self.storedBackgroundAlpha {
|
||||
self.backgroundAlpha = backgroundAlpha
|
||||
self.storedBackgroundAlpha = nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -96,6 +96,11 @@ final class DocumentWindowController: NSWindowController {
|
||||
self.toolbarController!.document = document
|
||||
self.contentViewController!.representedObject = document
|
||||
|
||||
// -> In case when the window was created as a restored window (the right side ones in the browsing mode)
|
||||
if document.isInViewingMode, let window = self.window as? AlphaWindow {
|
||||
window.backgroundAlpha = 1.0
|
||||
}
|
||||
|
||||
// FIXME: workaround for that contentView origin can stack into toolbar on Sierra (2016-09 on macOS 10.12)
|
||||
// -> cf. https://github.com/coteditor/CotEditor/issues/600
|
||||
if let window = self.window {
|
||||
|
Loading…
Reference in New Issue
Block a user