KMLiftSideCellView.swift 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // KMBookCellView.swift
  3. // PDF Master
  4. //
  5. // Created by lxy on 2022/11/14.
  6. //
  7. import Cocoa
  8. class KMLiftSideCellView: NSTableCellView {
  9. var box: KMBox?
  10. typealias selectClick = (_ index: Int) -> ()
  11. @IBOutlet weak var mothedImage: NSImageView!
  12. var buttonClick: selectClick?
  13. var index = 0
  14. var isSelect: Bool = false
  15. override func awakeFromNib() {
  16. super.awakeFromNib()
  17. self.addBox()
  18. }
  19. override func draw(_ dirtyRect: NSRect) {
  20. super.draw(dirtyRect)
  21. }
  22. @IBAction func updateLeftStyle(_ sender: Any) {
  23. self.buttonClick?(index)
  24. }
  25. func addBox() {
  26. if self.box == nil {
  27. self.box?.wantsLayer = true
  28. self.box = KMBox(frame: self.bounds)
  29. self.box?.borderWidth = 0
  30. self.box?.boxType = .custom
  31. self.addSubview(self.box!)
  32. self.box?.moveCallback = { [unowned self] (mouseEntered, mouseBox) in
  33. if mouseEntered {
  34. self.backgroundColor(NSColor(hex: "#DFE1E5"))
  35. } else {
  36. if !isSelect {
  37. self.backgroundColor(NSColor.clear)
  38. }
  39. }
  40. }
  41. self.box?.autoresizingMask = [.width, .height]
  42. } else {
  43. self.box!.frame = self.bounds
  44. }
  45. }
  46. }