From abec924d162aacd2b1921945943d49000ed11d38 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Fri, 23 Sep 2022 21:50:16 +0800 Subject: [PATCH] TooltipUI // Pack ctlTooltip into a package. --- Packages/vChewing_TooltipUI/.gitignore | 9 ++++++ Packages/vChewing_TooltipUI/Package.swift | 28 +++++++++++++++++++ Packages/vChewing_TooltipUI/README.md | 13 +++++++++ .../Sources/TooltipUI/TooltipUI.swift | 4 ++- Source/Modules/IMEStateData.swift | 3 +- Source/Modules/ctlInputMethod_Core.swift | 3 +- vChewing.xcodeproj/project.pbxproj | 21 ++++++-------- 7 files changed, 66 insertions(+), 15 deletions(-) create mode 100644 Packages/vChewing_TooltipUI/.gitignore create mode 100644 Packages/vChewing_TooltipUI/Package.swift create mode 100644 Packages/vChewing_TooltipUI/README.md rename Source/Modules/UIModules/TooltipUI/ctlTooltip.swift => Packages/vChewing_TooltipUI/Sources/TooltipUI/TooltipUI.swift (98%) diff --git a/Packages/vChewing_TooltipUI/.gitignore b/Packages/vChewing_TooltipUI/.gitignore new file mode 100644 index 00000000..3b298120 --- /dev/null +++ b/Packages/vChewing_TooltipUI/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/Packages/vChewing_TooltipUI/Package.swift b/Packages/vChewing_TooltipUI/Package.swift new file mode 100644 index 00000000..e0060db3 --- /dev/null +++ b/Packages/vChewing_TooltipUI/Package.swift @@ -0,0 +1,28 @@ +// swift-tools-version:5.3 +import PackageDescription + +let package = Package( + name: "TooltipUI", + platforms: [ + .macOS(.v10_11) + ], + products: [ + .library( + name: "TooltipUI", + targets: ["TooltipUI"] + ) + ], + dependencies: [ + .package(path: "../Fuziki_NSAttributedTextView"), + .package(path: "../vChewing_CocoaExtension"), + ], + targets: [ + .target( + name: "TooltipUI", + dependencies: [ + .product(name: "NSAttributedTextView", package: "Fuziki_NSAttributedTextView"), + .product(name: "CocoaExtension", package: "vChewing_CocoaExtension"), + ] + ) + ] +) diff --git a/Packages/vChewing_TooltipUI/README.md b/Packages/vChewing_TooltipUI/README.md new file mode 100644 index 00000000..b6692f65 --- /dev/null +++ b/Packages/vChewing_TooltipUI/README.md @@ -0,0 +1,13 @@ +# NotifierUI + +威注音的工具提示視窗。 + +``` +// (c) 2021 and onwards The vChewing Project (MIT-NTL License). +// ==================== +// This code is released under the MIT license (SPDX-License-Identifier: MIT) +// ... with NTL restriction stating that: +// No trademark license is granted to use the trade names, trademarks, service +// marks, or product names of Contributor, except as required to fulfill notice +// requirements defined in MIT License. +``` diff --git a/Source/Modules/UIModules/TooltipUI/ctlTooltip.swift b/Packages/vChewing_TooltipUI/Sources/TooltipUI/TooltipUI.swift similarity index 98% rename from Source/Modules/UIModules/TooltipUI/ctlTooltip.swift rename to Packages/vChewing_TooltipUI/Sources/TooltipUI/TooltipUI.swift index 9c58a041..42ac77c5 100644 --- a/Source/Modules/UIModules/TooltipUI/ctlTooltip.swift +++ b/Packages/vChewing_TooltipUI/Sources/TooltipUI/TooltipUI.swift @@ -6,9 +6,11 @@ // marks, or product names of Contributor, except as required to fulfill notice // requirements defined in MIT License. +import Cocoa +import CocoaExtension import NSAttributedTextView -public class ctlTooltip: NSWindowController { +public class TooltipUI: NSWindowController { public enum ColorStates { case normal case redAlert diff --git a/Source/Modules/IMEStateData.swift b/Source/Modules/IMEStateData.swift index 08abfbbf..9c7b761f 100644 --- a/Source/Modules/IMEStateData.swift +++ b/Source/Modules/IMEStateData.swift @@ -7,6 +7,7 @@ // requirements defined in MIT License. import Tekkon +import TooltipUI public struct StateData { private static var minCandidateLength: Int { @@ -101,7 +102,7 @@ public struct StateData { Self.allowedMarkLengthRange.contains(markedRange.count) } - var tooltipColorState: ctlTooltip.ColorStates = .normal + var tooltipColorState: TooltipUI.ColorStates = .normal var attributedStringNormal: NSAttributedString { /// 考慮到因為滑鼠點擊等其它行為導致的組字區內容遞交情況, diff --git a/Source/Modules/ctlInputMethod_Core.swift b/Source/Modules/ctlInputMethod_Core.swift index 2e9acb45..258a035e 100644 --- a/Source/Modules/ctlInputMethod_Core.swift +++ b/Source/Modules/ctlInputMethod_Core.swift @@ -13,6 +13,7 @@ import NotifierUI import Shared import ShiftKeyUpChecker import Tekkon +import TooltipUI /// 輸入法控制模組,乃在輸入法端用以控制輸入行為的基礎型別。 /// @@ -32,7 +33,7 @@ class ctlInputMethod: IMKInputController { PrefMgr.shared.useIMKCandidateWindow ? ctlCandidateIMK.init(.horizontal) : ctlCandidateUniversal.init(.horizontal) /// 工具提示視窗的共用副本。 - static var tooltipInstance = ctlTooltip() + static var tooltipInstance = TooltipUI() /// 浮動組字窗的共用副本。 static var popupCompositionBuffer = ctlPopupCompositionBuffer() diff --git a/vChewing.xcodeproj/project.pbxproj b/vChewing.xcodeproj/project.pbxproj index 481ef283..1095950c 100644 --- a/vChewing.xcodeproj/project.pbxproj +++ b/vChewing.xcodeproj/project.pbxproj @@ -18,7 +18,6 @@ 5B3133BF280B229700A4A505 /* KeyHandler_States.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B3133BE280B229700A4A505 /* KeyHandler_States.swift */; }; 5B40113928D7050D00A9D4CB /* Shared in Frameworks */ = {isa = PBXBuildFile; productRef = 5B40113828D7050D00A9D4CB /* Shared */; }; 5B40113C28D71C0100A9D4CB /* Uninstaller in Frameworks */ = {isa = PBXBuildFile; productRef = 5B40113B28D71C0100A9D4CB /* Uninstaller */; }; - 5B5F8AEE28C8826D007C11F1 /* ctlTooltip.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B5F8AED28C8826D007C11F1 /* ctlTooltip.swift */; }; 5B62A33D27AE7CC100A19448 /* ctlAboutWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A33C27AE7CC100A19448 /* ctlAboutWindow.swift */; }; 5B62A34727AE7CD900A19448 /* ctlCandidate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B62A34027AE7CD900A19448 /* ctlCandidate.swift */; }; 5B630A3C28CC97020010D076 /* ctlPopupCompositionBuffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B630A3B28CC97020010D076 /* ctlPopupCompositionBuffer.swift */; }; @@ -58,6 +57,7 @@ 5BC447A12865686500EDC323 /* data-zhuyinwen.plist in Resources */ = {isa = PBXBuildFile; fileRef = 5BEDB71F283B4AEA0078EB25 /* data-zhuyinwen.plist */; }; 5BC447A628656A1900EDC323 /* Placeholder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BC447A228656A1900EDC323 /* Placeholder.swift */; }; 5BC5E01E28DDE4770094E427 /* NotifierUI in Frameworks */ = {isa = PBXBuildFile; productRef = 5BC5E01D28DDE4770094E427 /* NotifierUI */; }; + 5BC5E02128DDEFE00094E427 /* TooltipUI in Frameworks */ = {isa = PBXBuildFile; productRef = 5BC5E02028DDEFE00094E427 /* TooltipUI */; }; 5BCCAFF828DB19A300AB1B27 /* PrefMgr_Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BCCAFF728DB19A300AB1B27 /* PrefMgr_Extension.swift */; }; 5BD0113D2818543900609769 /* KeyHandler_Core.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BD0113C2818543900609769 /* KeyHandler_Core.swift */; }; 5BD05BCA27B2A43D004C4F1D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6A2E40F5253A69DA00D1AE1D /* Images.xcassets */; }; @@ -203,7 +203,6 @@ 5B312684287800DE001AA720 /* FAQ.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = FAQ.md; sourceTree = ""; }; 5B3133BE280B229700A4A505 /* KeyHandler_States.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; fileEncoding = 4; indentWidth = 2; lineEnding = 0; path = KeyHandler_States.swift; sourceTree = ""; tabWidth = 2; usesTabs = 0; }; 5B40113A28D71B8700A9D4CB /* vChewing_Uninstaller */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = vChewing_Uninstaller; path = Packages/vChewing_Uninstaller; sourceTree = ""; }; - 5B5F8AED28C8826D007C11F1 /* ctlTooltip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ctlTooltip.swift; sourceTree = ""; }; 5B62A33C27AE7CC100A19448 /* ctlAboutWindow.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; fileEncoding = 4; indentWidth = 2; lineEnding = 0; path = ctlAboutWindow.swift; sourceTree = ""; tabWidth = 2; usesTabs = 0; }; 5B62A34027AE7CD900A19448 /* ctlCandidate.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; fileEncoding = 4; indentWidth = 2; lineEnding = 0; path = ctlCandidate.swift; sourceTree = ""; tabWidth = 2; usesTabs = 0; }; 5B630A3B28CC97020010D076 /* ctlPopupCompositionBuffer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ctlPopupCompositionBuffer.swift; sourceTree = ""; }; @@ -246,6 +245,7 @@ 5BC447A228656A1900EDC323 /* Placeholder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Placeholder.swift; sourceTree = ""; }; 5BC447AB2865BEF500EDC323 /* AUTHORS */ = {isa = PBXFileReference; lastKnownFileType = text; path = AUTHORS; sourceTree = ""; }; 5BC5E01C28DDE4270094E427 /* vChewing_NotifierUI */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = vChewing_NotifierUI; path = Packages/vChewing_NotifierUI; sourceTree = ""; }; + 5BC5E01F28DDEFD80094E427 /* vChewing_TooltipUI */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = vChewing_TooltipUI; path = Packages/vChewing_TooltipUI; sourceTree = ""; }; 5BCCAFF728DB19A300AB1B27 /* PrefMgr_Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrefMgr_Extension.swift; sourceTree = ""; }; 5BD0113C2818543900609769 /* KeyHandler_Core.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; fileEncoding = 4; lineEnding = 0; path = KeyHandler_Core.swift; sourceTree = ""; usesTabs = 0; }; 5BD05BB827B2A429004C4F1D /* vChewingPhraseEditor.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = vChewingPhraseEditor.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -348,6 +348,7 @@ 5B963C9D28D5BFB800DCEE88 /* CocoaExtension in Frameworks */, 5B98114828D6198700CBC605 /* PinyinPhonaConverter in Frameworks */, 5BFC63CF28D4ACA3004A77B7 /* LangModelAssembly in Frameworks */, + 5BC5E02128DDEFE00094E427 /* TooltipUI in Frameworks */, 5BDB7A3928D4824A001AC277 /* BookmarkManager in Frameworks */, 5B963CA328D5C23600DCEE88 /* SwiftExtension in Frameworks */, 5B40113928D7050D00A9D4CB /* Shared in Frameworks */, @@ -437,7 +438,6 @@ 5B62A33E27AE7CD900A19448 /* CandidateUI */, 5B630A3A28CC96D80010D076 /* PopupCompositionBufferUI */, 5BA9FD0927FED9F3002DE248 /* PrefUI */, - 5B62A34227AE7CD900A19448 /* TooltipUI */, ); path = UIModules; sourceTree = ""; @@ -473,14 +473,6 @@ path = CandidateUI; sourceTree = ""; }; - 5B62A34227AE7CD900A19448 /* TooltipUI */ = { - isa = PBXGroup; - children = ( - 5B5F8AED28C8826D007C11F1 /* ctlTooltip.swift */, - ); - path = TooltipUI; - sourceTree = ""; - }; 5B62A35027AE7F6600A19448 /* Data */ = { isa = PBXGroup; children = ( @@ -592,6 +584,7 @@ 5B963C9E28D5C14600DCEE88 /* vChewing_Shared */, 5B963CA128D5C22D00DCEE88 /* vChewing_SwiftExtension */, 5BDB7A3628D47587001AC277 /* vChewing_Tekkon */, + 5BC5E01F28DDEFD80094E427 /* vChewing_TooltipUI */, 5B40113A28D71B8700A9D4CB /* vChewing_Uninstaller */, 5BFC63CA28D49B2B004A77B7 /* vChewing_UpdateSputnik */, ); @@ -789,6 +782,7 @@ 5B40113828D7050D00A9D4CB /* Shared */, 5B40113B28D71C0100A9D4CB /* Uninstaller */, 5BC5E01D28DDE4770094E427 /* NotifierUI */, + 5BC5E02028DDEFE00094E427 /* TooltipUI */, ); productName = vChewing; productReference = 6A0D4EA215FC0D2D00ABF4B3 /* vChewing.app */; @@ -1062,7 +1056,6 @@ 5B62A33D27AE7CC100A19448 /* ctlAboutWindow.swift in Sources */, D47B92C027972AD100458394 /* main.swift in Sources */, D4A13D5A27A59F0B003BE359 /* ctlInputMethod_Core.swift in Sources */, - 5B5F8AEE28C8826D007C11F1 /* ctlTooltip.swift in Sources */, 5B0EF55F28CDBF8E00F8F7CE /* ctlClientListMgr.swift in Sources */, 5B21177028753B9D000443A9 /* ctlInputMethod_Delegates.swift in Sources */, 5B21176E28753B35000443A9 /* ctlInputMethod_HandleDisplay.swift in Sources */, @@ -1788,6 +1781,10 @@ isa = XCSwiftPackageProductDependency; productName = NotifierUI; }; + 5BC5E02028DDEFE00094E427 /* TooltipUI */ = { + isa = XCSwiftPackageProductDependency; + productName = TooltipUI; + }; 5BDB7A3828D4824A001AC277 /* BookmarkManager */ = { isa = XCSwiftPackageProductDependency; productName = BookmarkManager;