mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: added releasing all processes when closing the popup view
This commit is contained in:
@@ -893,7 +893,7 @@ public class ProcessView: NSStackView {
|
||||
self.toolTip = ""
|
||||
}
|
||||
|
||||
private func setLock(_ state: Bool) {
|
||||
public func setLock(_ state: Bool) {
|
||||
self.lock = state
|
||||
if self.lock {
|
||||
self.imageView.isHidden = true
|
||||
|
||||
@@ -14,11 +14,16 @@ import Cocoa
|
||||
public protocol Popup_p: NSView {
|
||||
var sizeCallback: ((NSSize) -> Void)? { get set }
|
||||
func settings() -> NSView?
|
||||
|
||||
func appear()
|
||||
func disappear()
|
||||
}
|
||||
|
||||
open class PopupWrapper: NSStackView, Popup_p {
|
||||
open var sizeCallback: ((NSSize) -> Void)? = nil
|
||||
open func settings() -> NSView? { return nil }
|
||||
open func appear() {}
|
||||
open func disappear() {}
|
||||
}
|
||||
|
||||
public class PopupWindow: NSWindow, NSWindowDelegate {
|
||||
@@ -124,6 +129,7 @@ internal class PopupViewController: NSViewController {
|
||||
|
||||
internal class PopupView: NSView {
|
||||
private var title: String? = nil
|
||||
private var view: Popup_p? = nil
|
||||
|
||||
private var foreground: NSVisualEffectView
|
||||
private var background: NSView
|
||||
@@ -189,6 +195,8 @@ internal class PopupView: NSView {
|
||||
}
|
||||
|
||||
public func setView(_ view: Popup_p?) {
|
||||
self.view = view
|
||||
|
||||
let width: CGFloat = (view?.frame.width ?? Constants.Popup.width) + (Constants.Popup.margins*2)
|
||||
let height: CGFloat = (view?.frame.height ?? 0) + Constants.Popup.headerHeight + (Constants.Popup.margins*2)
|
||||
|
||||
@@ -228,9 +236,12 @@ internal class PopupView: NSView {
|
||||
if let documentView = self.body.documentView {
|
||||
documentView.scroll(NSPoint(x: 0, y: documentView.bounds.size.height))
|
||||
}
|
||||
|
||||
self.view?.appear()
|
||||
}
|
||||
internal func disappear() {
|
||||
self.header.setCloseButton(false)
|
||||
self.view?.disappear()
|
||||
}
|
||||
|
||||
private func recalculateHeight(_ size: NSSize) {
|
||||
|
||||
@@ -108,6 +108,10 @@ internal class Popup: PopupWrapper {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
public override func disappear() {
|
||||
self.processes.forEach{ $0.setLock(false) }
|
||||
}
|
||||
|
||||
public func numberOfProcessesUpdated() {
|
||||
if self.processes.count == self.numberOfProcesses {
|
||||
return
|
||||
|
||||
@@ -175,6 +175,10 @@ internal class Popup: PopupWrapper {
|
||||
self.lineChart?.display()
|
||||
}
|
||||
|
||||
public override func disappear() {
|
||||
self.processes.forEach{ $0.setLock(false) }
|
||||
}
|
||||
|
||||
public func numberOfProcessesUpdated() {
|
||||
if self.processes.count == self.numberOfProcesses {
|
||||
return
|
||||
|
||||
@@ -139,6 +139,10 @@ internal class Popup: PopupWrapper {
|
||||
self.chart?.display()
|
||||
}
|
||||
|
||||
public override func disappear() {
|
||||
self.processes.forEach{ $0.setLock(false) }
|
||||
}
|
||||
|
||||
public func numberOfProcessesUpdated() {
|
||||
if self.processes.count == self.numberOfProcesses {
|
||||
return
|
||||
|
||||
@@ -154,6 +154,8 @@ private class Popup: NSStackView, Popup_p {
|
||||
}
|
||||
|
||||
public func settings() -> NSView? { return nil }
|
||||
public func appear() {}
|
||||
public func disappear() {}
|
||||
|
||||
@objc private func reinit() {
|
||||
self.subviews.forEach({ $0.removeFromSuperview() })
|
||||
|
||||
Reference in New Issue
Block a user