|
@@ -21,8 +21,7 @@ public class ComponentMenuItem: ComponentBaseXibView {
|
|
|
@IBOutlet var separatorDivider: ComponentDivider!
|
|
|
|
|
|
@IBOutlet var titleLabelLeftConst: NSLayoutConstraint!
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
// MARK: Private Property
|
|
|
private var _properties : ComponentMenuitemProperty = ComponentMenuitemProperty()
|
|
|
|
|
@@ -62,37 +61,36 @@ public class ComponentMenuItem: ComponentBaseXibView {
|
|
|
|
|
|
ComponentLibrary.shared.configMenuItemComponent(properties: _properties)
|
|
|
|
|
|
- self.setupUI()
|
|
|
+ setupUI()
|
|
|
|
|
|
- self.refreshUI()
|
|
|
+ refreshUI()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//MARK: - SetupUI
|
|
|
func setupUI() {
|
|
|
- self.contendBox.isHidden = true
|
|
|
- self.separatorBox.isHidden = true
|
|
|
+ contendBox.isHidden = true
|
|
|
+ separatorBox.isHidden = true
|
|
|
|
|
|
- if self.properties.type == .normal {
|
|
|
- self.contendBox.isHidden = false
|
|
|
+ if properties.type == .normal {
|
|
|
+ contendBox.isHidden = false
|
|
|
|
|
|
- } else if self.properties.type == .divider {
|
|
|
- self.separatorBox.isHidden = false
|
|
|
- self.separatorBox.borderWidth = 0
|
|
|
- self.separatorBox.borderColor = NSColor.clear
|
|
|
- self.separatorBox.fillColor = NSColor.clear
|
|
|
+ } else if properties.type == .divider {
|
|
|
+ separatorBox.isHidden = false
|
|
|
+ separatorBox.borderWidth = 0
|
|
|
+ separatorBox.borderColor = NSColor.clear
|
|
|
+ separatorBox.fillColor = NSColor.clear
|
|
|
|
|
|
let property: ComponentDividerProperty = ComponentDividerProperty(type: .horizontal, dash: false)
|
|
|
- self.separatorDivider.properties = property
|
|
|
+ separatorDivider.properties = property
|
|
|
|
|
|
- } else if self.properties.type == .header {
|
|
|
+ } else if properties.type == .header {
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
let checkboxProperties: ComponentCheckBoxProperty = ComponentCheckBoxProperty.init(size: .m,
|
|
|
state: .normal,
|
|
|
- isDisabled: self.properties.isDisabled,
|
|
|
+ isDisabled: properties.isDisabled,
|
|
|
showhelp: false,
|
|
|
text: nil,
|
|
|
checkboxType: .normal)
|
|
@@ -100,7 +98,7 @@ public class ComponentMenuItem: ComponentBaseXibView {
|
|
|
checkBox.properties = checkboxProperties
|
|
|
|
|
|
|
|
|
- checkBox.properties.isDisabled = self.properties.isDisabled
|
|
|
+ checkBox.properties.isDisabled = properties.isDisabled
|
|
|
checkBox.reloadData()
|
|
|
|
|
|
if properties.lefticon != nil {
|
|
@@ -123,79 +121,65 @@ public class ComponentMenuItem: ComponentBaseXibView {
|
|
|
righticonImage.isHidden = true
|
|
|
}
|
|
|
|
|
|
- if self.properties.keyEquivalent != nil &&
|
|
|
- self.properties.keyEquivalent?.isEmpty == false {
|
|
|
- self.keyEquivalentLabel.isHidden = false
|
|
|
+ if properties.keyEquivalent != nil &&
|
|
|
+ properties.keyEquivalent?.isEmpty == false {
|
|
|
+ keyEquivalentLabel.isHidden = false
|
|
|
} else {
|
|
|
- self.keyEquivalentLabel.isHidden = true
|
|
|
+ keyEquivalentLabel.isHidden = true
|
|
|
}
|
|
|
|
|
|
- if self.properties.multipleSelect == true {
|
|
|
- self.checkBox.isHidden = false
|
|
|
- self.leftIconImage.isHidden = true
|
|
|
- self.righticonImage.isHidden = true
|
|
|
- self.titleLabelLeftConst.constant = 40
|
|
|
+ if properties.multipleSelect == true {
|
|
|
+ checkBox.isHidden = false
|
|
|
+ leftIconImage.isHidden = true
|
|
|
+ righticonImage.isHidden = true
|
|
|
+ titleLabelLeftConst.constant = 40
|
|
|
} else {
|
|
|
- self.checkBox.isHidden = true
|
|
|
+ checkBox.isHidden = true
|
|
|
}
|
|
|
|
|
|
- self.properties.propertyInfo.viewWidth = 200
|
|
|
-
|
|
|
- self.titleLabel.stringValue = self.properties.text
|
|
|
+ properties.propertyInfo.viewWidth = 200
|
|
|
+
|
|
|
+ titleLabel.stringValue = properties.text
|
|
|
}
|
|
|
|
|
|
func refreshUI() {
|
|
|
|
|
|
- if self.properties.itemSelected == true {
|
|
|
- self.checkBox.properties.checkboxType = .selected
|
|
|
- self.checkBox.refreshUI()
|
|
|
+ if properties.itemSelected == true {
|
|
|
+ checkBox.properties.checkboxType = .selected
|
|
|
+ checkBox.refreshUI()
|
|
|
} else {
|
|
|
- self.checkBox.properties.checkboxType = .normal
|
|
|
- self.checkBox.refreshUI()
|
|
|
+ checkBox.properties.checkboxType = .normal
|
|
|
+ checkBox.refreshUI()
|
|
|
}
|
|
|
|
|
|
- self.contendBox.borderWidth = 0
|
|
|
- self.contendBox.borderColor = NSColor.clear
|
|
|
+ contendBox.borderWidth = 0
|
|
|
+ contendBox.borderColor = NSColor.clear
|
|
|
|
|
|
- var fillColor = self.properties.propertyInfo.color_nor
|
|
|
- var textColor = self.properties.propertyInfo.textColor
|
|
|
- var leftIconImg = self.properties.propertyInfo.leftIconImage_nor
|
|
|
- var rightIconImg = self.properties.propertyInfo.rightIconImage_nor
|
|
|
+ var fillColor = properties.propertyInfo.color_nor
|
|
|
+ var textColor = properties.propertyInfo.textColor
|
|
|
|
|
|
- if self.properties.state == .hover {
|
|
|
- fillColor = self.properties.propertyInfo.color_hov
|
|
|
- leftIconImg = self.properties.propertyInfo.leftIconImage_hov
|
|
|
- rightIconImg = self.properties.propertyInfo.rightIconImage_hov
|
|
|
+ if properties.state == .hover {
|
|
|
+ fillColor = properties.propertyInfo.color_hov
|
|
|
}
|
|
|
- if self.properties.itemSelected == true {
|
|
|
- fillColor = self.properties.propertyInfo.color_active
|
|
|
+ if properties.itemSelected == true {
|
|
|
+ fillColor = properties.propertyInfo.color_active
|
|
|
}
|
|
|
|
|
|
- if self.properties.isDisabled == true {
|
|
|
- fillColor = self.properties.propertyInfo.color_dis
|
|
|
- textColor = self.properties.propertyInfo.textColor_dis
|
|
|
- leftIconImg = self.properties.propertyInfo.leftIconImage_dis
|
|
|
- rightIconImg = self.properties.propertyInfo.rightIconImage_dis
|
|
|
+ if properties.isDisabled == true {
|
|
|
+ fillColor = properties.propertyInfo.color_dis
|
|
|
+ textColor = properties.propertyInfo.textColor_dis
|
|
|
}
|
|
|
|
|
|
- self.contendBox.fillColor = fillColor
|
|
|
-
|
|
|
- self.titleLabel.textColor = textColor
|
|
|
+ contendBox.fillColor = fillColor
|
|
|
|
|
|
- if let image = leftIconImg {
|
|
|
- self.leftIconImage.image = image
|
|
|
- }
|
|
|
-
|
|
|
- if let image = rightIconImg {
|
|
|
- self.righticonImage.image = image
|
|
|
- }
|
|
|
+ titleLabel.textColor = textColor
|
|
|
|
|
|
- self.titleLabel.font = properties.propertyInfo.textFont
|
|
|
- self.keyEquivalentLabel.font = properties.propertyInfo.textFont
|
|
|
+ titleLabel.font = properties.propertyInfo.textFont
|
|
|
+ keyEquivalentLabel.font = properties.propertyInfo.textFont
|
|
|
|
|
|
- self.keyEquivalentLabel.textColor = properties.propertyInfo.keyEquivalent_textColor
|
|
|
+ keyEquivalentLabel.textColor = properties.propertyInfo.keyEquivalent_textColor
|
|
|
|
|
|
- self.keyEquivalentLabel.stringValue = properties.keyEquivalent ?? ""
|
|
|
+ keyEquivalentLabel.stringValue = properties.keyEquivalent ?? ""
|
|
|
|
|
|
}
|
|
|
|
|
@@ -208,14 +192,14 @@ public class ComponentMenuItem: ComponentBaseXibView {
|
|
|
public override func mouseEntered(with event: NSEvent) {
|
|
|
super.mouseEntered(with: event)
|
|
|
|
|
|
- if self.properties.isDisabled == false &&
|
|
|
- self.properties.itemSelected == false {
|
|
|
+ if properties.isDisabled == false &&
|
|
|
+ properties.itemSelected == false {
|
|
|
|
|
|
- self.properties.state = .hover
|
|
|
+ properties.state = .hover
|
|
|
}
|
|
|
- self.refreshUI()
|
|
|
+ refreshUI()
|
|
|
|
|
|
- guard let callBack = self.mouseHandle else {
|
|
|
+ guard let callBack = mouseHandle else {
|
|
|
return
|
|
|
}
|
|
|
callBack(self, .enter, event)
|
|
@@ -224,7 +208,7 @@ public class ComponentMenuItem: ComponentBaseXibView {
|
|
|
public override func mouseMoved(with event: NSEvent) {
|
|
|
super.mouseMoved(with: event)
|
|
|
|
|
|
- guard let callBack = self.mouseHandle else {
|
|
|
+ guard let callBack = mouseHandle else {
|
|
|
return
|
|
|
}
|
|
|
callBack(self, .move, event)
|
|
@@ -233,14 +217,14 @@ public class ComponentMenuItem: ComponentBaseXibView {
|
|
|
public override func mouseExited(with event: NSEvent) {
|
|
|
super.mouseExited(with: event)
|
|
|
|
|
|
- if self.properties.isDisabled == false &&
|
|
|
- self.properties.itemSelected == false {
|
|
|
- self.properties.state = .normal
|
|
|
+ if properties.isDisabled == false &&
|
|
|
+ properties.itemSelected == false {
|
|
|
+ properties.state = .normal
|
|
|
}
|
|
|
|
|
|
- self.refreshUI()
|
|
|
+ refreshUI()
|
|
|
|
|
|
- guard let callBack = self.mouseHandle else {
|
|
|
+ guard let callBack = mouseHandle else {
|
|
|
return
|
|
|
}
|
|
|
callBack(self, .exit, event)
|
|
@@ -248,14 +232,14 @@ public class ComponentMenuItem: ComponentBaseXibView {
|
|
|
|
|
|
public override func mouseDown(with event: NSEvent) {
|
|
|
|
|
|
- if self.properties.isDisabled == false {
|
|
|
- if self.properties.itemSelected == true {
|
|
|
- self.properties.itemSelected = false
|
|
|
+ if properties.isDisabled == false {
|
|
|
+ if properties.itemSelected == true {
|
|
|
+ properties.itemSelected = false
|
|
|
} else {
|
|
|
- self.properties.itemSelected = true
|
|
|
+ properties.itemSelected = true
|
|
|
}
|
|
|
}
|
|
|
- self.refreshUI()
|
|
|
+ refreshUI()
|
|
|
|
|
|
}
|
|
|
|