|
@@ -43,7 +43,7 @@ class KMEditImageController: NSViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- var currentArea: CPDFEditTextArea?
|
|
|
+ var currentArea: CPDFEditImageArea?
|
|
|
|
|
|
//MARK: - func
|
|
|
override func viewDidAppear() {
|
|
@@ -105,11 +105,12 @@ class KMEditImageController: NSViewController {
|
|
|
rotateSelect.properties = ComponentSelectProperties(size: .s,
|
|
|
state: .normal,
|
|
|
creatable: true,
|
|
|
- text: "100%",
|
|
|
- regexString: "0123456789%")
|
|
|
+ text: "100",
|
|
|
+ textUnit: "°",
|
|
|
+ regexString: "0123456789-")
|
|
|
if true {
|
|
|
var opacityItems: [ComponentMenuitemProperty] = []
|
|
|
- for string in ["25%", "50%", "75%", "100%"] {
|
|
|
+ for string in ["0°", "45°", "-45°", "90°", "-90°"] {
|
|
|
let item = ComponentMenuitemProperty(type: .normal, text: string)
|
|
|
opacityItems.append(item)
|
|
|
}
|
|
@@ -135,12 +136,14 @@ class KMEditImageController: NSViewController {
|
|
|
opacityLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
|
|
|
|
|
|
opacitySlider.properties = ComponentSliderProperty(size: .m, percent: 1)
|
|
|
+ opacitySlider.delegate = self
|
|
|
|
|
|
opacitySelect.properties = ComponentSelectProperties(size: .s,
|
|
|
- state: .normal,
|
|
|
- creatable: true,
|
|
|
- text: "100%",
|
|
|
- regexString: "0123456789%")
|
|
|
+ state: .normal,
|
|
|
+ creatable: true,
|
|
|
+ text: "100",
|
|
|
+ textUnit: "%",
|
|
|
+ regexString: "0123456789%")
|
|
|
if true {
|
|
|
var opacityItems: [ComponentMenuitemProperty] = []
|
|
|
for string in ["25%", "50%", "75%", "100%"] {
|
|
@@ -165,7 +168,7 @@ class KMEditImageController: NSViewController {
|
|
|
|
|
|
func reloadData() {
|
|
|
|
|
|
- let areas = pdfView?.km_editingTextAreas() ?? []
|
|
|
+ let areas = pdfView?.km_editingImageAreas() ?? []
|
|
|
if areas.count == 0 {
|
|
|
currentArea = nil
|
|
|
} else if areas.count == 1 {
|
|
@@ -175,15 +178,32 @@ class KMEditImageController: NSViewController {
|
|
|
}
|
|
|
|
|
|
if let area = currentArea {
|
|
|
- let fontName = pdfView?.km_editTextAreasFontNames([area])
|
|
|
- let fontStyle = pdfView?.km_editTextAreasFontStyles([area])
|
|
|
- let fontSize = pdfView?.km_editTextAreasFontSizes([area])
|
|
|
- let bold = pdfView?.km_editTextAreasFontBolds([area])
|
|
|
- let itality = pdfView?.km_editTextAreasFontItalics([area])
|
|
|
- let alignment = pdfView?.km_editTextAreasTextAlignments([area])
|
|
|
- let colors = pdfView?.km_editTextAreasFontColors([area])
|
|
|
- let opacity = pdfView?.km_editAreasOpacitys([area])
|
|
|
- print("1")
|
|
|
+
|
|
|
+
|
|
|
+ if let opacitys = pdfView?.km_editAreasOpacitys([area]) {
|
|
|
+ if opacitys.count > 0 {
|
|
|
+ var opacity = opacitys.first ?? 1
|
|
|
+ opacity = min(1, opacity)
|
|
|
+ opacity = max(0, opacity)
|
|
|
+
|
|
|
+ opacitySelect.properties.text = String(format: "%.0f%@", opacity*100, "%")
|
|
|
+ opacitySelect.reloadData()
|
|
|
+
|
|
|
+ opacitySlider.properties.percent = opacity
|
|
|
+ opacitySlider.reloadData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if let rotates = pdfView?.km_editAreasRotates([area]) {
|
|
|
+ if rotates.count > 0 {
|
|
|
+ var rotate = rotates.first ?? 1
|
|
|
+
|
|
|
+ rotateSelect.properties.text = String(format: "%.0f", rotate)
|
|
|
+ rotateSelect.reloadData()
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -208,15 +228,64 @@ class KMEditImageController: NSViewController {
|
|
|
} else if sender == ExtrackButton {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ reloadData()
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //MARK: - MouseEvent
|
|
|
+ override func mouseDown(with event: NSEvent) {
|
|
|
+ super.mouseDown(with: event)
|
|
|
+
|
|
|
+ view.window?.makeFirstResponder(nil)
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
+//MARK: - ComponentSelectDelegate
|
|
|
extension KMEditImageController: ComponentSelectDelegate {
|
|
|
+ func componentSelectDidSelect(view: ComponentSelect?, menuItemProperty: ComponentMenuitemProperty?) {
|
|
|
+ if view == opacitySelect {
|
|
|
+ if let text = opacitySelect.properties.text {
|
|
|
+ let result = text.stringByDeleteCharString("%")
|
|
|
+ let opacity = result.stringToCGFloat()/100
|
|
|
+
|
|
|
+ pdfView?.setEditingAreasOpacity(opacity)
|
|
|
+
|
|
|
+ reloadData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ func componentSelectTextDidEndEditing(_ view: ComponentSelect) {
|
|
|
+ if view == opacitySelect {
|
|
|
+ if let text = opacitySelect.properties.text {
|
|
|
+ let result = text.stringByDeleteCharString("%")
|
|
|
+ let opacity = result.stringToCGFloat()/100
|
|
|
+
|
|
|
+ pdfView?.setEditingAreasOpacity(opacity)
|
|
|
+
|
|
|
+ reloadData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+//MARK: - ComponentCColorDelegate
|
|
|
extension KMEditImageController: ComponentCColorDelegate {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+//MARK: - ComponentSliderDelegate
|
|
|
+extension KMEditImageController: ComponentSliderDelegate {
|
|
|
+ func componentSliderDidUpdate(_ view: ComponentSlider) {
|
|
|
+ let percent = view.properties.percent
|
|
|
+
|
|
|
+ self.pdfView?.setEditingAreasOpacity(percent)
|
|
|
+
|
|
|
+ reloadData()
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|