|
@@ -8,14 +8,25 @@
|
|
|
import Cocoa
|
|
|
import KMComponentLibrary
|
|
|
|
|
|
+@objc protocol KMStampListItemDelegate: AnyObject {
|
|
|
+
|
|
|
+ @objc optional func kmStampListItemDelete(_ stampListItem: KMStampListItem)
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
class KMStampListItem: NSCollectionViewItem {
|
|
|
|
|
|
@IBOutlet var bottomBox: NSBox!
|
|
|
@IBOutlet var iconImage: NSImageView!
|
|
|
+ @IBOutlet var deleteButton: ComponentButton!
|
|
|
|
|
|
private var area: NSTrackingArea?
|
|
|
private var isMouseEnter: Bool = false
|
|
|
|
|
|
+ weak open var delegate: KMStampListItemDelegate?
|
|
|
+
|
|
|
+ var stampType: KMStampList_Type = .standard
|
|
|
+
|
|
|
var stampObject: CStampObject?
|
|
|
|
|
|
var signObject: KMSignature?
|
|
@@ -32,6 +43,11 @@ class KMStampListItem: NSCollectionViewItem {
|
|
|
// Do view setup here.
|
|
|
|
|
|
self.updateTrackingArea()
|
|
|
+
|
|
|
+ deleteButton.properties = ComponentButtonProperty(type: .default_tertiary, size: .xxs, onlyIcon: true, icon: NSImage(named: "pageEdit_delete"))
|
|
|
+ deleteButton.isHidden = true
|
|
|
+ deleteButton.setTarget(self, action: #selector(deleteButtonClicked(_:)))
|
|
|
+
|
|
|
}
|
|
|
|
|
|
override var isSelected: Bool {
|
|
@@ -86,8 +102,23 @@ class KMStampListItem: NSCollectionViewItem {
|
|
|
bottomBox.fillColor = NSColor.clear
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if stampType == .custom {
|
|
|
+ if isMouseEnter {
|
|
|
+ deleteButton.isHidden = false
|
|
|
+ } else {
|
|
|
+ deleteButton.isHidden = true
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ deleteButton.isHidden = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @objc func deleteButtonClicked(_ sender: ComponentButton) {
|
|
|
+ delegate?.kmStampListItemDelete?(self)
|
|
|
}
|
|
|
|
|
|
+ //MARK: - Mouse Event
|
|
|
override func mouseEntered(with event: NSEvent) {
|
|
|
super.mouseEntered(with: event)
|
|
|
|