Browse Source

【2025】【组件库】组件库完善

niehaoyu 4 months ago
parent
commit
d294b5dae0

+ 120 - 47
PDF Office/KMComponentLibrary/KMComponentLibrary/View/Button/ComponentButton.swift

@@ -35,6 +35,76 @@ public class ComponentButton: ComponentBaseXibView {
     open var keyEquivalentModifierMask: NSEvent.ModifierFlags = NSEvent.ModifierFlags()
     open var keyEquivalentModifierMask: NSEvent.ModifierFlags = NSEvent.ModifierFlags()
     
     
     // MARK: - 初始化
     // MARK: - 初始化
+    public override func draw(_ dirtyRect: NSRect) {
+        super.draw(dirtyRect)
+        
+        var fillColor =  properties.propertyInfo.color_nor
+        var borderWidth = properties.propertyInfo.borderWidth
+        var borderColor = properties.propertyInfo.borderColor_nor
+        
+        if properties.state == .normal {
+            
+        } else if properties.state == .hover {
+            fillColor = properties.propertyInfo.color_hov
+            borderWidth = properties.propertyInfo.borderWidth_hov
+            borderColor = properties.propertyInfo.borderColor_hov
+        } else if properties.state == .pressed {
+            fillColor = properties.propertyInfo.color_active
+            borderWidth = properties.propertyInfo.borderWidth_active
+            borderColor = properties.propertyInfo.borderColor_active
+        }
+        if properties.isDisabled == true {
+            fillColor = properties.propertyInfo.color_dis
+            borderWidth = properties.propertyInfo.borderWidth
+            borderColor = properties.propertyInfo.borderColor_dis
+        }
+        
+        let cornerRadius_topLeft: CGFloat = properties.propertyInfo.cornerRadius_topLeft
+        let cornerRadius_topRight: CGFloat = properties.propertyInfo.cornerRadius_topRight
+        let cornerRadius_bottomLeft: CGFloat = properties.propertyInfo.cornerRadius_bottomLeft
+        let cornerRadius_bottomRight: CGFloat = properties.propertyInfo.cornerRadius_bottomRight
+
+        let drawBounds = bounds.insetBy(dx: 1, dy: 1)
+        
+        let path = NSBezierPath()
+        path.lineWidth = borderWidth + 1
+        
+        path.move(to: NSPoint(x: drawBounds.minX + cornerRadius_bottomLeft, y: drawBounds.minY))
+        if cornerRadius_bottomLeft > 0 {
+            path.appendArc(from: NSPoint(x: drawBounds.minX + cornerRadius_bottomLeft, y: drawBounds.minY), to: NSPoint(x: drawBounds.minX + cornerRadius_bottomLeft, y: drawBounds.minY), radius: cornerRadius_bottomLeft) //左下角
+        }
+        
+        if cornerRadius_bottomRight > 0 {
+            path.appendArc(from: NSPoint(x: drawBounds.maxX, y: drawBounds.minY), to: NSPoint(x: drawBounds.maxX, y: drawBounds.minY + cornerRadius_bottomRight), radius: cornerRadius_bottomRight) //右下角
+        } else {
+            path.line(to: NSPoint(x: drawBounds.maxX, y: drawBounds.minY))
+        }
+        
+        if cornerRadius_topRight > 0 {
+            path.appendArc(from: NSPoint(x: drawBounds.maxX, y: drawBounds.maxY), to: NSPoint(x: drawBounds.maxX - cornerRadius_topRight, y: drawBounds.maxY), radius: cornerRadius_topRight) // 右上角
+        } else {
+            path.line(to: NSPoint(x: drawBounds.maxX, y: drawBounds.maxY))
+        }
+        
+        if cornerRadius_topLeft > 0 {
+            path.appendArc(from: NSPoint(x: drawBounds.minX, y: drawBounds.maxY), to: NSPoint(x: drawBounds.minX, y: drawBounds.maxY - cornerRadius_topLeft), radius: cornerRadius_topLeft) //左上角
+        } else {
+            path.line(to: NSPoint(x: drawBounds.minX, y: drawBounds.maxY))
+        }
+        
+        if cornerRadius_bottomLeft > 0 {
+            path.appendArc(from: NSPoint(x: drawBounds.minX, y: drawBounds.minY), to: NSPoint(x: drawBounds.minX + cornerRadius_bottomLeft, y: drawBounds.minY), radius: cornerRadius_bottomLeft) //左下角
+        } else {
+            path.line(to: NSPoint(x: drawBounds.minX, y: drawBounds.minY))
+        }
+        
+        borderColor.setStroke()
+        path.stroke()
+        path.close()
+        fillColor.setFill()
+        path.fill()
+        
+    }
     
     
     public required init?(coder decoder: NSCoder) {
     public required init?(coder decoder: NSCoder) {
         super.init(coder: decoder)
         super.init(coder: decoder)
@@ -47,8 +117,14 @@ public class ComponentButton: ComponentBaseXibView {
     
     
     public override func awakeFromNib() {
     public override func awakeFromNib() {
         super.awakeFromNib()
         super.awakeFromNib()
-
+        
         label.wantsLayer = true
         label.wantsLayer = true
+        
+        contendBox.fillColor = NSColor.clear
+        contendBox.borderColor = NSColor.clear
+        contendBox.cornerRadius = 0
+        contendBox.borderWidth = 0
+        
     }
     }
     
     
     
     
@@ -66,49 +142,39 @@ public class ComponentButton: ComponentBaseXibView {
             reloadData()
             reloadData()
         }
         }
     }
     }
-     
     
     
     //MARK: - setupUI
     //MARK: - setupUI
     
     
     func setupUI() {
     func setupUI() {
-       leftIcon.isHidden = true
-       label.isHidden = true
-       rightIcon.isHidden = true
+        leftIcon.isHidden = true
+        label.isHidden = true
+        rightIcon.isHidden = true
         
         
         if properties.onlyIcon == true {
         if properties.onlyIcon == true {
             leftIcon.isHidden = false
             leftIcon.isHidden = false
         } else {
         } else {
-           label.isHidden = false
+            label.isHidden = false
             if properties.showLeftIcon == true &&
             if properties.showLeftIcon == true &&
                 properties.showRightIcon == true {
                 properties.showRightIcon == true {
-                
-                 leftIcon.isHidden = false
-                 rightIcon.isHidden = false
-                
+                leftIcon.isHidden = false
+                rightIcon.isHidden = false
             } else if properties.showLeftIcon == true &&
             } else if properties.showLeftIcon == true &&
                         properties.showRightIcon == false {
                         properties.showRightIcon == false {
-              leftIcon.isHidden = false
-                
-            } else if properties.showLeftIcon == false && 
+                leftIcon.isHidden = false
+            } else if properties.showLeftIcon == false &&
                         properties.showRightIcon == true {
                         properties.showRightIcon == true {
                 rightIcon.isHidden = false
                 rightIcon.isHidden = false
-                
-            } else {
-                
             }
             }
         }
         }
     }
     }
     
     
     func refreshUI() {
     func refreshUI() {
-        var fillColor =  properties.propertyInfo.color_nor
-        var borderWidth = properties.propertyInfo.borderWidth
-        var borderColor = properties.propertyInfo.borderColor_nor
         
         
         var textColor = properties.propertyInfo.textColor
         var textColor = properties.propertyInfo.textColor
         
         
         var leftImage = properties.icon
         var leftImage = properties.icon
         var rightImage = properties.icon
         var rightImage = properties.icon
-
+        
         if properties.state == .normal {
         if properties.state == .normal {
             if let image = properties.propertyInfo.leftIcon_nor {
             if let image = properties.propertyInfo.leftIcon_nor {
                 leftImage = image
                 leftImage = image
@@ -117,38 +183,49 @@ public class ComponentButton: ComponentBaseXibView {
                 rightImage = image
                 rightImage = image
             }
             }
         } else if properties.state == .hover {
         } else if properties.state == .hover {
-            fillColor = properties.propertyInfo.color_hov
-            borderWidth = properties.propertyInfo.borderWidth_hov
-            borderColor = properties.propertyInfo.borderColor_hov
             textColor = properties.propertyInfo.textColor_hov
             textColor = properties.propertyInfo.textColor_hov
-            
             if let image = properties.propertyInfo.leftIcon_hov {
             if let image = properties.propertyInfo.leftIcon_hov {
                 leftImage = image
                 leftImage = image
+            } else {
+                if let image = properties.propertyInfo.leftIcon_nor?.filled(with: textColor) {
+                    leftImage = image
+                } else if let image = properties.icon?.filled(with: textColor) {
+                    leftImage = image
+                }
             }
             }
             if let image = properties.propertyInfo.rightIcon_hov {
             if let image = properties.propertyInfo.rightIcon_hov {
                 rightImage = image
                 rightImage = image
+            } else {
+                if let image = properties.propertyInfo.rightIcon_nor?.filled(with: textColor) {
+                    rightImage = image
+                } else if let image = properties.icon?.filled(with: textColor) {
+                    rightImage = image
+                }
             }
             }
-
         } else if properties.state == .pressed {
         } else if properties.state == .pressed {
-            fillColor = properties.propertyInfo.color_active
-            borderWidth = properties.propertyInfo.borderWidth_active
-            borderColor = properties.propertyInfo.borderColor_active
             textColor = properties.propertyInfo.textColor_Active
             textColor = properties.propertyInfo.textColor_Active
-            
             if let image = properties.propertyInfo.leftIcon_press {
             if let image = properties.propertyInfo.leftIcon_press {
                 leftImage = image
                 leftImage = image
+            } else {
+                if let image = properties.propertyInfo.leftIcon_nor?.filled(with: textColor) {
+                    leftImage = image
+                } else if let image = properties.icon?.filled(with: textColor) {
+                    leftImage = image
+                }
             }
             }
+            
             if let image = properties.propertyInfo.rightIcon_press {
             if let image = properties.propertyInfo.rightIcon_press {
                 rightImage = image
                 rightImage = image
+            } else {
+                if let image = properties.propertyInfo.rightIcon_nor?.filled(with: textColor) {
+                    rightImage = image
+                } else if let image = properties.icon?.filled(with: textColor) {
+                    rightImage = image
+                }
             }
             }
-            
         }
         }
         if properties.isDisabled == true {
         if properties.isDisabled == true {
-            fillColor = properties.propertyInfo.color_dis
-            borderWidth = properties.propertyInfo.borderWidth
-            borderColor = properties.propertyInfo.borderColor_dis
             textColor = properties.propertyInfo.textColor_dis
             textColor = properties.propertyInfo.textColor_dis
-            
             if let image = properties.propertyInfo.leftIcon_dis {
             if let image = properties.propertyInfo.leftIcon_dis {
                 leftImage = image
                 leftImage = image
             } else {
             } else {
@@ -160,18 +237,17 @@ public class ComponentButton: ComponentBaseXibView {
             }
             }
             if let image = properties.propertyInfo.rightIcon_dis {
             if let image = properties.propertyInfo.rightIcon_dis {
                 rightImage = image
                 rightImage = image
+            } else {
+                if let image = properties.propertyInfo.rightIcon_nor?.filled(with: textColor) {
+                    rightImage = image
+                } else if let image = properties.icon?.filled(with: textColor) {
+                    rightImage = image
+                }
             }
             }
         }
         }
-         
-        contendBox.fillColor = fillColor
-        contendBox.borderColor = borderColor
-        contendBox.cornerRadius = properties.propertyInfo.cornerRadius
-        contendBox.borderWidth = borderWidth
-         
         label.textColor = textColor
         label.textColor = textColor
-        
         label.font = properties.propertyInfo.textFont
         label.font = properties.propertyInfo.textFont
-         
+        
         if let image = leftImage {
         if let image = leftImage {
             leftIcon.image = image
             leftIcon.image = image
         }
         }
@@ -238,17 +314,16 @@ public class ComponentButton: ComponentBaseXibView {
         }
         }
         leftIcon.autoresizingMask = [.minXMargin, .maxXMargin, .minYMargin, .maxYMargin]
         leftIcon.autoresizingMask = [.minXMargin, .maxXMargin, .minYMargin, .maxYMargin]
         
         
+        display()
     }
     }
     
     
     public func reloadData() {
     public func reloadData() {
         DispatchQueue.main.async {
         DispatchQueue.main.async {
-            
             self.setupUI()
             self.setupUI()
             
             
             self.refreshUI()
             self.refreshUI()
         }
         }
     }
     }
-
     
     
     //MARK: - Public Method
     //MARK: - Public Method
     
     
@@ -285,8 +360,7 @@ public class ComponentButton: ComponentBaseXibView {
     
     
     public override func mouseMoved(with event: NSEvent) {
     public override func mouseMoved(with event: NSEvent) {
         super.mouseMoved(with: event)
         super.mouseMoved(with: event)
-        
-        
+         
     }
     }
      
      
     public override func mouseExited(with event: NSEvent) {
     public override func mouseExited(with event: NSEvent) {
@@ -315,7 +389,6 @@ public class ComponentButton: ComponentBaseXibView {
         if properties.isDisabled == false {
         if properties.isDisabled == false {
             if properties.keepPressState == false {
             if properties.keepPressState == false {
                 properties.state = .hover
                 properties.state = .hover
-                
                 refreshUI()
                 refreshUI()
             }
             }
             window?.makeFirstResponder(self)
             window?.makeFirstResponder(self)

+ 5 - 0
PDF Office/KMComponentLibrary/KMComponentLibrary/View/Button/ComponentButtonProperty.swift

@@ -217,6 +217,11 @@ extension ComponentLibrary {
         if let value = ComponentLibrary.shared.getComponentValueFromKey(self.getCornerRadius(size: properties.size)) {
         if let value = ComponentLibrary.shared.getComponentValueFromKey(self.getCornerRadius(size: properties.size)) {
             let currentValue = value as! CGFloat
             let currentValue = value as! CGFloat
             properties.propertyInfo.cornerRadius = currentValue
             properties.propertyInfo.cornerRadius = currentValue
+        
+            properties.propertyInfo.cornerRadius_topLeft = currentValue
+            properties.propertyInfo.cornerRadius_topRight = currentValue
+            properties.propertyInfo.cornerRadius_bottomLeft = currentValue
+            properties.propertyInfo.cornerRadius_bottomRight = currentValue
         }
         }
         
         
         //Button
         //Button

+ 2 - 49
PDF Office/KMComponentLibrary/KMComponentLibrary/View/Dropdown/ComponentDropdown.swift

@@ -91,52 +91,7 @@ public class ComponentDropdown: ComponentBaseXibView {
         rightBtnRightConst.constant = 0
         rightBtnRightConst.constant = 0
          
          
         switch properties.type {
         switch properties.type {
-        case .default_primary:
-            buttonType = .primary
-            buttonOnlyIcon = false
-            buttonShowLeft = false
-            buttonShowRight = true
-            
-            break
-        case .default_graySecondary:
-            
-            buttonType = .gray
-            buttonOnlyIcon = false
-            buttonShowLeft = false
-            buttonShowRight = true
-            
-            break
-        case .default_defaultTertiary:
-            buttonType = .default_tertiary
-            buttonOnlyIcon = false
-            buttonShowLeft = false
-            buttonShowRight = true
-            
-            break
-        case .default_textPrimary:
-            buttonType = .text_primary
-            buttonOnlyIcon = false
-            buttonShowLeft = false
-            buttonShowRight = true
-            
-            break
-        case .default_textGray:
-            buttonType = .text_gray
-            buttonOnlyIcon = false
-            buttonShowLeft = false
-            buttonShowRight = true
-            
-            break
-        case .default_IconGray:
-            buttonType = .gray
-            buttonOnlyIcon = true
-            
-            break
-        case .default_Icon:
-            buttonType = .text_gray
-            buttonOnlyIcon = true
-            
-            break
+        
         case .split_primary:
         case .split_primary:
             splitCenterDivider.isHidden = false
             splitCenterDivider.isHidden = false
             splitRightButton.isHidden = false
             splitRightButton.isHidden = false
@@ -329,9 +284,7 @@ extension ComponentDropdown {
         var svgTemplate = ""
         var svgTemplate = ""
         let colorHex = color.colorToHexString()
         let colorHex = color.colorToHexString()
         let alpha = color.alphaComponent
         let alpha = color.alphaComponent
-        if properties.type == .default_IconGray ||
-            properties.type == .default_Icon ||
-            properties.size == .m {
+        if properties.size == .m {
             svgTemplate = """
             svgTemplate = """
             <svg width="12" height="8" viewBox="0 0 12 8" fill="none" xmlns="http://www.w3.org/2000/svg">
             <svg width="12" height="8" viewBox="0 0 12 8" fill="none" xmlns="http://www.w3.org/2000/svg">
             <path fill-rule="evenodd" clip-rule="evenodd" d="M0.410765 0.910826C0.736202 0.585389 1.26384 0.585389 1.58928 0.910826L6.00002 5.32157L10.4108 0.910826C10.7362 0.585389 11.2638 0.585389 11.5893 0.910826C11.9147 1.23626 11.9147 1.7639 11.5893 2.08934L6.58928 7.08934C6.26384 7.41477 5.7362 7.41477 5.41076 7.08934L0.410765 2.08934C0.0853278 1.7639 0.0853278 1.23626 0.410765 0.910826Z" fill="\(colorHex)" fill-opacity="\(alpha)"/>
             <path fill-rule="evenodd" clip-rule="evenodd" d="M0.410765 0.910826C0.736202 0.585389 1.26384 0.585389 1.58928 0.910826L6.00002 5.32157L10.4108 0.910826C10.7362 0.585389 11.2638 0.585389 11.5893 0.910826C11.9147 1.23626 11.9147 1.7639 11.5893 2.08934L6.58928 7.08934C6.26384 7.41477 5.7362 7.41477 5.41076 7.08934L0.410765 2.08934C0.0853278 1.7639 0.0853278 1.23626 0.410765 0.910826Z" fill="\(colorHex)" fill-opacity="\(alpha)"/>

+ 4 - 89
PDF Office/KMComponentLibrary/KMComponentLibrary/View/Dropdown/ComponentDropdownProperty.swift

@@ -8,21 +8,13 @@
 import Cocoa
 import Cocoa
 
 
 @objc public enum DropdownType : Int {
 @objc public enum DropdownType : Int {
-    case default_primary = 0
-    case default_graySecondary
-    case default_defaultTertiary
-    case default_textPrimary
-    case default_textGray
-    case default_IconGray
-    case default_Icon
     case split_primary
     case split_primary
     case split_graySecondary
     case split_graySecondary
 }
 }
 
 
 //MARK: - Menu
 //MARK: - Menu
-@objcMembers
-public class ComponentDropdownProperty: NSObject {
-    public var type: DropdownType = .default_primary
+@objcMembers public class ComponentDropdownProperty: NSObject {
+    public var type: DropdownType = .split_primary
     public var size: ComponentSize = .m
     public var size: ComponentSize = .m
     public var split: Bool = false //分割线
     public var split: Bool = false //分割线
 //    public var popupShow: Bool = false //下拉菜单是否显示,显示状态下保持选中状态
 //    public var popupShow: Bool = false //下拉菜单是否显示,显示状态下保持选中状态
@@ -32,7 +24,7 @@ public class ComponentDropdownProperty: NSObject {
     
     
     public var propertyInfo = DropDownPropertyInfo()
     public var propertyInfo = DropDownPropertyInfo()
     
     
-    public init(type: DropdownType = .default_primary, 
+    public init(type: DropdownType = .split_primary,
                 size: ComponentSize = .m,
                 size: ComponentSize = .m,
                 state: ComponentState = .normal,
                 state: ComponentState = .normal,
                 split: Bool = false,
                 split: Bool = false,
@@ -113,84 +105,7 @@ extension ComponentLibrary {
     // MARK: 文字颜色
     // MARK: 文字颜色
     
     
     private func getArrowColor(type: DropdownType, state: ComponentState, isDisable: Bool) -> String {
     private func getArrowColor(type: DropdownType, state: ComponentState, isDisable: Bool) -> String {
-        if type == .default_primary {
-            if isDisable == true {
-                return "comp-button/primary-colorText-dis"
-            }
-            if state == .normal {
-                return "comp-button/primary-colorText-nor"
-            } else if state == .hover {
-                return "comp-button/primary-colorText-hov"
-            } else if state == .pressed {
-                return "comp-button/primary-colorText-pres"
-            }
-        } else if type == .default_graySecondary {
-            if isDisable == true {
-                return "comp-button/gray-colorText-dis"
-            }
-            if state == .normal {
-                return "comp-button/gray-colorText-nor"
-            } else if state == .hover {
-                return "comp-button/gray-colorText-hov"
-            } else if state == .pressed {
-                return "comp-button/gray-colorText-pres"
-            }
-        } else if type == .default_defaultTertiary {
-            if isDisable == true {
-                return "comp-button/default-colorText-dis"
-            }
-            if state == .normal {
-                return "comp-button/default-colorText-nor"
-            } else if state == .hover {
-                return "comp-button/default-colorText-hov"
-            } else if state == .pressed {
-                return "comp-button/default-colorText-pres"
-            }
-        } else if type == .default_textPrimary {
-            if isDisable == true {
-                return "comp-button/textPrimary-colorText-dis"
-            }
-            if state == .normal {
-                return "comp-button/textPrimary-colorText-nor"
-            } else if state == .hover {
-                return "comp-button/textPrimary-colorText-hov"
-            } else if state == .pressed {
-                return "comp-button/textPrimary-colorText-pres"
-            }
-        } else if type == .default_textGray {
-            if isDisable == true {
-                return "comp-button/textGray-colorText-dis"
-            }
-            if state == .normal {
-                return "comp-button/textGray-colorText-nor"
-            } else if state == .hover {
-                return "comp-button/textGray-colorText-hov"
-            } else if state == .pressed {
-                return "comp-button/textGray-colorText-pres"
-            }
-        } else if type == .default_IconGray {
-            if state == .normal {
-                return "comp-button/gray-colorText-nor"
-            } else if state == .hover {
-                return "comp-button/gray-colorText-hov"
-            } else if state == .pressed {
-                return "comp-button/gray-colorText-pres"
-            }
-            if isDisable == true {
-                return "comp-button/gray-colorText-dis"
-            }
-        } else if type == .default_Icon {
-            if isDisable == true {
-                return "comp-button/textGray-colorText-dis"
-            }
-            if state == .normal {
-                return "comp-button/textGray-colorText-nor"
-            } else if state == .hover {
-                return "comp-button/textGray-colorText-hov"
-            } else if state == .pressed {
-                return "comp-button/textGray-colorText-pres"
-            }
-        } else if type == .split_primary {
+        if type == .split_primary {
             if isDisable == true {
             if isDisable == true {
                 return "comp-button/primary-colorText-dis"
                 return "comp-button/primary-colorText-dis"
             }
             }

+ 5 - 5
PDF Office/KMComponentLibrary/KMComponentLibrary/View/Dropdown/ComponentDropdownTool/ComponentDropdownTool.xib

@@ -21,14 +21,14 @@
             <rect key="frame" x="0.0" y="0.0" width="90" height="28"/>
             <rect key="frame" x="0.0" y="0.0" width="90" height="28"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
             <subviews>
-                <box boxType="custom" cornerRadius="4" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="gR5-ep-FQt">
+                <box boxType="custom" borderWidth="0.0" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="gR5-ep-FQt">
                     <rect key="frame" x="0.0" y="0.0" width="90" height="28"/>
                     <rect key="frame" x="0.0" y="0.0" width="90" height="28"/>
                     <view key="contentView" id="7bE-Wb-A2c">
                     <view key="contentView" id="7bE-Wb-A2c">
-                        <rect key="frame" x="1" y="1" width="88" height="26"/>
+                        <rect key="frame" x="0.0" y="0.0" width="90" height="28"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                         <subviews>
                             <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="3Q8-Jd-E0Q">
                             <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="3Q8-Jd-E0Q">
-                                <rect key="frame" x="4" y="3" width="20" height="20"/>
+                                <rect key="frame" x="4" y="4" width="20" height="20"/>
                                 <constraints>
                                 <constraints>
                                     <constraint firstAttribute="width" constant="20" id="XUp-4U-paZ"/>
                                     <constraint firstAttribute="width" constant="20" id="XUp-4U-paZ"/>
                                     <constraint firstAttribute="height" constant="20" id="tTn-Yt-alR"/>
                                     <constraint firstAttribute="height" constant="20" id="tTn-Yt-alR"/>
@@ -36,7 +36,7 @@
                                 <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="test" id="LAY-Nf-0Yy"/>
                                 <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="test" id="LAY-Nf-0Yy"/>
                             </imageView>
                             </imageView>
                             <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="bCx-g4-O4c">
                             <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="bCx-g4-O4c">
-                                <rect key="frame" x="66" y="5" width="16" height="16"/>
+                                <rect key="frame" x="68" y="6" width="16" height="16"/>
                                 <constraints>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="16" id="EIa-U3-aEN"/>
                                     <constraint firstAttribute="height" constant="16" id="EIa-U3-aEN"/>
                                     <constraint firstAttribute="width" constant="16" id="gYx-uH-r0e"/>
                                     <constraint firstAttribute="width" constant="16" id="gYx-uH-r0e"/>
@@ -44,7 +44,7 @@
                                 <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="suffix" id="Zeh-ld-kXN"/>
                                 <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="suffix" id="Zeh-ld-kXN"/>
                             </imageView>
                             </imageView>
                             <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lEZ-As-k9B">
                             <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="lEZ-As-k9B">
-                                <rect key="frame" x="31" y="5" width="37" height="16"/>
+                                <rect key="frame" x="31" y="6" width="37" height="16"/>
                                 <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="N7c-5z-wAT">
                                 <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="N7c-5z-wAT">
                                     <font key="font" metaFont="system"/>
                                     <font key="font" metaFont="system"/>
                                     <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
                                     <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>

+ 1 - 1
PDF Office/PDF Master/KMClass/ComponentLibraryDemo/Demo/DropdownDemoVC.swift

@@ -40,7 +40,7 @@ class DropdownDemoVC: NSViewController, ComponentGroupDelegate, ComponentDropdow
     @IBOutlet weak var toolDisableBtn: NSButton!
     @IBOutlet weak var toolDisableBtn: NSButton!
     @IBOutlet weak var toolWidthConst: NSLayoutConstraint!
     @IBOutlet weak var toolWidthConst: NSLayoutConstraint!
     
     
-    let properties_Dropdown: ComponentDropdownProperty = ComponentDropdownProperty(type: .default_primary,
+    let properties_Dropdown: ComponentDropdownProperty = ComponentDropdownProperty(type: .split_primary,
                                                                                    size: .m,
                                                                                    size: .m,
                                                                                    state: .normal,
                                                                                    state: .normal,
                                                                                    split: false,
                                                                                    split: false,

+ 22 - 16
PDF Office/PDF Master/KMClass/KMHomeViewController/Views/KMHomeOpenView/KMHomeOpenView.swift

@@ -23,7 +23,7 @@ class KMHomeOpenView: BaseXibView {
     
     
     @IBOutlet weak var contendView: NSView!
     @IBOutlet weak var contendView: NSView!
     @IBOutlet weak var openFileButton: ComponentButton!
     @IBOutlet weak var openFileButton: ComponentButton!
-    @IBOutlet weak var createFileDropdown: ComponentDropdown!
+    @IBOutlet var createFileButton: ComponentButton!
     
     
     var groupView: ComponentGroup!
     var groupView: ComponentGroup!
     var createWC: KMURLCreatePDFWindowController = KMURLCreatePDFWindowController(windowNibName: "KMURLCreatePDFWindowController")
     var createWC: KMURLCreatePDFWindowController = KMURLCreatePDFWindowController(windowNibName: "KMURLCreatePDFWindowController")
@@ -57,16 +57,19 @@ class KMHomeOpenView: BaseXibView {
                                                             state: .normal,
                                                             state: .normal,
                                                             buttonText: KMLocalizedString("Open Files"),
                                                             buttonText: KMLocalizedString("Open Files"),
                                                             keepPressState: false)
                                                             keepPressState: false)
-        
         openFileButton.setTarget(self, action: #selector(openFileAction(_:)))
         openFileButton.setTarget(self, action: #selector(openFileAction(_:)))
         
         
-        createFileDropdown.properties = ComponentDropdownProperty(type: .default_defaultTertiary,
-                                                                  size: .m,
-                                                                  state: .normal,
-                                                                  split: false,
-                                                                  disabled: false,
-                                                                  text: KMLocalizedString("Create PDF"))
-        createFileDropdown.componentDelegate = self
+        createFileButton.properties = ComponentButtonProperty(type: .default_tertiary,
+                                                              size: .m,
+                                                              showRightIcon: true,
+                                                              buttonText: KMLocalizedString("Create PDF"))
+        createFileButton.properties.propertyInfo.rightIcon_nor = NSImage(named: "arrowDown")
+        createFileButton.properties.propertyInfo.rightIcon_press = NSImage(named: "arrowDown_press")
+        createFileButton.properties.propertyInfo.cornerRadius_topLeft = 0
+        createFileButton.properties.propertyInfo.cornerRadius_bottomLeft = 0
+        createFileButton.reloadData()
+        createFileButton.setTarget(self, action: #selector(createFileAction(_:)))
+        
     }
     }
     
     
     //MARK: - GroupView
     //MARK: - GroupView
@@ -96,12 +99,12 @@ class KMHomeOpenView: BaseXibView {
         groupView?.frame = CGRectMake(310, 0, CGRectGetWidth(self.bounds), viewHeight)
         groupView?.frame = CGRectMake(310, 0, CGRectGetWidth(self.bounds), viewHeight)
         groupView.updateGroupInfo(menuItemArr)
         groupView.updateGroupInfo(menuItemArr)
         
         
-        var point = convert(createFileDropdown.frame.origin, to: nil)
+        var point = convert(createFileButton.frame.origin, to: nil)
         point.y -= viewHeight
         point.y -= viewHeight
-        groupView.showWithPoint(point, relativeTo: createFileDropdown)
+        groupView.showWithPoint(point, relativeTo: createFileButton)
         
         
-        createFileDropdown.properties.state = .pressed
-        createFileDropdown.reloadData()
+        createFileButton.properties.state = .pressed
+        createFileButton.reloadData()
         
         
     }
     }
     
     
@@ -109,9 +112,8 @@ class KMHomeOpenView: BaseXibView {
         if groupView != nil {
         if groupView != nil {
             groupView.removeFromSuperview()
             groupView.removeFromSuperview()
         }
         }
-        createFileDropdown.properties.state = .normal
-        createFileDropdown.reloadData()
-        
+        createFileButton.properties.state = .normal
+        createFileButton.reloadData()
     }
     }
     
     
     //MARK: - Action
     //MARK: - Action
@@ -128,6 +130,10 @@ class KMHomeOpenView: BaseXibView {
         }
         }
     }
     }
     
     
+    @objc func createFileAction(_ sender: NSView) {
+        showGroupView()
+    }
+    
     func newFromFile() {
     func newFromFile() {
         let openPanel = NSOpenPanel()
         let openPanel = NSOpenPanel()
         openPanel.allowedFileTypes = KMImageToPDFMethod.supportedImageTypes()
         openPanel.allowedFileTypes = KMImageToPDFMethod.supportedImageTypes()

+ 2 - 2
PDF Office/PDF Master/KMClass/KMHomeViewController/Views/KMHomeOpenView/KMHomeOpenView.xib

@@ -9,7 +9,7 @@
         <customObject id="-2" userLabel="File's Owner" customClass="KMHomeOpenView" customModule="PDF_Reader_Pro" customModuleProvider="target">
         <customObject id="-2" userLabel="File's Owner" customClass="KMHomeOpenView" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
             <connections>
                 <outlet property="contendView" destination="WKT-j5-JeE" id="CRK-fN-CSp"/>
                 <outlet property="contendView" destination="WKT-j5-JeE" id="CRK-fN-CSp"/>
-                <outlet property="createFileDropdown" destination="a9d-ow-nE7" id="sNA-8o-2bF"/>
+                <outlet property="createFileButton" destination="a9d-ow-nE7" id="RNv-A5-N8B"/>
                 <outlet property="openFileButton" destination="xSX-hx-O74" id="Hg1-Sa-p35"/>
                 <outlet property="openFileButton" destination="xSX-hx-O74" id="Hg1-Sa-p35"/>
             </connections>
             </connections>
         </customObject>
         </customObject>
@@ -28,7 +28,7 @@
                                 <constraint firstAttribute="height" constant="40" id="Z7F-aM-NF8"/>
                                 <constraint firstAttribute="height" constant="40" id="Z7F-aM-NF8"/>
                             </constraints>
                             </constraints>
                         </customView>
                         </customView>
-                        <customView translatesAutoresizingMaskIntoConstraints="NO" id="a9d-ow-nE7" customClass="ComponentDropdown" customModule="KMComponentLibrary">
+                        <customView translatesAutoresizingMaskIntoConstraints="NO" id="a9d-ow-nE7" customClass="ComponentButton" customModule="KMComponentLibrary">
                             <rect key="frame" x="0.0" y="0.0" width="208" height="40"/>
                             <rect key="frame" x="0.0" y="0.0" width="208" height="40"/>
                             <constraints>
                             <constraints>
                                 <constraint firstAttribute="height" constant="40" id="5Vu-b0-GV8"/>
                                 <constraint firstAttribute="height" constant="40" id="5Vu-b0-GV8"/>

+ 2 - 1
PDF Office/PDF Master/KMClass/KMHomeViewController/Views/KMHomeRightView/HeaderFooterView/KMHomeFilesHeaderView.swift

@@ -73,7 +73,8 @@ public class KMHomeFilesHeaderView: BaseXibView {
         deleteButton.properties = ComponentButtonProperty(type: .default_tertiary,
         deleteButton.properties = ComponentButtonProperty(type: .default_tertiary,
                                                           size: .xxs,
                                                           size: .xxs,
                                                           state: .normal,
                                                           state: .normal,
-                                                          onlyIcon: true)
+                                                          onlyIcon: true,
+                                                          keepPressState: false)
         deleteButton.properties.propertyInfo.leftIcon_nor = NSImage(named: "file_delete")
         deleteButton.properties.propertyInfo.leftIcon_nor = NSImage(named: "file_delete")
         deleteButton.properties.propertyInfo.leftIcon_dis = NSImage(named: "file_delete_dis")
         deleteButton.properties.propertyInfo.leftIcon_dis = NSImage(named: "file_delete_dis")
         deleteButton.reloadData()
         deleteButton.reloadData()

PDF Office/PDF Master/KMClass/KMHomeViewController/home.xcassets/icon_suffix.imageset/Contents.json → PDF Office/PDF Master/KMClass/KMHomeViewController/home.xcassets/arrowDown.imageset/Contents.json


PDF Office/PDF Master/KMClass/KMHomeViewController/home.xcassets/icon_suffix.imageset/icon_suffix.pdf → PDF Office/PDF Master/KMClass/KMHomeViewController/home.xcassets/arrowDown.imageset/icon_suffix.pdf


+ 12 - 0
PDF Office/PDF Master/KMClass/KMHomeViewController/home.xcassets/arrowDown_press.imageset/Contents.json

@@ -0,0 +1,12 @@
+{
+  "images" : [
+    {
+      "filename" : "arrowDown_press.pdf",
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

+ 76 - 0
PDF Office/PDF Master/KMClass/KMHomeViewController/home.xcassets/arrowDown_press.imageset/arrowDown_press.pdf

@@ -0,0 +1,76 @@
+%PDF-1.7
+
+1 0 obj
+  << >>
+endobj
+
+2 0 obj
+  << /Length 3 0 R >>
+stream
+/DeviceRGB CS
+/DeviceRGB cs
+q
+1.000000 0.000000 -0.000000 1.000000 4.166748 6.504028 cm
+0.509804 0.741176 1.000000 scn
+0.244078 6.585268 m
+0.569515 6.910705 1.097152 6.910705 1.422589 6.585268 c
+5.833333 2.174523 l
+10.244078 6.585268 l
+10.569514 6.910705 11.097152 6.910705 11.422588 6.585268 c
+11.748026 6.259831 11.748026 5.732193 11.422588 5.406757 c
+6.422589 0.406757 l
+6.097152 0.081320 5.569514 0.081320 5.244078 0.406757 c
+0.244078 5.406757 l
+-0.081359 5.732193 -0.081359 6.259831 0.244078 6.585268 c
+h
+f*
+n
+Q
+
+endstream
+endobj
+
+3 0 obj
+  517
+endobj
+
+4 0 obj
+  << /Annots []
+     /Type /Page
+     /MediaBox [ 0.000000 0.000000 20.000000 20.000000 ]
+     /Resources 1 0 R
+     /Contents 2 0 R
+     /Parent 5 0 R
+  >>
+endobj
+
+5 0 obj
+  << /Kids [ 4 0 R ]
+     /Count 1
+     /Type /Pages
+  >>
+endobj
+
+6 0 obj
+  << /Pages 5 0 R
+     /Type /Catalog
+  >>
+endobj
+
+xref
+0 7
+0000000000 65535 f
+0000000010 00000 n
+0000000034 00000 n
+0000000607 00000 n
+0000000629 00000 n
+0000000802 00000 n
+0000000876 00000 n
+trailer
+<< /ID [ (some) (id) ]
+   /Root 6 0 R
+   /Size 7
+>>
+startxref
+935
+%%EOF