KMBookletMaskView.swift 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // KMBookletMaskView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by liujiajie on 2023/11/8.
  6. //
  7. import Cocoa
  8. let kIndicatorWidth = 32.0
  9. let kIndicatorHeight = 32.0
  10. class KMBookletMaskView: NSView{
  11. var progressIndicator: NSProgressIndicator?
  12. override init(frame frameRect: NSRect) {
  13. super.init(frame: frameRect)
  14. var indicator = NSProgressIndicator.init(frame: NSRect(x: (frameRect.size.width - kIndicatorWidth)/2, y: (frameRect.size.height - kIndicatorHeight)/2, width: kIndicatorWidth, height: kIndicatorHeight))
  15. indicator.style = .spinning
  16. self.progressIndicator = indicator
  17. indicator.startAnimation(true)
  18. self.addSubview(indicator)
  19. }
  20. required init?(coder: NSCoder) {
  21. super.init(coder: coder)
  22. }
  23. override func draw(_ dirtyRect: NSRect) {
  24. super.draw(dirtyRect)
  25. self.wantsLayer = true
  26. self.layer?.backgroundColor = NSColor.clear.cgColor
  27. }
  28. override func mouseDown(with event: NSEvent) {
  29. }
  30. override func mouseUp(with event: NSEvent) {
  31. }
  32. }