1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- //
- // KMTransitionInfo.swift
- // PDF Reader Pro
- //
- // Created by liujiajie on 2024/1/17.
- //
- import Foundation
- let SKPasteboardTypeTransition = "net.sourceforge.skim-app.pasteboard.transition"
- class KMTransitionInfo: NSObject{
-
- var transitionStyle: SKAnimationTransitionStyle = .noTransition
- var duration: Float = 0.0
- var shouldRestrict = false {
- didSet {
- // KMPrint("")
- }
- }
- var thumbnail: KMThumbnail?
- var label: String = ""
- var title: String {
- get {
- return NSLocalizedString("Page Transition", comment: "Box title")
- }
- }
-
- var properties: NSDictionary?{
- get{
- return [SKStyleNameKey: SKTransitionController.name(for: transitionStyle) ?? "", SKDurationKey: NSNumber(value: duration), SKShouldRestrictKey: NSNumber(value: shouldRestrict)] as [String : Any] as NSDictionary
- }
- set{
- if let value = newValue?[SKStyleNameKey] {
- transitionStyle = SKTransitionController.style(forName: value as? String)
- }
- if let value = newValue?[SKDurationKey] {
- duration = value as! Float
- }
- if let value = newValue?[SKShouldRestrictKey] {
- shouldRestrict = value as! Bool
- }
- }
- }
- override init() {
- super.init()
-
- self.transitionStyle = .noTransition
- self.duration = 1.0
- self.shouldRestrict = false
- self.thumbnail = nil
- self.label = ""
- }
-
- init(propertyList: NSDictionary, ofType: String) {
- super.init()
- if ofType == SKPasteboardTypeTransition {
- self.properties = propertyList
- } else {
-
- }
- }
-
- override var description: String {
- return "<\(type(of: self)) \(Unmanaged.passUnretained(self).toOpaque())> \(properties)"
- }
-
- class func readableTypesForPasteboard(pasteboard: NSPasteboard) -> NSArray {
- return NSArray(objects: SKPasteboardTypeTransition)
- }
-
- class func readingOptionsForType(type: String, pasteboard: NSPasteboard) -> NSPasteboard.ReadingOptions {
- if type == SKPasteboardTypeTransition {
- return .asPropertyList
- }
- return .asData
- }
-
- func writableTypesForPasteboard(pasteboard: NSPasteboard) -> NSArray {
- return NSArray(objects: SKPasteboardTypeTransition)
- }
-
- func pasteboardPropertyListForType(type: String) -> Any? {
- if type == SKPasteboardTypeTransition {
- return properties
- }
- return nil
- }
- }
|