Bladeren bron

[系统菜单] - 幻灯片

liujiajie 1 jaar geleden
bovenliggende
commit
047d78f56a

+ 80 - 65
PDF Office/PDF Master/Class/PDFWindowController/MainWindowController/SKPresentationOptionsSheetController.swift

@@ -28,71 +28,34 @@ class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate
     @IBOutlet var tableView: KMBotaTableView!
     @IBOutlet var separateCheckButton: NSButton!
     @IBOutlet var boxes, transitionLabels, transitionControls, buttons: NSArray!
-    @IBOutlet var arrayController: NSArrayController!
+//    @IBOutlet var arrayController: NSArrayController!
     @IBOutlet var effectPopUpButton: NSPopUpButton!
-    
-    
+    @IBOutlet var effectLabel: NSTextField!
+    @IBOutlet var durationLabel: NSTextField!
+    @IBOutlet var durationSlider: NSSlider!
+    @IBOutlet var durationTF: NSTextField!
+    @IBOutlet var extentLabel: NSTextField!
+    @IBOutlet var screeBtn: NSButtonCell!
+    @IBOutlet var pageBtn: NSButtonCell!
+    @IBOutlet var synchoronizBox: NSBox!
+    @IBOutlet var cancelBtn: NSButton!
+    @IBOutlet var okBtn: NSButton!
+    @IBOutlet var pageTransitionBox: NSBox!
     
     var closeCallBack: closePresentationControllerCallBack?
-    var separate = false{
-        willSet{
-            if newValue != separate {
-//                SKImageToolTipWindow.sharedToolTipWindow().orderOut(nil)
-                
-                let window = self.window
-                let isVisible = window?.isVisible ?? false
-                var frame = window?.frame ?? NSRect.zero
-                let scrollView = tableView?.enclosingScrollView
-                var extraWidth: CGFloat
-                let firstResponder = window?.firstResponder
-                var editor: NSTextView? = nil
-                
-                if let textView = firstResponder as? NSTextView {
-                    editor = textView
-                    if textView.isFieldEditor {
-//                        firstResponder = textView.delegate
-                    }
-                }
-                
-                if arrayController.commitEditing(), let editor = editor, window?.firstResponder != editor {
-                    window?.makeFirstResponder(firstResponder)
-                }
-                
-                if separate {
-                    makeTransitions()
-                    
-                    extraWidth = (scrollView?.frame.width ?? 0) + TABLE_OFFSET
-                    frame.size.width += extraWidth
-                    frame.origin.x -= floor(0.5 * extraWidth)
-                    window?.setFrame(frame, display: isVisible, animate: isVisible)
-                    scrollView?.isHidden = false
-                } else {
-                    scrollView?.isHidden = true
-                    extraWidth = (scrollView?.frame.width ?? 0) + TABLE_OFFSET
-                    frame.size.width -= extraWidth
-                    frame.origin.x += floor(0.5 * extraWidth)
-                    window?.setFrame(frame, display: isVisible, animate: isVisible)
-                }
-
-//                (undoRedoManager.prepare(withInvocationTarget: self) as AnyObject).separate = sparate == fasle
-            }
-        }
-        didSet{
-            
-        }
-    }
+    var separate = false
     var transition: KMTransitionInfo = KMTransitionInfo()
     var transitions: NSArray?{
         willSet{
-            if newValue != transitions {
+           
+        }
+        didSet{
+            if transitions != oldValue {
 //                (undoRedoManager?.prepare(withInvocationTarget: self) as AnyObject).transitions = transitions
                 stopObservingTransitions(infos: transitions as! [KMTransitionInfo])
                 startObservingTransitions(transitions as! [KMTransitionInfo])
             }
         }
-        didSet{
-            
-        }
     }
     var currentTransitions: NSArray?{
         get{
@@ -209,10 +172,10 @@ class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate
         let count = SKTransitionController.transitionNames().count
 //        let transitionStylePopUpButton = transitionControls[0] as! NSPopUpButton
 //        transitionStylePopUpButton.removeAllItems()
-//        for i in 0..<count {
-//            transitionStylePopUpButton.addItem(withTitle: SKTransitionController.localizedName(for: SKAnimationTransitionStyle(rawValue: UInt(i)) ?? .noTransition))
-//            transitionStylePopUpButton.lastItem?.tag = i
-//        }
+        for i in 0..<count {
+            effectPopUpButton.addItem(withTitle: SKTransitionController.localizedName(for: SKAnimationTransitionStyle(rawValue: UInt(i)) ?? .noTransition))
+            effectPopUpButton.lastItem?.tag = i
+        }
 
         notesDocumentPopUpButton.item(at: 0)?.title = NSLocalizedString("None", comment: "Menu item title")
 
@@ -273,15 +236,16 @@ class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate
         }
     }
     
-    func makeTransitions() { if transitions != nil { return }
+    func makeTransitions() { 
+        if transitions != nil { return }
         let tableColumn = tableView?.tableColumn(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: PAGE_COLUMNID))
         let cell = tableColumn?.dataCell
         var labelWidth: CGFloat = 0.0
         
         var array = [Any]()
-        let dictionary = transition.properties
-        let arr: NSArray = transitionController.pageTransitions! as NSArray
-        let ptEnum = arr.objectEnumerator()
+        _ = transition.properties
+        let arr: NSArray? = transitionController.pageTransitions as NSArray?
+        let ptEnum = arr?.objectEnumerator()
         var tn: KMThumbnail? = nil
         
         for next in (controller?.leftSideViewController.thumbnails)! {
@@ -289,7 +253,7 @@ class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate
                 let info = KMTransitionInfo()
                 info.thumbnail = tn
                 info.label = "\(tn!.label)\(RIGHTARROW_CHARACTER)\(next.label)"
-                info.properties = ptEnum.nextObject() as! NSDictionary
+                info.properties = ptEnum?.nextObject() as? NSDictionary
                 array.append(info)
                 (cell as AnyObject).setStringValue(info.label)
                 labelWidth = max(labelWidth, ceil(((cell as AnyObject).cellSize?.width)!))
@@ -303,7 +267,7 @@ class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate
         tableColumn?.width = labelWidth
         
         var frame: NSRect = tableView?.enclosingScrollView?.frame ?? .zero
-        let wi: CGFloat = tableColumn?.value(forKeyPath: "@sum.width") as! CGFloat
+        let wi: CGFloat = 61//tableColumn?.value(forKeyPath: "@sum.width") as! CGFloat
         frame.size.width = 19.0 + wi
         tableView?.enclosingScrollView?.frame = frame
         
@@ -312,7 +276,58 @@ class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate
     override var windowNibName: NSNib.Name?{
         return "TransitionSheet"
     }
+    
+    func changePageTransitionType() {
+//                SKImageToolTipWindow.sharedToolTipWindow().orderOut(nil)
+        let window = self.window
+        let isVisible = window?.isVisible ?? false
+        var frame = window?.frame ?? NSRect.zero
+        let scrollView = tableView?.enclosingScrollView
+        var extraWidth: CGFloat
+        let firstResponder = window?.firstResponder
+        var editor: NSTextView? = nil
+        
+        if let textView = firstResponder as? NSTextView {
+            editor = textView
+            if textView.isFieldEditor {
+                //                        firstResponder = textView.delegate
+            }
+        }
+        
+        if let editor = editor, window?.firstResponder != editor {
+            window?.makeFirstResponder(firstResponder)
+        }
+        
+        if separate {
+            makeTransitions()
+            
+            extraWidth = (scrollView?.frame.width ?? 0) + TABLE_OFFSET
+            frame.size.width += extraWidth
+            frame.origin.x -= floor(0.5 * extraWidth)
+            window?.setFrame(frame, display: isVisible, animate: isVisible)
+            scrollView?.isHidden = false
+        } else {
+            scrollView?.isHidden = true
+            extraWidth = (scrollView?.frame.width ?? 0) + TABLE_OFFSET
+            frame.size.width -= extraWidth
+            frame.origin.x += floor(0.5 * extraWidth)
+            window?.setFrame(frame, display: isVisible, animate: isVisible)
+        }
+        
+        //                (undoRedoManager.prepare(withInvocationTarget: self) as AnyObject).separate = sparate == fasle
+        
+    }
    
+    @IBAction func pageTransitionAction(_ sender: NSButton) {
+        separate = sender.state == .on
+       
+        changePageTransitionType()
+    }
+    
+    
+    @IBAction func changeDurationSlider(_ sender: NSSlider) {
+        self.durationTF.stringValue = sender.stringValue
+    }
     @IBAction func cancelAction(_ sender: Any) {
         if let handle = closeCallBack {
             handle(self)
@@ -393,7 +408,7 @@ class SKPresentationOptionsSheetController: NSWindowController, NSWindowDelegate
             guard let infos = pboard.readObjects(forClasses: [KMTransitionInfo.self], options: [:]) as? [KMTransitionInfo], infos.count > 0 else {
                 return false
             }
-            let propertie: NSDictionary = infos[0].properties
+            let propertie: NSDictionary? = infos[0].properties
             
             if row == -1 {
                 transitions?.setValue(propertie, forKey: PROPERTIES_KEY)

+ 24 - 73
PDF Office/PDF Master/Class/PDFWindowController/MainWindowController/TransitionSheet.xib

@@ -8,10 +8,20 @@
     <objects>
         <customObject id="-2" userLabel="File's Owner" customClass="SKPresentationOptionsSheetController" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
-                <outlet property="arrayController" destination="127" id="148"/>
+                <outlet property="cancelBtn" destination="31" id="3TJ-W1-rhh"/>
+                <outlet property="durationLabel" destination="25" id="uvm-pe-ACg"/>
+                <outlet property="durationSlider" destination="30" id="p18-Dd-z9f"/>
+                <outlet property="durationTF" destination="28" id="xzE-OB-bhF"/>
+                <outlet property="effectLabel" destination="9" id="CQN-sh-iIx"/>
                 <outlet property="effectPopUpButton" destination="13" id="cO1-zP-wn0"/>
+                <outlet property="extentLabel" destination="26" id="YxA-wn-FGQ"/>
                 <outlet property="notesDocumentPopUpButton" destination="69" id="99"/>
+                <outlet property="okBtn" destination="27" id="RoG-f4-1M9"/>
+                <outlet property="pageBtn" destination="11" id="1Ze-Zy-G3w"/>
+                <outlet property="pageTransitionBox" destination="67" id="Uql-ze-DT0"/>
+                <outlet property="screeBtn" destination="12" id="qPN-Ad-FaF"/>
                 <outlet property="separateCheckButton" destination="138" id="346"/>
+                <outlet property="synchoronizBox" destination="68" id="bOE-ap-wgY"/>
                 <outlet property="tableView" destination="279" id="287"/>
                 <outlet property="window" destination="7" id="63"/>
             </connections>
@@ -40,6 +50,7 @@ DQ
                         </buttonCell>
                         <connections>
                             <accessibilityConnection property="link" destination="31" id="461"/>
+                            <action selector="okAction:" target="-2" id="3k6-Ji-BSx"/>
                         </connections>
                     </button>
                     <button imageHugsTitle="YES" verticalHuggingPriority="750" id="31">
@@ -52,8 +63,11 @@ DQ
 Gw
 </string>
                         </buttonCell>
+                        <connections>
+                            <action selector="cancelAction:" target="-2" id="7Fi-nJ-GQh"/>
+                        </connections>
                     </button>
-                    <box borderType="line" id="67">
+                    <box borderType="line" title="Page Transition" id="67">
                         <rect key="frame" x="123" y="120" width="286" height="118"/>
                         <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
                         <view key="contentView" id="nHl-1V-Bnj">
@@ -63,7 +77,7 @@ Gw
                                 <textField focusRingType="none" verticalHuggingPriority="750" id="28">
                                     <rect key="frame" x="216" y="42" width="50" height="22"/>
                                     <autoresizingMask key="autoresizingMask"/>
-                                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="442">
+                                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" title="1.0" drawsBackground="YES" id="442">
                                         <numberFormatter key="formatter" formatterBehavior="custom10_4" positiveFormat="#,##0.0" negativeFormat="-#,##0.0" formatWidth="-1" minimumIntegerDigits="1" maximumIntegerDigits="2000000000" minimumFractionDigits="1" maximumFractionDigits="1" decimalSeparator="." groupingSeparator="," id="29">
                                             <nil key="negativeInfinitySymbol"/>
                                             <nil key="positiveInfinitySymbol"/>
@@ -73,15 +87,6 @@ Gw
                                         <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
                                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                     </textFieldCell>
-                                    <connections>
-                                        <accessibilityConnection property="title" destination="25" id="48"/>
-                                        <binding destination="127" name="value" keyPath="selection.duration" id="504">
-                                            <dictionary key="options">
-                                                <real key="NSMultipleValuesPlaceholder" value="-1"/>
-                                                <real key="NSNoSelectionPlaceholder" value="-1"/>
-                                            </dictionary>
-                                        </binding>
-                                    </connections>
                                 </textField>
                                 <slider verticalHuggingPriority="750" id="30">
                                     <rect key="frame" x="82" y="38" width="128" height="26"/>
@@ -90,10 +95,7 @@ Gw
                                         <font key="font" size="12" name="Helvetica"/>
                                     </sliderCell>
                                     <connections>
-                                        <accessibilityConnection property="link" destination="28" id="459"/>
-                                        <accessibilityConnection property="link" destination="10" id="460"/>
-                                        <accessibilityConnection property="title" destination="25" id="47"/>
-                                        <binding destination="127" name="value" keyPath="selection.duration" id="493"/>
+                                        <action selector="changeDurationSlider:" target="-2" id="2QH-Mx-YnZ"/>
                                     </connections>
                                 </slider>
                                 <popUpButton imageHugsTitle="YES" verticalHuggingPriority="750" id="13">
@@ -104,16 +106,6 @@ Gw
                                         <font key="font" metaFont="menu"/>
                                         <menu key="menu" id="14"/>
                                     </popUpButtonCell>
-                                    <connections>
-                                        <accessibilityConnection property="link" destination="30" id="458"/>
-                                        <accessibilityConnection property="title" destination="9" id="49"/>
-                                        <binding destination="127" name="selectedTag" keyPath="selection.transitionStyle" id="505">
-                                            <dictionary key="options">
-                                                <real key="NSMultipleValuesPlaceholder" value="-1"/>
-                                                <real key="NSNoSelectionPlaceholder" value="-1"/>
-                                            </dictionary>
-                                        </binding>
-                                    </connections>
                                 </popUpButton>
                                 <textField focusRingType="none" verticalHuggingPriority="750" id="9">
                                     <rect key="frame" x="35" y="75" width="44" height="17"/>
@@ -139,7 +131,7 @@ Gw
                                     <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                                     <size key="cellSize" width="64" height="18"/>
                                     <size key="intercellSpacing" width="4" height="2"/>
-                                    <buttonCell key="prototype" type="radio" imagePosition="leading" alignment="left" inset="2" id="446">
+                                    <buttonCell key="prototype" type="radio" imagePosition="leading" alignment="left" state="on" inset="2" id="446">
                                         <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
                                         <font key="font" metaFont="system"/>
                                     </buttonCell>
@@ -148,29 +140,15 @@ Gw
                                             <buttonCell type="radio" title="Screen" imagePosition="leading" alignment="left" state="on" inset="2" id="12">
                                                 <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
                                                 <font key="font" metaFont="system"/>
-                                                <connections>
-                                                    <accessibilityConnection property="title" destination="26" id="51"/>
-                                                </connections>
                                             </buttonCell>
                                         </column>
                                         <column>
                                             <buttonCell type="radio" title="Page" imagePosition="leading" alignment="left" tag="1" inset="2" id="11">
                                                 <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
                                                 <font key="font" metaFont="system"/>
-                                                <connections>
-                                                    <accessibilityConnection property="title" destination="26" id="52"/>
-                                                </connections>
                                             </buttonCell>
                                         </column>
                                     </cells>
-                                    <connections>
-                                        <binding destination="127" name="selectedTag" keyPath="selection.shouldRestrict" id="506">
-                                            <dictionary key="options">
-                                                <real key="NSMultipleValuesPlaceholder" value="-1"/>
-                                                <real key="NSNoSelectionPlaceholder" value="-1"/>
-                                            </dictionary>
-                                        </binding>
-                                    </connections>
                                 </matrix>
                                 <textField focusRingType="none" verticalHuggingPriority="750" id="26">
                                     <rect key="frame" x="30" y="15" width="49" height="17"/>
@@ -183,18 +161,6 @@ Gw
                                 </textField>
                             </subviews>
                         </view>
-                        <connections>
-                            <binding destination="127" name="displayPatternTitle2" keyPath="selection.label" previousBinding="512" id="513">
-                                <dictionary key="options">
-                                    <string key="NSDisplayPattern">%{title1}@ %{title2}@</string>
-                                </dictionary>
-                            </binding>
-                            <binding destination="127" name="displayPatternTitle1" keyPath="selection.title" id="512">
-                                <dictionary key="options">
-                                    <string key="NSDisplayPattern">%{title1}@ %{title2}@</string>
-                                </dictionary>
-                            </binding>
-                        </connections>
                     </box>
                     <box borderType="line" title="Synchronized Notes Document" id="68">
                         <rect key="frame" x="123" y="56" width="286" height="60"/>
@@ -226,6 +192,9 @@ Gw
                             <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
                             <font key="font" metaFont="system"/>
                         </buttonCell>
+                        <connections>
+                            <action selector="pageTransitionAction:" target="-2" id="Ocs-hT-yI8"/>
+                        </connections>
                     </button>
                     <scrollView hidden="YES" horizontalLineScroll="34" horizontalPageScroll="10" verticalLineScroll="34" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" id="276">
                         <rect key="frame" x="20" y="20" width="98" height="240"/>
@@ -247,9 +216,6 @@ Gw
                                                 <color key="backgroundColor" white="0.33333298560000002" alpha="1" colorSpace="calibratedWhite"/>
                                             </tableHeaderCell>
                                             <imageCell key="dataCell" controlSize="small" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="283"/>
-                                            <connections>
-                                                <binding destination="127" name="value" keyPath="arrangedObjects.thumbnail.image" id="285"/>
-                                            </connections>
                                         </tableColumn>
                                         <tableColumn identifier="page" editable="NO" width="10" minWidth="10" maxWidth="1000" id="281">
                                             <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
@@ -262,9 +228,6 @@ Gw
                                                 <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
                                             </textFieldCell>
                                             <tableColumnResizingMask key="resizingMask" resizeWithTable="YES"/>
-                                            <connections>
-                                                <binding destination="127" name="value" keyPath="arrangedObjects.label" id="397"/>
-                                            </connections>
                                         </tableColumn>
                                     </tableColumns>
                                     <connections>
@@ -309,20 +272,8 @@ Gw
                 <outlet property="object3" destination="26" id="465"/>
             </connections>
         </customObject>
-        <customObject id="466" userLabel="Transition Controls" customClass="SKIBArray">
-            <connections>
-                <outlet property="object1" destination="13" id="470"/>
-                <outlet property="object2" destination="30" id="471"/>
-                <outlet property="object3" destination="28" id="472"/>
-                <outlet property="object4" destination="10" id="488"/>
-            </connections>
-        </customObject>
-        <customObject id="480" userLabel="Boxes" customClass="SKIBArray">
-            <connections>
-                <outlet property="object1" destination="67" id="486"/>
-                <outlet property="object2" destination="68" id="487"/>
-            </connections>
-        </customObject>
+        <customObject id="466" userLabel="Transition Controls" customClass="SKIBArray"/>
+        <customObject id="480" userLabel="Boxes" customClass="SKIBArray"/>
         <customObject id="476" userLabel="Buttons" customClass="SKIBArray">
             <connections>
                 <outlet property="object1" destination="27" id="478"/>

+ 4 - 4
PDF Office/PDF Master/Class/PDFWindowController/Tools/KMTransitionInfo.swift

@@ -18,18 +18,18 @@ class KMTransitionInfo: NSObject{
     var label: String = ""
     var title: String {return NSLocalizedString("Page Transition", comment: "Box title")}
     
-    var properties: NSDictionary{
+    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] {
+            if let value = newValue?[SKStyleNameKey] {
                 transitionStyle = SKTransitionController.style(forName: value as? String)
             }
-            if let value = newValue[SKDurationKey] {
+            if let value = newValue?[SKDurationKey] {
                 duration = value as! Float
             }
-            if let value = newValue[SKShouldRestrictKey] {
+            if let value = newValue?[SKShouldRestrictKey] {
                 shouldRestrict = value as! Bool
             }
         }

+ 1 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift

@@ -430,6 +430,7 @@ extension KMMainViewController {
 //            }];
         let presentationSheetController = SKPresentationOptionsSheetController(windowNibName: "TransitionSheet")
 //        let presentationSheetController = SKPresentationOptionsSheetController(for: MainWindowController)
+        presentationSheetController.controller = self
         let window = NSWindow.currentWindow()
         window.km_beginSheet(windowC: presentationSheetController)
         presentationSheetController.closeCallBack = { vc in