|
@@ -15,11 +15,11 @@ import AppKit
|
|
|
@objc optional func componentSelectZoomDidReduce(view: ComponentSelectZoom)
|
|
|
|
|
|
@objc optional func componentSelectZoomDidAdd(view: ComponentSelectZoom)
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public class ComponentSelectZoom: ComponentBaseXibView {
|
|
|
-
|
|
|
+
|
|
|
@IBOutlet var contendBox: NSBox!
|
|
|
@IBOutlet var reduceButton: ComponentButton!
|
|
|
@IBOutlet var addButton: ComponentButton!
|
|
@@ -29,11 +29,9 @@ public class ComponentSelectZoom: ComponentBaseXibView {
|
|
|
|
|
|
// MARK: Private Property
|
|
|
private var _properties : ComponentSelectZoomProperty = ComponentSelectZoomProperty()
|
|
|
-
|
|
|
- private var menuitemPropertys: [ComponentMenuitemProperty] = []
|
|
|
-
|
|
|
+
|
|
|
private var selItemProperty: ComponentMenuitemProperty? = ComponentMenuitemProperty()
|
|
|
-
|
|
|
+
|
|
|
private var isGroupViewShow: Bool = false
|
|
|
|
|
|
private var groupView: ComponentGroup!
|
|
@@ -66,31 +64,14 @@ public class ComponentSelectZoom: ComponentBaseXibView {
|
|
|
contendBox.fillColor = NSColor.clear
|
|
|
|
|
|
reduceButton.properties = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, state: .normal, onlyIcon: true)
|
|
|
- reduceButton.properties.propertyInfo.leftIcon_nor = ComponentLibrary.shared.image(forResource: "reduce")
|
|
|
- reduceButton.properties.propertyInfo.leftIcon_dis = ComponentLibrary.shared.image(forResource: "reduce_dis")
|
|
|
- reduceButton.reloadData()
|
|
|
reduceButton.setTarget(self, action: #selector(reductButtonClick(_ :)))
|
|
|
|
|
|
addButton.properties = ComponentButtonProperty(type: .text_gray_opacity, size: .xs, state: .normal, onlyIcon: true)
|
|
|
- addButton.properties.propertyInfo.leftIcon_nor = ComponentLibrary.shared.image(forResource: "add")
|
|
|
- addButton.properties.propertyInfo.leftIcon_dis = ComponentLibrary.shared.image(forResource: "add_dis")
|
|
|
- addButton.reloadData()
|
|
|
addButton.setTarget(self, action: #selector(addButtonClick(_ :)))
|
|
|
|
|
|
infoBox.borderWidth = 0
|
|
|
infoBox.borderColor = NSColor.clear
|
|
|
|
|
|
- var menuItemArr: [ComponentMenuitemProperty] = []
|
|
|
- for i in 0...5 {
|
|
|
- let properties_Menuitem: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false,
|
|
|
- itemSelected: false,
|
|
|
- isDisabled: false,
|
|
|
- keyEquivalent: nil,
|
|
|
- text: "menu item - " + String(i))
|
|
|
- menuItemArr.append(properties_Menuitem)
|
|
|
- }
|
|
|
- self.updateMenuItemsArr(menuItemArr)
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//Setter
|
|
@@ -103,34 +84,48 @@ public class ComponentSelectZoom: ComponentBaseXibView {
|
|
|
|
|
|
ComponentLibrary.shared.configSelectZoomComponent(properties: _properties)
|
|
|
|
|
|
- self.reloadData()
|
|
|
-
|
|
|
+ reloadData()
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//MARK: - Public
|
|
|
public func reloadData() {
|
|
|
+ setupUI()
|
|
|
|
|
|
- self.setupUI()
|
|
|
-
|
|
|
- self.refreshUI()
|
|
|
- }
|
|
|
-
|
|
|
- public func updateMenuItemsArr(_ propertys: [ComponentMenuitemProperty]) {
|
|
|
- self.menuitemPropertys = propertys
|
|
|
-
|
|
|
+ refreshUI()
|
|
|
}
|
|
|
+
|
|
|
|
|
|
public func updatePropertyText(_ text: String) {
|
|
|
properties.text = text
|
|
|
|
|
|
- self.refreshUI()
|
|
|
+ refreshUI()
|
|
|
|
|
|
}
|
|
|
|
|
|
//MARK: - SetupUI
|
|
|
func setupUI() {
|
|
|
|
|
|
+ if let image = properties.leftIcon_nor {
|
|
|
+ reduceButton.properties.propertyInfo.leftIcon_nor = image
|
|
|
+ }
|
|
|
+ if let image = properties.leftIcon_dis {
|
|
|
+ reduceButton.properties.propertyInfo.leftIcon_dis = image
|
|
|
+ }
|
|
|
+ if let image = properties.dropdownIcon {
|
|
|
+ dropdownImage.image = image
|
|
|
+ }
|
|
|
+ if let image = properties.rightIcon_nor {
|
|
|
+ addButton.properties.propertyInfo.leftIcon_nor = image
|
|
|
+ }
|
|
|
+ if let image = properties.rightIcon_dis {
|
|
|
+ addButton.properties.propertyInfo.leftIcon_dis = image
|
|
|
+ }
|
|
|
+
|
|
|
+ reduceButton.reloadData()
|
|
|
+
|
|
|
+ addButton.reloadData()
|
|
|
}
|
|
|
|
|
|
func refreshUI() {
|
|
@@ -152,10 +147,11 @@ public class ComponentSelectZoom: ComponentBaseXibView {
|
|
|
infoColor = properties.propertyInfo.color_dis
|
|
|
infoLabel.textColor = properties.propertyInfo.textColor_dis
|
|
|
}
|
|
|
+ infoLabel.stringValue = properties.text
|
|
|
|
|
|
infoBox.fillColor = infoColor
|
|
|
infoBox.cornerRadius = properties.propertyInfo.cornerRadius
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
func showGroupView() {
|
|
@@ -164,7 +160,7 @@ public class ComponentSelectZoom: ComponentBaseXibView {
|
|
|
}
|
|
|
|
|
|
var viewHeight: CGFloat = 8.0
|
|
|
- for item in self.menuitemPropertys {
|
|
|
+ for item in properties.menuItemArr {
|
|
|
item.state = .normal
|
|
|
item.itemSelected = false
|
|
|
if item == selItemProperty {
|
|
@@ -184,77 +180,78 @@ public class ComponentSelectZoom: ComponentBaseXibView {
|
|
|
groupView?.reloadData()
|
|
|
groupView.groupDelegate = self
|
|
|
groupView?.show(relativeTo: self)
|
|
|
- groupView?.updateGroupInfo(menuitemPropertys)
|
|
|
- self.isGroupViewShow = true
|
|
|
+ groupView?.updateGroupInfo(properties.menuItemArr)
|
|
|
+
|
|
|
+ isGroupViewShow = true
|
|
|
}
|
|
|
|
|
|
func hideGroupView() {
|
|
|
- self.groupView?.removeGroupView()
|
|
|
+ groupView?.removeGroupView()
|
|
|
|
|
|
- self.isGroupViewShow = false
|
|
|
+ isGroupViewShow = false
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@objc func reductButtonClick(_ sender: ComponentButton) {
|
|
|
- self.delegate?.componentSelectZoomDidReduce?(view: self)
|
|
|
+ delegate?.componentSelectZoomDidReduce?(view: self)
|
|
|
}
|
|
|
|
|
|
@objc func addButtonClick(_ sender: ComponentButton) {
|
|
|
- self.delegate?.componentSelectZoomDidAdd?(view: self)
|
|
|
+ delegate?.componentSelectZoomDidAdd?(view: self)
|
|
|
}
|
|
|
|
|
|
//MARK: - MouseEvent
|
|
|
public override func mouseEntered(with event: NSEvent) {
|
|
|
super.mouseEntered(with: event)
|
|
|
|
|
|
- self.refreshUI()
|
|
|
+ refreshUI()
|
|
|
}
|
|
|
|
|
|
public override func mouseMoved(with event: NSEvent) {
|
|
|
super.mouseMoved(with: event)
|
|
|
|
|
|
- if self.properties.isDisabled == false &&
|
|
|
+ if properties.isDisabled == false &&
|
|
|
properties.state != .pressed {
|
|
|
- let point = self.convert(event.locationInWindow, from: nil)
|
|
|
- if CGRectContainsPoint(self.infoBox.frame, point) {
|
|
|
- self.properties.state = .hover
|
|
|
+ let point = convert(event.locationInWindow, from: nil)
|
|
|
+ if CGRectContainsPoint(infoBox.frame, point) {
|
|
|
+ properties.state = .hover
|
|
|
} else {
|
|
|
properties.state = .normal
|
|
|
}
|
|
|
- self.refreshUI()
|
|
|
+ refreshUI()
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public override func mouseExited(with event: NSEvent) {
|
|
|
super.mouseExited(with: event)
|
|
|
|
|
|
- if self.properties.isDisabled == false &&
|
|
|
+ if properties.isDisabled == false &&
|
|
|
properties.state != .pressed {
|
|
|
- self.properties.state = .normal
|
|
|
+ properties.state = .normal
|
|
|
}
|
|
|
|
|
|
- self.refreshUI()
|
|
|
+ refreshUI()
|
|
|
}
|
|
|
|
|
|
public override func mouseDown(with event: NSEvent) {
|
|
|
super.mouseDown(with: event)
|
|
|
|
|
|
- if self.properties.isDisabled == false {
|
|
|
- let point = self.convert(event.locationInWindow, from: nil)
|
|
|
- if CGRectContainsPoint(self.infoBox.frame, point) {
|
|
|
- self.properties.state = .pressed
|
|
|
+ if properties.isDisabled == false {
|
|
|
+ let point = convert(event.locationInWindow, from: nil)
|
|
|
+ if CGRectContainsPoint(infoBox.frame, point) {
|
|
|
+ properties.state = .pressed
|
|
|
|
|
|
- self.showGroupView()
|
|
|
+ showGroupView()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- self.refreshUI()
|
|
|
+ refreshUI()
|
|
|
|
|
|
}
|
|
|
|
|
|
public override func mouseUp(with event: NSEvent) {
|
|
|
super.mouseUp(with: event)
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -262,24 +259,24 @@ public class ComponentSelectZoom: ComponentBaseXibView {
|
|
|
|
|
|
extension ComponentSelectZoom: ComponentGroupDelegate {
|
|
|
public func componentGroupDidDismiss(group: ComponentGroup?) {
|
|
|
- self.properties.state = .normal
|
|
|
+ properties.state = .normal
|
|
|
|
|
|
- self.isGroupViewShow = false
|
|
|
+ isGroupViewShow = false
|
|
|
|
|
|
- self.hideGroupView()
|
|
|
-
|
|
|
- self.refreshUI()
|
|
|
+ hideGroupView()
|
|
|
+
|
|
|
+ refreshUI()
|
|
|
}
|
|
|
|
|
|
public func componentGroupDidSelect(group: ComponentGroup?, menuItemProperty: ComponentMenuitemProperty?) {
|
|
|
- self.infoLabel.stringValue = menuItemProperty?.text ?? ""
|
|
|
+ properties.text = menuItemProperty?.text ?? ""
|
|
|
+
|
|
|
+ properties.state = .normal
|
|
|
|
|
|
- self.properties.state = .normal
|
|
|
+ refreshUI()
|
|
|
|
|
|
- self.refreshUI()
|
|
|
+ selItemProperty = menuItemProperty
|
|
|
|
|
|
- self.selItemProperty = menuItemProperty
|
|
|
-
|
|
|
- self.delegate?.componentSelectZoomDidSelect?(view: self, menuItemProperty: selItemProperty)
|
|
|
+ delegate?.componentSelectZoomDidSelect?(view: self, menuItemProperty: selItemProperty)
|
|
|
}
|
|
|
}
|