123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- //
- // KMAlignmentController.swift
- // PDF Reader Pro
- //
- // Created by tangchao on 2024/7/10.
- //
- import Cocoa
- class KMAlignmentController: NSViewController {
- @IBOutlet weak var box1: NSBox!
- @IBOutlet weak var box2: NSBox!
- @IBOutlet weak var box3: NSBox!
- @IBOutlet weak var box4: NSBox!
-
- private var vc1_: KMDesignButton?
- private var vc2_: KMDesignButton?
- private var vc3_: KMDesignButton?
- private var vc4_: KMDesignButton?
-
- var itemAction: KMCommonClickBlock?
-
- private var isHor_ = false
- var isHor: Bool {
- get {
- return self.isHor_
- }
- }
-
- private var areaCount_ : Int = 0
- var areaCount: Int {
- get {
- return self.areaCount_
- }
- }
-
- deinit {
- KMPrint("KMAlignmentController deinit.")
- }
-
- convenience init(withIsHor isHor: Bool, areaCount: Int) {
- self.init(nibName: "KMAlignmentController", bundle: nil)
-
- self.isHor_ = isHor
- self.areaCount_ = areaCount
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
- self.view.wantsLayer = true
- self.view.layer?.backgroundColor = .white
-
- self.vc1_ = KMDesignButton(withType: .Image)
- self.box1.contentView = self.vc1_!.view
- self.box1.borderWidth = 0
- self.vc1_?.pagination()
- self.vc1_?.target = self
- self.vc1_?.action = #selector(_itemClick)
- if self.isHor {
- self.vc1_?.image = NSImage(named: "KMImageNameEditPDFImage45_1")!
- } else {
- self.vc1_?.image = NSImage(named: "KMImageNameEditPDFImage48_1")!
- }
-
- self.vc1_?.tag = 0
-
- self.vc2_ = KMDesignButton(withType: .Image)
- self.box2.contentView = self.vc2_!.view
- self.box2.borderWidth = 0
- self.vc2_?.pagination()
- self.vc2_?.target = self
- self.vc2_?.action = #selector(_itemClick)
- if self.isHor {
- self.vc2_?.image = NSImage(named: "KMImageNameEditPDFImage46_1")!
- } else {
- self.vc2_?.image = NSImage(named: "KMImageNameEditPDFImage49_1")!
- }
- self.vc2_?.tag = 1
-
- self.vc3_ = KMDesignButton(withType: .Image)
- self.box3.contentView = self.vc3_!.view
- self.box3.borderWidth = 0
- self.vc3_?.pagination()
- self.vc3_?.target = self
- self.vc3_?.action = #selector(_itemClick)
- if self.isHor {
- self.vc3_?.image = NSImage(named: "KMImageNameEditPDFImage47_1")!
- } else {
- self.vc3_?.image = NSImage(named: "KMImageNameEditPDFImage50_1")!
- }
- self.vc3_?.tag = 2
-
- self.vc4_ = KMDesignButton(withType: .Image)
- self.box4.contentView = self.vc4_!.view
- self.box4.borderWidth = 0
- self.vc4_?.pagination()
- self.vc4_?.target = self
- self.vc4_?.action = #selector(_itemClick)
- if self.isHor {
- // KMImageNameEditPDFImage21
- self.vc4_?.image = NSImage(named: "KMImageNameEditPDFImage21_1")!
- self.vc4_?._image_disabled = NSImage(named: "KMImageNameEditPDFImage21")!
- } else {
- // KMImageNameEditPDFImage20
- self.vc4_?.image = NSImage(named: "KMImageNameEditPDFImage20_1")!
- self.vc4_?._image_disabled = NSImage(named: "KMImageNameEditPDFImage20")!
- }
- self.vc4_?.tag = 3
-
- self.vc4_?.state = self.areaCount > 2 ? .Norm : .Disabled
- self.vc4_?.button.isEnabled = self.areaCount > 2
-
- self.reloadData()
- }
-
- @objc private func _itemClick(_ sender: NSButton) {
- self.itemAction?(sender.tag)
- }
-
- func reloadData() {
- if KMAppearance.isDarkMode() {
- self.view.layer?.backgroundColor = KMAppearance.Layout.l0Color().cgColor
- self.vc1_?.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1)
- self.vc2_?.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1)
- self.vc3_?.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1)
- self.vc4_?.background_hov = NSColor(red: 71/255, green: 72/255, blue: 75/255, alpha: 1)
- } else {
- self.view.layer?.backgroundColor = .white
- self.vc1_?.background_hov = NSColor(red: 237/255, green: 238/255, blue: 240/255, alpha: 1)
- self.vc2_?.background_hov = NSColor(red: 237/255, green: 238/255, blue: 240/255, alpha: 1)
- self.vc3_?.background_hov = NSColor(red: 237/255, green: 238/255, blue: 240/255, alpha: 1)
- self.vc4_?.background_hov = NSColor(red: 237/255, green: 238/255, blue: 240/255, alpha: 1)
- }
- }
-
- }
|