diff --git a/LookinDemo/AppKitDemo/AppKitDemo.xcodeproj/project.pbxproj b/LookinDemo/AppKitDemo/AppKitDemo.xcodeproj/project.pbxproj new file mode 100644 index 0000000..c92517e --- /dev/null +++ b/LookinDemo/AppKitDemo/AppKitDemo.xcodeproj/project.pbxproj @@ -0,0 +1,421 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 563F6BC2A9007E85EEADEFCA /* Pods_AppKitDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 487BBCEFD7E4472483D380D5 /* Pods_AppKitDemo.framework */; }; + E925F5132CD9BC2900D290EF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E925F50C2CD9BC2900D290EF /* AppDelegate.swift */; }; + E925F5142CD9BC2900D290EF /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E925F5112CD9BC2900D290EF /* ViewController.swift */; }; + E925F5152CD9BC2900D290EF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E925F50E2CD9BC2900D290EF /* Assets.xcassets */; }; + E925F5162CD9BC2900D290EF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E925F5102CD9BC2900D290EF /* Main.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 487BBCEFD7E4472483D380D5 /* Pods_AppKitDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AppKitDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 4D1201923DFCF7059DD29ADF /* Pods-AppKitDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AppKitDemo.release.xcconfig"; path = "Target Support Files/Pods-AppKitDemo/Pods-AppKitDemo.release.xcconfig"; sourceTree = ""; }; + A9B1B552DA2D19564128318D /* Pods-AppKitDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AppKitDemo.debug.xcconfig"; path = "Target Support Files/Pods-AppKitDemo/Pods-AppKitDemo.debug.xcconfig"; sourceTree = ""; }; + E925F4FA2CD9BC2400D290EF /* AppKitDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AppKitDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; + E925F50C2CD9BC2900D290EF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + E925F50D2CD9BC2900D290EF /* AppKitDemo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AppKitDemo.entitlements; sourceTree = ""; }; + E925F50E2CD9BC2900D290EF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + E925F50F2CD9BC2900D290EF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + E925F5112CD9BC2900D290EF /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + E925F4F72CD9BC2400D290EF /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 563F6BC2A9007E85EEADEFCA /* Pods_AppKitDemo.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 12340C716D79CF698512E9F9 /* Pods */ = { + isa = PBXGroup; + children = ( + A9B1B552DA2D19564128318D /* Pods-AppKitDemo.debug.xcconfig */, + 4D1201923DFCF7059DD29ADF /* Pods-AppKitDemo.release.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; + C2BFAF28A6900E1743745DC3 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 487BBCEFD7E4472483D380D5 /* Pods_AppKitDemo.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + E925F4F12CD9BC2400D290EF = { + isa = PBXGroup; + children = ( + E925F5122CD9BC2900D290EF /* AppKitDemo */, + E925F4FB2CD9BC2400D290EF /* Products */, + 12340C716D79CF698512E9F9 /* Pods */, + C2BFAF28A6900E1743745DC3 /* Frameworks */, + ); + sourceTree = ""; + }; + E925F4FB2CD9BC2400D290EF /* Products */ = { + isa = PBXGroup; + children = ( + E925F4FA2CD9BC2400D290EF /* AppKitDemo.app */, + ); + name = Products; + sourceTree = ""; + }; + E925F5122CD9BC2900D290EF /* AppKitDemo */ = { + isa = PBXGroup; + children = ( + E925F50C2CD9BC2900D290EF /* AppDelegate.swift */, + E925F50D2CD9BC2900D290EF /* AppKitDemo.entitlements */, + E925F50E2CD9BC2900D290EF /* Assets.xcassets */, + E925F5102CD9BC2900D290EF /* Main.storyboard */, + E925F5112CD9BC2900D290EF /* ViewController.swift */, + ); + path = AppKitDemo; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + E925F4F92CD9BC2400D290EF /* AppKitDemo */ = { + isa = PBXNativeTarget; + buildConfigurationList = E925F5092CD9BC2500D290EF /* Build configuration list for PBXNativeTarget "AppKitDemo" */; + buildPhases = ( + 9897681301CBA2C59E615ABC /* [CP] Check Pods Manifest.lock */, + E925F4F62CD9BC2400D290EF /* Sources */, + E925F4F72CD9BC2400D290EF /* Frameworks */, + E925F4F82CD9BC2400D290EF /* Resources */, + 32B0E38D0BC7EDFC22784F3D /* [CP] Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = AppKitDemo; + productName = AppKitDemo; + productReference = E925F4FA2CD9BC2400D290EF /* AppKitDemo.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + E925F4F22CD9BC2400D290EF /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1610; + LastUpgradeCheck = 1610; + TargetAttributes = { + E925F4F92CD9BC2400D290EF = { + CreatedOnToolsVersion = 16.1; + }; + }; + }; + buildConfigurationList = E925F4F52CD9BC2400D290EF /* Build configuration list for PBXProject "AppKitDemo" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = E925F4F12CD9BC2400D290EF; + productRefGroup = E925F4FB2CD9BC2400D290EF /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + E925F4F92CD9BC2400D290EF /* AppKitDemo */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + E925F4F82CD9BC2400D290EF /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E925F5152CD9BC2900D290EF /* Assets.xcassets in Resources */, + E925F5162CD9BC2900D290EF /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 32B0E38D0BC7EDFC22784F3D /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-AppKitDemo/Pods-AppKitDemo-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-AppKitDemo/Pods-AppKitDemo-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-AppKitDemo/Pods-AppKitDemo-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 9897681301CBA2C59E615ABC /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-AppKitDemo-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + E925F4F62CD9BC2400D290EF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E925F5132CD9BC2900D290EF /* AppDelegate.swift in Sources */, + E925F5142CD9BC2900D290EF /* ViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + E925F5102CD9BC2900D290EF /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + E925F50F2CD9BC2900D290EF /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + E925F5072CD9BC2500D290EF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 15.1; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + E925F5082CD9BC2500D290EF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 15.1; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + }; + name = Release; + }; + E925F50A2CD9BC2500D290EF /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = A9B1B552DA2D19564128318D /* Pods-AppKitDemo.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = AppKitDemo/AppKitDemo.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = D5Q73692VW; + ENABLE_HARDENED_RUNTIME = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INFOPLIST_KEY_NSMainStoryboardFile = Main; + INFOPLIST_KEY_NSPrincipalClass = NSApplication; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.JH.AppKitDemo; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + E925F50B2CD9BC2500D290EF /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 4D1201923DFCF7059DD29ADF /* Pods-AppKitDemo.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = AppKitDemo/AppKitDemo.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = D5Q73692VW; + ENABLE_HARDENED_RUNTIME = YES; + ENABLE_USER_SCRIPT_SANDBOXING = NO; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INFOPLIST_KEY_NSMainStoryboardFile = Main; + INFOPLIST_KEY_NSPrincipalClass = NSApplication; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.JH.AppKitDemo; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + E925F4F52CD9BC2400D290EF /* Build configuration list for PBXProject "AppKitDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E925F5072CD9BC2500D290EF /* Debug */, + E925F5082CD9BC2500D290EF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + E925F5092CD9BC2500D290EF /* Build configuration list for PBXNativeTarget "AppKitDemo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E925F50A2CD9BC2500D290EF /* Debug */, + E925F50B2CD9BC2500D290EF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = E925F4F22CD9BC2400D290EF /* Project object */; +} diff --git a/LookinDemo/AppKitDemo/AppKitDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/LookinDemo/AppKitDemo/AppKitDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/LookinDemo/AppKitDemo/AppKitDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/LookinDemo/AppKitDemo/AppKitDemo.xcworkspace/contents.xcworkspacedata b/LookinDemo/AppKitDemo/AppKitDemo.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..d4cb2ca --- /dev/null +++ b/LookinDemo/AppKitDemo/AppKitDemo.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/LookinDemo/AppKitDemo/AppKitDemo/AppDelegate.swift b/LookinDemo/AppKitDemo/AppKitDemo/AppDelegate.swift new file mode 100644 index 0000000..69eb055 --- /dev/null +++ b/LookinDemo/AppKitDemo/AppKitDemo/AppDelegate.swift @@ -0,0 +1,30 @@ +// +// AppDelegate.swift +// AppKitDemo +// +// Created by JH on 2024/11/5. +// + +import Cocoa + +@main +class AppDelegate: NSObject, NSApplicationDelegate { + + + + + func applicationDidFinishLaunching(_ aNotification: Notification) { + // Insert code here to initialize your application + } + + func applicationWillTerminate(_ aNotification: Notification) { + // Insert code here to tear down your application + } + + func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } + + +} + diff --git a/LookinDemo/AppKitDemo/AppKitDemo/AppKitDemo.entitlements b/LookinDemo/AppKitDemo/AppKitDemo/AppKitDemo.entitlements new file mode 100644 index 0000000..997a18c --- /dev/null +++ b/LookinDemo/AppKitDemo/AppKitDemo/AppKitDemo.entitlements @@ -0,0 +1,14 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + com.apple.security.network.client + + com.apple.security.network.server + + + diff --git a/LookinDemo/AppKitDemo/AppKitDemo/Assets.xcassets/AccentColor.colorset/Contents.json b/LookinDemo/AppKitDemo/AppKitDemo/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/LookinDemo/AppKitDemo/AppKitDemo/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/LookinDemo/AppKitDemo/AppKitDemo/Assets.xcassets/AppIcon.appiconset/Contents.json b/LookinDemo/AppKitDemo/AppKitDemo/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..3f00db4 --- /dev/null +++ b/LookinDemo/AppKitDemo/AppKitDemo/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "scale" : "1x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "512x512" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "512x512" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/LookinDemo/AppKitDemo/AppKitDemo/Assets.xcassets/Contents.json b/LookinDemo/AppKitDemo/AppKitDemo/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/LookinDemo/AppKitDemo/AppKitDemo/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/LookinDemo/AppKitDemo/AppKitDemo/Base.lproj/Main.storyboard b/LookinDemo/AppKitDemo/AppKitDemo/Base.lproj/Main.storyboard new file mode 100644 index 0000000..4f242db --- /dev/null +++ b/LookinDemo/AppKitDemo/AppKitDemo/Base.lproj/Main.storyboard @@ -0,0 +1,718 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift b/LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift new file mode 100644 index 0000000..31803e0 --- /dev/null +++ b/LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift @@ -0,0 +1,57 @@ +// +// ViewController.swift +// AppKitDemo +// +// Created by JH on 2024/11/5. +// + +import Cocoa + +class View: NSView { + override var isFlipped: Bool { true } +} + +extension NSView { + var backgroundColor: NSColor? { + set { + setValue(newValue, forKeyPath: "backgroundColor") + } + get { + value(forKeyPath: "backgroundColor") as? NSColor + } + } +} + +class ViewController: NSViewController { + override func viewDidLoad() { + super.viewDidLoad() + + let subview = NSView() + subview.backgroundColor = .red + subview.frame = CGRect(x: 10, y: 10, width: 100, height: 100) + view.addSubview(subview) + + let subview2 = NSView() + subview2.backgroundColor = .blue + subview2.frame = CGRect(x: 10, y: 10, width: 50, height: 50) + subview.addSubview(subview2) + + guard let bitmapRep = view.bitmapImageRepForCachingDisplay(in: view.bounds) else { + return + } + view.cacheDisplay(in: view.bounds, to: bitmapRep) + let image = NSImage(size: view.bounds.size) + image.addRepresentation(bitmapRep) + try? image.tiffRepresentation?.write(to: .desktopDirectory.appending(path: "Test.tiff")) + } + + override var representedObject: Any? { + didSet { + // Update the view, if already loaded. + } + } + + override func viewDidAppear() { + super.viewDidAppear() + } +} diff --git a/LookinDemo/AppKitDemo/Podfile b/LookinDemo/AppKitDemo/Podfile new file mode 100644 index 0000000..f503f57 --- /dev/null +++ b/LookinDemo/AppKitDemo/Podfile @@ -0,0 +1,5 @@ +use_frameworks! + +target 'AppKitDemo' do + pod 'LookinServer', :path=>'../../' +end diff --git a/LookinDemo/AppKitDemo/Podfile.lock b/LookinDemo/AppKitDemo/Podfile.lock new file mode 100644 index 0000000..dd54fbf --- /dev/null +++ b/LookinDemo/AppKitDemo/Podfile.lock @@ -0,0 +1,18 @@ +PODS: + - LookinServer (1.2.8): + - LookinServer/Core (= 1.2.8) + - LookinServer/Core (1.2.8) + +DEPENDENCIES: + - LookinServer (from `../../`) + +EXTERNAL SOURCES: + LookinServer: + :path: "../../" + +SPEC CHECKSUMS: + LookinServer: 32e176f3ef9dfbda52026e2d9e18b7204c141272 + +PODFILE CHECKSUM: 0eea96142f9864079641953fac183889175edfb2 + +COCOAPODS: 1.15.2 diff --git a/LookinDemo/OC_Pod/LookinDemoOC.xcodeproj/project.pbxproj b/LookinDemo/OC_Pod/LookinDemoOC.xcodeproj/project.pbxproj index 0618884..a6fd392 100644 --- a/LookinDemo/OC_Pod/LookinDemoOC.xcodeproj/project.pbxproj +++ b/LookinDemo/OC_Pod/LookinDemoOC.xcodeproj/project.pbxproj @@ -35,6 +35,7 @@ A76A15A028F43C5B00086B38 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; A76A15A228F43C5B00086B38 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; A76A15A328F43C5B00086B38 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + E94749E72CD4C2FB00CB2204 /* LookinDemoOC.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = LookinDemoOC.entitlements; sourceTree = ""; }; FD8E7F541A46626F2CA92333 /* Pods-LookinDemoOC.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-LookinDemoOC.release.xcconfig"; path = "Target Support Files/Pods-LookinDemoOC/Pods-LookinDemoOC.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -79,6 +80,7 @@ A76A159028F43C5A00086B38 /* LookinDemoOC */ = { isa = PBXGroup; children = ( + E94749E72CD4C2FB00CB2204 /* LookinDemoOC.entitlements */, A76A159128F43C5A00086B38 /* AppDelegate.h */, A76A159228F43C5A00086B38 /* AppDelegate.m */, A76A159428F43C5A00086B38 /* SceneDelegate.h */, @@ -365,6 +367,8 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = LookinDemoOC/LookinDemoOC.entitlements; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; @@ -381,8 +385,10 @@ MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = Lookin.LookinDemoOC; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = YES; SWIFT_EMIT_LOC_STRINGS = YES; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,6"; }; name = Debug; }; @@ -392,6 +398,8 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = LookinDemoOC/LookinDemoOC.entitlements; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; @@ -408,8 +416,10 @@ MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = Lookin.LookinDemoOC; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = YES; SWIFT_EMIT_LOC_STRINGS = YES; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,6"; }; name = Release; }; diff --git a/LookinDemo/OC_Pod/LookinDemoOC/LookinDemoOC.entitlements b/LookinDemo/OC_Pod/LookinDemoOC/LookinDemoOC.entitlements new file mode 100644 index 0000000..7a2230d --- /dev/null +++ b/LookinDemo/OC_Pod/LookinDemoOC/LookinDemoOC.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.network.client + + com.apple.security.network.server + + + diff --git a/LookinDemo/OC_Pod/Podfile.lock b/LookinDemo/OC_Pod/Podfile.lock index 53bfdf7..8e47ade 100644 --- a/LookinDemo/OC_Pod/Podfile.lock +++ b/LookinDemo/OC_Pod/Podfile.lock @@ -1,7 +1,7 @@ PODS: - - LookinServer (1.2.6): - - LookinServer/Core (= 1.2.6) - - LookinServer/Core (1.2.6) + - LookinServer (1.2.8): + - LookinServer/Core (= 1.2.8) + - LookinServer/Core (1.2.8) DEPENDENCIES: - LookinServer (from `../../`) @@ -11,8 +11,8 @@ EXTERNAL SOURCES: :path: "../../" SPEC CHECKSUMS: - LookinServer: de929b55f8fa2e241c18c39af3f900eaa9166389 + LookinServer: 32e176f3ef9dfbda52026e2d9e18b7204c141272 PODFILE CHECKSUM: c1b5f203c9e81bcbf3888ba95a03c31e2435a4f7 -COCOAPODS: 1.13.0 +COCOAPODS: 1.15.2 diff --git a/LookinServer.podspec b/LookinServer.podspec index c5ce5fc..c1b6219 100644 --- a/LookinServer.podspec +++ b/LookinServer.podspec @@ -6,12 +6,16 @@ Pod::Spec.new do |spec| spec.homepage = "https://lookin.work" spec.license = "GPL-3.0" spec.author = { "Li Kai" => "lookin@lookin.work" } + spec.macos.deployment_target = "11.0" spec.ios.deployment_target = "9.0" spec.tvos.deployment_target = '9.0' spec.visionos.deployment_target = "1.0" spec.default_subspecs = 'Core' spec.source = { :git => "https://github.com/QMUI/LookinServer.git", :tag => "1.2.8"} - spec.framework = "UIKit" + spec.macos.framework = "AppKit" + spec.ios.framework = "UIKit" + spec.tvos.framework = "UIKit" + spec.visionos.framework = "UIKit" spec.requires_arc = true spec.subspec 'Core' do |ss| diff --git a/Package.swift b/Package.swift index b26b327..e0b3e69 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,7 @@ import PackageDescription let package = Package( name: "LookinServer", platforms: [ - .iOS(.v9),.tvOS(.v9) + .iOS(.v9),.tvOS(.v9), .macOS(.v11) ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. diff --git a/Src/Base/LookinIvarTrace.h b/Src/Base/LookinIvarTrace.h index 3904385..75388e1 100644 --- a/Src/Base/LookinIvarTrace.h +++ b/Src/Base/LookinIvarTrace.h @@ -25,9 +25,7 @@ extern NSString *const LookinIvarTraceRelationValue_Self; #pragma mark - No Coding -#if TARGET_OS_IPHONE @property(nonatomic, weak) id hostObject; -#endif @end diff --git a/Src/Main/Server/Category/CALayer+LookinServer.h b/Src/Main/Server/Category/CALayer+LookinServer.h index 83584a9..9117148 100644 --- a/Src/Main/Server/Category/CALayer+LookinServer.h +++ b/Src/Main/Server/Category/CALayer+LookinServer.h @@ -9,30 +9,28 @@ // #import "LookinDefines.h" -#import "TargetConditionals.h" -#import @interface CALayer (LookinServer) /// 如果 myView.layer == myLayer,则 myLayer.lks_hostView 会返回 myView -@property(nonatomic, readonly, weak) UIView *lks_hostView; +@property(nonatomic, readonly, weak) LookinView *lks_hostView; -- (UIWindow *)lks_window; +- (LookinWindow *)lks_window; -- (CGRect)lks_frameInWindow:(UIWindow *)window; +- (CGRect)lks_frameInWindow:(LookinWindow *)window; -- (UIImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality; +- (LookinImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality; /// 当没有 sublayers 时,该方法返回 nil -- (UIImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality; +- (LookinImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality; /// 获取和该对象有关的对象的 Class 层级树 - (NSArray *> *)lks_relatedClassChainList; - (NSArray *)lks_selfRelation; -@property(nonatomic, strong) UIColor *lks_backgroundColor; -@property(nonatomic, strong) UIColor *lks_borderColor; -@property(nonatomic, strong) UIColor *lks_shadowColor; +@property(nonatomic, strong) LookinColor *lks_backgroundColor; +@property(nonatomic, strong) LookinColor *lks_borderColor; +@property(nonatomic, strong) LookinColor *lks_shadowColor; @property(nonatomic, assign) CGFloat lks_shadowOffsetWidth; @property(nonatomic, assign) CGFloat lks_shadowOffsetHeight; diff --git a/Src/Main/Server/Category/CALayer+LookinServer.m b/Src/Main/Server/Category/CALayer+LookinServer.m index 233734d..65488dc 100644 --- a/Src/Main/Server/Category/CALayer+LookinServer.m +++ b/Src/Main/Server/Category/CALayer+LookinServer.m @@ -17,39 +17,47 @@ #import "LookinServerDefines.h" #import "UIColor+LookinServer.h" #import "LKS_MultiplatformAdapter.h" +#import "NSWindow+LookinServer.h" @implementation CALayer (LookinServer) -- (UIWindow *)lks_window { +- (LookinWindow *)lks_window { CALayer *layer = self; while (layer) { - UIView *hostView = layer.lks_hostView; + LookinView *hostView = layer.lks_hostView; if (hostView.window) { return hostView.window; - } else if ([hostView isKindOfClass:[UIWindow class]]) { - return (UIWindow *)hostView; +#if !TARGET_OS_OSX + } else if ([hostView isKindOfClass:[LookinWindow class]]) { + return (LookinWindow *)hostView; +#endif } layer = layer.superlayer; } return nil; } -- (CGRect)lks_frameInWindow:(UIWindow *)window { - UIWindow *selfWindow = [self lks_window]; +- (CGRect)lks_frameInWindow:(LookinWindow *)window { + LookinWindow *selfWindow = [self lks_window]; if (!selfWindow) { return CGRectZero; } +#if TARGET_OS_IPHONE CGRect rectInSelfWindow = [selfWindow.layer convertRect:self.frame fromLayer:self.superlayer]; CGRect rectInWindow = [window convertRect:rectInSelfWindow fromWindow:selfWindow]; +#elif TARGET_OS_OSX + CGRect rectInSelfWindow = [selfWindow.lks_rootView.layer convertRect:self.frame fromLayer:self.superlayer]; + CGRect rectInWindow = [window.lks_rootView convertRect:rectInSelfWindow fromView:selfWindow.lks_rootView]; +#endif return rectInWindow; } #pragma mark - Host View -- (UIView *)lks_hostView { - if (self.delegate && [self.delegate isKindOfClass:UIView.class]) { - UIView *view = (UIView *)self.delegate; +- (LookinView *)lks_hostView { + if (self.delegate && [self.delegate isKindOfClass:LookinView.class]) { + LookinView *view = (LookinView *)self.delegate; if (view.layer == self) { return view; } @@ -59,7 +67,7 @@ - (UIView *)lks_hostView { #pragma mark - Screenshot -- (UIImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality { +- (LookinImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality { CGFloat screenScale = [LKS_MultiplatformAdapter mainScreenScale]; CGFloat pixelWidth = self.frame.size.width * screenScale; @@ -81,6 +89,7 @@ - (UIImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality { NSLog(@"LookinServer - Failed to capture screenshot. Invalid context size: %@ x %@", @(contextSize.width), @(contextSize.height)); return nil; } +#if TARGET_OS_IPHONE UIGraphicsBeginImageContextWithOptions(contextSize, NO, renderScale); CGContextRef context = UIGraphicsGetCurrentContext(); if (self.lks_hostView && !self.lks_hostView.lks_isChildrenViewOfTabBar) { @@ -91,9 +100,31 @@ - (UIImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality { UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; +#elif TARGET_OS_OSX + NSImage *image = nil; + NSView *view = self.lks_hostView; + if (view) { + NSBitmapImageRep *representation = [view bitmapImageRepForCachingDisplayInRect:view.bounds]; + if (!representation) { + return nil; + } + [view cacheDisplayInRect:view.bounds toBitmapImageRep:representation]; + image = [[NSImage alloc] initWithSize:representation.size]; + [image addRepresentation:representation]; + return image; + + } else { + image = [[NSImage alloc] initWithSize:contextSize]; + [image lockFocusFlipped:self.isGeometryFlipped]; + CGContextRef context = NSGraphicsContext.currentContext.CGContext; + [self renderInContext:context]; + [image unlockFocus]; + } + return image; +#endif } -- (UIImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { +- (LookinImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { if (!self.sublayers.count) { return nil; } @@ -112,7 +143,11 @@ - (UIImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { // 如果算出的 renderScale 大于 1 则取 1,因为似乎用 1 渲染的速度要比一个别的奇怪的带小数点的数字要更快 renderScale = MIN(screenScale * LookinNodeImageMaxLengthInPx / maxLength, 1); } - + CGSize contextSize = self.frame.size; + if (contextSize.width <= 0 || contextSize.height <= 0 || contextSize.width > 20000 || contextSize.height > 20000) { + NSLog(@"LookinServer - Failed to capture screenshot. Invalid context size: %@ x %@", @(contextSize.width), @(contextSize.height)); + return nil; + } if (self.sublayers.count) { NSArray *sublayers = [self.sublayers copy]; NSMutableArray *visibleSublayers = [NSMutableArray arrayWithCapacity:sublayers.count]; @@ -122,13 +157,7 @@ - (UIImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { [visibleSublayers addObject:sublayer]; } }]; - - CGSize contextSize = self.frame.size; - if (contextSize.width <= 0 || contextSize.height <= 0 || contextSize.width > 20000 || contextSize.height > 20000) { - NSLog(@"LookinServer - Failed to capture screenshot. Invalid context size: %@ x %@", @(contextSize.width), @(contextSize.height)); - return nil; - } - +#if TARGET_OS_IPHONE UIGraphicsBeginImageContextWithOptions(contextSize, NO, renderScale); CGContextRef context = UIGraphicsGetCurrentContext(); if (self.lks_hostView && !self.lks_hostView.lks_isChildrenViewOfTabBar) { @@ -139,10 +168,29 @@ - (UIImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); + +#elif TARGET_OS_OSX + NSImage *image = nil; + NSView *view = self.lks_hostView; + if (view) { + NSBitmapImageRep *representation = [view bitmapImageRepForCachingDisplayInRect:view.bounds]; + if (!representation) { + return nil; + } + [view cacheDisplayInRect:view.bounds toBitmapImageRep:representation]; + image = [[NSImage alloc] initWithSize:representation.size]; + [image addRepresentation:representation]; + } else { + image = [[NSImage alloc] initWithSize:contextSize]; + [image lockFocusFlipped:self.isGeometryFlipped]; + CGContextRef context = NSGraphicsContext.currentContext.CGContext; + [self renderInContext:context]; + [image unlockFocus]; + } +#endif [visibleSublayers enumerateObjectsUsingBlock:^(CALayer * _Nonnull sublayer, NSUInteger idx, BOOL * _Nonnull stop) { sublayer.hidden = NO; }]; - return image; } return nil; @@ -151,10 +199,10 @@ - (UIImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { - (NSArray *> *)lks_relatedClassChainList { NSMutableArray *array = [NSMutableArray arrayWithCapacity:2]; if (self.lks_hostView) { - [array addObject:[CALayer lks_getClassListOfObject:self.lks_hostView endingClass:@"UIView"]]; - UIViewController* vc = [self.lks_hostView lks_findHostViewController]; + [array addObject:[CALayer lks_getClassListOfObject:self.lks_hostView endingClass:LookinViewString]]; + NSViewController* vc = [self.lks_hostView lks_findHostViewController]; if (vc) { - [array addObject:[CALayer lks_getClassListOfObject:vc endingClass:@"UIViewController"]]; + [array addObject:[CALayer lks_getClassListOfObject:vc endingClass:LookinViewControllerString]]; } } else { [array addObject:[CALayer lks_getClassListOfObject:self endingClass:@"CALayer"]]; @@ -175,7 +223,7 @@ - (UIImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { NSMutableArray *array = [NSMutableArray array]; NSMutableArray *ivarTraces = [NSMutableArray array]; if (self.lks_hostView) { - UIViewController* vc = [self.lks_hostView lks_findHostViewController]; + LookinViewController* vc = [self.lks_hostView lks_findHostViewController]; if (vc) { [array addObject:[NSString stringWithFormat:@"(%@ *).view", NSStringFromClass(vc.class)]]; @@ -193,24 +241,24 @@ - (UIImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { return array.count ? array.copy : nil; } -- (UIColor *)lks_backgroundColor { - return [UIColor lks_colorWithCGColor:self.backgroundColor]; +- (LookinColor *)lks_backgroundColor { + return [LookinColor lks_colorWithCGColor:self.backgroundColor]; } -- (void)setLks_backgroundColor:(UIColor *)lks_backgroundColor { +- (void)setLks_backgroundColor:(LookinColor *)lks_backgroundColor { self.backgroundColor = lks_backgroundColor.CGColor; } -- (UIColor *)lks_borderColor { - return [UIColor lks_colorWithCGColor:self.borderColor]; +- (LookinColor *)lks_borderColor { + return [LookinColor lks_colorWithCGColor:self.borderColor]; } -- (void)setLks_borderColor:(UIColor *)lks_borderColor { +- (void)setLks_borderColor:(LookinColor *)lks_borderColor { self.borderColor = lks_borderColor.CGColor; } -- (UIColor *)lks_shadowColor { - return [UIColor lks_colorWithCGColor:self.shadowColor]; +- (LookinColor *)lks_shadowColor { + return [LookinColor lks_colorWithCGColor:self.shadowColor]; } -- (void)setLks_shadowColor:(UIColor *)lks_shadowColor { +- (void)setLks_shadowColor:(LookinColor *)lks_shadowColor { self.shadowColor = lks_shadowColor.CGColor; } diff --git a/Src/Main/Server/Category/NSButton+LookinServer.h b/Src/Main/Server/Category/NSButton+LookinServer.h new file mode 100644 index 0000000..89005dd --- /dev/null +++ b/Src/Main/Server/Category/NSButton+LookinServer.h @@ -0,0 +1,22 @@ +// +// NSButton+LookinServer.h +// LookinServer +// +// Created by JH on 2024/11/7. +// + +#import "TargetConditionals.h" + +#if TARGET_OS_OSX + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface NSButton (LookinServer) +@property (nonatomic, readonly) NSButtonType lks_buttonType; +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/Src/Main/Server/Category/NSButton+LookinServer.m b/Src/Main/Server/Category/NSButton+LookinServer.m new file mode 100644 index 0000000..f2e3771 --- /dev/null +++ b/Src/Main/Server/Category/NSButton+LookinServer.m @@ -0,0 +1,16 @@ +// +// NSButton+LookinServer.m +// LookinServer +// +// Created by JH on 2024/11/7. +// + +#import "NSButton+LookinServer.h" + +#if TARGET_OS_OSX +@implementation NSButton (LookinServer) +- (NSButtonType)lks_buttonType { + return [[self valueForKeyPath:@"cell._buttonType"] unsignedIntegerValue]; +} +@end +#endif diff --git a/Src/Main/Server/Category/NSScrollView+LookinServer.h b/Src/Main/Server/Category/NSScrollView+LookinServer.h new file mode 100644 index 0000000..6ee3c9b --- /dev/null +++ b/Src/Main/Server/Category/NSScrollView+LookinServer.h @@ -0,0 +1,24 @@ +// +// NSScrollView+LookinServer.h +// LookinServer +// +// Created by JH on 2024/11/7. +// + +#import "TargetConditionals.h" + +#if TARGET_OS_OSX +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface NSScrollView (LookinServer) + +@property (nonatomic) CGPoint lks_contentOffset; +@property (nonatomic) CGSize lks_contentSize; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/Src/Main/Server/Category/NSScrollView+LookinServer.m b/Src/Main/Server/Category/NSScrollView+LookinServer.m new file mode 100644 index 0000000..dd9441e --- /dev/null +++ b/Src/Main/Server/Category/NSScrollView+LookinServer.m @@ -0,0 +1,30 @@ +// +// NSScrollView+LookinServer.m +// LookinServer +// +// Created by JH on 2024/11/7. +// + +#import "NSScrollView+LookinServer.h" +#if TARGET_OS_OSX + +@implementation NSScrollView (LookinServer) + +- (void)setLks_contentOffset:(CGPoint)lks_contentOffset { + [self.contentView scrollToPoint:lks_contentOffset]; +} + +- (CGPoint)lks_contentOffset { + return self.contentView.bounds.origin; +} + +- (void)setLks_contentSize:(CGSize)lks_contentSize { + [self.documentView setFrameSize:lks_contentSize]; +} + +- (CGSize)lks_contentSize { + return self.documentView.frame.size; +} + +@end +#endif diff --git a/Src/Main/Server/Category/NSWindow+LookinServer.h b/Src/Main/Server/Category/NSWindow+LookinServer.h new file mode 100644 index 0000000..0ce2c75 --- /dev/null +++ b/Src/Main/Server/Category/NSWindow+LookinServer.h @@ -0,0 +1,28 @@ +// +// NSWindow+LookinServer.h +// LookinServer +// +// Created by JH on 11/5/24. +// + +#import "TargetConditionals.h" + +#if TARGET_OS_OSX + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface NSWindow (LookinServer) +// NSWindow 的 rootView 是 contentView 的 superview,例如 NSThemeFrame +@property (nonatomic, readonly) NSView *lks_rootView; + +- (NSImage *)lks_snapshotImage; + +- (CGRect)lks_bounds; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/Src/Main/Server/Category/NSWindow+LookinServer.m b/Src/Main/Server/Category/NSWindow+LookinServer.m new file mode 100644 index 0000000..829e589 --- /dev/null +++ b/Src/Main/Server/Category/NSWindow+LookinServer.m @@ -0,0 +1,33 @@ +// +// NSWindow+LookinServer.m +// LookinServer +// +// Created by JH on 11/5/24. +// + +#import "NSWindow+LookinServer.h" + +#if TARGET_OS_OSX + +@implementation NSWindow (LookinServer) + +- (NSView *)lks_rootView { + return self.contentView.superview; +} + +- (NSImage *)lks_snapshotImage { + CGImageRef cgImage = CGWindowListCreateImage(CGRectZero, kCGWindowListOptionIncludingWindow, (int)self.windowNumber, kCGWindowImageBoundsIgnoreFraming); + NSImage *image = [[NSImage alloc] initWithCGImage:cgImage size:self.frame.size]; + CGImageRelease(cgImage); + return image; +} + +- (CGRect)lks_bounds { + CGRect frame = self.frame; + frame.origin = CGPointZero; + return frame; +} + +@end + +#endif diff --git a/Src/Main/Server/Category/UIBlurEffect+LookinServer.h b/Src/Main/Server/Category/UIBlurEffect+LookinServer.h index 1623a8d..aae7010 100644 --- a/Src/Main/Server/Category/UIBlurEffect+LookinServer.h +++ b/Src/Main/Server/Category/UIBlurEffect+LookinServer.h @@ -8,6 +8,10 @@ // https://lookin.work // +#import "TargetConditionals.h" + +#if TARGET_OS_IPHONE + #import @interface UIBlurEffect (LookinServer) @@ -18,4 +22,6 @@ @end +#endif + #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Category/UIBlurEffect+LookinServer.m b/Src/Main/Server/Category/UIBlurEffect+LookinServer.m index ddc36ac..e02f6fb 100644 --- a/Src/Main/Server/Category/UIBlurEffect+LookinServer.m +++ b/Src/Main/Server/Category/UIBlurEffect+LookinServer.m @@ -12,6 +12,8 @@ #import "NSObject+Lookin.h" #import +#if TARGET_OS_IPHONE + @implementation UIBlurEffect (LookinServer) #ifdef LOOKIN_SERVER_DISABLE_HOOK @@ -54,4 +56,6 @@ - (NSNumber *)lks_effectStyleNumber { @end +#endif + #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Category/UIColor+LookinServer.h b/Src/Main/Server/Category/UIColor+LookinServer.h index 9b4133f..c11196c 100644 --- a/Src/Main/Server/Category/UIColor+LookinServer.h +++ b/Src/Main/Server/Category/UIColor+LookinServer.h @@ -8,9 +8,9 @@ // https://lookin.work // -#import +#import "LookinDefines.h" -@interface UIColor (LookinServer) +@interface LookinColor (LookinServer) - (NSArray *)lks_rgbaComponents; + (instancetype)lks_colorFromRGBAComponents:(NSArray *)components; @@ -19,7 +19,7 @@ - (NSString *)lks_hexString; /// will check if the argument is a real CGColor -+ (UIColor *)lks_colorWithCGColor:(CGColorRef)cgColor; ++ (LookinColor *)lks_colorWithCGColor:(CGColorRef)cgColor; @end diff --git a/Src/Main/Server/Category/UIColor+LookinServer.m b/Src/Main/Server/Category/UIColor+LookinServer.m index ce1aea9..0b87b6f 100644 --- a/Src/Main/Server/Category/UIColor+LookinServer.m +++ b/Src/Main/Server/Category/UIColor+LookinServer.m @@ -10,7 +10,7 @@ #import "UIColor+LookinServer.h" -@implementation UIColor (LookinServer) +@implementation LookinColor (LookinServer) - (NSArray *)lks_rgbaComponents { CGFloat r, g, b, a; @@ -50,7 +50,7 @@ + (instancetype)lks_colorFromRGBAComponents:(NSArray *)components { NSAssert(NO, @""); return nil; } - UIColor *color = [UIColor colorWithRed:components[0].doubleValue green:components[1].doubleValue blue:components[2].doubleValue alpha:components[3].doubleValue]; + LookinColor *color = [LookinColor colorWithRed:components[0].doubleValue green:components[1].doubleValue blue:components[2].doubleValue alpha:components[3].doubleValue]; return color; } @@ -111,10 +111,10 @@ - (NSString *)lks_hexString { NSInteger alpha = a * 255; return [[NSString stringWithFormat:@"#%@%@%@%@", - [UIColor _alignColorHexStringLength:[UIColor _hexStringWithInteger:alpha]], - [UIColor _alignColorHexStringLength:[UIColor _hexStringWithInteger:red]], - [UIColor _alignColorHexStringLength:[UIColor _hexStringWithInteger:green]], - [UIColor _alignColorHexStringLength:[UIColor _hexStringWithInteger:blue]]] lowercaseString]; + [LookinColor _alignColorHexStringLength:[LookinColor _hexStringWithInteger:alpha]], + [LookinColor _alignColorHexStringLength:[LookinColor _hexStringWithInteger:red]], + [LookinColor _alignColorHexStringLength:[LookinColor _hexStringWithInteger:green]], + [LookinColor _alignColorHexStringLength:[LookinColor _hexStringWithInteger:blue]]] lowercaseString]; } // 对于色值只有单位数的,在前面补一个0,例如“F”会补齐为“0F” @@ -168,14 +168,14 @@ + (NSString *)_hexLetterStringWithInteger:(NSInteger)integer { return letter; } -+ (UIColor *)lks_colorWithCGColor:(CGColorRef)cgColor { ++ (LookinColor *)lks_colorWithCGColor:(CGColorRef)cgColor { if (!cgColor) { return nil; } if (CFGetTypeID(cgColor) != CGColorGetTypeID()) { return nil; } - return [UIColor colorWithCGColor:cgColor]; + return [LookinColor colorWithCGColor:cgColor]; } @end diff --git a/Src/Main/Server/Category/UIImage+LookinServer.h b/Src/Main/Server/Category/UIImage+LookinServer.h index cf7f6ff..442f5ea 100644 --- a/Src/Main/Server/Category/UIImage+LookinServer.h +++ b/Src/Main/Server/Category/UIImage+LookinServer.h @@ -8,9 +8,9 @@ // https://lookin.work // -#import +#import "LookinDefines.h" -@interface UIImage (LookinServer) +@interface LookinImage (LookinServer) /// 该方法的实现需要 Hook,因此若定义了 LOOKIN_SERVER_DISABLE_HOOK 宏,则属性会返回 nil @property(nonatomic, copy) NSString *lks_imageSourceName; diff --git a/Src/Main/Server/Category/UIImage+LookinServer.m b/Src/Main/Server/Category/UIImage+LookinServer.m index 97f8264..7029ce2 100644 --- a/Src/Main/Server/Category/UIImage+LookinServer.m +++ b/Src/Main/Server/Category/UIImage+LookinServer.m @@ -12,7 +12,7 @@ #import "UIImage+LookinServer.h" #import "LookinServerDefines.h" -@implementation UIImage (LookinServer) +@implementation LookinImage (LookinServer) #ifdef LOOKIN_SERVER_DISABLE_HOOK @@ -32,6 +32,7 @@ + (void)load { Method newMethod = class_getClassMethod([self class], @selector(lks_imageNamed:)); method_exchangeImplementations(oriMethod, newMethod); +#if TARGET_OS_IPHONE oriMethod = class_getClassMethod([self class], @selector(imageWithContentsOfFile:)); newMethod = class_getClassMethod([self class], @selector(lks_imageWithContentsOfFile:)); method_exchangeImplementations(oriMethod, newMethod); @@ -45,9 +46,19 @@ + (void)load { newMethod = class_getClassMethod([self class], @selector(lks_imageNamed:inBundle:withConfiguration:)); method_exchangeImplementations(oriMethod, newMethod); } +#endif + +#if TARGET_OS_OSX +#endif }); } ++ (LookinImage *)lks_imageNamed:(NSString *)name { + LookinImage *image = [self lks_imageNamed:name]; + image.lks_imageSourceName = name; + return image; +} +#if TARGET_OS_IPHONE + (nullable UIImage *)lks_imageNamed:(NSString *)name inBundle:(nullable NSBundle *)bundle withConfiguration:(nullable UIImageConfiguration *)configuration API_AVAILABLE(ios(13.0),tvos(13.0),watchos(6.0)) { UIImage *image = [self lks_imageNamed:name inBundle:bundle withConfiguration:configuration]; @@ -62,12 +73,6 @@ + (nullable UIImage *)lks_imageNamed:(NSString *)name inBundle:(nullable NSBundl return image; } -+ (UIImage *)lks_imageNamed:(NSString *)name { - UIImage *image = [self lks_imageNamed:name]; - image.lks_imageSourceName = name; - return image; -} - + (UIImage *)lks_imageWithContentsOfFile:(NSString *)path { UIImage *image = [self lks_imageWithContentsOfFile:path]; @@ -75,6 +80,10 @@ + (UIImage *)lks_imageWithContentsOfFile:(NSString *)path { image.lks_imageSourceName = fileName; return image; } +#endif + +#if TARGET_OS_OSX +#endif - (void)setLks_imageSourceName:(NSString *)lks_imageSourceName { [self lookin_bindObject:lks_imageSourceName.copy forKey:@"lks_imageSourceName"]; @@ -87,7 +96,13 @@ - (NSString *)lks_imageSourceName { #endif /* LOOKIN_SERVER_DISABLE_HOOK */ - (NSData *)lookin_data { +#if TARGET_OS_IPHONE return UIImagePNGRepresentation(self); +#endif + +#if TARGET_OS_OSX + return [NSBitmapImageRep representationOfImageRepsInArray:self.representations usingType:(NSBitmapImageFileTypePNG) properties:@{}];; +#endif } @end diff --git a/Src/Main/Server/Category/UIImageView+LookinServer.h b/Src/Main/Server/Category/UIImageView+LookinServer.h index 6da9028..5f74fa0 100644 --- a/Src/Main/Server/Category/UIImageView+LookinServer.h +++ b/Src/Main/Server/Category/UIImageView+LookinServer.h @@ -8,9 +8,9 @@ // https://lookin.work // -#import +#import "LookinDefines.h" -@interface UIImageView (LookinServer) +@interface LookinImageView (LookinServer) - (NSString *)lks_imageSourceName; - (NSNumber *)lks_imageViewOidIfHasImage; diff --git a/Src/Main/Server/Category/UIImageView+LookinServer.m b/Src/Main/Server/Category/UIImageView+LookinServer.m index 76e83cf..b4341e2 100644 --- a/Src/Main/Server/Category/UIImageView+LookinServer.m +++ b/Src/Main/Server/Category/UIImageView+LookinServer.m @@ -12,7 +12,7 @@ #import "UIImage+LookinServer.h" #import "NSObject+LookinServer.h" -@implementation UIImageView (LookinServer) +@implementation LookinImageView (LookinServer) - (NSString *)lks_imageSourceName { return self.image.lks_imageSourceName; diff --git a/Src/Main/Server/Category/UILabel+LookinServer.h b/Src/Main/Server/Category/UILabel+LookinServer.h index 92c9294..9325178 100644 --- a/Src/Main/Server/Category/UILabel+LookinServer.h +++ b/Src/Main/Server/Category/UILabel+LookinServer.h @@ -8,6 +8,10 @@ // https://lookin.work // +#import "TargetConditionals.h" + +#if TARGET_OS_IPHONE + #import @interface UILabel (LookinServer) @@ -18,4 +22,6 @@ @end +#endif + #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Category/UILabel+LookinServer.m b/Src/Main/Server/Category/UILabel+LookinServer.m index b7b9f70..e00d492 100644 --- a/Src/Main/Server/Category/UILabel+LookinServer.m +++ b/Src/Main/Server/Category/UILabel+LookinServer.m @@ -10,6 +10,7 @@ #import "UILabel+LookinServer.h" +#if TARGET_OS_IPHONE @implementation UILabel (LookinServer) - (CGFloat)lks_fontSize { @@ -25,5 +26,6 @@ - (NSString *)lks_fontName { } @end +#endif #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Category/UITableView+LookinServer.h b/Src/Main/Server/Category/UITableView+LookinServer.h index 881fa36..0c004b4 100644 --- a/Src/Main/Server/Category/UITableView+LookinServer.h +++ b/Src/Main/Server/Category/UITableView+LookinServer.h @@ -8,6 +8,9 @@ // https://lookin.work // +#import "TargetConditionals.h" + +#if TARGET_OS_IPHONE #import @interface UITableView (LookinServer) @@ -15,5 +18,6 @@ - (NSArray *)lks_numberOfRows; @end +#endif #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Category/UITableView+LookinServer.m b/Src/Main/Server/Category/UITableView+LookinServer.m index 3788e3f..c26ef2e 100644 --- a/Src/Main/Server/Category/UITableView+LookinServer.m +++ b/Src/Main/Server/Category/UITableView+LookinServer.m @@ -11,6 +11,7 @@ #import "UITableView+LookinServer.h" #import "LookinServerDefines.h" +#if TARGET_OS_IPHONE @implementation UITableView (LookinServer) - (NSArray *)lks_numberOfRows { @@ -25,5 +26,9 @@ @implementation UITableView (LookinServer) } @end +#endif + +#if TARGET_OS_OSX +#endif #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Category/UITextField+LookinServer.h b/Src/Main/Server/Category/UITextField+LookinServer.h index 429c30b..62cdfc3 100644 --- a/Src/Main/Server/Category/UITextField+LookinServer.h +++ b/Src/Main/Server/Category/UITextField+LookinServer.h @@ -8,9 +8,9 @@ // https://lookin.work // -#import +#import "LookinDefines.h" -@interface UITextField (LookinServer) +@interface LookinTextField (LookinServer) @property(nonatomic, assign) CGFloat lks_fontSize; @@ -18,4 +18,5 @@ @end + #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Category/UITextField+LookinServer.m b/Src/Main/Server/Category/UITextField+LookinServer.m index 9e07a76..5b37cd5 100644 --- a/Src/Main/Server/Category/UITextField+LookinServer.m +++ b/Src/Main/Server/Category/UITextField+LookinServer.m @@ -8,15 +8,16 @@ // https://lookin.work // + #import "UITextField+LookinServer.h" -@implementation UITextField (LookinServer) +@implementation LookinTextField (LookinServer) - (CGFloat)lks_fontSize { return self.font.pointSize; } - (void)setLks_fontSize:(CGFloat)lks_fontSize { - UIFont *font = [self.font fontWithSize:lks_fontSize]; + LookinFont *font = [self.font fontWithSize:lks_fontSize]; self.font = font; } diff --git a/Src/Main/Server/Category/UITextView+LookinServer.h b/Src/Main/Server/Category/UITextView+LookinServer.h index e36b2ab..d7ba596 100644 --- a/Src/Main/Server/Category/UITextView+LookinServer.h +++ b/Src/Main/Server/Category/UITextView+LookinServer.h @@ -8,9 +8,9 @@ // https://lookin.work // -#import +#import "LookinDefines.h" -@interface UITextView (LookinServer) +@interface LookinTextView (LookinServer) @property(nonatomic, assign) CGFloat lks_fontSize; diff --git a/Src/Main/Server/Category/UITextView+LookinServer.m b/Src/Main/Server/Category/UITextView+LookinServer.m index bd81a8b..7d1538c 100644 --- a/Src/Main/Server/Category/UITextView+LookinServer.m +++ b/Src/Main/Server/Category/UITextView+LookinServer.m @@ -8,15 +8,16 @@ // https://lookin.work // + #import "UITextView+LookinServer.h" -@implementation UITextView (LookinServer) +@implementation LookinTextView (LookinServer) - (CGFloat)lks_fontSize { return self.font.pointSize; } - (void)setLks_fontSize:(CGFloat)lks_fontSize { - UIFont *font = [self.font fontWithSize:lks_fontSize]; + LookinFont *font = [self.font fontWithSize:lks_fontSize]; self.font = font; } diff --git a/Src/Main/Server/Category/UIView+LookinServer.h b/Src/Main/Server/Category/UIView+LookinServer.h index eca36a1..e4c8bc6 100644 --- a/Src/Main/Server/Category/UIView+LookinServer.h +++ b/Src/Main/Server/Category/UIView+LookinServer.h @@ -9,18 +9,17 @@ // #import "LookinDefines.h" -#import -@interface UIView (LookinServer) +@interface LookinView (LookinServer) /// 如果 myViewController.view = myView,则可以通过 myView 的 lks_findHostViewController 方法找到 myViewController -- (UIViewController *)lks_findHostViewController; +- (LookinViewController *)lks_findHostViewController; /// 是否是 UITabBar 的 childrenView,如果是的话,则截图时需要强制使用 renderInContext: 的方式而非 drawViewHierarchyInRect:afterScreenUpdates: 否则在 iOS 13 上获取到的图像是空的不知道为什么 @property(nonatomic, assign) BOOL lks_isChildrenViewOfTabBar; /// point 是相对于 receiver 自身的坐标系 -- (UIView *)lks_subviewAtPoint:(CGPoint)point preferredClasses:(NSArray *)preferredClasses; +- (LookinView *)lks_subviewAtPoint:(CGPoint)point preferredClasses:(NSArray *)preferredClasses; - (CGFloat)lks_bestWidth; - (CGFloat)lks_bestHeight; @@ -39,6 +38,12 @@ - (NSArray *> *)lks_constraints; +#if TARGET_OS_OSX +- (LookinImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality; +/// 当没有 sublayers 时,该方法返回 nil +- (LookinImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality; +#endif + @end #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Category/UIView+LookinServer.m b/Src/Main/Server/Category/UIView+LookinServer.m index 9cfa5f3..c579724 100644 --- a/Src/Main/Server/Category/UIView+LookinServer.m +++ b/Src/Main/Server/Category/UIView+LookinServer.m @@ -14,25 +14,51 @@ #import "LookinAutoLayoutConstraint.h" #import "LookinServerDefines.h" #import "LKS_MultiplatformAdapter.h" +#import "LookinAutoLayoutConstraint+LookinServer.h" +#import "NSWindow+LookinServer.h" +@implementation LookinView (LookinServer) -@implementation UIView (LookinServer) +#if TARGET_OS_OSX +- (CGFloat)alpha { + return self.alphaValue; +} +- (void)setContentCompressionResistancePriority:(NSLayoutPriority)priority + forAxis:(NSLayoutConstraintOrientation)axis { + [self setContentCompressionResistancePriority:priority forOrientation:axis]; +} +- (void)setContentHuggingPriority:(NSLayoutPriority)priority + forAxis:(NSLayoutConstraintOrientation)axis { + [self setContentHuggingPriority:priority forOrientation:axis]; +} + +- (float)contentHuggingPriorityForAxis:(NSLayoutConstraintOrientation)axis { + return [self contentHuggingPriorityForOrientation:axis]; +} + +- (float)contentCompressionResistancePriorityForAxis:(NSLayoutConstraintOrientation)axis { + return [self contentCompressionResistancePriorityForOrientation:axis]; +} +- (NSArray *)constraintsAffectingLayoutForAxis:(NSLayoutConstraintOrientation)orientation { + return [self constraintsAffectingLayoutForOrientation:orientation]; +} +#endif -- (UIViewController *)lks_findHostViewController { - UIResponder *responder = [self nextResponder]; +- (LookinViewController *)lks_findHostViewController { + LookinResponder *responder = [self nextResponder]; if (!responder) { return nil; } - if (![responder isKindOfClass:[UIViewController class]]) { + if (![responder isKindOfClass:[LookinViewController class]]) { return nil; } - UIViewController *viewController = (UIViewController *)responder; + LookinViewController *viewController = (LookinViewController *)responder; if (viewController.view != self) { return nil; } return viewController; } -- (UIView *)lks_subviewAtPoint:(CGPoint)point preferredClasses:(NSArray *)preferredClasses { +- (LookinView *)lks_subviewAtPoint:(CGPoint)point preferredClasses:(NSArray *)preferredClasses { BOOL isPreferredClassForSelf = [preferredClasses lookin_any:^BOOL(Class obj) { return [self isKindOfClass:obj]; }]; @@ -40,7 +66,7 @@ - (UIView *)lks_subviewAtPoint:(CGPoint)point preferredClasses:(NSArray * return self; } - UIView *targetView = [self.subviews lookin_lastFiltered:^BOOL(__kindof UIView *obj) { + LookinView *targetView = [self.subviews lookin_lastFiltered:^BOOL(__kindof LookinView *obj) { if (obj.hidden || obj.alpha <= 0.01) { return NO; } @@ -58,7 +84,15 @@ - (UIView *)lks_subviewAtPoint:(CGPoint)point preferredClasses:(NSArray * } - (CGSize)lks_bestSize { +#if TARGET_OS_IPHONE return [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)]; +#elif TARGET_OS_OSX + if ([self isKindOfClass:[NSControl class]]) { + return [((NSControl *)self) sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)]; + } else { + return self.fittingSize; + } +#endif } - (CGFloat)lks_bestWidth { @@ -77,54 +111,62 @@ - (BOOL)lks_isChildrenViewOfTabBar { } - (void)setLks_verticalContentHuggingPriority:(float)lks_verticalContentHuggingPriority { - [self setContentHuggingPriority:lks_verticalContentHuggingPriority forAxis:UILayoutConstraintAxisVertical]; + [self setContentHuggingPriority:lks_verticalContentHuggingPriority forAxis:LookinLayoutConstraintAxisVertical]; } - (float)lks_verticalContentHuggingPriority { - return [self contentHuggingPriorityForAxis:UILayoutConstraintAxisVertical]; + return [self contentHuggingPriorityForAxis:LookinLayoutConstraintAxisVertical]; } - (void)setLks_horizontalContentHuggingPriority:(float)lks_horizontalContentHuggingPriority { - [self setContentHuggingPriority:lks_horizontalContentHuggingPriority forAxis:UILayoutConstraintAxisHorizontal]; + [self setContentHuggingPriority:lks_horizontalContentHuggingPriority forAxis:LookinLayoutConstraintAxisHorizontal]; } - (float)lks_horizontalContentHuggingPriority { - return [self contentHuggingPriorityForAxis:UILayoutConstraintAxisHorizontal]; + return [self contentHuggingPriorityForAxis:LookinLayoutConstraintAxisHorizontal]; } - (void)setLks_verticalContentCompressionResistancePriority:(float)lks_verticalContentCompressionResistancePriority { - [self setContentCompressionResistancePriority:lks_verticalContentCompressionResistancePriority forAxis:UILayoutConstraintAxisVertical]; + [self setContentCompressionResistancePriority:lks_verticalContentCompressionResistancePriority forAxis:LookinLayoutConstraintAxisVertical]; } - (float)lks_verticalContentCompressionResistancePriority { - return [self contentCompressionResistancePriorityForAxis:UILayoutConstraintAxisVertical]; + return [self contentCompressionResistancePriorityForAxis:LookinLayoutConstraintAxisVertical]; } - (void)setLks_horizontalContentCompressionResistancePriority:(float)lks_horizontalContentCompressionResistancePriority { - [self setContentCompressionResistancePriority:lks_horizontalContentCompressionResistancePriority forAxis:UILayoutConstraintAxisHorizontal]; + [self setContentCompressionResistancePriority:lks_horizontalContentCompressionResistancePriority forAxis:LookinLayoutConstraintAxisHorizontal]; } - (float)lks_horizontalContentCompressionResistancePriority { - return [self contentCompressionResistancePriorityForAxis:UILayoutConstraintAxisHorizontal]; + return [self contentCompressionResistancePriorityForAxis:LookinLayoutConstraintAxisHorizontal]; } + (void)lks_rebuildGlobalInvolvedRawConstraints { - [[LKS_MultiplatformAdapter allWindows] enumerateObjectsUsingBlock:^(__kindof UIWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) { + [[LKS_MultiplatformAdapter allWindows] enumerateObjectsUsingBlock:^(__kindof LookinWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) { +#if TARGET_OS_IPHONE [self lks_removeInvolvedRawConstraintsForViewsRootedByView:window]; +#elif TARGET_OS_OSX + [self lks_removeInvolvedRawConstraintsForViewsRootedByView:window.lks_rootView]; +#endif }]; - [[LKS_MultiplatformAdapter allWindows] enumerateObjectsUsingBlock:^(__kindof UIWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) { + [[LKS_MultiplatformAdapter allWindows] enumerateObjectsUsingBlock:^(__kindof LookinWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) { +#if TARGET_OS_IPHONE [self lks_addInvolvedRawConstraintsForViewsRootedByView:window]; +#elif TARGET_OS_OSX + [self lks_addInvolvedRawConstraintsForViewsRootedByView:window.lks_rootView]; +#endif }]; } -+ (void)lks_addInvolvedRawConstraintsForViewsRootedByView:(UIView *)rootView { ++ (void)lks_addInvolvedRawConstraintsForViewsRootedByView:(LookinView *)rootView { [rootView.constraints enumerateObjectsUsingBlock:^(__kindof NSLayoutConstraint * _Nonnull constraint, NSUInteger idx, BOOL * _Nonnull stop) { - UIView *firstView = constraint.firstItem; - if ([firstView isKindOfClass:[UIView class]] && ![firstView.lks_involvedRawConstraints containsObject:constraint]) { + LookinView *firstView = constraint.firstItem; + if ([firstView isKindOfClass:[LookinView class]] && ![firstView.lks_involvedRawConstraints containsObject:constraint]) { if (!firstView.lks_involvedRawConstraints) { firstView.lks_involvedRawConstraints = [NSMutableArray array]; } [firstView.lks_involvedRawConstraints addObject:constraint]; } - UIView *secondView = constraint.secondItem; - if ([secondView isKindOfClass:[UIView class]] && ![secondView.lks_involvedRawConstraints containsObject:constraint]) { + LookinView *secondView = constraint.secondItem; + if ([secondView isKindOfClass:[LookinView class]] && ![secondView.lks_involvedRawConstraints containsObject:constraint]) { if (!secondView.lks_involvedRawConstraints) { secondView.lks_involvedRawConstraints = [NSMutableArray array]; } @@ -132,14 +174,14 @@ + (void)lks_addInvolvedRawConstraintsForViewsRootedByView:(UIView *)rootView { } }]; - [rootView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull subview, NSUInteger idx, BOOL * _Nonnull stop) { + [rootView.subviews enumerateObjectsUsingBlock:^(__kindof LookinView * _Nonnull subview, NSUInteger idx, BOOL * _Nonnull stop) { [self lks_addInvolvedRawConstraintsForViewsRootedByView:subview]; }]; } -+ (void)lks_removeInvolvedRawConstraintsForViewsRootedByView:(UIView *)rootView { ++ (void)lks_removeInvolvedRawConstraintsForViewsRootedByView:(LookinView *)rootView { [rootView.lks_involvedRawConstraints removeAllObjects]; - [rootView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull subview, NSUInteger idx, BOOL * _Nonnull stop) { + [rootView.subviews enumerateObjectsUsingBlock:^(__kindof LookinView * _Nonnull subview, NSUInteger idx, BOOL * _Nonnull stop) { [self lks_removeInvolvedRawConstraintsForViewsRootedByView:subview]; }]; } @@ -161,8 +203,8 @@ - (void)setLks_involvedRawConstraints:(NSMutableArray *)lk · 如果设置了 View1 的 center 和 superview 的 center 保持一致,则 superview 的 width 和 height 也会出现在 effectiveConstraints 里,但不会出现在 lks_involvedRawConstraints 里(这点可以理解,毕竟这种场景下 superview 的 width 和 height 确实会影响到 View1) */ NSMutableArray *effectiveConstraints = [NSMutableArray array]; - [effectiveConstraints addObjectsFromArray:[self constraintsAffectingLayoutForAxis:UILayoutConstraintAxisHorizontal]]; - [effectiveConstraints addObjectsFromArray:[self constraintsAffectingLayoutForAxis:UILayoutConstraintAxisVertical]]; + [effectiveConstraints addObjectsFromArray:[self constraintsAffectingLayoutForAxis:LookinLayoutConstraintAxisHorizontal]]; + [effectiveConstraints addObjectsFromArray:[self constraintsAffectingLayoutForAxis:LookinLayoutConstraintAxisVertical]]; NSArray *lookinConstraints = [self.lks_involvedRawConstraints lookin_map:^id(NSUInteger idx, __kindof NSLayoutConstraint *constraint) { BOOL isEffective = [effectiveConstraints containsObject:constraint]; @@ -192,17 +234,20 @@ - (LookinConstraintItemType)_lks_constraintItemTypeForItem:(id)item { // 在 runtime 时,这里会遇到的 UILayoutGuide 和 _UILayoutGuide 居然是 UIView 的子类,不知道是看错了还是有什么玄机,所以在判断是否是 UIView 之前要先判断这个 if (@available(iOS 9.0, *)) { - if ([item isKindOfClass:[UILayoutGuide class]]) { + if ([item isKindOfClass:[LookinLayoutGuide class]]) { return LookinConstraintItemTypeLayoutGuide; } } + +#if TARGET_OS_IPHONE NSString *className = NSStringFromClass([item class]); if ([className hasSuffix:@"_UILayoutGuide"]) { return LookinConstraintItemTypeLayoutGuide; } +#endif - if ([item isKindOfClass:[UIView class]]) { + if ([item isKindOfClass:[LookinView class]]) { return LookinConstraintItemTypeView; } @@ -210,6 +255,99 @@ - (LookinConstraintItemType)_lks_constraintItemTypeForItem:(id)item { return LookinConstraintItemTypeUnknown; } +#pragma mark - Screenshot + +#if TARGET_OS_OSX +- (LookinImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality { + + CGFloat screenScale = [LKS_MultiplatformAdapter mainScreenScale]; + CGFloat pixelWidth = self.frame.size.width * screenScale; + CGFloat pixelHeight = self.frame.size.height * screenScale; + if (pixelWidth <= 0 || pixelHeight <= 0) { + return nil; + } + + CGFloat renderScale = lowQuality ? 1 : 0; + CGFloat maxLength = MAX(pixelWidth, pixelHeight); + if (maxLength > LookinNodeImageMaxLengthInPx) { + // 确保最终绘制出的图片长和宽都不能超过 LookinNodeImageMaxLengthInPx + // 如果算出的 renderScale 大于 1 则取 1,因为似乎用 1 渲染的速度要比一个别的奇怪的带小数点的数字要更快 + renderScale = MIN(screenScale * LookinNodeImageMaxLengthInPx / maxLength, 1); + } + + CGSize contextSize = self.frame.size; + if (contextSize.width <= 0 || contextSize.height <= 0 || contextSize.width > 20000 || contextSize.height > 20000) { + NSLog(@"LookinServer - Failed to capture screenshot. Invalid context size: %@ x %@", @(contextSize.width), @(contextSize.height)); + return nil; + } + + NSBitmapImageRep *rep = [self bitmapImageRepForCachingDisplayInRect:self.bounds]; + if (!rep) { + return nil; + } + [self cacheDisplayInRect:self.bounds toBitmapImageRep:rep]; + + NSImage *image = [[NSImage alloc] initWithSize:rep.size]; + + [image addRepresentation:rep]; + + return image; +} + +- (LookinImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { + if (!self.subviews.count) { + return nil; + } + + CGFloat screenScale = [LKS_MultiplatformAdapter mainScreenScale]; + CGFloat pixelWidth = self.frame.size.width * screenScale; + CGFloat pixelHeight = self.frame.size.height * screenScale; + if (pixelWidth <= 0 || pixelHeight <= 0) { + return nil; + } + + CGFloat renderScale = lowQuality ? 1 : 0; + CGFloat maxLength = MAX(pixelWidth, pixelHeight); + if (maxLength > LookinNodeImageMaxLengthInPx) { + // 确保最终绘制出的图片长和宽都不能超过 LookinNodeImageMaxLengthInPx + // 如果算出的 renderScale 大于 1 则取 1,因为似乎用 1 渲染的速度要比一个别的奇怪的带小数点的数字要更快 + renderScale = MIN(screenScale * LookinNodeImageMaxLengthInPx / maxLength, 1); + } + + if (self.subviews.count) { + NSArray *subviews = [self.subviews copy]; + NSMutableArray *visibleSubviews = [NSMutableArray arrayWithCapacity:subviews.count]; + [subviews enumerateObjectsUsingBlock:^(__kindof NSView * _Nonnull subview, NSUInteger idx, BOOL * _Nonnull stop) { + if (!subview.hidden) { + subview.hidden = YES; + [visibleSubviews addObject:subview]; + } + }]; + + CGSize contextSize = self.frame.size; + if (contextSize.width <= 0 || contextSize.height <= 0 || contextSize.width > 20000 || contextSize.height > 20000) { + NSLog(@"LookinServer - Failed to capture screenshot. Invalid context size: %@ x %@", @(contextSize.width), @(contextSize.height)); + return nil; + } + + NSBitmapImageRep *rep = [self bitmapImageRepForCachingDisplayInRect:self.bounds]; + if (!rep) { + return nil; + } + [self cacheDisplayInRect:self.bounds toBitmapImageRep:rep]; + + NSImage *image = [[NSImage alloc] initWithSize:rep.size]; + + [image addRepresentation:rep]; + [visibleSubviews enumerateObjectsUsingBlock:^(NSView * _Nonnull subview, NSUInteger idx, BOOL * _Nonnull stop) { + subview.hidden = NO; + }]; + return image; + } + return nil; +} +#endif + @end #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Category/UIViewController+LookinServer.h b/Src/Main/Server/Category/UIViewController+LookinServer.h index 1cab2a6..8a1976c 100644 --- a/Src/Main/Server/Category/UIViewController+LookinServer.h +++ b/Src/Main/Server/Category/UIViewController+LookinServer.h @@ -8,11 +8,11 @@ // https://lookin.work // -#import +#import "LookinDefines.h" -@interface UIViewController (LookinServer) +@interface LookinViewController (LookinServer) -+ (UIViewController *)lks_visibleViewController; ++ (LookinViewController *)lks_visibleViewController; @end diff --git a/Src/Main/Server/Category/UIViewController+LookinServer.m b/Src/Main/Server/Category/UIViewController+LookinServer.m index 2833eab..1988229 100644 --- a/Src/Main/Server/Category/UIViewController+LookinServer.m +++ b/Src/Main/Server/Category/UIViewController+LookinServer.m @@ -13,17 +13,26 @@ #import #import "LKS_MultiplatformAdapter.h" -@implementation UIViewController (LookinServer) +@implementation LookinViewController (LookinServer) -+ (nullable UIViewController *)lks_visibleViewController { ++ (nullable LookinViewController *)lks_visibleViewController { +#if TARGET_OS_IPHONE + LookinViewController *rootViewController = [LKS_MultiplatformAdapter keyWindow].rootViewController; + LookinViewController *visibleViewController = [rootViewController lks_visibleViewControllerIfExist]; + return visibleViewController; +#endif + +#if TARGET_OS_OSX - UIViewController *rootViewController = [LKS_MultiplatformAdapter keyWindow].rootViewController; - UIViewController *visibleViewController = [rootViewController lks_visibleViewControllerIfExist]; + LookinViewController *rootViewController = [LKS_MultiplatformAdapter keyWindow].contentViewController; + LookinViewController *visibleViewController = [rootViewController lks_visibleViewControllerIfExist]; return visibleViewController; +#endif } -- (UIViewController *)lks_visibleViewControllerIfExist { +- (LookinViewController *)lks_visibleViewControllerIfExist { +#if TARGET_OS_IPHONE if (self.presentedViewController) { return [self.presentedViewController lks_visibleViewControllerIfExist]; } @@ -41,6 +50,21 @@ - (UIViewController *)lks_visibleViewControllerIfExist { } else { return nil; } +#endif + +#if TARGET_OS_OSX + if (self.presentedViewControllers) { + for (NSViewController *presentedViewController in self.presentedViewControllers) { + return [presentedViewController lks_visibleViewControllerIfExist]; + } + } + + if (self.isViewLoaded && !self.view.hidden && self.view.alphaValue > 0.01) { + return self; + } else { + return nil; + } +#endif } @end diff --git a/Src/Main/Server/Category/UIVisualEffectView+LookinServer.h b/Src/Main/Server/Category/UIVisualEffectView+LookinServer.h index 697d840..82edcc0 100644 --- a/Src/Main/Server/Category/UIVisualEffectView+LookinServer.h +++ b/Src/Main/Server/Category/UIVisualEffectView+LookinServer.h @@ -8,6 +8,9 @@ // https://lookin.work // +#import "TargetConditionals.h" + +#if TARGET_OS_IPHONE #import @interface UIVisualEffectView (LookinServer) @@ -17,5 +20,6 @@ - (NSNumber *)lks_blurEffectStyleNumber; @end +#endif #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Category/UIVisualEffectView+LookinServer.m b/Src/Main/Server/Category/UIVisualEffectView+LookinServer.m index df06b10..1935784 100644 --- a/Src/Main/Server/Category/UIVisualEffectView+LookinServer.m +++ b/Src/Main/Server/Category/UIVisualEffectView+LookinServer.m @@ -11,6 +11,7 @@ #import "UIVisualEffectView+LookinServer.h" #import "UIBlurEffect+LookinServer.h" +#if TARGET_OS_IPHONE @implementation UIVisualEffectView (LookinServer) - (void)setLks_blurEffectStyleNumber:(NSNumber *)lks_blurEffectStyleNumber { @@ -29,5 +30,9 @@ - (NSNumber *)lks_blurEffectStyleNumber { } @end +#endif + +#if TARGET_OS_OSX +#endif #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Connection/LKS_ConnectionManager.h b/Src/Main/Server/Connection/LKS_ConnectionManager.h index 684127b..841fc02 100644 --- a/Src/Main/Server/Connection/LKS_ConnectionManager.h +++ b/Src/Main/Server/Connection/LKS_ConnectionManager.h @@ -8,7 +8,13 @@ // https://lookin.work // +#import "TargetConditionals.h" + +#if TARGET_OS_IPHONE #import +#elif TARGET_OS_OSX +#import +#endif extern NSString *const LKS_ConnectionDidEndNotificationName; diff --git a/Src/Main/Server/Connection/LKS_ConnectionManager.m b/Src/Main/Server/Connection/LKS_ConnectionManager.m index c1ec8fc..f03b2c7 100644 --- a/Src/Main/Server/Connection/LKS_ConnectionManager.m +++ b/Src/Main/Server/Connection/LKS_ConnectionManager.m @@ -47,8 +47,15 @@ - (instancetype)init { if (self = [super init]) { NSLog(@"LookinServer - Will launch. Framework version: %@", LOOKIN_SERVER_READABLE_VERSION); +#if TARGET_OS_IPHONE [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleApplicationDidBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleWillResignActiveNotification) name:UIApplicationWillResignActiveNotification object:nil]; +#endif + +#if TARGET_OS_OSX + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleApplicationDidBecomeActive) name:NSApplicationDidBecomeActiveNotification object:nil]; +// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleWillResignActiveNotification) name:NSApplicationWillResignActiveNotification object:nil]; +#endif [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleLocalInspect:) name:@"Lookin_2D" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleLocalInspect:) name:@"Lookin_3D" object:nil]; @@ -98,6 +105,8 @@ - (void)searchPortToListenIfNoConnection { - (BOOL)isiOSAppOnMac { #if TARGET_OS_SIMULATOR return YES; +#elif TARGET_OS_OSX + return YES; #else if (@available(iOS 14.0, *)) { // isiOSAppOnMac 这个 API 看似在 iOS 14.0 上可用,但其实在 iOS 14 beta 上是不存在的、有 unrecognized selector 问题,因此这里要用 respondsToSelector 做一下保护 @@ -229,6 +238,7 @@ - (void)ioFrameChannel:(Lookin_PTChannel*)channel didEndWithError:(NSError*)erro #pragma mark - Handler - (void)_handleLocalInspect:(NSNotification *)note { +#if TARGET_OS_IPHONE UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Lookin" message:@"Failed to run local inspection. The feature has been removed. Please use the computer version of Lookin or consider SDKs like FLEX for similar functionality." preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; [alertController addAction:okAction]; @@ -236,6 +246,13 @@ - (void)_handleLocalInspect:(NSNotification *)note { UIViewController *rootViewController = [keyWindow rootViewController]; [rootViewController presentViewController:alertController animated:YES completion:nil]; +#elif TARGET_OS_OSX + NSAlert *alert = [[NSAlert alloc] init]; + alert.messageText = @"Lookin"; + alert.informativeText = @"Failed to run local inspection. The feature has been removed. Please use the computer version of Lookin or consider SDKs like FLEX for similar functionality."; + [alert addButtonWithTitle:@"OK"]; + [alert runModal]; +#endif NSLog(@"LookinServer - Failed to run local inspection. The feature has been removed. Please use the computer version of Lookin or consider SDKs like FLEX for similar functionality."); } diff --git a/Src/Main/Server/Connection/LKS_RequestHandler.m b/Src/Main/Server/Connection/LKS_RequestHandler.m index c9d1572..103f5a4 100644 --- a/Src/Main/Server/Connection/LKS_RequestHandler.m +++ b/Src/Main/Server/Connection/LKS_RequestHandler.m @@ -26,6 +26,9 @@ #import "LKS_AttrModificationPatchHandler.h" #import "LKS_HierarchyDetailsHandler.h" #import "LookinStaticAsyncUpdateTask.h" +#import "NSValue+Lookin.h" +#import "LookinHierarchyInfo+LookinServer.h" +#import "LookinObject+LookinServer.h" @interface LKS_RequestHandler () @@ -249,16 +252,16 @@ - (void)handleRequestType:(uint32_t)requestType tag:(uint32_t)tag object:(id)obj return; } unsigned long imageViewOid = [(NSNumber *)object unsignedLongValue]; - UIImageView *imageView = (UIImageView *)[NSObject lks_objectWithOid:imageViewOid]; + LookinImageView *imageView = (LookinImageView *)[NSObject lks_objectWithOid:imageViewOid]; if (!imageView) { [self _submitResponseWithError:LookinErr_ObjNotFound requestType:requestType tag:tag]; return; } - if (![imageView isKindOfClass:[UIImageView class]]) { + if (![imageView isKindOfClass:[LookinImageView class]]) { [self _submitResponseWithError:LookinErr_Inner requestType:requestType tag:tag]; return; } - UIImage *image = imageView.image; + LookinImage *image = imageView.image; NSData *imageData = [image lookin_data]; [self _submitResponseWithData:imageData requestType:requestType tag:tag]; @@ -271,12 +274,12 @@ - (void)handleRequestType:(uint32_t)requestType tag:(uint32_t)tag object:(id)obj unsigned long recognizerOid = ((NSNumber *)params[@"oid"]).unsignedLongValue; BOOL shouldBeEnabled = ((NSNumber *)params[@"enable"]).boolValue; - UIGestureRecognizer *recognizer = (UIGestureRecognizer *)[NSObject lks_objectWithOid:recognizerOid]; + LookinGestureRecognizer *recognizer = (LookinGestureRecognizer *)[NSObject lks_objectWithOid:recognizerOid]; if (!recognizer) { [self _submitResponseWithError:LookinErr_ObjNotFound requestType:requestType tag:tag]; return; } - if (![recognizer isKindOfClass:[UIGestureRecognizer class]]) { + if (![recognizer isKindOfClass:[LookinGestureRecognizer class]]) { [self _submitResponseWithError:LookinErr_Inner requestType:requestType tag:tag]; return; } @@ -502,18 +505,18 @@ - (void)_handleInvokeWithObject:(NSObject *)obj selector:(SEL)selector resultDes [invocation getReturnValue:&rectValue]; *description = NSStringFromCGAffineTransform(rectValue); - } else if (strcmp(returnType, @encode(UIEdgeInsets)) == 0) { - UIEdgeInsets targetValue; + } else if (strcmp(returnType, @encode(LookinInsets)) == 0) { + LookinInsets targetValue; [invocation getReturnValue:&targetValue]; - *description = NSStringFromUIEdgeInsets(targetValue); - + *description = NSStringFromInsets(targetValue); +#if !TARGET_OS_OSX } else if (strcmp(returnType, @encode(UIOffset)) == 0) { UIOffset targetValue; [invocation getReturnValue:&targetValue]; *description = NSStringFromUIOffset(targetValue); - +#endif } else { - if (@available(iOS 11.0, tvOS 11.0, *)) { + if (@available(iOS 11.0, tvOS 11.0, macOS 10.15, *)) { if (strcmp(returnType, @encode(NSDirectionalEdgeInsets)) == 0) { NSDirectionalEdgeInsets targetValue; [invocation getReturnValue:&targetValue]; diff --git a/Src/Main/Server/Connection/RequestHandler/LKS_AttrModificationPatchHandler.m b/Src/Main/Server/Connection/RequestHandler/LKS_AttrModificationPatchHandler.m index bc1cbcd..b018868 100644 --- a/Src/Main/Server/Connection/RequestHandler/LKS_AttrModificationPatchHandler.m +++ b/Src/Main/Server/Connection/RequestHandler/LKS_AttrModificationPatchHandler.m @@ -29,7 +29,22 @@ + (void)handleLayerOids:(NSArray *)oids lowImageQuality:(BOOL)lowIma LookinDisplayItemDetail *detail = [LookinDisplayItemDetail new]; detail.displayItemOid = oid; - CALayer *layer = (CALayer *)[NSObject lks_objectWithOid:oid]; + id object = [NSObject lks_objectWithOid:oid]; +#if TARGET_OS_OSX + NSView *view = object; + if (view && [view isKindOfClass:[NSView class]] && !view.layer) { + if (idx == 0) { + detail.soloScreenshot = [view lks_soloScreenshotWithLowQuality:lowImageQuality]; + detail.groupScreenshot = [view lks_groupScreenshotWithLowQuality:lowImageQuality]; + } else { + detail.groupScreenshot = [view lks_groupScreenshotWithLowQuality:lowImageQuality]; + } + block(detail, oids.count, nil); + return; + } +#endif + + CALayer *layer = object; if (![layer isKindOfClass:[CALayer class]]) { block(nil, idx + 1, LookinErr_ObjNotFound); *stop = YES; diff --git a/Src/Main/Server/Connection/RequestHandler/LKS_CustomAttrModificationHandler.m b/Src/Main/Server/Connection/RequestHandler/LKS_CustomAttrModificationHandler.m index 1935ef5..e39a656 100644 --- a/Src/Main/Server/Connection/RequestHandler/LKS_CustomAttrModificationHandler.m +++ b/Src/Main/Server/Connection/RequestHandler/LKS_CustomAttrModificationHandler.m @@ -9,7 +9,7 @@ #import "LKS_CustomAttrModificationHandler.h" #import "LKS_CustomAttrSetterManager.h" #import "UIColor+LookinServer.h" - +#import "NSValue+Lookin.h" @implementation LKS_CustomAttrModificationHandler + (BOOL)handleModification:(LookinCustomAttrModification *)modification { @@ -72,7 +72,7 @@ + (BOOL)handleModification:(LookinCustomAttrModification *)modification { if (![newValue isKindOfClass:[NSArray class]]) { return NO; } - UIColor *color = [UIColor lks_colorFromRGBAComponents:newValue]; + LookinColor *color = [LookinColor lks_colorFromRGBAComponents:newValue]; if (!color) { return NO; } @@ -141,7 +141,7 @@ + (BOOL)handleModification:(LookinCustomAttrModification *)modification { if (!setter) { return NO; } - setter(newValue.UIEdgeInsetsValue); + setter(newValue.InsetsValue); return YES; } diff --git a/Src/Main/Server/Connection/RequestHandler/LKS_HierarchyDetailsHandler.m b/Src/Main/Server/Connection/RequestHandler/LKS_HierarchyDetailsHandler.m index 28999f9..b4bef1e 100644 --- a/Src/Main/Server/Connection/RequestHandler/LKS_HierarchyDetailsHandler.m +++ b/Src/Main/Server/Connection/RequestHandler/LKS_HierarchyDetailsHandler.m @@ -1,4 +1,4 @@ -#ifdef SHOULD_COMPILE_LOOKIN_SERVER +#ifdef SHOULD_COMPILE_LOOKIN_SERVER // // LKS_HierarchyDetailsHandler.m @@ -16,7 +16,7 @@ #import "LookinServerDefines.h" #import "LKS_CustomAttrGroupsMaker.h" #import "LKS_HierarchyDisplayItemsMaker.h" - +#import "NSValue+Lookin.h" @interface LKS_HierarchyDetailsHandler () @property(nonatomic, strong) NSMutableArray *taskPackages; @@ -52,7 +52,7 @@ - (void)startWithPackages:(NSArray *)pack self.progressBlock = progressBlock; self.finishBlock = finishBlock; - [UIView lks_rebuildGlobalInvolvedRawConstraints]; + [LookinView lks_rebuildGlobalInvolvedRawConstraints]; [self _dequeueAndHandlePackage]; } @@ -74,18 +74,58 @@ - (void)_dequeueAndHandlePackage { itemDetail.displayItemOid = task.oid; id object = [NSObject lks_objectWithOid:task.oid]; + +#if TARGET_OS_OSX + NSView *view = object; + if (view && [view isKindOfClass:[NSView class]] && !view.layer) { + if (task.taskType == LookinStaticAsyncUpdateTaskTypeSoloScreenshot) { + LookinImage *image = [view lks_soloScreenshotWithLowQuality:NO]; + itemDetail.soloScreenshot = image; + } else if (task.taskType == LookinStaticAsyncUpdateTaskTypeGroupScreenshot) { + LookinImage *image = [view lks_groupScreenshotWithLowQuality:NO]; + itemDetail.groupScreenshot = image; + } + + BOOL shouldMakeAttr = [self queryIfShouldMakeAttrsFromTask:task]; + if (shouldMakeAttr) { + itemDetail.attributesGroupList = [LKS_AttrGroupsMaker attrGroupsForView:view]; + + NSString *version = task.clientReadableVersion; + if (version.length > 0 && [version lookin_numbericOSVersion] >= 10004) { + LKS_CustomAttrGroupsMaker *maker = [[LKS_CustomAttrGroupsMaker alloc] initWithView:view]; + [maker execute]; + itemDetail.customAttrGroupList = [maker getGroups]; + itemDetail.customDisplayTitle = [maker getCustomDisplayTitle]; + itemDetail.danceUISource = [maker getDanceUISource]; + } + [self.attrGroupsSyncedOids addObject:@(task.oid)]; + } + if (task.needBasisVisualInfo) { + itemDetail.frameValue = [NSValue valueWithCGRect:view.frame]; + itemDetail.boundsValue = [NSValue valueWithCGRect:view.bounds]; + itemDetail.hiddenValue = [NSNumber numberWithBool:view.isHidden]; + itemDetail.alphaValue = @(view.alphaValue); + } + + if (task.needSubitems) { + itemDetail.subitems = [LKS_HierarchyDisplayItemsMaker subitemsOfView:view]; + } + + return itemDetail; + } +#endif if (!object || ![object isKindOfClass:[CALayer class]]) { itemDetail.failureCode = -1; return itemDetail; } CALayer *layer = object; - + if (task.taskType == LookinStaticAsyncUpdateTaskTypeSoloScreenshot) { - UIImage *image = [layer lks_soloScreenshotWithLowQuality:NO]; + LookinImage *image = [layer lks_soloScreenshotWithLowQuality:NO]; itemDetail.soloScreenshot = image; } else if (task.taskType == LookinStaticAsyncUpdateTaskTypeGroupScreenshot) { - UIImage *image = [layer lks_groupScreenshotWithLowQuality:NO]; + LookinImage *image = [layer lks_groupScreenshotWithLowQuality:NO]; itemDetail.groupScreenshot = image; } @@ -103,7 +143,6 @@ - (void)_dequeueAndHandlePackage { } [self.attrGroupsSyncedOids addObject:@(task.oid)]; } - if (task.needBasisVisualInfo) { itemDetail.frameValue = [NSValue valueWithCGRect:layer.frame]; itemDetail.boundsValue = [NSValue valueWithCGRect:layer.bounds]; diff --git a/Src/Main/Server/Connection/RequestHandler/LKS_InbuiltAttrModificationHandler.m b/Src/Main/Server/Connection/RequestHandler/LKS_InbuiltAttrModificationHandler.m index 7911609..455f2b0 100644 --- a/Src/Main/Server/Connection/RequestHandler/LKS_InbuiltAttrModificationHandler.m +++ b/Src/Main/Server/Connection/RequestHandler/LKS_InbuiltAttrModificationHandler.m @@ -16,7 +16,7 @@ #import "LookinStaticAsyncUpdateTask.h" #import "LookinServerDefines.h" #import "LKS_CustomAttrGroupsMaker.h" - +#import "NSValue+Lookin.h" @implementation LKS_InbuiltAttrModificationHandler + (void)handleModification:(LookinAttributeModification *)modification completion:(void (^)(LookinDisplayItemDetail *data, NSError *error))completion { @@ -154,15 +154,17 @@ + (void)handleModification:(LookinAttributeModification *)modification completio break; } case LookinAttrTypeUIEdgeInsets: { - UIEdgeInsets expectedValue = [(NSValue *)modification.value UIEdgeInsetsValue]; + LookinInsets expectedValue = [(NSValue *)modification.value InsetsValue]; [setterInvocation setArgument:&expectedValue atIndex:2]; break; } +#if !TARGET_OS_OSX case LookinAttrTypeUIOffset: { UIOffset expectedValue = [(NSValue *)modification.value UIOffsetValue]; [setterInvocation setArgument:&expectedValue atIndex:2]; break; } +#endif case LookinAttrTypeCustomObj: case LookinAttrTypeNSString: { NSObject *expectedValue = modification.value; @@ -172,7 +174,7 @@ + (void)handleModification:(LookinAttributeModification *)modification completio } case LookinAttrTypeUIColor: { NSArray *rgba = modification.value; - UIColor *expectedValue = [UIColor lks_colorFromRGBAComponents:rgba]; + LookinColor *expectedValue = [LookinColor lks_colorFromRGBAComponents:rgba]; [setterInvocation setArgument:&expectedValue atIndex:2]; [setterInvocation retainArguments]; break; @@ -197,8 +199,8 @@ + (void)handleModification:(LookinAttributeModification *)modification completio CALayer *layer = nil; if ([receiver isKindOfClass:[CALayer class]]) { layer = (CALayer *)receiver; - } else if ([receiver isKindOfClass:[UIView class]]) { - layer = ((UIView *)receiver).layer; + } else if ([receiver isKindOfClass:[LookinView class]]) { + layer = ((LookinView *)receiver).layer; } else { completion(nil, LookinErr_ObjNotFound); return; @@ -219,6 +221,7 @@ + (void)handleModification:(LookinAttributeModification *)modification completio detail.boundsValue = [NSValue valueWithCGRect:layer.bounds]; detail.hiddenValue = [NSNumber numberWithBool:layer.isHidden]; detail.alphaValue = @(layer.opacity); + completion(detail, error); }); } @@ -233,6 +236,23 @@ + (void)handlePatchWithTasks:(NSArray *)tasks blo LookinDisplayItemDetail *itemDetail = [LookinDisplayItemDetail new]; itemDetail.displayItemOid = task.oid; id object = [NSObject lks_objectWithOid:task.oid]; + +#if TARGET_OS_OSX + NSView *view = object; + if (view && [view isKindOfClass:[NSView class]] && !view.layer) { + if (task.taskType == LookinStaticAsyncUpdateTaskTypeSoloScreenshot) { + LookinImage *image = [view lks_soloScreenshotWithLowQuality:NO]; + itemDetail.soloScreenshot = image; + } else if (task.taskType == LookinStaticAsyncUpdateTaskTypeGroupScreenshot) { + LookinImage *image = [view lks_groupScreenshotWithLowQuality:NO]; + itemDetail.groupScreenshot = image; + } + block(itemDetail); + return; + } +#endif + + if (!object || ![object isKindOfClass:[CALayer class]]) { block(itemDetail); return; @@ -240,10 +260,10 @@ + (void)handlePatchWithTasks:(NSArray *)tasks blo CALayer *layer = object; if (task.taskType == LookinStaticAsyncUpdateTaskTypeSoloScreenshot) { - UIImage *image = [layer lks_soloScreenshotWithLowQuality:NO]; + LookinImage *image = [layer lks_soloScreenshotWithLowQuality:NO]; itemDetail.soloScreenshot = image; } else if (task.taskType == LookinStaticAsyncUpdateTaskTypeGroupScreenshot) { - UIImage *image = [layer lks_groupScreenshotWithLowQuality:NO]; + LookinImage *image = [layer lks_groupScreenshotWithLowQuality:NO]; itemDetail.groupScreenshot = image; } block(itemDetail); diff --git a/Src/Main/Server/Others/LKSConfigManager.h b/Src/Main/Server/Others/LKSConfigManager.h index 1eecebe..766de88 100644 --- a/Src/Main/Server/Others/LKSConfigManager.h +++ b/Src/Main/Server/Others/LKSConfigManager.h @@ -7,7 +7,17 @@ // Created by likai.123 on 2023/1/10. // +#import + +#if TARGET_OS_IPHONE #import +#endif + +#if TARGET_OS_OSX +#import +#endif + +#import "LookinDefines.h" NS_ASSUME_NONNULL_BEGIN @@ -15,10 +25,12 @@ NS_ASSUME_NONNULL_BEGIN + (NSArray *)collapsedClassList; -+ (NSDictionary *)colorAlias; ++ (NSDictionary *)colorAlias; + (BOOL)shouldCaptureScreenshotOfLayer:(CALayer *)layer; - +#if TARGET_OS_OSX ++ (BOOL)shouldCaptureScreenshotOfView:(NSView *)view; +#endif @end NS_ASSUME_NONNULL_END diff --git a/Src/Main/Server/Others/LKSConfigManager.m b/Src/Main/Server/Others/LKSConfigManager.m index 830866a..5f75360 100644 --- a/Src/Main/Server/Others/LKSConfigManager.m +++ b/Src/Main/Server/Others/LKSConfigManager.m @@ -50,8 +50,8 @@ @implementation LKSConfigManager return nil; } -+ (NSDictionary *)colorAlias { - NSDictionary *result = [self queryColorAliasWithClass:[NSObject class] selector:@"lookin_colorAlias"]; ++ (NSDictionary *)colorAlias { + NSDictionary *result = [self queryColorAliasWithClass:[NSObject class] selector:@"lookin_colorAlias"]; if (result) { return result; } @@ -61,11 +61,11 @@ @implementation LKSConfigManager if (!configClass) { return nil; } - NSDictionary *legacyCodeResult = [self queryColorAliasWithClass:configClass selector:@"colors"]; + NSDictionary *legacyCodeResult = [self queryColorAliasWithClass:configClass selector:@"colors"]; return legacyCodeResult; } -+ (NSDictionary *)queryColorAliasWithClass:(Class)class selector:(NSString *)selectorName { ++ (NSDictionary *)queryColorAliasWithClass:(Class)class selector:(NSString *)selectorName { SEL selector = NSSelectorFromString(selectorName); if (![class respondsToSelector:selector]) { return nil; @@ -82,13 +82,13 @@ @implementation LKSConfigManager NSMutableDictionary *validDictionary = [NSMutableDictionary dictionary]; [(NSDictionary *)colorAlias enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { if ([key isKindOfClass:[NSString class]]) { - if ([obj isKindOfClass:[UIColor class]]) { + if ([obj isKindOfClass:[LookinColor class]]) { [validDictionary setObject:obj forKey:key]; } else if ([obj isKindOfClass:[NSDictionary class]]) { __block BOOL isValidSubDict = YES; [((NSDictionary *)obj) enumerateKeysAndObjectsUsingBlock:^(id _Nonnull subKey, id _Nonnull subObj, BOOL * _Nonnull stop) { - if (![subKey isKindOfClass:[NSString class]] || ![subObj isKindOfClass:[UIColor class]]) { + if (![subKey isKindOfClass:[NSString class]] || ![subObj isKindOfClass:[LookinColor class]]) { isValidSubDict = NO; *stop = YES; } @@ -111,7 +111,7 @@ + (BOOL)shouldCaptureScreenshotOfLayer:(CALayer *)layer { if (![self shouldCaptureImageOfLayer:layer]) { return NO; } - UIView *view = layer.lks_hostView; + LookinView *view = layer.lks_hostView; if (!view) { return YES; } @@ -121,6 +121,25 @@ + (BOOL)shouldCaptureScreenshotOfLayer:(CALayer *)layer { return YES; } +#if TARGET_OS_OSX ++ (BOOL)shouldCaptureScreenshotOfView:(NSView *)view { + if (!view) { + return YES; + } + if (![self shouldCaptureImageOfView:view]) { + return NO; + } + CALayer *layer = view.layer; + if (!layer) { + return YES; + } + if (![self shouldCaptureImageOfLayer:layer]) { + return NO; + } + return YES; +} +#endif + + (BOOL)shouldCaptureImageOfLayer:(CALayer *)layer { if (!layer) { return YES; @@ -155,7 +174,7 @@ + (BOOL)shouldCaptureImageOfLayer:(CALayer *)layer { return YES; } -+ (BOOL)shouldCaptureImageOfView:(UIView *)view { ++ (BOOL)shouldCaptureImageOfView:(LookinView *)view { if (!view) { return YES; } diff --git a/Src/Main/Server/Others/LKS_AttrGroupsMaker.h b/Src/Main/Server/Others/LKS_AttrGroupsMaker.h index 1902da2..824843d 100644 --- a/Src/Main/Server/Others/LKS_AttrGroupsMaker.h +++ b/Src/Main/Server/Others/LKS_AttrGroupsMaker.h @@ -15,7 +15,9 @@ @interface LKS_AttrGroupsMaker : NSObject + (NSArray *)attrGroupsForLayer:(CALayer *)layer; - +#if TARGET_OS_OSX ++ (NSArray *)attrGroupsForView:(NSView *)view; +#endif @end #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Others/LKS_AttrGroupsMaker.m b/Src/Main/Server/Others/LKS_AttrGroupsMaker.m index c140f21..b529341 100644 --- a/Src/Main/Server/Others/LKS_AttrGroupsMaker.m +++ b/Src/Main/Server/Others/LKS_AttrGroupsMaker.m @@ -16,7 +16,7 @@ #import "LookinIvarTrace.h" #import "UIColor+LookinServer.h" #import "LookinServerDefines.h" - +#import "NSValue+Lookin.h" @implementation LKS_AttrGroupsMaker + (NSArray *)attrGroupsForLayer:(CALayer *)layer { @@ -88,6 +88,77 @@ @implementation LKS_AttrGroupsMaker return groups; } +#if TARGET_OS_OSX ++ (NSArray *)attrGroupsForView:(NSView *)view { + if (!view) { + NSAssert(NO, @""); + return nil; + } + NSArray *groups = [[LookinDashboardBlueprint groupIDs] lookin_map:^id(NSUInteger idx, LookinAttrGroupIdentifier groupID) { + LookinAttributesGroup *group = [LookinAttributesGroup new]; + group.identifier = groupID; + + NSArray *secIDs = [LookinDashboardBlueprint sectionIDsForGroupID:groupID]; + group.attrSections = [secIDs lookin_map:^id(NSUInteger idx, LookinAttrSectionIdentifier secID) { + LookinAttributesSection *sec = [LookinAttributesSection new]; + sec.identifier = secID; + + NSArray *attrIDs = [LookinDashboardBlueprint attrIDsForSectionID:secID]; + sec.attributes = [attrIDs lookin_map:^id(NSUInteger idx, LookinAttrIdentifier attrID) { + NSInteger minAvailableVersion = [LookinDashboardBlueprint minAvailableOSVersionWithAttrID:attrID]; + if (minAvailableVersion > 0 && (NSProcessInfo.processInfo.operatingSystemVersion.majorVersion < minAvailableVersion)) { + // iOS 版本过低不支持该属性 + return nil; + } + + id targetObj = nil; + if ([LookinDashboardBlueprint isUIViewPropertyWithAttrID:attrID]) { + targetObj = view; + } else { + targetObj = view.layer; + } + + if (targetObj) { + Class targetClass = NSClassFromString([LookinDashboardBlueprint classNameWithAttrID:attrID]); + if (![targetObj isKindOfClass:targetClass]) { + return nil; + } + + LookinAttribute *attr = [self _attributeWithIdentifer:attrID targetObject:targetObj]; + return attr; + } else { + return nil; + } + }]; + + if (sec.attributes.count) { + return sec; + } else { + return nil; + } + }]; + + if ([groupID isEqualToString:LookinAttrGroup_AutoLayout]) { + // 这里特殊处理一下,如果 AutoLayout 里面不包含 Constraints 的话(只有 Hugging 和 Resistance),就丢弃掉这整个 AutoLayout 不显示 + BOOL hasConstraits = [group.attrSections lookin_any:^BOOL(LookinAttributesSection *obj) { + return [obj.identifier isEqualToString:LookinAttrSec_AutoLayout_Constraints]; + }]; + if (!hasConstraits) { + return nil; + } + } + + if (group.attrSections.count) { + return group; + } else { + return nil; + } + }]; + + return groups; +} +#endif + + (LookinAttribute *)_attributeWithIdentifer:(LookinAttrIdentifier)identifier targetObject:(id)target { if (!target) { NSAssert(NO, @""); @@ -251,18 +322,18 @@ + (LookinAttribute *)_attributeWithIdentifer:(LookinAttrIdentifier)identifier ta attribute.attrType = LookinAttrTypeCGAffineTransform; attribute.value = [NSValue valueWithCGAffineTransform:targetValue]; - } else if (strcmp(returnType, @encode(UIEdgeInsets)) == 0) { - UIEdgeInsets targetValue; + } else if (strcmp(returnType, @encode(LookinInsets)) == 0) { + LookinInsets targetValue; [invocation getReturnValue:&targetValue]; attribute.attrType = LookinAttrTypeUIEdgeInsets; - attribute.value = [NSValue valueWithUIEdgeInsets:targetValue]; - + attribute.value = [NSValue valueWithInsets:targetValue]; +#if !TARGET_OS_OSX } else if (strcmp(returnType, @encode(UIOffset)) == 0) { UIOffset targetValue; [invocation getReturnValue:&targetValue]; attribute.attrType = LookinAttrTypeUIOffset; attribute.value = [NSValue valueWithUIOffset:targetValue]; - +#endif } else { NSString *argType_string = [[NSString alloc] lookin_safeInitWithUTF8String:returnType]; if ([argType_string hasPrefix:@"@"]) { @@ -278,7 +349,7 @@ + (LookinAttribute *)_attributeWithIdentifer:(LookinAttrIdentifier)identifier ta if (attribute.attrType == LookinAttrTypeUIColor) { if (returnObjValue == nil) { attribute.value = nil; - } else if ([returnObjValue isKindOfClass:[UIColor class]] && [returnObjValue respondsToSelector:@selector(lks_rgbaComponents)]) { + } else if ([returnObjValue isKindOfClass:[LookinColor class]] && [returnObjValue respondsToSelector:@selector(lks_rgbaComponents)]) { attribute.value = [returnObjValue lks_rgbaComponents]; } else { // https://github.com/QMUI/LookinServer/issues/124 diff --git a/Src/Main/Server/Others/LKS_CustomAttrGroupsMaker.h b/Src/Main/Server/Others/LKS_CustomAttrGroupsMaker.h index 781711a..1586fd9 100644 --- a/Src/Main/Server/Others/LKS_CustomAttrGroupsMaker.h +++ b/Src/Main/Server/Others/LKS_CustomAttrGroupsMaker.h @@ -13,7 +13,9 @@ @interface LKS_CustomAttrGroupsMaker : NSObject - (instancetype)initWithLayer:(CALayer *)layer; - +#if TARGET_OS_OSX +- (instancetype)initWithView:(NSView *)view; +#endif - (void)execute; - (NSArray *)getGroups; diff --git a/Src/Main/Server/Others/LKS_CustomAttrGroupsMaker.m b/Src/Main/Server/Others/LKS_CustomAttrGroupsMaker.m index 428b683..89df56b 100644 --- a/Src/Main/Server/Others/LKS_CustomAttrGroupsMaker.m +++ b/Src/Main/Server/Others/LKS_CustomAttrGroupsMaker.m @@ -26,12 +26,24 @@ @interface LKS_CustomAttrGroupsMaker () @property(nonatomic, copy) NSString *resolvedDanceUISource; @property(nonatomic, strong) NSMutableArray *resolvedGroups; +#if TARGET_OS_OSX +@property(nonatomic, weak) NSView *view; +#endif @property(nonatomic, weak) CALayer *layer; - @end @implementation LKS_CustomAttrGroupsMaker +#if TARGET_OS_OSX +- (instancetype)initWithView:(NSView *)view { + if (self = [super init]) { + self.sectionAndAttrs = [NSMutableDictionary dictionary]; + self.view = view; + } + return self; +} +#endif + - (instancetype)initWithLayer:(CALayer *)layer { if (self = [super init]) { self.sectionAndAttrs = [NSMutableDictionary dictionary]; @@ -41,10 +53,17 @@ - (instancetype)initWithLayer:(CALayer *)layer { } - (void)execute { +#if TARGET_OS_IPHONE if (!self.layer) { NSAssert(NO, @""); return; } +#elif TARGET_OS_OSX + if (!self.view && !self.layer) { + NSAssert(NO, @""); + return; + } +#endif NSMutableArray *selectors = [NSMutableArray array]; [selectors addObject:@"lookin_customDebugInfos"]; for (int i = 0; i < 5; i++) { @@ -52,11 +71,23 @@ - (void)execute { } for (NSString *name in selectors) { - [self makeAttrsForViewOrLayer:self.layer selectorName:name]; - - UIView *view = self.layer.lks_hostView; - if (view) { - [self makeAttrsForViewOrLayer:view selectorName:name]; +#if TARGET_OS_OSX + if (self.view && !self.view.layer) { + [self makeAttrsForViewOrLayer:self.view selectorName:name]; + CALayer *layer = self.view.layer; + if (layer) { + [self makeAttrsForViewOrLayer:layer selectorName:name]; + } + continue; + } +#endif + if (self.layer) { + [self makeAttrsForViewOrLayer:self.layer selectorName:name]; + + LookinView *view = self.layer.lks_hostView; + if (view) { + [self makeAttrsForViewOrLayer:view selectorName:name]; + } } } @@ -91,7 +122,7 @@ - (void)makeAttrsForViewOrLayer:(id)viewOrLayer selectorName:(NSString *)selecto if (!viewOrLayer || !selectorName.length) { return; } - if (![viewOrLayer isKindOfClass:[UIView class]] && ![viewOrLayer isKindOfClass:[CALayer class]]) { + if (![viewOrLayer isKindOfClass:[LookinView class]] && ![viewOrLayer isKindOfClass:[CALayer class]]) { return; } SEL selector = NSSelectorFromString(selectorName); @@ -239,13 +270,13 @@ + (LookinAttribute *)attrFromRawDict:(NSDictionary *)dict saveCustomSetter:(BOOL } if ([fixedType isEqualToString:@"color"]) { - if (value != nil && ![value isKindOfClass:[UIColor class]]) { + if (value != nil && ![value isKindOfClass:[LookinColor class]]) { // nil 是合法的 NSLog(@"LookinServer - Wrong value type."); return nil; } attr.attrType = LookinAttrTypeUIColor; - attr.value = [(UIColor *)value lks_rgbaComponents]; + attr.value = [(LookinColor *)value lks_rgbaComponents]; if (saveCustomSetter && dict[@"retainedSetter"]) { NSString *uniqueID = [[NSUUID new] UUIDString]; @@ -372,8 +403,8 @@ + (LookinAttribute *)attrFromRawDict:(NSDictionary *)dict saveCustomSetter:(BOOL @"opacity": shadowInfo[@"opacity"], @"radius": shadowInfo[@"radius"] } mutableCopy]; - if ([shadowInfo[@"color"] isKindOfClass:[UIColor class]]) { - checkedShadowInfo[@"color"] = [(UIColor *)shadowInfo[@"color"] lks_rgbaComponents]; + if ([shadowInfo[@"color"] isKindOfClass:[LookinColor class]]) { + checkedShadowInfo[@"color"] = [(LookinColor *)shadowInfo[@"color"] lks_rgbaComponents]; } attr.attrType = LookinAttrTypeShadow; diff --git a/Src/Main/Server/Others/LKS_CustomAttrSetterManager.h b/Src/Main/Server/Others/LKS_CustomAttrSetterManager.h index 7fccc77..2f0589b 100644 --- a/Src/Main/Server/Others/LKS_CustomAttrSetterManager.h +++ b/Src/Main/Server/Others/LKS_CustomAttrSetterManager.h @@ -5,18 +5,24 @@ // // Created by likai.123 on 2023/11/4. // - +#import +#if TARGET_OS_IPHONE #import +#endif +#if TARGET_OS_OSX +#import +#endif +#import "LookinDefines.h" typedef void(^LKS_StringSetter)(NSString *); typedef void(^LKS_NumberSetter)(NSNumber *); typedef void(^LKS_BoolSetter)(BOOL); -typedef void(^LKS_ColorSetter)(UIColor *); +typedef void(^LKS_ColorSetter)(LookinColor *); typedef void(^LKS_EnumSetter)(NSString *); typedef void(^LKS_RectSetter)(CGRect); typedef void(^LKS_SizeSetter)(CGSize); typedef void(^LKS_PointSetter)(CGPoint); -typedef void(^LKS_InsetsSetter)(UIEdgeInsets); +typedef void(^LKS_InsetsSetter)(LookinInsets); @interface LKS_CustomAttrSetterManager : NSObject diff --git a/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.h b/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.h index 7cf658e..888beb3 100644 --- a/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.h +++ b/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.h @@ -7,13 +7,26 @@ // Created by likai.123 on 2023/11/1. // +#import + +#if TARGET_OS_IPHONE #import +#endif + +#if TARGET_OS_OSX +#import +#endif + +#import "LookinDefines.h" @class LookinDisplayItem; @interface LKS_CustomDisplayItemsMaker : NSObject - (instancetype)initWithLayer:(CALayer *)layer saveAttrSetter:(BOOL)saveAttrSetter; +#if TARGET_OS_OSX +- (instancetype)initWithView:(NSView *)view saveAttrSetter:(BOOL)saveAttrSetter; +#endif - (NSArray *)make; diff --git a/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.m b/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.m index bdffcfc..7870138 100644 --- a/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.m +++ b/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.m @@ -14,15 +14,32 @@ #import "LKS_CustomAttrGroupsMaker.h" @interface LKS_CustomDisplayItemsMaker () - +#if TARGET_OS_OSX +@property(nonatomic, weak) NSView *view; +#endif @property(nonatomic, weak) CALayer *layer; @property(nonatomic, assign) BOOL saveAttrSetter; @property(nonatomic, strong) NSMutableArray *allSubitems; @end + + @implementation LKS_CustomDisplayItemsMaker + + +#if TARGET_OS_OSX +- (instancetype)initWithView:(NSView *)view saveAttrSetter:(BOOL)saveAttrSetter { + if (self = [super init]) { + self.view = view; + self.saveAttrSetter = saveAttrSetter; + self.allSubitems = [NSMutableArray array]; + } + return self; +} +#endif + - (instancetype)initWithLayer:(CALayer *)layer saveAttrSetter:(BOOL)saveAttrSetter { if (self = [super init]) { self.layer = layer; @@ -33,6 +50,30 @@ - (instancetype)initWithLayer:(CALayer *)layer saveAttrSetter:(BOOL)saveAttrSett } - (NSArray *)make { +#if TARGET_OS_OSX + if (self.view && !self.view.layer) { + NSMutableArray *selectors = [NSMutableArray array]; + [selectors addObject:@"lookin_customDebugInfos"]; + for (int i = 0; i < 5; i++) { + [selectors addObject:[NSString stringWithFormat:@"lookin_customDebugInfos_%@", @(i)]]; + } + + for (NSString *name in selectors) { + [self makeSubitemsForViewOrLayer:self.view selectorName:name]; + + CALayer *layer = self.view.layer; + if (layer) { + [self makeSubitemsForViewOrLayer:layer selectorName:name]; + } + } + + if (self.allSubitems.count) { + return self.allSubitems; + } else { + return nil; + } + } +#endif if (!self.layer) { NSAssert(NO, @""); return nil; @@ -46,7 +87,7 @@ - (instancetype)initWithLayer:(CALayer *)layer saveAttrSetter:(BOOL)saveAttrSett for (NSString *name in selectors) { [self makeSubitemsForViewOrLayer:self.layer selectorName:name]; - UIView *view = self.layer.lks_hostView; + LookinView *view = self.layer.lks_hostView; if (view) { [self makeSubitemsForViewOrLayer:view selectorName:name]; } @@ -63,7 +104,7 @@ - (void)makeSubitemsForViewOrLayer:(id)viewOrLayer selectorName:(NSString *)sele if (!viewOrLayer || !selectorName.length) { return; } - if (![viewOrLayer isKindOfClass:[UIView class]] && ![viewOrLayer isKindOfClass:[CALayer class]]) { + if (![viewOrLayer isKindOfClass:[LookinView class]] && ![viewOrLayer isKindOfClass:[CALayer class]]) { return; } SEL selector = NSSelectorFromString(selectorName); diff --git a/Src/Main/Server/Others/LKS_EventHandlerMaker.h b/Src/Main/Server/Others/LKS_EventHandlerMaker.h index cc12c49..5b1e122 100644 --- a/Src/Main/Server/Others/LKS_EventHandlerMaker.h +++ b/Src/Main/Server/Others/LKS_EventHandlerMaker.h @@ -14,7 +14,7 @@ @interface LKS_EventHandlerMaker : NSObject -+ (NSArray *)makeForView:(UIView *)view; ++ (NSArray *)makeForView:(LookinView *)view; @end diff --git a/Src/Main/Server/Others/LKS_EventHandlerMaker.m b/Src/Main/Server/Others/LKS_EventHandlerMaker.m index 200543e..34e8ed0 100644 --- a/Src/Main/Server/Others/LKS_EventHandlerMaker.m +++ b/Src/Main/Server/Others/LKS_EventHandlerMaker.m @@ -20,15 +20,14 @@ @implementation LKS_EventHandlerMaker -+ (NSArray *)makeForView:(UIView *)view { ++ (NSArray *)makeForView:(LookinView *)view { if (!view) { return nil; } NSMutableArray *allHandlers = nil; - - if ([view isKindOfClass:[UIControl class]]) { - NSArray *targetActionHandlers = [self _targetActionHandlersForControl:(UIControl *)view]; + if ([view isKindOfClass:[LookinControl class]]) { + NSArray *targetActionHandlers = [self _targetActionHandlersForControl:(LookinControl *)view]; if (targetActionHandlers.count) { if (!allHandlers) { allHandlers = [NSMutableArray array]; @@ -48,11 +47,11 @@ @implementation LKS_EventHandlerMaker return allHandlers.copy; } -+ (NSArray *)_gestureHandlersForView:(UIView *)view { ++ (NSArray *)_gestureHandlersForView:(LookinView *)view { if (view.gestureRecognizers.count == 0) { return nil; } - NSArray *handlers = [view.gestureRecognizers lookin_map:^id(NSUInteger idx, __kindof UIGestureRecognizer *recognizer) { + NSArray *handlers = [view.gestureRecognizers lookin_map:^id(NSUInteger idx, __kindof LookinGestureRecognizer *recognizer) { LookinEventHandler *handler = [LookinEventHandler new]; handler.handlerType = LookinEventHandlerTypeGesture; handler.eventName = NSStringFromClass([recognizer class]); @@ -84,7 +83,7 @@ @implementation LKS_EventHandlerMaker return handlers; } -+ (NSString *)_inheritedRecognizerNameForRecognizer:(UIGestureRecognizer *)recognizer { ++ (NSString *)_inheritedRecognizerNameForRecognizer:(LookinGestureRecognizer *)recognizer { if (!recognizer) { NSAssert(NO, @""); return nil; @@ -106,7 +105,7 @@ + (NSString *)_inheritedRecognizerNameForRecognizer:(UIGestureRecognizer *)recog [UIRotationGestureRecognizer class], [UIPinchGestureRecognizer class], [UITapGestureRecognizer class]]; -#else +#elif TARGET_OS_IPHONE baseRecognizers = @[[UILongPressGestureRecognizer class], [UIScreenEdgePanGestureRecognizer class], [UIPanGestureRecognizer class], @@ -114,11 +113,25 @@ + (NSString *)_inheritedRecognizerNameForRecognizer:(UIGestureRecognizer *)recog [UIRotationGestureRecognizer class], [UIPinchGestureRecognizer class], [UITapGestureRecognizer class]]; +#elif TARGET_OS_OSX + baseRecognizers = @[[NSClickGestureRecognizer class], + [NSMagnificationGestureRecognizer class], + [NSPanGestureRecognizer class], + [NSPressGestureRecognizer class], + [NSRotationGestureRecognizer class]]; +#else + baseRecognizers = @[]; #endif }); +#if TARGET_OS_IPHONE __block NSString *result = @"UIGestureRecognizer"; +#elif TARGET_OS_OSX + __block NSString *result = @"NSGestureRecognizer"; +#endif + + [baseRecognizers enumerateObjectsUsingBlock:^(Class _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ([recognizer isMemberOfClass:obj]) { // 自身就是基本款,则直接置为 nil @@ -135,17 +148,65 @@ + (NSString *)_inheritedRecognizerNameForRecognizer:(UIGestureRecognizer *)recog return result; } -+ (NSArray *)_targetActionHandlersForControl:(UIControl *)control { ++ (NSArray *)_targetActionHandlersForControl:(LookinControl *)control { static dispatch_once_t onceToken; static NSArray *allEvents = nil; dispatch_once(&onceToken,^{ +#if TARGET_OS_IPHONE allEvents = @[@(UIControlEventTouchDown), @(UIControlEventTouchDownRepeat), @(UIControlEventTouchDragInside), @(UIControlEventTouchDragOutside), @(UIControlEventTouchDragEnter), @(UIControlEventTouchDragExit), @(UIControlEventTouchUpInside), @(UIControlEventTouchUpOutside), @(UIControlEventTouchCancel), @(UIControlEventValueChanged), @(UIControlEventEditingDidBegin), @(UIControlEventEditingChanged), @(UIControlEventEditingDidEnd), @(UIControlEventEditingDidEndOnExit)]; if (@available(iOS 9.0, *)) { allEvents = [allEvents arrayByAddingObject:@(UIControlEventPrimaryActionTriggered)]; } +#elif TARGET_OS_OSX + allEvents = @[ + @(NSEventMaskLeftMouseDown), + @(NSEventMaskLeftMouseUp), + @(NSEventMaskRightMouseDown), + @(NSEventMaskRightMouseUp), + @(NSEventMaskMouseMoved), + @(NSEventMaskLeftMouseDragged), + @(NSEventMaskRightMouseDragged), + @(NSEventMaskMouseEntered), + @(NSEventMaskMouseExited), + @(NSEventMaskKeyDown), + @(NSEventMaskKeyUp), + @(NSEventMaskFlagsChanged), + @(NSEventMaskAppKitDefined), + @(NSEventMaskSystemDefined), + @(NSEventMaskApplicationDefined), + @(NSEventMaskPeriodic), + @(NSEventMaskCursorUpdate), + @(NSEventMaskScrollWheel), + @(NSEventMaskTabletPoint), + @(NSEventMaskTabletProximity), + @(NSEventMaskOtherMouseDown), + @(NSEventMaskOtherMouseUp), + @(NSEventMaskOtherMouseDragged), + @(NSEventMaskGesture), + @(NSEventMaskMagnify), + @(NSEventMaskSwipe), + @(NSEventMaskRotate), + @(NSEventMaskBeginGesture), + @(NSEventMaskEndGesture), + @(NSEventMaskSmartMagnify), + @(NSEventMaskPressure), + @(NSEventMaskDirectTouch), + @(NSEventMaskAny), + ]; + if (@available(macOS 10.15, *)) { + allEvents = [allEvents arrayByAddingObject:@(NSEventMaskChangeMode)]; + } +#endif }); +#if TARGET_OS_IPHONE NSSet *allTargets = control.allTargets; +#elif TARGET_OS_OSX + NSMutableSet *allTargets = [NSMutableSet set]; + if (control.target) { + [allTargets addObject:control.target]; + } +#endif if (!allTargets.count) { return nil; @@ -153,9 +214,9 @@ + (NSString *)_inheritedRecognizerNameForRecognizer:(UIGestureRecognizer *)recog NSMutableArray *handlers = [NSMutableArray array]; +#if TARGET_OS_IPHONE [allEvents enumerateObjectsUsingBlock:^(NSNumber * _Nonnull eventNum, NSUInteger idx, BOOL * _Nonnull stop) { UIControlEvents event = [eventNum unsignedIntegerValue]; - NSMutableArray *targetActions = [NSMutableArray array]; [allTargets enumerateObjectsUsingBlock:^(id _Nonnull target, BOOL * _Nonnull stop) { @@ -176,10 +237,21 @@ + (NSString *)_inheritedRecognizerNameForRecognizer:(UIGestureRecognizer *)recog [handlers addObject:handler]; } }]; +#elif TARGET_OS_OSX + if (control.target && control.action) { + NSEventMask eventMask = [[control valueForKeyPath:@"cell.sendActionOnMask"] unsignedIntegerValue]; + LookinEventHandler *handler = [LookinEventHandler new]; + handler.handlerType = LookinEventHandlerTypeTargetAction; + handler.eventName = [self _nameFromEventMask:eventMask]; + handler.targetActions = @[[LookinStringTwoTuple tupleWithFirst:[LKS_Helper descriptionOfObject:control.target] second:NSStringFromSelector(control.action)]]; + [handlers addObject:handler]; + } +#endif return handlers; } +#if TARGET_OS_IPHONE + (NSString *)_nameFromControlEvent:(UIControlEvents)event { static dispatch_once_t onceToken; static NSDictionary *eventsAndNames = nil; @@ -209,6 +281,56 @@ + (NSString *)_nameFromControlEvent:(UIControlEvents)event { NSString *name = eventsAndNames[@(event)]; return name; } +#elif TARGET_OS_OSX ++ (NSString *)_nameFromEventMask:(NSEventMask)eventMask { + static dispatch_once_t onceToken; + static NSDictionary *eventsAndNames = nil; + dispatch_once(&onceToken,^{ + NSMutableDictionary *eventsAndNames_m = @{ + @(NSEventMaskLeftMouseDown): @"NSEventMaskLeftMouseDown", + @(NSEventMaskLeftMouseUp): @"NSEventMaskLeftMouseUp", + @(NSEventMaskRightMouseDown): @"NSEventMaskRightMouseDown", + @(NSEventMaskRightMouseUp): @"NSEventMaskRightMouseUp", + @(NSEventMaskMouseMoved): @"NSEventMaskMouseMoved", + @(NSEventMaskLeftMouseDragged): @"NSEventMaskLeftMouseDragged", + @(NSEventMaskRightMouseDragged): @"NSEventMaskRightMouseDragged", + @(NSEventMaskMouseEntered): @"NSEventMaskMouseEntered", + @(NSEventMaskMouseExited): @"NSEventMaskMouseExited", + @(NSEventMaskKeyDown): @"NSEventMaskKeyDown", + @(NSEventMaskKeyUp): @"NSEventMaskKeyUp", + @(NSEventMaskFlagsChanged): @"NSEventMaskFlagsChanged", + @(NSEventMaskAppKitDefined): @"NSEventMaskAppKitDefined", + @(NSEventMaskSystemDefined): @"NSEventMaskSystemDefined", + @(NSEventMaskApplicationDefined): @"NSEventMaskApplicationDefined", + @(NSEventMaskPeriodic): @"NSEventMaskPeriodic", + @(NSEventMaskCursorUpdate): @"NSEventMaskCursorUpdate", + @(NSEventMaskScrollWheel): @"NSEventMaskScrollWheel", + @(NSEventMaskTabletPoint): @"NSEventMaskTabletPoint", + @(NSEventMaskTabletProximity): @"NSEventMaskTabletProximity", + @(NSEventMaskOtherMouseDown): @"NSEventMaskOtherMouseDown", + @(NSEventMaskOtherMouseUp): @"NSEventMaskOtherMouseUp", + @(NSEventMaskOtherMouseDragged): @"NSEventMaskOtherMouseDragged", + @(NSEventMaskGesture): @"NSEventMaskGesture", + @(NSEventMaskMagnify): @"NSEventMaskMagnify", + @(NSEventMaskSwipe): @"NSEventMaskSwipe", + @(NSEventMaskRotate): @"NSEventMaskRotate", + @(NSEventMaskBeginGesture): @"NSEventMaskBeginGesture", + @(NSEventMaskEndGesture): @"NSEventMaskEndGesture", + @(NSEventMaskSmartMagnify): @"NSEventMaskSmartMagnify", + @(NSEventMaskPressure): @"NSEventMaskPressure", + @(NSEventMaskDirectTouch): @"NSEventMaskDirectTouch", + @(NSEventMaskAny): @"NSEventMaskAny", + }.mutableCopy; + if (@available(macOS 10.15, *)) { + eventsAndNames_m[@(NSEventMaskChangeMode)] = @"NSEventMaskChangeMode"; + } + eventsAndNames = eventsAndNames_m.copy; + }); + + NSString *name = eventsAndNames[@(eventMask)]; + return name; +} +#endif @end diff --git a/Src/Main/Server/Others/LKS_ExportManager.m b/Src/Main/Server/Others/LKS_ExportManager.m index be040b9..0c423ef 100644 --- a/Src/Main/Server/Others/LKS_ExportManager.m +++ b/Src/Main/Server/Others/LKS_ExportManager.m @@ -15,7 +15,9 @@ #import "LookinAppInfo.h" #import "LookinServerDefines.h" #import "LKS_MultiplatformAdapter.h" +#import "LookinHierarchyInfo+LookinServer.h" +#if TARGET_OS_IPHONE @interface LKS_ExportManagerMaskView : UIView @property(nonatomic, strong) UIView *tipsView; @@ -87,15 +89,19 @@ - (void)layoutSubviews { } @end +#endif + +#if TARGET_OS_OSX +#endif @interface LKS_ExportManager () #if TARGET_OS_TV -#else +#elif TARGET_OS_IPHONE @property(nonatomic, strong) UIDocumentInteractionController *documentController; +@property(nonatomic, strong) LKS_ExportManagerMaskView *maskView; #endif -@property(nonatomic, strong) LKS_ExportManagerMaskView *maskView; @end @@ -114,7 +120,7 @@ + (id)allocWithZone:(struct _NSZone *)zone{ return [self sharedInstance]; } -#if TARGET_OS_TV +#if TARGET_OS_TV || TARGET_OS_OSX - (void)exportAndShare { NSAssert(NO, @"not supported"); } diff --git a/Src/Main/Server/Others/LKS_GestureTargetActionsSearcher.h b/Src/Main/Server/Others/LKS_GestureTargetActionsSearcher.h index def0ca9..37c9461 100644 --- a/Src/Main/Server/Others/LKS_GestureTargetActionsSearcher.h +++ b/Src/Main/Server/Others/LKS_GestureTargetActionsSearcher.h @@ -7,7 +7,17 @@ // Created by likai.123 on 2023/9/11. // +#import + +#if TARGET_OS_IPHONE #import +#endif + +#if TARGET_OS_OSX +#import +#endif + +#import "LookinDefines.h" @class LookinTwoTuple; @@ -17,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN /// 返回一个 UIGestureRecognizer 实例身上绑定的 target & action 信息 /// tuple.first => LookinWeakContainer(包裹着 target),tuple.second => action(方法名字符串) -+ (NSArray *)getTargetActionsFromRecognizer:(UIGestureRecognizer *)recognizer; ++ (NSArray *)getTargetActionsFromRecognizer:(LookinGestureRecognizer *)recognizer; @end diff --git a/Src/Main/Server/Others/LKS_GestureTargetActionsSearcher.m b/Src/Main/Server/Others/LKS_GestureTargetActionsSearcher.m index 0487bff..d1f5115 100644 --- a/Src/Main/Server/Others/LKS_GestureTargetActionsSearcher.m +++ b/Src/Main/Server/Others/LKS_GestureTargetActionsSearcher.m @@ -15,7 +15,7 @@ @implementation LKS_GestureTargetActionsSearcher -+ (NSArray *)getTargetActionsFromRecognizer:(UIGestureRecognizer *)recognizer { ++ (NSArray *)getTargetActionsFromRecognizer:(LookinGestureRecognizer *)recognizer { if (!recognizer) { return @[]; } diff --git a/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.h b/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.h index 6e9bbe0..5f551ed 100644 --- a/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.h +++ b/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.h @@ -25,7 +25,9 @@ /// 把 layer 的 sublayers 转换为 displayItem 数组并返回 + (NSArray *)subitemsOfLayer:(CALayer *)layer; - +#if TARGET_OS_OSX ++ (NSArray *)subitemsOfView:(NSView *)view; +#endif @end #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m b/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m index 4207a43..58ff98a 100644 --- a/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m +++ b/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m @@ -1,4 +1,4 @@ -#ifdef SHOULD_COMPILE_LOOKIN_SERVER +#ifdef SHOULD_COMPILE_LOOKIN_SERVER // // LKS_HierarchyDisplayItemsMaker.m @@ -20,17 +20,38 @@ #import "LKS_CustomDisplayItemsMaker.h" #import "LKS_CustomAttrSetterManager.h" #import "LKS_MultiplatformAdapter.h" - +#import "NSValue+Lookin.h" +#import "LookinObject+LookinServer.h" +#import "NSWindow+LookinServer.h" @implementation LKS_HierarchyDisplayItemsMaker + (NSArray *)itemsWithScreenshots:(BOOL)hasScreenshots attrList:(BOOL)hasAttrList lowImageQuality:(BOOL)lowQuality readCustomInfo:(BOOL)readCustomInfo saveCustomSetter:(BOOL)saveCustomSetter { [[LKS_TraceManager sharedInstance] reload]; - NSArray *windows = [LKS_MultiplatformAdapter allWindows]; + NSArray *windows = [LKS_MultiplatformAdapter allWindows]; NSMutableArray *resultArray = [NSMutableArray arrayWithCapacity:windows.count]; - [windows enumerateObjectsUsingBlock:^(__kindof UIWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) { + [windows enumerateObjectsUsingBlock:^(__kindof LookinWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) { +#if TARGET_OS_IPHONE LookinDisplayItem *item = [self _displayItemWithLayer:window.layer screenshots:hasScreenshots attrList:hasAttrList lowImageQuality:lowQuality readCustomInfo:readCustomInfo saveCustomSetter:saveCustomSetter]; +#elif TARGET_OS_OSX + CALayer *rootLayer = window.lks_rootView.layer; + LookinDisplayItem *item = [LookinDisplayItem new]; + item.windowObject = [LookinObject instanceWithObject:window]; + item.frame = window.lks_bounds; + item.bounds = window.lks_bounds; + item.backgroundColor = window.backgroundColor; + item.shouldCaptureImage = YES; + item.alpha = window.alphaValue; + item.groupScreenshot = [rootLayer lks_groupScreenshotWithLowQuality:lowQuality]; + item.soloScreenshot = [rootLayer lks_soloScreenshotWithLowQuality:lowQuality]; + item.screenshotEncodeType = LookinDisplayItemImageEncodeTypeNSData; + if (rootLayer) { + item.subitems = @[[self _displayItemWithLayer:rootLayer screenshots:hasScreenshots attrList:hasAttrList lowImageQuality:lowQuality readCustomInfo:readCustomInfo saveCustomSetter:saveCustomSetter]]; + } else { + item.subitems = @[[self _displayItemWithView:window.lks_rootView screenshots:hasScreenshots attrList:hasAttrList lowImageQuality:lowQuality readCustomInfo:readCustomInfo saveCustomSetter:saveCustomSetter]]; + } +#endif item.representedAsKeyWindow = window.isKeyWindow; if (item) { [resultArray addObject:item]; @@ -47,7 +68,7 @@ + (LookinDisplayItem *)_displayItemWithLayer:(CALayer *)layer screenshots:(BOOL) LookinDisplayItem *item = [LookinDisplayItem new]; CGRect layerFrame = layer.frame; - UIView *hostView = layer.lks_hostView; + LookinView *hostView = layer.lks_hostView; if (hostView && hostView.superview) { layerFrame = [hostView.superview convertRect:layerFrame toView:nil]; } @@ -78,18 +99,24 @@ + (LookinDisplayItem *)_displayItemWithLayer:(CALayer *)layer screenshots:(BOOL) item.layerObject = [LookinObject instanceWithObject:layer]; item.shouldCaptureImage = [LKSConfigManager shouldCaptureScreenshotOfLayer:layer]; - if (layer.lks_hostView) { - UIView *view = layer.lks_hostView; + LookinView *view = layer.lks_hostView; + if (view) { +#if TARGET_OS_OSX + item.flipped = view.isFlipped; +#endif item.viewObject = [LookinObject instanceWithObject:view]; item.eventHandlers = [LKS_EventHandlerMaker makeForView:view]; - item.backgroundColor = view.backgroundColor; + item.backgroundColor = [view valueForKeyPath:@"backgroundColor"]; - UIViewController* vc = [view lks_findHostViewController]; + LookinViewController* vc = [view lks_findHostViewController]; if (vc) { item.hostViewControllerObject = [LookinObject instanceWithObject:vc]; } } else { - item.backgroundColor = [UIColor lks_colorWithCGColor:layer.backgroundColor]; +#if TARGET_OS_OSX + item.flipped = layer.isGeometryFlipped; +#endif + item.backgroundColor = [LookinColor lks_colorWithCGColor:layer.backgroundColor]; } if (layer.sublayers.count) { @@ -111,7 +138,7 @@ + (LookinDisplayItem *)_displayItemWithLayer:(CALayer *)layer screenshots:(BOOL) } else { item.subitems = customSubitems; } - } + } } return item; @@ -124,7 +151,7 @@ + (LookinDisplayItem *)_displayItemWithLayer:(CALayer *)layer screenshots:(BOOL) [[LKS_TraceManager sharedInstance] reload]; NSMutableArray *resultSubitems = [NSMutableArray array]; - + NSArray *sublayers = [layer.sublayers copy]; [sublayers enumerateObjectsUsingBlock:^(__kindof CALayer * _Nonnull sublayer, NSUInteger idx, BOOL * _Nonnull stop) { LookinDisplayItem *sublayer_item = [self _displayItemWithLayer:sublayer screenshots:NO attrList:NO lowImageQuality:NO readCustomInfo:YES saveCustomSetter:YES]; @@ -132,7 +159,7 @@ + (LookinDisplayItem *)_displayItemWithLayer:(CALayer *)layer screenshots:(BOOL) [resultSubitems addObject:sublayer_item]; } }]; - + NSArray *customSubitems = [[[LKS_CustomDisplayItemsMaker alloc] initWithLayer:layer saveAttrSetter:YES] make]; if (customSubitems.count > 0) { [resultSubitems addObjectsFromArray:customSubitems]; @@ -141,6 +168,124 @@ + (LookinDisplayItem *)_displayItemWithLayer:(CALayer *)layer screenshots:(BOOL) return resultSubitems; } +#if TARGET_OS_OSX ++ (LookinDisplayItem *)_displayItemWithView:(NSView *)view screenshots:(BOOL)hasScreenshots attrList:(BOOL)hasAttrList lowImageQuality:(BOOL)lowQuality readCustomInfo:(BOOL)readCustomInfo saveCustomSetter:(BOOL)saveCustomSetter { + if (!view) { + return nil; + } + + LookinDisplayItem *item = [LookinDisplayItem new]; + CGRect viewFrame = view.frame; + + if (view.superview) { + viewFrame = [view.superview convertRect:viewFrame toView:nil]; + } + if ([self validateFrame:viewFrame]) { + item.frame = view.frame; + } else { + NSLog(@"LookinServer - The layer frame(%@) seems really weird. Lookin will ignore it to avoid potential render error in Lookin.", NSStringFromCGRect(view.frame)); + item.frame = CGRectZero; + } + item.bounds = view.bounds; + item.flipped = view.isFlipped; + if (hasScreenshots) { + item.soloScreenshot = [view lks_soloScreenshotWithLowQuality:lowQuality]; + item.groupScreenshot = [view lks_groupScreenshotWithLowQuality:lowQuality]; + item.screenshotEncodeType = LookinDisplayItemImageEncodeTypeNSData; + } + + if (hasAttrList) { + item.attributesGroupList = [LKS_AttrGroupsMaker attrGroupsForView:view]; + LKS_CustomAttrGroupsMaker *maker = [[LKS_CustomAttrGroupsMaker alloc] initWithView:view]; + [maker execute]; + item.customAttrGroupList = [maker getGroups]; + item.customDisplayTitle = [maker getCustomDisplayTitle]; + item.danceuiSource = [maker getDanceUISource]; + } + + item.isHidden = view.isHidden; + item.alpha = view.alphaValue; + item.viewObject = [LookinObject instanceWithObject:view]; + if (view.layer) { + item.layerObject = [LookinObject instanceWithObject:view.layer]; + } + item.shouldCaptureImage = [LKSConfigManager shouldCaptureScreenshotOfView:view]; + + item.viewObject = [LookinObject instanceWithObject:view]; + item.eventHandlers = [LKS_EventHandlerMaker makeForView:view]; + item.backgroundColor = [view valueForKeyPath:@"backgroundColor"]; + + LookinViewController* vc = [view lks_findHostViewController]; + if (vc) { + item.hostViewControllerObject = [LookinObject instanceWithObject:vc]; + } + + + if (view.subviews.count) { + NSArray *subviews = [view.subviews copy]; + NSMutableArray *allSubitems = [NSMutableArray arrayWithCapacity:subviews.count]; + [subviews enumerateObjectsUsingBlock:^(__kindof NSView * _Nonnull subview, NSUInteger idx, BOOL * _Nonnull stop) { + if (!subview.layer) { + LookinDisplayItem *sub_item = [self _displayItemWithView:subview screenshots:hasScreenshots attrList:hasAttrList lowImageQuality:lowQuality readCustomInfo:readCustomInfo saveCustomSetter:saveCustomSetter]; + if (sub_item) { + [allSubitems addObject:sub_item]; + } + } else { + LookinDisplayItem *sub_item = [self _displayItemWithLayer:subview.layer screenshots:hasScreenshots attrList:hasAttrList lowImageQuality:lowQuality readCustomInfo:readCustomInfo saveCustomSetter:saveCustomSetter]; + if (sub_item) { + [allSubitems addObject:sub_item]; + } + } + }]; + item.subitems = [allSubitems copy]; + } + if (readCustomInfo) { + NSArray *customSubitems = [[[LKS_CustomDisplayItemsMaker alloc] initWithView:view saveAttrSetter:saveCustomSetter] make]; + if (customSubitems.count > 0) { + if (item.subitems) { + item.subitems = [item.subitems arrayByAddingObjectsFromArray:customSubitems]; + } else { + item.subitems = customSubitems; + } + } + } + + return item; +} + ++ (NSArray *)subitemsOfView:(NSView *)view { + if (!view || view.subviews.count == 0) { + return @[]; + } + [[LKS_TraceManager sharedInstance] reload]; + + NSMutableArray *resultSubitems = [NSMutableArray array]; + + NSArray *subviews = [view.subviews copy]; + [subviews enumerateObjectsUsingBlock:^(__kindof NSView * _Nonnull subview, NSUInteger idx, BOOL * _Nonnull stop) { + if (!subview.layer) { + LookinDisplayItem *sub_item = [self _displayItemWithView:subview screenshots:NO attrList:NO lowImageQuality:NO readCustomInfo:YES saveCustomSetter:YES]; + if (sub_item) { + [resultSubitems addObject:sub_item]; + } + } else { + LookinDisplayItem *sub_item = [self _displayItemWithLayer:subview.layer screenshots:NO attrList:NO lowImageQuality:NO readCustomInfo:YES saveCustomSetter:YES]; + if (sub_item) { + [resultSubitems addObject:sub_item]; + } + } + }]; + + NSArray *customSubitems = [[[LKS_CustomDisplayItemsMaker alloc] initWithView:view saveAttrSetter:YES] make]; + if (customSubitems.count > 0) { + [resultSubitems addObjectsFromArray:customSubitems]; + } + + return resultSubitems; +} +#endif + + + (BOOL)validateFrame:(CGRect)frame { return !CGRectIsNull(frame) && !CGRectIsInfinite(frame) && ![self cgRectIsNaN:frame] && ![self cgRectIsInf:frame] && ![self cgRectIsUnreasonable:frame]; } diff --git a/Src/Main/Server/Others/LKS_TraceManager.m b/Src/Main/Server/Others/LKS_TraceManager.m index b90fdf3..31632e0 100644 --- a/Src/Main/Server/Others/LKS_TraceManager.m +++ b/Src/Main/Server/Others/LKS_TraceManager.m @@ -14,7 +14,7 @@ #import "LookinServerDefines.h" #import "LookinWeakContainer.h" #import "LKS_MultiplatformAdapter.h" - +#import "NSWindow+LookinServer.h" #ifdef LOOKIN_SERVER_SWIFT_ENABLED #if __has_include() @@ -75,23 +75,29 @@ - (void)reload { [self _markIVarsInAllClassLevelsOfObject:obj.object]; }]; - [[LKS_MultiplatformAdapter allWindows] enumerateObjectsUsingBlock:^(__kindof UIWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) { + [[LKS_MultiplatformAdapter allWindows] enumerateObjectsUsingBlock:^(__kindof LookinWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) { +#if TARGET_OS_IPHONE [self _addTraceForLayersRootedByLayer:window.layer]; +#elif TARGET_OS_OSX + [self _addTraceForLayersRootedByLayer:window.lks_rootView.layer]; +#endif }]; } - (void)_addTraceForLayersRootedByLayer:(CALayer *)layer { - UIView *view = layer.lks_hostView; + LookinView *view = layer.lks_hostView; +#if TARGET_OS_IPHONE if ([view.superview lks_isChildrenViewOfTabBar]) { view.lks_isChildrenViewOfTabBar = YES; } else if ([view isKindOfClass:[UITabBar class]]) { view.lks_isChildrenViewOfTabBar = YES; } +#endif if (view) { [self _markIVarsInAllClassLevelsOfObject:view]; - UIViewController* vc = [view lks_findHostViewController]; + LookinViewController* vc = [view lks_findHostViewController]; if (vc) { [self _markIVarsInAllClassLevelsOfObject:vc]; } @@ -106,13 +112,42 @@ - (void)_addTraceForLayersRootedByLayer:(CALayer *)layer { }]; } -- (void)_buildSpecialTraceForView:(UIView *)view { - UIViewController* vc = [view lks_findHostViewController]; +#if TARGET_OS_OSX +- (void)_addTraceForInterfaceObject:(id)interfaceObject { +// LookinView *view = window.contentView; + + if ([interfaceObject isKindOfClass:[NSWindow class]]) { + [self _markIVarsInAllClassLevelsOfObject:interfaceObject]; + NSWindow *window = interfaceObject; + if (window.contentView) { + [self _addTraceForInterfaceObject:window.contentView]; + } + } else if ([interfaceObject isKindOfClass:[NSView class]]) { + NSView *view = interfaceObject; + [self _markIVarsInAllClassLevelsOfObject:view]; + LookinViewController* vc = [view lks_findHostViewController]; + if (vc) { + [self _markIVarsInAllClassLevelsOfObject:vc]; + } + [self _buildSpecialTraceForView:view]; + if (view.layer) { + [self _markIVarsInAllClassLevelsOfObject:view.layer]; + } + [[view.subviews copy] enumerateObjectsUsingBlock:^(__kindof NSView * _Nonnull subview, NSUInteger idx, BOOL * _Nonnull stop) { + [self _addTraceForInterfaceObject:subview]; + }]; + } +} +#endif + +- (void)_buildSpecialTraceForView:(LookinView *)view { + LookinViewController* vc = [view lks_findHostViewController]; if (vc) { view.lks_specialTrace = [NSString stringWithFormat:@"%@.view", NSStringFromClass(vc.class)]; - } else if ([view isKindOfClass:[UIWindow class]]) { - CGFloat currentWindowLevel = ((UIWindow *)view).windowLevel; +#if TARGET_OS_IPHONE + } else if ([view isKindOfClass:[LookinWindow class]]) { + CGFloat currentWindowLevel = ((LookinWindow *)view).windowLevel; if (((UIWindow *)view).isKeyWindow) { view.lks_specialTrace = [NSString stringWithFormat:@"KeyWindow ( Level: %@ )", @(currentWindowLevel)]; @@ -122,7 +157,7 @@ - (void)_buildSpecialTraceForView:(UIView *)view { } else if ([view isKindOfClass:[UITableViewCell class]]) { ((UITableViewCell *)view).backgroundView.lks_specialTrace = @"cell.backgroundView"; ((UITableViewCell *)view).accessoryView.lks_specialTrace = @"cell.accessoryView"; - + } else if ([view isKindOfClass:[UITableView class]]) { UITableView *tableView = (UITableView *)view; @@ -144,31 +179,75 @@ - (void)_buildSpecialTraceForView:(UIView *)view { UIView *secFooterView = [tableView footerViewForSection:secIdx]; secFooterView.lks_specialTrace = [NSString stringWithFormat:@"sectionFooter { sec: %@ }", @(secIdx)]; }]; - - } else if ([view isKindOfClass:[UICollectionView class]]) { - UICollectionView *collectionView = (UICollectionView *)view; + } else if ([view isKindOfClass:[UITableViewHeaderFooterView class]]) { + UITableViewHeaderFooterView *headerFooterView = (UITableViewHeaderFooterView *)view; + headerFooterView.textLabel.lks_specialTrace = @"sectionHeaderFooter.textLabel"; + headerFooterView.detailTextLabel.lks_specialTrace = @"sectionHeaderFooter.detailTextLabel"; +#elif TARGET_OS_OSX + } else if ([view isKindOfClass:[NSTableView class]]) { + NSTableView *tableView = (NSTableView *)view; + tableView.headerView.lks_specialTrace = @"tableView.headerView"; + NSRect visibleRect = tableView.visibleRect; + NSIndexSet *visibleRowIndexes = [NSIndexSet indexSetWithIndexesInRange:[tableView rowsInRect:visibleRect]]; + [visibleRowIndexes enumerateIndexesUsingBlock:^(NSUInteger row, BOOL * _Nonnull stop) { + NSTableRowView *rowView = [tableView rowViewAtRow:row makeIfNecessary:NO]; + NSInteger level = NSNotFound; + if ([tableView isKindOfClass:[NSOutlineView class]]) { + NSOutlineView *outlineView = (NSOutlineView *)tableView; + level = [outlineView levelForRow:row]; + } + + if (level != NSNotFound) { + rowView.lks_specialTrace = [NSString stringWithFormat:@"{ level: %@, row: %@ }", @(level), @(row)]; + } else { + rowView.lks_specialTrace = [NSString stringWithFormat:@"{ row: %@ }", @(row)]; + } + + NSInteger numberOfColumns = [tableView numberOfColumns]; + for (NSInteger column = 0; column < numberOfColumns; column++) { + NSView *cellView = [rowView viewAtColumn:column]; + if (cellView && [cellView isKindOfClass:[NSView class]]) { + if (level != NSNotFound) { + cellView.lks_specialTrace = [NSString stringWithFormat:@"{ level: %@, row: %@, column: %@ }", @(level), @(row), @(column)]; + } else { + cellView.lks_specialTrace = [NSString stringWithFormat:@"{ row: %@, column: %@ }", @(row), @(column)]; + } + } + } + }]; +#endif + } else if ([view isKindOfClass:[LookinCollectionView class]]) { + LookinCollectionView *collectionView = (LookinCollectionView *)view; collectionView.backgroundView.lks_specialTrace = @"collectionView.backgroundView"; - +#if TARGET_OS_IPHONE if (@available(iOS 9.0, *)) { - [[collectionView indexPathsForVisibleSupplementaryElementsOfKind:UICollectionElementKindSectionHeader] enumerateObjectsUsingBlock:^(NSIndexPath * _Nonnull indexPath, NSUInteger idx, BOOL * _Nonnull stop) { - UIView *headerView = [collectionView supplementaryViewForElementKind:UICollectionElementKindSectionHeader atIndexPath:indexPath]; + [[collectionView indexPathsForVisibleSupplementaryElementsOfKind:LookinCollectionElementKindSectionHeader] enumerateObjectsUsingBlock:^(NSIndexPath * _Nonnull indexPath, NSUInteger idx, BOOL * _Nonnull stop) { + LookinView *headerView = [collectionView supplementaryViewForElementKind:LookinCollectionElementKindSectionHeader atIndexPath:indexPath]; headerView.lks_specialTrace = [NSString stringWithFormat:@"sectionHeader { sec:%@ }", @(indexPath.section)]; }]; - [[collectionView indexPathsForVisibleSupplementaryElementsOfKind:UICollectionElementKindSectionFooter] enumerateObjectsUsingBlock:^(NSIndexPath * _Nonnull indexPath, NSUInteger idx, BOOL * _Nonnull stop) { - UIView *footerView = [collectionView supplementaryViewForElementKind:UICollectionElementKindSectionFooter atIndexPath:indexPath]; + [[collectionView indexPathsForVisibleSupplementaryElementsOfKind:LookinCollectionElementKindSectionFooter] enumerateObjectsUsingBlock:^(NSIndexPath * _Nonnull indexPath, NSUInteger idx, BOOL * _Nonnull stop) { + LookinView *footerView = [collectionView supplementaryViewForElementKind:LookinCollectionElementKindSectionFooter atIndexPath:indexPath]; footerView.lks_specialTrace = [NSString stringWithFormat:@"sectionFooter { sec:%@ }", @(indexPath.section)]; }]; } - [[collectionView visibleCells] enumerateObjectsUsingBlock:^(__kindof UICollectionViewCell * _Nonnull cell, NSUInteger idx, BOOL * _Nonnull stop) { NSIndexPath *indexPath = [collectionView indexPathForCell:cell]; cell.lks_specialTrace = [NSString stringWithFormat:@"{ item:%@, sec:%@ }", @(indexPath.item), @(indexPath.section)]; }]; - - } else if ([view isKindOfClass:[UITableViewHeaderFooterView class]]) { - UITableViewHeaderFooterView *headerFooterView = (UITableViewHeaderFooterView *)view; - headerFooterView.textLabel.lks_specialTrace = @"sectionHeaderFooter.textLabel"; - headerFooterView.detailTextLabel.lks_specialTrace = @"sectionHeaderFooter.detailTextLabel"; +#elif TARGET_OS_OSX + [[collectionView indexPathsForVisibleSupplementaryElementsOfKind:LookinCollectionElementKindSectionHeader] enumerateObjectsUsingBlock:^(NSIndexPath * _Nonnull indexPath, BOOL * _Nonnull stop) { + LookinView *headerView = [collectionView supplementaryViewForElementKind:LookinCollectionElementKindSectionHeader atIndexPath:indexPath]; + headerView.lks_specialTrace = [NSString stringWithFormat:@"sectionHeader { sec:%@ }", @(indexPath.section)]; + }]; + [[collectionView indexPathsForVisibleSupplementaryElementsOfKind:LookinCollectionElementKindSectionFooter] enumerateObjectsUsingBlock:^(NSIndexPath * _Nonnull indexPath, BOOL * _Nonnull stop) { + LookinView *footerView = [collectionView supplementaryViewForElementKind:LookinCollectionElementKindSectionFooter atIndexPath:indexPath]; + footerView.lks_specialTrace = [NSString stringWithFormat:@"sectionFooter { sec:%@ }", @(indexPath.section)]; + }]; + [[collectionView visibleItems] enumerateObjectsUsingBlock:^(NSCollectionViewItem * _Nonnull item, NSUInteger idx, BOOL * _Nonnull stop) { + NSIndexPath *indexPath = [collectionView indexPathForItem:item]; + item.lks_specialTrace = [NSString stringWithFormat:@"{ item:%@, sec:%@ }", @(indexPath.item), @(indexPath.section)]; + }]; +#endif } } @@ -184,7 +263,7 @@ - (void)_markIVarsOfObject:(NSObject *)hostObject class:(Class)targetClass { return; } - NSArray *prefixesToTerminateRecursion = @[@"NSObject", @"UIResponder", @"UIButton", @"UIButtonLabel"]; + NSArray *prefixesToTerminateRecursion = @[@"NSObject", @"UIResponder", @"UIButton", @"UIButtonLabel", @"NSResponder"]; BOOL hasPrefix = [prefixesToTerminateRecursion lookin_any:^BOOL(NSString *prefix) { return [NSStringFromClass(targetClass) hasPrefix:prefix]; }]; @@ -202,10 +281,10 @@ - (void)_markIVarsOfObject:(NSObject *)hostObject class:(Class)targetClass { } NSString *ivarClassName = [ivarType substringWithRange:NSMakeRange(2, ivarType.length - 3)]; Class ivarClass = NSClassFromString(ivarClassName); - if (![ivarClass isSubclassOfClass:[UIView class]] + if (![ivarClass isSubclassOfClass:[LookinView class]] && ![ivarClass isSubclassOfClass:[CALayer class]] - && ![ivarClass isSubclassOfClass:[UIViewController class]] - && ![ivarClass isSubclassOfClass:[UIGestureRecognizer class]]) { + && ![ivarClass isSubclassOfClass:[LookinViewController class]] + && ![ivarClass isSubclassOfClass:[LookinGestureRecognizer class]]) { continue; } const char * ivarNameChar = ivar_getName(ivar); @@ -225,14 +304,14 @@ - (void)_markIVarsOfObject:(NSObject *)hostObject class:(Class)targetClass { if (hostObject == ivarObject) { ivarTrace.relation = LookinIvarTraceRelationValue_Self; - } else if ([hostObject isKindOfClass:[UIView class]]) { + } else if ([hostObject isKindOfClass:[LookinView class]]) { CALayer *ivarLayer = nil; if ([ivarObject isKindOfClass:[CALayer class]]) { ivarLayer = (CALayer *)ivarObject; - } else if ([ivarObject isKindOfClass:[UIView class]]) { - ivarLayer = ((UIView *)ivarObject).layer; + } else if ([ivarObject isKindOfClass:[LookinView class]]) { + ivarLayer = ((LookinView *)ivarObject).layer; } - if (ivarLayer && (ivarLayer.superlayer == ((UIView *)hostObject).layer)) { + if (ivarLayer && (ivarLayer.superlayer == ((LookinView *)hostObject).layer)) { ivarTrace.relation = @"superview"; } } @@ -278,13 +357,13 @@ - (NSString *)makeDisplayClassNameWithSuper:(Class)superClass childClass:(Class) [set addObject:({ LookinIvarTrace *trace = [LookinIvarTrace new]; - trace.hostClassName = @"UIView"; + trace.hostClassName = LookinViewString; trace.ivarName = @"_window"; trace; })]; [set addObject:({ LookinIvarTrace *trace = [LookinIvarTrace new]; - trace.hostClassName = @"UIViewController"; + trace.hostClassName = LookinViewControllerString; trace.ivarName = @"_view"; trace; })]; @@ -296,7 +375,7 @@ - (NSString *)makeDisplayClassNameWithSuper:(Class)superClass childClass:(Class) })]; [set addObject:({ LookinIvarTrace *trace = [LookinIvarTrace new]; - trace.hostClassName = @"UIViewController"; + trace.hostClassName = LookinViewControllerString; trace.ivarName = @"_parentViewController"; trace; })]; diff --git a/Src/Main/Server/Others/LookinAutoLayoutConstraint+LookinServer.h b/Src/Main/Server/Others/LookinAutoLayoutConstraint+LookinServer.h new file mode 100644 index 0000000..bc9bb3a --- /dev/null +++ b/Src/Main/Server/Others/LookinAutoLayoutConstraint+LookinServer.h @@ -0,0 +1,17 @@ +// +// LookinAutoLayoutConstraint+LookinServer.h +// LookinServer +// +// Created by JH on 2024/11/5. +// + +#import "LookinAutoLayoutConstraint.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface LookinAutoLayoutConstraint (LookinServer) ++ (instancetype)instanceFromNSConstraint:(NSLayoutConstraint *)constraint isEffective:(BOOL)isEffective firstItemType:(LookinConstraintItemType)firstItemType secondItemType:(LookinConstraintItemType)secondItemType; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Src/Main/Server/Others/LookinAutoLayoutConstraint+LookinServer.m b/Src/Main/Server/Others/LookinAutoLayoutConstraint+LookinServer.m new file mode 100644 index 0000000..6be850e --- /dev/null +++ b/Src/Main/Server/Others/LookinAutoLayoutConstraint+LookinServer.m @@ -0,0 +1,31 @@ +// +// LookinAutoLayoutConstraint+LookinServer.m +// LookinServer +// +// Created by JH on 2024/11/5. +// + +#import "LookinAutoLayoutConstraint+LookinServer.h" +#import "LookinObject+LookinServer.h" + +@implementation LookinAutoLayoutConstraint (LookinServer) ++ (instancetype)instanceFromNSConstraint:(NSLayoutConstraint *)constraint isEffective:(BOOL)isEffective firstItemType:(LookinConstraintItemType)firstItemType secondItemType:(LookinConstraintItemType)secondItemType { + LookinAutoLayoutConstraint *instance = [LookinAutoLayoutConstraint new]; + instance.effective = isEffective; + instance.active = constraint.active; + instance.shouldBeArchived = constraint.shouldBeArchived; + instance.firstItem = [LookinObject instanceWithObject:constraint.firstItem]; + instance.firstItemType = firstItemType; + instance.firstAttribute = constraint.firstAttribute; + instance.relation = constraint.relation; + instance.secondItem = [LookinObject instanceWithObject:constraint.secondItem]; + instance.secondItemType = secondItemType; + instance.secondAttribute = constraint.secondAttribute; + instance.multiplier = constraint.multiplier; + instance.constant = constraint.constant; + instance.priority = constraint.priority; + instance.identifier = constraint.identifier; + + return instance; +} +@end diff --git a/Src/Main/Server/Others/LookinHierarchyInfo+LookinServer.h b/Src/Main/Server/Others/LookinHierarchyInfo+LookinServer.h new file mode 100644 index 0000000..49d65e3 --- /dev/null +++ b/Src/Main/Server/Others/LookinHierarchyInfo+LookinServer.h @@ -0,0 +1,19 @@ +// +// LookinHierarchyInfo+LookinServer.h +// LookinServer +// +// Created by JH on 2024/11/5. +// + +#import "LookinHierarchyInfo.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface LookinHierarchyInfo (LookinServer) +/// version 可能为 nil,此时说明 Client 版本号 < 1.0.4 ++ (instancetype)staticInfoWithLookinVersion:(NSString *)version; + ++ (instancetype)exportedInfo; +@end + +NS_ASSUME_NONNULL_END diff --git a/Src/Main/Server/Others/LookinHierarchyInfo+LookinServer.m b/Src/Main/Server/Others/LookinHierarchyInfo+LookinServer.m new file mode 100644 index 0000000..67a196b --- /dev/null +++ b/Src/Main/Server/Others/LookinHierarchyInfo+LookinServer.m @@ -0,0 +1,47 @@ +// +// LookinHierarchyInfo+LookinServer.m +// LookinServer +// +// Created by JH on 2024/11/5. +// + +#import "LookinHierarchyInfo+LookinServer.h" +#import "LookinHierarchyInfo.h" +#import "LookinAttributesGroup.h" +#import "LookinDisplayItem.h" +#import "LookinAppInfo.h" +#import "NSArray+Lookin.h" +#import "NSString+Lookin.h" +#import "LKS_HierarchyDisplayItemsMaker.h" +#import "LKSConfigManager.h" +#import "LKS_CustomAttrSetterManager.h" +@implementation LookinHierarchyInfo (LookinServer) + ++ (instancetype)staticInfoWithLookinVersion:(NSString *)version { + BOOL readCustomInfo = NO; + // Client 1.0.4 开始支持 customInfo + if (version && [version lookin_numbericOSVersion] >= 10004) { + readCustomInfo = YES; + } + + [[LKS_CustomAttrSetterManager sharedInstance] removeAll]; + + LookinHierarchyInfo *info = [LookinHierarchyInfo new]; + info.serverVersion = LOOKIN_SERVER_VERSION; + info.displayItems = [LKS_HierarchyDisplayItemsMaker itemsWithScreenshots:NO attrList:NO lowImageQuality:NO readCustomInfo:readCustomInfo saveCustomSetter:YES]; + info.appInfo = [LookinAppInfo currentInfoWithScreenshot:NO icon:YES localIdentifiers:nil]; + info.collapsedClassList = [LKSConfigManager collapsedClassList]; + info.colorAlias = [LKSConfigManager colorAlias]; + return info; +} + ++ (instancetype)exportedInfo { + LookinHierarchyInfo *info = [LookinHierarchyInfo new]; + info.serverVersion = LOOKIN_SERVER_VERSION; + info.displayItems = [LKS_HierarchyDisplayItemsMaker itemsWithScreenshots:YES attrList:YES lowImageQuality:YES readCustomInfo:YES saveCustomSetter:NO]; + info.appInfo = [LookinAppInfo currentInfoWithScreenshot:NO icon:YES localIdentifiers:nil]; + info.collapsedClassList = [LKSConfigManager collapsedClassList]; + info.colorAlias = [LKSConfigManager colorAlias]; + return info; +} +@end diff --git a/Src/Main/Server/Others/LookinObject+LookinServer.h b/Src/Main/Server/Others/LookinObject+LookinServer.h new file mode 100644 index 0000000..cad8c1e --- /dev/null +++ b/Src/Main/Server/Others/LookinObject+LookinServer.h @@ -0,0 +1,17 @@ +// +// LookinObject+LookinServer.h +// LookinServer +// +// Created by JH on 2024/11/5. +// + +#import "LookinObject.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface LookinObject (LookinServer) + ++ (instancetype)instanceWithObject:(NSObject *)object; +@end + +NS_ASSUME_NONNULL_END diff --git a/Src/Main/Server/Others/LookinObject+LookinServer.m b/Src/Main/Server/Others/LookinObject+LookinServer.m new file mode 100644 index 0000000..50f9bfb --- /dev/null +++ b/Src/Main/Server/Others/LookinObject+LookinServer.m @@ -0,0 +1,26 @@ +// +// LookinObject+LookinServer.m +// LookinServer +// +// Created by JH on 2024/11/5. +// + +#import "LookinObject+LookinServer.h" +#import "NSObject+LookinServer.h" +#import "LookinIvarTrace.h" + +@implementation LookinObject (LookinServer) ++ (instancetype)instanceWithObject:(NSObject *)object { + LookinObject *lookinObj = [LookinObject new]; + lookinObj.oid = [object lks_registerOid]; + + lookinObj.memoryAddress = [NSString stringWithFormat:@"%p", object]; + lookinObj.classChainList = [object lks_classChainList]; + + lookinObj.specialTrace = object.lks_specialTrace; + lookinObj.ivarTraces = object.lks_ivarTraces; + + return lookinObj; +} + +@end diff --git a/Src/Main/Shared/Category/Color+Lookin.h b/Src/Main/Shared/Category/Color+Lookin.h index 9a49ab9..f6b57d1 100644 --- a/Src/Main/Shared/Category/Color+Lookin.h +++ b/Src/Main/Shared/Category/Color+Lookin.h @@ -11,8 +11,8 @@ #if TARGET_OS_IPHONE -#elif TARGET_OS_MAC - +#elif TARGET_OS_OSX +#import @interface NSColor (Lookin) + (instancetype)lookin_colorFromRGBAComponents:(NSArray *)components; diff --git a/Src/Main/Shared/Category/Color+Lookin.m b/Src/Main/Shared/Category/Color+Lookin.m index 4f5ede1..5b9a310 100644 --- a/Src/Main/Shared/Category/Color+Lookin.m +++ b/Src/Main/Shared/Category/Color+Lookin.m @@ -11,8 +11,8 @@ #if TARGET_OS_IPHONE -#elif TARGET_OS_MAC - +#elif TARGET_OS_OSX +#import @implementation NSColor (Lookin) + (instancetype)lookin_colorFromRGBAComponents:(NSArray *)components { diff --git a/Src/Main/Shared/Category/Image+Lookin.h b/Src/Main/Shared/Category/Image+Lookin.h index 7fe33c8..b3a1d48 100644 --- a/Src/Main/Shared/Category/Image+Lookin.h +++ b/Src/Main/Shared/Category/Image+Lookin.h @@ -11,7 +11,9 @@ #if TARGET_OS_IPHONE -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX + +#import @interface NSImage (LookinClient) diff --git a/Src/Main/Shared/Category/Image+Lookin.m b/Src/Main/Shared/Category/Image+Lookin.m index d285d54..cc7b9cd 100644 --- a/Src/Main/Shared/Category/Image+Lookin.m +++ b/Src/Main/Shared/Category/Image+Lookin.m @@ -11,12 +11,12 @@ #if TARGET_OS_IPHONE -#elif TARGET_OS_MAC - +#elif TARGET_OS_OSX +#import @implementation NSImage (LookinClient) - (NSData *)lookin_data { - return [self TIFFRepresentation]; + return [NSBitmapImageRep representationOfImageRepsInArray:self.representations usingType:(NSBitmapImageFileTypePNG) properties:@{}]; } @end diff --git a/Src/Main/Shared/Category/NSObject+Lookin.m b/Src/Main/Shared/Category/NSObject+Lookin.m index d206613..77d3d69 100644 --- a/Src/Main/Shared/Category/NSObject+Lookin.m +++ b/Src/Main/Shared/Category/NSObject+Lookin.m @@ -12,6 +12,7 @@ #import #import "TargetConditionals.h" #import "LookinWeakContainer.h" +#import "Image+Lookin.h" @implementation NSObject (Lookin) @@ -117,7 +118,7 @@ - (long)lookin_getBindLongForKey:(NSString *)key { - (void)lookin_bindPoint:(CGPoint)pointValue forKey:(NSString *)key { #if TARGET_OS_IPHONE [self lookin_bindObject:[NSValue valueWithCGPoint:pointValue] forKey:key]; -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX NSPoint nsPoint = NSMakePoint(pointValue.x, pointValue.y); [self lookin_bindObject:[NSValue valueWithPoint:nsPoint] forKey:key]; #endif @@ -128,7 +129,7 @@ - (CGPoint)lookin_getBindPointForKey:(NSString *)key { if ([object isKindOfClass:[NSValue class]]) { #if TARGET_OS_IPHONE CGPoint pointValue = [(NSValue *)object CGPointValue]; -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX NSPoint nsPointValue = [(NSValue *)object pointValue]; CGPoint pointValue = CGPointMake(nsPointValue.x, nsPointValue.y); #endif @@ -165,7 +166,7 @@ - (id)lookin_encodedObjectWithType:(LookinCodingValueType)type { b = 0; a = 0; } -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX NSColor *color = [((NSColor *)self) colorUsingColorSpace:NSColorSpace.sRGBColorSpace]; [color getRed:&r green:&g blue:&b alpha:&a]; #endif @@ -187,10 +188,10 @@ - (id)lookin_encodedObjectWithType:(LookinCodingValueType)type { NSAssert(NO, @""); return nil; } -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX if ([self isKindOfClass:[NSImage class]]) { NSImage *image = (NSImage *)self; - return [image TIFFRepresentation]; + return [image lookin_data]; } else { NSAssert(NO, @""); diff --git a/Src/Main/Shared/Category/NSSet+Lookin.h b/Src/Main/Shared/Category/NSSet+Lookin.h index f09a704..58038c3 100644 --- a/Src/Main/Shared/Category/NSSet+Lookin.h +++ b/Src/Main/Shared/Category/NSSet+Lookin.h @@ -10,12 +10,10 @@ #import "LookinDefines.h" - - #import "TargetConditionals.h" #if TARGET_OS_IPHONE #import -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX #import #endif diff --git a/Src/Main/Shared/Category/NSString+Lookin.h b/Src/Main/Shared/Category/NSString+Lookin.h index 15f1171..c48e867 100644 --- a/Src/Main/Shared/Category/NSString+Lookin.h +++ b/Src/Main/Shared/Category/NSString+Lookin.h @@ -10,8 +10,6 @@ #import "LookinDefines.h" - - #import @interface NSString (Lookin) diff --git a/Src/Main/Shared/Category/NSString+Lookin.m b/Src/Main/Shared/Category/NSString+Lookin.m index 9b76fb5..3e297cc 100644 --- a/Src/Main/Shared/Category/NSString+Lookin.m +++ b/Src/Main/Shared/Category/NSString+Lookin.m @@ -64,7 +64,7 @@ + (NSString *)lookin_rgbaStringFromColor:(LookinColor *)color { #if TARGET_OS_IPHONE UIColor *rgbColor = color; -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX NSColor *rgbColor = [color colorUsingColorSpace:NSColorSpace.sRGBColorSpace]; #endif diff --git a/Src/Main/Shared/Category/NSValue+Lookin.h b/Src/Main/Shared/Category/NSValue+Lookin.h new file mode 100644 index 0000000..ca8603d --- /dev/null +++ b/Src/Main/Shared/Category/NSValue+Lookin.h @@ -0,0 +1,39 @@ +// +// NSValue+Lookin.h +// LookinServer +// +// Created by JH on 2024/11/5. +// + +#import +#import "LookinDefines.h" + +NS_ASSUME_NONNULL_BEGIN + +NSString *NSStringFromInsets(LookinInsets insets); +#if TARGET_OS_OSX +NSString *NSStringFromCGAffineTransform(CGAffineTransform transform); +NSString *NSStringFromCGVector(CGVector vector); +NSString *NSStringFromCGRect(CGRect rect); +NSString *NSStringFromCGPoint(CGPoint point); +NSString *NSStringFromCGSize(CGSize size); +NSString *NSStringFromDirectionalEdgeInsets(NSDirectionalEdgeInsets insets); +#endif +@interface NSValue (Lookin) +#if TARGET_OS_OSX ++ (NSValue *)valueWithCGVector:(CGVector)vector; ++ (NSValue *)valueWithCGRect:(CGRect)rect; ++ (NSValue *)valueWithCGPoint:(CGPoint)point; ++ (NSValue *)valueWithCGSize:(CGSize)size; ++ (NSValue *)valueWithCGAffineTransform:(CGAffineTransform)transform; +- (CGAffineTransform)CGAffineTransformValue; +- (CGVector)CGVectorValue; +- (CGRect)CGRectValue; +- (CGPoint)CGPointValue; +- (CGSize)CGSizeValue; +#endif ++ (NSValue *)valueWithInsets:(LookinInsets)insets; +- (LookinInsets)InsetsValue; +@end + +NS_ASSUME_NONNULL_END diff --git a/Src/Main/Shared/Category/NSValue+Lookin.m b/Src/Main/Shared/Category/NSValue+Lookin.m new file mode 100644 index 0000000..50871fd --- /dev/null +++ b/Src/Main/Shared/Category/NSValue+Lookin.m @@ -0,0 +1,99 @@ +// +// NSValue+Lookin.m +// LookinServer +// +// Created by JH on 2024/11/5. +// + +#import "NSValue+Lookin.h" + +NSString *NSStringFromInsets(LookinInsets insets) { + return [NSString stringWithFormat:@"{%.*g, %.*g, %.*g, %.*g}", 17, insets.top, 17, insets.left, 17, insets.bottom, 17, insets.right]; +} +#if TARGET_OS_OSX +NSString *NSStringFromCGAffineTransform(CGAffineTransform transform) { + return [NSString stringWithFormat:@"[%.*g, %.*g, %.*g, %.*g, %.*g, %.*g]", 17, transform.a, 17, transform.b, 17, transform.c, 17, transform.d, 17, transform.tx, 17, transform.ty]; +} +NSString *NSStringFromCGVector(CGVector vector) { + return [NSString stringWithFormat:@"{%.*g, %.*g}", 17, vector.dx, 17, vector.dy]; +} +NSString *NSStringFromCGRect(CGRect rect) { + return NSStringFromRect(rect); +} +NSString *NSStringFromCGPoint(CGPoint point) { + return NSStringFromPoint(point); +} +NSString *NSStringFromCGSize(CGSize size) { + return NSStringFromSize(size); +} +NSString *NSStringFromDirectionalEdgeInsets(NSDirectionalEdgeInsets insets) { + return [NSString stringWithFormat:@"{%.*g, %.*g, %.*g, %.*g}", 17, insets.top, 17, insets.leading, 17, insets.bottom, 17, insets.trailing]; +} +#endif +@implementation NSValue (Lookin) +#if TARGET_OS_OSX ++ (NSValue *)valueWithCGVector:(CGVector)vector { + return [self valueWithBytes:&vector objCType:@encode(CGVector)]; +} + ++ (NSValue *)valueWithCGRect:(CGRect)rect { + return [self valueWithRect:rect]; +} + ++ (NSValue *)valueWithCGSize:(CGSize)size { + return [self valueWithSize:size]; +} + ++ (NSValue *)valueWithCGPoint:(CGPoint)point { + return [self valueWithPoint:point]; +} + ++ (NSValue *)valueWithCGAffineTransform:(CGAffineTransform)transform { + return [self valueWithBytes:&transform objCType:@encode(CGAffineTransform)]; +} + +- (CGAffineTransform)CGAffineTransformValue { + CGAffineTransform transform; + [self getValue:&transform]; + return transform; +} + +- (CGVector)CGVectorValue { + CGVector vector; + [self getValue:&vector]; + return vector; +} + +- (CGRect)CGRectValue { + return [self rectValue]; +} + +- (CGPoint)CGPointValue { + return [self pointValue]; +} + +- (CGSize)CGSizeValue { + return [self sizeValue]; +} +#endif ++ (NSValue *)valueWithInsets:(LookinInsets)insets { +#if TARGET_OS_IPHONE + return [self valueWithUIEdgeInsets:insets]; +#endif + +#if TARGET_OS_OSX + return [self valueWithEdgeInsets:insets]; +#endif +} + +- (LookinInsets)InsetsValue { +#if TARGET_OS_IPHONE + return self.UIEdgeInsetsValue; +#endif + +#if TARGET_OS_OSX + return [self edgeInsetsValue]; +#endif +} + +@end diff --git a/Src/Main/Server/Others/LKS_MultiplatformAdapter.h b/Src/Main/Shared/LKS_MultiplatformAdapter.h similarity index 67% rename from Src/Main/Server/Others/LKS_MultiplatformAdapter.h rename to Src/Main/Shared/LKS_MultiplatformAdapter.h index dc13f64..2b7875d 100644 --- a/Src/Main/Server/Others/LKS_MultiplatformAdapter.h +++ b/Src/Main/Shared/LKS_MultiplatformAdapter.h @@ -7,15 +7,23 @@ // #import +#if TARGET_OS_IPHONE #import +#endif + +#if TARGET_OS_OSX +#import +#endif + +#import "LookinDefines.h" NS_ASSUME_NONNULL_BEGIN @interface LKS_MultiplatformAdapter : NSObject -+ (UIWindow *)keyWindow; ++ (LookinWindow *)keyWindow; -+ (NSArray *)allWindows; ++ (NSArray *)allWindows; + (CGRect)mainScreenBounds; @@ -23,6 +31,8 @@ NS_ASSUME_NONNULL_BEGIN + (BOOL)isiPad; ++ (BOOL)isMac; + @end NS_ASSUME_NONNULL_END diff --git a/Src/Main/Server/Others/LKS_MultiplatformAdapter.m b/Src/Main/Shared/LKS_MultiplatformAdapter.m similarity index 61% rename from Src/Main/Server/Others/LKS_MultiplatformAdapter.m rename to Src/Main/Shared/LKS_MultiplatformAdapter.m index 8c04b98..5646566 100644 --- a/Src/Main/Server/Others/LKS_MultiplatformAdapter.m +++ b/Src/Main/Shared/LKS_MultiplatformAdapter.m @@ -1,17 +1,25 @@ #ifdef SHOULD_COMPILE_LOOKIN_SERVER // // LKS_MultiplatformAdapter.m -// +// // // Created by nixjiang on 2024/3/12. // #import "LKS_MultiplatformAdapter.h" + +#if TARGET_OS_IPHONE #import +#endif + +#if TARGET_OS_OSX +#import +#endif @implementation LKS_MultiplatformAdapter + (BOOL)isiPad { +#if TARGET_OS_IPHONE static BOOL s_isiPad = NO; static dispatch_once_t onceToken; @@ -21,25 +29,53 @@ + (BOOL)isiPad { }); return s_isiPad; +#else + return NO; +#endif +} + ++ (BOOL)isMac { +#if TARGET_OS_OSX + return YES; +#else + return NO; +#endif } + (CGRect)mainScreenBounds { -#if TARGET_OS_VISION +#if TARGET_OS_VISION || TARGET_OS_MACCATALYST return [LKS_MultiplatformAdapter getFirstActiveWindowScene].coordinateSpace.bounds; -#else +#elif TARGET_OS_IPHONE return [UIScreen mainScreen].bounds; +#elif TARGET_OS_OSX + // 这里不能返回屏幕的bounds,因为在macOS上,窗口可以不全屏显示,Lookin的设计是基于窗口的,一般iOS中屏幕的bounds就是窗口的bounds,所以这里直接返回窗口的bounds + CGFloat maxWidth = 0; + CGFloat maxHeight = 0; + CGRect bounds = CGRectZero; + for (NSWindow *window in NSApplication.sharedApplication.windows) { + maxWidth = MAX(maxWidth, window.frame.size.width); + maxHeight = MAX(maxHeight, window.frame.size.height); + } + bounds.size = CGSizeMake(maxWidth, maxHeight); + return bounds; +#else + return CGRectZero; #endif } + (CGFloat)mainScreenScale { #if TARGET_OS_VISION return 2.f; -#else +#elif TARGET_OS_IPHONE return [UIScreen mainScreen].scale; +#elif TARGET_OS_OSX + return [NSScreen mainScreen].backingScaleFactor; +#else + return 1.f; #endif } -#if TARGET_OS_VISION +#if TARGET_OS_VISION || TARGET_OS_MACCATALYST + (UIWindowScene *)getFirstActiveWindowScene { for (UIScene *scene in UIApplication.sharedApplication.connectedScenes) { if (![scene isKindOfClass:UIWindowScene.class]) { @@ -54,15 +90,19 @@ + (UIWindowScene *)getFirstActiveWindowScene { } #endif -+ (UIWindow *)keyWindow { ++ (LookinWindow *)keyWindow { #if TARGET_OS_VISION return [self getFirstActiveWindowScene].keyWindow; +#elif TARGET_OS_IPHONE + return [LookinApplication sharedApplication].keyWindow; +#elif TARGET_OS_OSX + return [LookinApplication sharedApplication].windows.firstObject; #else - return [UIApplication sharedApplication].keyWindow; + return nil; #endif } -+ (NSArray *)allWindows { ++ (NSArray *)allWindows { #if TARGET_OS_VISION NSMutableArray *windows = [NSMutableArray new]; for (UIScene *scene in @@ -83,7 +123,7 @@ + (UIWindow *)keyWindow { return [windows copy]; #else - return [[UIApplication sharedApplication].windows copy]; + return [[LookinApplication sharedApplication].windows copy]; #endif } diff --git a/Src/Main/Shared/LookinAppInfo.h b/Src/Main/Shared/LookinAppInfo.h index 1082d12..4fc8c98 100644 --- a/Src/Main/Shared/LookinAppInfo.h +++ b/Src/Main/Shared/LookinAppInfo.h @@ -15,7 +15,8 @@ typedef NS_ENUM(NSInteger, LookinAppInfoDevice) { LookinAppInfoDeviceSimulator, // 模拟器 LookinAppInfoDeviceIPad, // iPad 真机 - LookinAppInfoDeviceOthers // 应该视为 iPhone 真机 + LookinAppInfoDeviceOthers, // 应该视为 iPhone 真机 + LookinAppInfoDeviceMac, // 使用AppKit的Mac应用(非 Catalyst) }; @interface LookinAppInfo : NSObject @@ -57,16 +58,10 @@ typedef NS_ENUM(NSInteger, LookinAppInfoDevice) { - (BOOL)isEqualToAppInfo:(LookinAppInfo *)info; -#if TARGET_OS_IPHONE - + (LookinAppInfo *)currentInfoWithScreenshot:(BOOL)hasScreenshot icon:(BOOL)hasIcon localIdentifiers:(NSArray *)localIdentifiers; -#else - @property(nonatomic, assign) NSTimeInterval cachedTimestamp; -#endif - @end #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Shared/LookinAppInfo.m b/Src/Main/Shared/LookinAppInfo.m index 1e61d7a..14ab857 100644 --- a/Src/Main/Shared/LookinAppInfo.m +++ b/Src/Main/Shared/LookinAppInfo.m @@ -77,7 +77,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { NSData *appIconData = UIImagePNGRepresentation(self.appIcon); [aCoder encodeObject:appIconData forKey:CodingKey_AppIcon]; -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX NSData *screenshotData = [self.screenshot TIFFRepresentation]; [aCoder encodeObject:screenshotData forKey:CodingKey_Screenshot]; @@ -129,7 +129,6 @@ - (BOOL)isEqualToAppInfo:(LookinAppInfo *)info { return NO; } -#if TARGET_OS_IPHONE + (LookinAppInfo *)currentInfoWithScreenshot:(BOOL)hasScreenshot icon:(BOOL)hasIcon localIdentifiers:(NSArray *)localIdentifiers { NSInteger selfIdentifier = [self getAppInfoIdentifier]; @@ -149,20 +148,38 @@ + (LookinAppInfo *)currentInfoWithScreenshot:(BOOL)hasScreenshot icon:(BOOL)hasI #endif info.appInfoIdentifier = selfIdentifier; info.appName = [self appName]; +#if TARGET_OS_IPHONE info.deviceDescription = [UIDevice currentDevice].name; +#endif + +#if TARGET_OS_OSX + info.deviceDescription = [NSHost currentHost].localizedName; +#endif info.appBundleIdentifier = [[NSBundle mainBundle] bundleIdentifier]; if ([self isSimulator]) { info.deviceType = LookinAppInfoDeviceSimulator; } else if ([LKS_MultiplatformAdapter isiPad]) { info.deviceType = LookinAppInfoDeviceIPad; + } else if ([LKS_MultiplatformAdapter isMac]) { + info.deviceType = LookinAppInfoDeviceMac; } else { info.deviceType = LookinAppInfoDeviceOthers; } - info.osDescription = [UIDevice currentDevice].systemVersion; - +#if TARGET_OS_IPHONE + info.osDescription = [NSString stringWithFormat:@"iOS %@", [UIDevice currentDevice].systemVersion]; NSString *mainVersionStr = [[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."].firstObject; info.osMainVersion = [mainVersionStr integerValue]; +#elif TARGET_OS_OSX + NSOperatingSystemVersion operatingSystemVersion = [NSProcessInfo processInfo].operatingSystemVersion; + if (operatingSystemVersion.patchVersion) { + info.osDescription = [NSString stringWithFormat:@"macOS %ld.%ld.%ld", operatingSystemVersion.majorVersion, operatingSystemVersion.minorVersion, operatingSystemVersion.patchVersion]; + } else { + info.osDescription = [NSString stringWithFormat:@"macOS %ld.%ld", operatingSystemVersion.majorVersion, operatingSystemVersion.minorVersion]; + } + info.osMainVersion = operatingSystemVersion.majorVersion; +#endif + CGSize screenSize = [LKS_MultiplatformAdapter mainScreenBounds].size; info.screenWidth = screenSize.width; @@ -186,10 +203,10 @@ + (NSString *)appName { return displayName.length ? displayName : name; } -+ (UIImage *)appIcon { ++ (LookinImage *)appIcon { #if TARGET_OS_TV return nil; -#else +#elif TARGET_OS_IPHONE NSString *imageName; id CFBundleIcons = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIcons"]; if ([CFBundleIcons respondsToSelector:@selector(objectForKey:)]) { @@ -205,14 +222,17 @@ + (UIImage *)appIcon { return nil; } return [UIImage imageNamed:imageName]; +#elif TARGET_OS_OSX + return [[NSApplication sharedApplication] applicationIconImage]; #endif } -+ (UIImage *)screenshotImage { - UIWindow *window = [LKS_MultiplatformAdapter keyWindow]; ++ (LookinImage *)screenshotImage { + LookinWindow *window = [LKS_MultiplatformAdapter keyWindow]; if (!window) { return nil; } +#if TARGET_OS_IPHONE CGSize size = window.bounds.size; if (size.width <= 0 || size.height <= 0) { // *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UIGraphicsBeginImageContext() failed to allocate CGBitampContext: size={0, 0}, scale=3.000000, bitmapInfo=0x2002. Use UIGraphicsImageRenderer to avoid this assert.' @@ -224,6 +244,14 @@ + (UIImage *)screenshotImage { [window drawViewHierarchyInRect:window.bounds afterScreenUpdates:YES]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); +#elif TARGET_OS_OSX + if (!window) { + return nil; + } + CGImageRef cgImage = CGWindowListCreateImage(CGRectZero, kCGWindowListOptionIncludingWindow, (int)window.windowNumber, kCGWindowImageBoundsIgnoreFraming); + NSImage *image = [[NSImage alloc] initWithCGImage:cgImage size:window.frame.size]; + CGImageRelease(cgImage); +#endif return image; } @@ -235,7 +263,6 @@ + (BOOL)isSimulator { return NO; } -#endif + (NSInteger)getAppInfoIdentifier { static dispatch_once_t onceToken; diff --git a/Src/Main/Shared/LookinAttrIdentifiers.h b/Src/Main/Shared/LookinAttrIdentifiers.h index 577d532..53025eb 100644 --- a/Src/Main/Shared/LookinAttrIdentifiers.h +++ b/Src/Main/Shared/LookinAttrIdentifiers.h @@ -22,6 +22,7 @@ extern LookinAttrGroupIdentifier const LookinAttrGroup_Relation; extern LookinAttrGroupIdentifier const LookinAttrGroup_Layout; extern LookinAttrGroupIdentifier const LookinAttrGroup_AutoLayout; extern LookinAttrGroupIdentifier const LookinAttrGroup_ViewLayer; + extern LookinAttrGroupIdentifier const LookinAttrGroup_UIImageView; extern LookinAttrGroupIdentifier const LookinAttrGroup_UILabel; extern LookinAttrGroupIdentifier const LookinAttrGroup_UIControl; @@ -33,6 +34,16 @@ extern LookinAttrGroupIdentifier const LookinAttrGroup_UITextField; extern LookinAttrGroupIdentifier const LookinAttrGroup_UIVisualEffectView; extern LookinAttrGroupIdentifier const LookinAttrGroup_UIStackView; +extern LookinAttrGroupIdentifier const LookinAttrGroup_NSImageView; +extern LookinAttrGroupIdentifier const LookinAttrGroup_NSControl; +extern LookinAttrGroupIdentifier const LookinAttrGroup_NSButton; +extern LookinAttrGroupIdentifier const LookinAttrGroup_NSScrollView; +extern LookinAttrGroupIdentifier const LookinAttrGroup_NSTableView; +extern LookinAttrGroupIdentifier const LookinAttrGroup_NSTextView; +extern LookinAttrGroupIdentifier const LookinAttrGroup_NSTextField; +extern LookinAttrGroupIdentifier const LookinAttrGroup_NSVisualEffectView; +extern LookinAttrGroupIdentifier const LookinAttrGroup_NSStackView; + extern LookinAttrGroupIdentifier const LookinAttrGroup_UserCustom; #pragma mark - Section @@ -64,9 +75,10 @@ extern LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_Corner; extern LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_BgColor; extern LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_Border; extern LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_Shadow; +extern LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_Tag; + extern LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_ContentMode; extern LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_TintColor; -extern LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_Tag; extern LookinAttrSectionIdentifier const LookinAttrSec_UIImageView_Name; extern LookinAttrSectionIdentifier const LookinAttrSec_UIImageView_Open; @@ -132,6 +144,102 @@ extern LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Distribution; extern LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Alignment; extern LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Spacing; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSImageView_Name; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSImageView_Open; + +extern LookinAttrSectionIdentifier const LookinAttrSec_NSControl_State; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSControl_ControlSize; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSControl_Font; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSControl_Alignment; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSControl_Misc; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSControl_Value; + + +extern LookinAttrSectionIdentifier const LookinAttrSec_NSButton_ButtonType; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSButton_Title; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSButton_BezelStyle; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSButton_Bordered; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSButton_Transparent; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSButton_BezelColor; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSButton_ContentTintColor; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSButton_Misc; + +extern LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_ContentOffset; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_ContentSize; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_ContentInset; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_BorderType; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_Scroller; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_Ruler; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_LineScroll; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_PageScroll; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_ScrollElasiticity; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_Misc; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_Magnification; + +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_RowHeight; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_AutomaticRowHeights; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_IntercellSpacing; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_Style; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_ColumnAutoresizingStyle; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_GridStyleMask; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_SelectionHighlightStyle; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_GridColor; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_RowSizeStyle; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_NumberOfRows; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_NumberOfColumns; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_UseAlternatingRowBackgroundColors; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_AllowsColumnReordering; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_AllowsColumnResizing; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_AllowsMultipleSelection; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_AllowsEmptySelection; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_AllowsColumnSelection; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_AllowsTypeSelect; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_DraggingDestinationFeedbackStyle; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_Autosave; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_FloatsGroupRows; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_RowActionsVisible; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_UsesStaticContents; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_UserInterfaceLayoutDirection; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_VerticalMotionCanBeginDrag; + + +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_Font; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_Basic; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_String; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_TextColor; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_Alignment; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_ContainerInset; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_BaseWritingDirection; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_Size; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_Resizable; + +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Bordered; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Bezeled; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_BezelStyle; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Editable; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Selectable; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_DrawsBackground; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_PreferredMaxLayoutWidth; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_MaximumNumberOfLines; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_AllowsDefaultTighteningForTruncation; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_LineBreakStrategy; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Placeholder; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_TextColor; + +extern LookinAttrSectionIdentifier const LookinAttrSec_NSVisualEffectView_Material; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSVisualEffectView_InteriorBackgroundStyle; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSVisualEffectView_BlendingMode; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSVisualEffectView_State; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSVisualEffectView_Emphasized; + +extern LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Orientation; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_EdgeInsets; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_DetachesHiddenViews; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Distribution; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Alignment; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Spacing; + + #pragma mark - Attr typedef NSString * LookinAttrIdentifier; @@ -254,4 +362,130 @@ extern LookinAttrIdentifier const LookinAttr_UIStackView_Distribution_Distributi extern LookinAttrIdentifier const LookinAttr_UIStackView_Alignment_Alignment; extern LookinAttrIdentifier const LookinAttr_UIStackView_Spacing_Spacing; +extern LookinAttrIdentifier const LookinAttr_NSImageView_Name_Name; +extern LookinAttrIdentifier const LookinAttr_NSImageView_Open_Open; + + +extern LookinAttrIdentifier const LookinAttr_NSControl_State_Enabled; +extern LookinAttrIdentifier const LookinAttr_NSControl_State_Highlighted; +extern LookinAttrIdentifier const LookinAttr_NSControl_State_Continuous; +extern LookinAttrIdentifier const LookinAttr_NSControl_ControlSize_Size; +extern LookinAttrIdentifier const LookinAttr_NSControl_Font_Name; +extern LookinAttrIdentifier const LookinAttr_NSControl_Font_Size; +extern LookinAttrIdentifier const LookinAttr_NSControl_Alignment_Alignment; +extern LookinAttrIdentifier const LookinAttr_NSControl_Misc_WritingDirection; +extern LookinAttrIdentifier const LookinAttr_NSControl_Misc_IgnoresMultiClick; +extern LookinAttrIdentifier const LookinAttr_NSControl_Misc_UsesSingleLineMode; +extern LookinAttrIdentifier const LookinAttr_NSControl_Misc_AllowsExpansionToolTips; +extern LookinAttrIdentifier const LookinAttr_NSControl_Value_StringValue; +extern LookinAttrIdentifier const LookinAttr_NSControl_Value_IntValue; +extern LookinAttrIdentifier const LookinAttr_NSControl_Value_IntegerValue; +extern LookinAttrIdentifier const LookinAttr_NSControl_Value_FloatValue; +extern LookinAttrIdentifier const LookinAttr_NSControl_Value_DoubleValue; +extern LookinAttrIdentifier const LookinAttr_NSButton_ButtonType_ButtonType; +extern LookinAttrIdentifier const LookinAttr_NSButton_Title_Title; +extern LookinAttrIdentifier const LookinAttr_NSButton_Title_AlernateTitle; +extern LookinAttrIdentifier const LookinAttr_NSButton_BezelStyle_BezelStyle; +extern LookinAttrIdentifier const LookinAttr_NSButton_Bordered_Bordered; +extern LookinAttrIdentifier const LookinAttr_NSButton_Transparent_Transparent; +extern LookinAttrIdentifier const LookinAttr_NSButton_BezelColor_BezelColor; +extern LookinAttrIdentifier const LookinAttr_NSButton_ContentTintColor_ContentTintColor; +extern LookinAttrIdentifier const LookinAttr_NSButton_Misc_ShowsBorderOnlyWhileMouseInside; +extern LookinAttrIdentifier const LookinAttr_NSButton_Misc_MaxAcceleratorLevel; +extern LookinAttrIdentifier const LookinAttr_NSButton_Misc_SpringLoaded; +extern LookinAttrIdentifier const LookinAttr_NSButton_Misc_HasDestructiveAction; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_ContentOffset_Offset; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_ContentSize_Size; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_ContentInset_ContentInset; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_ContentInset_AutomaticallyAdjustsContentInsets; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_BorderType_BorderType; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_Scroller_Horizontal; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_Scroller_Vertical; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_Scroller_AutohidesScrollers; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_Scroller_ScrollerStyle; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_Scroller_ScrollerKnobStyle; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_Scroller_ScrollerInsets; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_Ruler_Horizontal; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_Ruler_Vertical; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_Ruler_Visible; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_LineScroll_Horizontal; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_LineScroll_Vertical; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_LineScroll_LineScroll; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_PageScroll_Horizontal; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_PageScroll_Vertical; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_PageScroll_PageScroll; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_ScrollElasiticity_Horizontal; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_ScrollElasiticity_Vertical; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_Misc_ScrollsDynamically; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_Misc_UsesPredominantAxisScrolling; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_Magnification_AllowsMagnification; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_Magnification_Magnification; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_Magnification_Max; +extern LookinAttrIdentifier const LookinAttr_NSScrollView_Magnification_Min; +extern LookinAttrIdentifier const LookinAttr_NSTableView_AllowsColumnReordering_AllowsColumnReordering; +extern LookinAttrIdentifier const LookinAttr_NSTableView_AllowsColumnResizing_AllowsColumnResizing; +extern LookinAttrIdentifier const LookinAttr_NSTableView_ColumnAutoresizingStyle_ColumnAutoresizingStyle; +extern LookinAttrIdentifier const LookinAttr_NSTableView_GridStyleMask_GridStyleMask; +extern LookinAttrIdentifier const LookinAttr_NSTableView_IntercellSpacing_IntercellSpacing; +extern LookinAttrIdentifier const LookinAttr_NSTableView_UseAlternatingRowBackgroundColors_UseAlternatingRowBackgroundColors; +extern LookinAttrIdentifier const LookinAttr_NSTableView_GridColor_GridColor; +extern LookinAttrIdentifier const LookinAttr_NSTableView_RowSizeStyle_RowSizeStyle; +extern LookinAttrIdentifier const LookinAttr_NSTableView_RowHeight_RowHeight; +extern LookinAttrIdentifier const LookinAttr_NSTableView_NumberOfRows_NumberOfRows; +extern LookinAttrIdentifier const LookinAttr_NSTableView_NumberOfColumns_NumberOfColumns; +extern LookinAttrIdentifier const LookinAttr_NSTableView_VerticalMotionCanBeginDrag_VerticalMotionCanBeginDrag; +extern LookinAttrIdentifier const LookinAttr_NSTableView_AllowsMultipleSelection_AllowsMultipleSelection; +extern LookinAttrIdentifier const LookinAttr_NSTableView_AllowsEmptySelection_AllowsEmptySelection; +extern LookinAttrIdentifier const LookinAttr_NSTableView_AllowsColumnSelection_AllowsColumnSelection; +extern LookinAttrIdentifier const LookinAttr_NSTableView_AllowsTypeSelect_AllowsTypeSelect; +extern LookinAttrIdentifier const LookinAttr_NSTableView_SelectionHighlightStyle_SelectionHighlightStyle; +extern LookinAttrIdentifier const LookinAttr_NSTableView_DraggingDestinationFeedbackStyle_DraggingDestinationFeedbackStyle; +extern LookinAttrIdentifier const LookinAttr_NSTableView_AutomaticRowHeights_AutomaticRowHeights; +extern LookinAttrIdentifier const LookinAttr_NSTableView_AutosaveName_AutosaveName; +extern LookinAttrIdentifier const LookinAttr_NSTableView_AutosaveTableColumns_AutosaveTableColumns; +extern LookinAttrIdentifier const LookinAttr_NSTableView_FloatsGroupRows_FloatsGroupRows; +extern LookinAttrIdentifier const LookinAttr_NSTableView_RowActionsVisible_RowActionsVisible; +extern LookinAttrIdentifier const LookinAttr_NSTableView_UsesStaticContents_UsesStaticContents; +extern LookinAttrIdentifier const LookinAttr_NSTableView_UserInterfaceLayoutDirection_UserInterfaceLayoutDirection; +extern LookinAttrIdentifier const LookinAttr_NSTableView_Style_Style; +extern LookinAttrIdentifier const LookinAttr_NSTextView_Font_Name; +extern LookinAttrIdentifier const LookinAttr_NSTextView_Font_Size; +extern LookinAttrIdentifier const LookinAttr_NSTextView_Basic_Editable; +extern LookinAttrIdentifier const LookinAttr_NSTextView_Basic_Selectable; +extern LookinAttrIdentifier const LookinAttr_NSTextView_Basic_RichText; +extern LookinAttrIdentifier const LookinAttr_NSTextView_Basic_FieldEditor; +extern LookinAttrIdentifier const LookinAttr_NSTextView_Basic_ImportsGraphics; +extern LookinAttrIdentifier const LookinAttr_NSTextView_String_String; +extern LookinAttrIdentifier const LookinAttr_NSTextView_TextColor_Color; +extern LookinAttrIdentifier const LookinAttr_NSTextView_Alignment_Alignment; +extern LookinAttrIdentifier const LookinAttr_NSTextView_ContainerInset_Inset; +extern LookinAttrIdentifier const LookinAttr_NSTextView_BaseWritingDirection_BaseWritingDirection; +extern LookinAttrIdentifier const LookinAttr_NSTextView_MaxSize_MaxSize; +extern LookinAttrIdentifier const LookinAttr_NSTextView_MinSize_MinSize; +extern LookinAttrIdentifier const LookinAttr_NSTextView_Resizable_Horizontal; +extern LookinAttrIdentifier const LookinAttr_NSTextView_Resizable_Vertical; +extern LookinAttrIdentifier const LookinAttr_NSTextField_Bordered_Bordered; +extern LookinAttrIdentifier const LookinAttr_NSTextField_Bezeled_Bezeled; +extern LookinAttrIdentifier const LookinAttr_NSTextField_Editable_Editable; +extern LookinAttrIdentifier const LookinAttr_NSTextField_Selectable_Selectable; +extern LookinAttrIdentifier const LookinAttr_NSTextField_DrawsBackground_DrawsBackground; +extern LookinAttrIdentifier const LookinAttr_NSTextField_BezelStyle_BezelStyle; +extern LookinAttrIdentifier const LookinAttr_NSTextField_PreferredMaxLayoutWidth_PreferredMaxLayoutWidth; +extern LookinAttrIdentifier const LookinAttr_NSTextField_MaximumNumberOfLines_MaximumNumberOfLines; +extern LookinAttrIdentifier const LookinAttr_NSTextField_AllowsDefaultTighteningForTruncation_AllowsDefaultTighteningForTruncation; +extern LookinAttrIdentifier const LookinAttr_NSTextField_LineBreakStrategy_LineBreakStrategy; +extern LookinAttrIdentifier const LookinAttr_NSTextField_Placeholder_Placeholder; +extern LookinAttrIdentifier const LookinAttr_NSTextField_TextColor_Color; +extern LookinAttrIdentifier const LookinAttr_NSVisualEffectView_Material_Material; +extern LookinAttrIdentifier const LookinAttr_NSVisualEffectView_InteriorBackgroundStyle_InteriorBackgroundStyle; +extern LookinAttrIdentifier const LookinAttr_NSVisualEffectView_BlendingMode_BlendingMode; +extern LookinAttrIdentifier const LookinAttr_NSVisualEffectView_State_State; +extern LookinAttrIdentifier const LookinAttr_NSVisualEffectView_Emphasized_Emphasized; +extern LookinAttrIdentifier const LookinAttr_NSStackView_Orientation_Orientation; +extern LookinAttrIdentifier const LookinAttr_NSStackView_EdgeInsets_EdgeInsets; +extern LookinAttrIdentifier const LookinAttr_NSStackView_DetachesHiddenViews_DetachesHiddenViews; +extern LookinAttrIdentifier const LookinAttr_NSStackView_Distribution_Distribution; +extern LookinAttrIdentifier const LookinAttr_NSStackView_Alignment_Alignment; +extern LookinAttrIdentifier const LookinAttr_NSStackView_Spacing_Spacing; + #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Shared/LookinAttrIdentifiers.m b/Src/Main/Shared/LookinAttrIdentifiers.m index 29a1f98..2a13640 100644 --- a/Src/Main/Shared/LookinAttrIdentifiers.m +++ b/Src/Main/Shared/LookinAttrIdentifiers.m @@ -23,6 +23,7 @@ LookinAttrGroupIdentifier const LookinAttrGroup_Layout = @"l"; LookinAttrGroupIdentifier const LookinAttrGroup_AutoLayout = @"a"; LookinAttrGroupIdentifier const LookinAttrGroup_ViewLayer = @"vl"; + LookinAttrGroupIdentifier const LookinAttrGroup_UIImageView = @"i"; LookinAttrGroupIdentifier const LookinAttrGroup_UILabel = @"la"; LookinAttrGroupIdentifier const LookinAttrGroup_UIControl = @"co"; @@ -34,6 +35,19 @@ LookinAttrGroupIdentifier const LookinAttrGroup_UIVisualEffectView = @"ve"; LookinAttrGroupIdentifier const LookinAttrGroup_UIStackView = @"UIStackView"; + + +LookinAttrGroupIdentifier const LookinAttrGroup_NSImageView = @"NSImageView"; +LookinAttrGroupIdentifier const LookinAttrGroup_NSControl = @"NSControl"; +LookinAttrGroupIdentifier const LookinAttrGroup_NSButton = @"NSButton"; +LookinAttrGroupIdentifier const LookinAttrGroup_NSScrollView = @"NSScrollView"; +LookinAttrGroupIdentifier const LookinAttrGroup_NSTableView = @"NSTableView"; +LookinAttrGroupIdentifier const LookinAttrGroup_NSTextView = @"NSTextView"; +LookinAttrGroupIdentifier const LookinAttrGroup_NSTextField = @"NSTextField"; +LookinAttrGroupIdentifier const LookinAttrGroup_NSVisualEffectView = @"NSVisualEffectView"; +LookinAttrGroupIdentifier const LookinAttrGroup_NSStackView = @"NSStackView"; + + LookinAttrGroupIdentifier const LookinAttrGroup_UserCustom = @"guc"; // user custom #pragma mark - Section @@ -67,6 +81,8 @@ LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_TintColor = @"v_t"; LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_Tag = @"v_ta"; + + LookinAttrSectionIdentifier const LookinAttrSec_UIImageView_Name = @"i_n"; LookinAttrSectionIdentifier const LookinAttrSec_UIImageView_Open = @"i_o"; @@ -131,6 +147,91 @@ LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Alignment = @"usv_align"; LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Spacing = @"usv_spa"; +LookinAttrSectionIdentifier const LookinAttrSec_NSImageView_Name = @"NSImageView_Name"; +LookinAttrSectionIdentifier const LookinAttrSec_NSImageView_Open = @"NSImageView_Open"; +LookinAttrSectionIdentifier const LookinAttrSec_NSControl_State = @"NSControl_State"; +LookinAttrSectionIdentifier const LookinAttrSec_NSControl_ControlSize = @"NSControl_ControlSize"; +LookinAttrSectionIdentifier const LookinAttrSec_NSControl_Font = @"NSControl_Font"; +LookinAttrSectionIdentifier const LookinAttrSec_NSControl_Alignment = @"NSControl_Alignment"; +LookinAttrSectionIdentifier const LookinAttrSec_NSControl_Misc = @"NSControl_Misc"; +LookinAttrSectionIdentifier const LookinAttrSec_NSControl_Value = @"NSControl_Value"; +LookinAttrSectionIdentifier const LookinAttrSec_NSButton_ButtonType = @"NSButton_ButtonType"; +LookinAttrSectionIdentifier const LookinAttrSec_NSButton_Title = @"NSButton_Title"; +LookinAttrSectionIdentifier const LookinAttrSec_NSButton_BezelStyle = @"NSButton_BezelStyle"; +LookinAttrSectionIdentifier const LookinAttrSec_NSButton_Bordered = @"NSButton_Bordered"; +LookinAttrSectionIdentifier const LookinAttrSec_NSButton_Transparent = @"NSButton_Transparent"; +LookinAttrSectionIdentifier const LookinAttrSec_NSButton_BezelColor = @"NSButton_BezelColor"; +LookinAttrSectionIdentifier const LookinAttrSec_NSButton_ContentTintColor = @"NSButton_ContentTintColor"; +LookinAttrSectionIdentifier const LookinAttrSec_NSButton_Misc = @"NSButton_Misc"; +LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_ContentOffset = @"NSScrollView_ContentOffset"; +LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_ContentSize = @"NSScrollView_ContentSize"; +LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_ContentInset = @"NSScrollView_ContentInset"; +LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_BorderType = @"NSScrollView_BorderType"; +LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_Scroller = @"NSScrollView_Scroller"; +LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_Ruler = @"NSScrollView_Ruler"; +LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_LineScroll = @"NSScrollView_LineScroll"; +LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_PageScroll = @"NSScrollView_PageScroll"; +LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_ScrollElasiticity = @"NSScrollView_ScrollElasiticity"; +LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_Misc = @"NSScrollView_Misc"; +LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_Magnification = @"NSScrollView_Magnification"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_RowHeight = @"NSTableView_RowHeight"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_AutomaticRowHeights = @"NSTableView_AutomaticRowHeights"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_IntercellSpacing = @"NSTableView_IntercellSpacing"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_Style = @"NSTableView_Style"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_ColumnAutoresizingStyle = @"NSTableView_ColumnAutoresizingStyle"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_GridStyleMask = @"NSTableView_GridStyleMask"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_SelectionHighlightStyle = @"NSTableView_SelectionHighlightStyle"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_GridColor = @"NSTableView_GridColor"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_RowSizeStyle = @"NSTableView_RowSizeStyle"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_NumberOfRows = @"NSTableView_NumberOfRows"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_NumberOfColumns = @"NSTableView_NumberOfColumns"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_UseAlternatingRowBackgroundColors = @"NSTableView_UseAlternatingRowBackgroundColors"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_AllowsColumnReordering = @"NSTableView_AllowsColumnReordering"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_AllowsColumnResizing = @"NSTableView_AllowsColumnResizing"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_AllowsMultipleSelection = @"NSTableView_AllowsMultipleSelection"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_AllowsEmptySelection = @"NSTableView_AllowsEmptySelection"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_AllowsColumnSelection = @"NSTableView_AllowsColumnSelection"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_AllowsTypeSelect = @"NSTableView_AllowsTypeSelect"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_DraggingDestinationFeedbackStyle = @"NSTableView_DraggingDestinationFeedbackStyle"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_Autosave = @"NSTableView_Autosave"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_FloatsGroupRows = @"NSTableView_FloatsGroupRows"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_RowActionsVisible = @"NSTableView_RowActionsVisible"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_UsesStaticContents = @"NSTableView_UsesStaticContents"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_UserInterfaceLayoutDirection = @"NSTableView_UserInterfaceLayoutDirection"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_VerticalMotionCanBeginDrag = @"NSTableView_VerticalMotionCanBeginDrag"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_Font = @"NSTextView_Font"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_Basic = @"NSTextView_Basic"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_String = @"NSTextView_String"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_TextColor = @"NSTextView_TextColor"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_Alignment = @"NSTextView_Alignment"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_ContainerInset = @"NSTextView_ContainerInset"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_BaseWritingDirection = @"NSTextView_BaseWritingDirection"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_Size = @"NSTextView_Size"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_Resizable = @"NSTextView_Resizable"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Bordered = @"NSTextField_Bordered"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Bezeled = @"NSTextField_Bezeled"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_BezelStyle = @"NSTextField_BezelStyle"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Editable = @"NSTextField_Editable"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Selectable = @"NSTextField_Selectable"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_DrawsBackground = @"NSTextField_DrawsBackground"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_PreferredMaxLayoutWidth = @"NSTextField_PreferredMaxLayoutWidth"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_MaximumNumberOfLines = @"NSTextField_MaximumNumberOfLines"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_AllowsDefaultTighteningForTruncation = @"NSTextField_AllowsDefaultTighteningForTruncation"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_LineBreakStrategy = @"NSTextField_LineBreakStrategy"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Placeholder = @"NSTextField_Placeholder"; +LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_TextColor = @"NSTextField_TextColor"; +LookinAttrSectionIdentifier const LookinAttrSec_NSVisualEffectView_Material = @"NSVisualEffectView_Material"; +LookinAttrSectionIdentifier const LookinAttrSec_NSVisualEffectView_InteriorBackgroundStyle = @"NSVisualEffectView_InteriorBackgroundStyle"; +LookinAttrSectionIdentifier const LookinAttrSec_NSVisualEffectView_BlendingMode = @"NSVisualEffectView_BlendingMode"; +LookinAttrSectionIdentifier const LookinAttrSec_NSVisualEffectView_State = @"NSVisualEffectView_State"; +LookinAttrSectionIdentifier const LookinAttrSec_NSVisualEffectView_Emphasized = @"NSVisualEffectView_Emphasized"; +LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Orientation = @"NSStackView_Orientation"; +LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_EdgeInsets = @"NSStackView_EdgeInsets"; +LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_DetachesHiddenViews = @"NSStackView_DetachesHiddenViews"; +LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Distribution = @"NSStackView_Distribution"; +LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Alignment = @"NSStackView_Alignment"; +LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Spacing = @"NSStackView_Spacing"; + #pragma mark - Attr LookinAttrIdentifier const LookinAttr_None = @"n"; @@ -250,4 +351,129 @@ LookinAttrIdentifier const LookinAttr_UIStackView_Alignment_Alignment = @"usv_ali_ali"; LookinAttrIdentifier const LookinAttr_UIStackView_Spacing_Spacing = @"usv_spa_spa"; +LookinAttrIdentifier const LookinAttr_NSImageView_Name_Name = @"NSImageView_Name_Name"; +LookinAttrIdentifier const LookinAttr_NSImageView_Open_Open = @"NSImageView_Open_Open"; +LookinAttrIdentifier const LookinAttr_NSControl_State_Enabled = @"NSControl_State_Enabled"; +LookinAttrIdentifier const LookinAttr_NSControl_State_Highlighted = @"NSControl_State_Highlighted"; +LookinAttrIdentifier const LookinAttr_NSControl_State_Continuous = @"NSControl_State_Continuous"; +LookinAttrIdentifier const LookinAttr_NSControl_ControlSize_Size = @"NSControl_ControlSize_Size"; +LookinAttrIdentifier const LookinAttr_NSControl_Font_Name = @"NSControl_Font_Name"; +LookinAttrIdentifier const LookinAttr_NSControl_Font_Size = @"NSControl_Font_Size"; +LookinAttrIdentifier const LookinAttr_NSControl_Alignment_Alignment = @"NSControl_Alignment_Alignment"; +LookinAttrIdentifier const LookinAttr_NSControl_Misc_WritingDirection = @"NSControl_Misc_WritingDirection"; +LookinAttrIdentifier const LookinAttr_NSControl_Misc_IgnoresMultiClick = @"NSControl_Misc_IgnoresMultiClick"; +LookinAttrIdentifier const LookinAttr_NSControl_Misc_UsesSingleLineMode = @"NSControl_Misc_UsesSingleLineMode"; +LookinAttrIdentifier const LookinAttr_NSControl_Misc_AllowsExpansionToolTips = @"NSControl_Misc_AllowsExpansionToolTips"; +LookinAttrIdentifier const LookinAttr_NSControl_Value_StringValue = @"NSControl_Value_StringValue"; +LookinAttrIdentifier const LookinAttr_NSControl_Value_IntValue = @"NSControl_Value_IntValue"; +LookinAttrIdentifier const LookinAttr_NSControl_Value_IntegerValue = @"NSControl_Value_IntegerValue"; +LookinAttrIdentifier const LookinAttr_NSControl_Value_FloatValue = @"NSControl_Value_FloatValue"; +LookinAttrIdentifier const LookinAttr_NSControl_Value_DoubleValue = @"NSControl_Value_DoubleValue"; +LookinAttrIdentifier const LookinAttr_NSButton_ButtonType_ButtonType = @"NSButton_ButtonType_ButtonType"; +LookinAttrIdentifier const LookinAttr_NSButton_Title_Title = @"NSButton_Title_Title"; +LookinAttrIdentifier const LookinAttr_NSButton_Title_AlernateTitle = @"NSButton_Title_AlernateTitle"; +LookinAttrIdentifier const LookinAttr_NSButton_BezelStyle_BezelStyle = @"NSButton_BezelStyle_BezelStyle"; +LookinAttrIdentifier const LookinAttr_NSButton_Bordered_Bordered = @"NSButton_Bordered_Bordered"; +LookinAttrIdentifier const LookinAttr_NSButton_Transparent_Transparent = @"NSButton_Transparent_Transparent"; +LookinAttrIdentifier const LookinAttr_NSButton_BezelColor_BezelColor = @"NSButton_BezelColor_BezelColor"; +LookinAttrIdentifier const LookinAttr_NSButton_ContentTintColor_ContentTintColor = @"NSButton_ContentTintColor_ContentTintColor"; +LookinAttrIdentifier const LookinAttr_NSButton_Misc_ShowsBorderOnlyWhileMouseInside = @"NSButton_Misc_ShowsBorderOnlyWhileMouseInside"; +LookinAttrIdentifier const LookinAttr_NSButton_Misc_MaxAcceleratorLevel = @"NSButton_Misc_MaxAcceleratorLevel"; +LookinAttrIdentifier const LookinAttr_NSButton_Misc_SpringLoaded = @"NSButton_Misc_SpringLoaded"; +LookinAttrIdentifier const LookinAttr_NSButton_Misc_HasDestructiveAction = @"NSButton_Misc_HasDestructiveAction"; +LookinAttrIdentifier const LookinAttr_NSScrollView_ContentOffset_Offset = @"NSScrollView_ContentOffset_Offset"; +LookinAttrIdentifier const LookinAttr_NSScrollView_ContentSize_Size = @"NSScrollView_ContentSize_Size"; +LookinAttrIdentifier const LookinAttr_NSScrollView_ContentInset_ContentInset = @"NSScrollView_ContentInset_ContentInset"; +LookinAttrIdentifier const LookinAttr_NSScrollView_ContentInset_AutomaticallyAdjustsContentInsets = @"NSScrollView_ContentInset_AutomaticallyAdjustsContentInsets"; +LookinAttrIdentifier const LookinAttr_NSScrollView_BorderType_BorderType = @"NSScrollView_BorderType_BorderType"; +LookinAttrIdentifier const LookinAttr_NSScrollView_Scroller_Horizontal = @"NSScrollView_Scroller_Horizontal"; +LookinAttrIdentifier const LookinAttr_NSScrollView_Scroller_Vertical = @"NSScrollView_Scroller_Vertical"; +LookinAttrIdentifier const LookinAttr_NSScrollView_Scroller_AutohidesScrollers = @"NSScrollView_Scroller_AutohidesScrollers"; +LookinAttrIdentifier const LookinAttr_NSScrollView_Scroller_ScrollerStyle = @"NSScrollView_Scroller_ScrollerStyle"; +LookinAttrIdentifier const LookinAttr_NSScrollView_Scroller_ScrollerKnobStyle = @"NSScrollView_Scroller_ScrollerKnobStyle"; +LookinAttrIdentifier const LookinAttr_NSScrollView_Scroller_ScrollerInsets = @"NSScrollView_Scroller_ScrollerInsets"; +LookinAttrIdentifier const LookinAttr_NSScrollView_Ruler_Horizontal = @"NSScrollView_Ruler_Horizontal"; +LookinAttrIdentifier const LookinAttr_NSScrollView_Ruler_Vertical = @"NSScrollView_Ruler_Vertical"; +LookinAttrIdentifier const LookinAttr_NSScrollView_Ruler_Visible = @"NSScrollView_Ruler_Visible"; +LookinAttrIdentifier const LookinAttr_NSScrollView_LineScroll_Horizontal = @"NSScrollView_LineScroll_Horizontal"; +LookinAttrIdentifier const LookinAttr_NSScrollView_LineScroll_Vertical = @"NSScrollView_LineScroll_Vertical"; +LookinAttrIdentifier const LookinAttr_NSScrollView_LineScroll_LineScroll = @"NSScrollView_LineScroll_LineScroll"; +LookinAttrIdentifier const LookinAttr_NSScrollView_PageScroll_Horizontal = @"NSScrollView_PageScroll_Horizontal"; +LookinAttrIdentifier const LookinAttr_NSScrollView_PageScroll_Vertical = @"NSScrollView_PageScroll_Vertical"; +LookinAttrIdentifier const LookinAttr_NSScrollView_PageScroll_PageScroll = @"NSScrollView_PageScroll_PageScroll"; +LookinAttrIdentifier const LookinAttr_NSScrollView_ScrollElasiticity_Horizontal = @"NSScrollView_ScrollElasiticity_Horizontal"; +LookinAttrIdentifier const LookinAttr_NSScrollView_ScrollElasiticity_Vertical = @"NSScrollView_ScrollElasiticity_Vertical"; +LookinAttrIdentifier const LookinAttr_NSScrollView_Misc_ScrollsDynamically = @"NSScrollView_Misc_ScrollsDynamically"; +LookinAttrIdentifier const LookinAttr_NSScrollView_Misc_UsesPredominantAxisScrolling = @"NSScrollView_Misc_UsesPredominantAxisScrolling"; +LookinAttrIdentifier const LookinAttr_NSScrollView_Magnification_AllowsMagnification = @"NSScrollView_Magnification_AllowsMagnification"; +LookinAttrIdentifier const LookinAttr_NSScrollView_Magnification_Magnification = @"NSScrollView_Magnification_Magnification"; +LookinAttrIdentifier const LookinAttr_NSScrollView_Magnification_Max = @"NSScrollView_Magnification_Max"; +LookinAttrIdentifier const LookinAttr_NSScrollView_Magnification_Min = @"NSScrollView_Magnification_Min"; +LookinAttrIdentifier const LookinAttr_NSTableView_AllowsColumnReordering_AllowsColumnReordering = @"NSTableView_AllowsColumnReordering_AllowsColumnReordering"; +LookinAttrIdentifier const LookinAttr_NSTableView_AllowsColumnResizing_AllowsColumnResizing = @"NSTableView_AllowsColumnResizing_AllowsColumnResizing"; +LookinAttrIdentifier const LookinAttr_NSTableView_ColumnAutoresizingStyle_ColumnAutoresizingStyle = @"NSTableView_ColumnAutoresizingStyle_ColumnAutoresizingStyle"; +LookinAttrIdentifier const LookinAttr_NSTableView_GridStyleMask_GridStyleMask = @"NSTableView_GridStyleMask_GridStyleMask"; +LookinAttrIdentifier const LookinAttr_NSTableView_IntercellSpacing_IntercellSpacing = @"NSTableView_IntercellSpacing_IntercellSpacing"; +LookinAttrIdentifier const LookinAttr_NSTableView_UseAlternatingRowBackgroundColors_UseAlternatingRowBackgroundColors = @"NSTableView_UseAlternatingRowBackgroundColors_UseAlternatingRowBackgroundColors"; +LookinAttrIdentifier const LookinAttr_NSTableView_GridColor_GridColor = @"NSTableView_GridColor_GridColor"; +LookinAttrIdentifier const LookinAttr_NSTableView_RowSizeStyle_RowSizeStyle = @"NSTableView_RowSizeStyle_RowSizeStyle"; +LookinAttrIdentifier const LookinAttr_NSTableView_RowHeight_RowHeight = @"NSTableView_RowHeight_RowHeight"; +LookinAttrIdentifier const LookinAttr_NSTableView_NumberOfRows_NumberOfRows = @"NSTableView_NumberOfRows_NumberOfRows"; +LookinAttrIdentifier const LookinAttr_NSTableView_NumberOfColumns_NumberOfColumns = @"NSTableView_NumberOfColumns_NumberOfColumns"; +LookinAttrIdentifier const LookinAttr_NSTableView_VerticalMotionCanBeginDrag_VerticalMotionCanBeginDrag = @"NSTableView_VerticalMotionCanBeginDrag_VerticalMotionCanBeginDrag"; +LookinAttrIdentifier const LookinAttr_NSTableView_AllowsMultipleSelection_AllowsMultipleSelection = @"NSTableView_AllowsMultipleSelection_AllowsMultipleSelection"; +LookinAttrIdentifier const LookinAttr_NSTableView_AllowsEmptySelection_AllowsEmptySelection = @"NSTableView_AllowsEmptySelection_AllowsEmptySelection"; +LookinAttrIdentifier const LookinAttr_NSTableView_AllowsColumnSelection_AllowsColumnSelection = @"NSTableView_AllowsColumnSelection_AllowsColumnSelection"; +LookinAttrIdentifier const LookinAttr_NSTableView_AllowsTypeSelect_AllowsTypeSelect = @"NSTableView_AllowsTypeSelect_AllowsTypeSelect"; +LookinAttrIdentifier const LookinAttr_NSTableView_SelectionHighlightStyle_SelectionHighlightStyle = @"NSTableView_SelectionHighlightStyle_SelectionHighlightStyle"; +LookinAttrIdentifier const LookinAttr_NSTableView_DraggingDestinationFeedbackStyle_DraggingDestinationFeedbackStyle = @"NSTableView_DraggingDestinationFeedbackStyle_DraggingDestinationFeedbackStyle"; +LookinAttrIdentifier const LookinAttr_NSTableView_AutomaticRowHeights_AutomaticRowHeights = @"NSTableView_AutomaticRowHeights_AutomaticRowHeights"; +LookinAttrIdentifier const LookinAttr_NSTableView_AutosaveName_AutosaveName = @"NSTableView_AutosaveName_AutosaveName"; +LookinAttrIdentifier const LookinAttr_NSTableView_AutosaveTableColumns_AutosaveTableColumns = @"NSTableView_AutosaveTableColumns_AutosaveTableColumns"; +LookinAttrIdentifier const LookinAttr_NSTableView_FloatsGroupRows_FloatsGroupRows = @"NSTableView_FloatsGroupRows_FloatsGroupRows"; +LookinAttrIdentifier const LookinAttr_NSTableView_RowActionsVisible_RowActionsVisible = @"NSTableView_RowActionsVisible_RowActionsVisible"; +LookinAttrIdentifier const LookinAttr_NSTableView_UsesStaticContents_UsesStaticContents = @"NSTableView_UsesStaticContents_UsesStaticContents"; +LookinAttrIdentifier const LookinAttr_NSTableView_UserInterfaceLayoutDirection_UserInterfaceLayoutDirection = @"NSTableView_UserInterfaceLayoutDirection_UserInterfaceLayoutDirection"; +LookinAttrIdentifier const LookinAttr_NSTableView_Style_Style = @"NSTableView_Style_Style"; +LookinAttrIdentifier const LookinAttr_NSTextView_Font_Name = @"NSTextView_Font_Name"; +LookinAttrIdentifier const LookinAttr_NSTextView_Font_Size = @"NSTextView_Font_Size"; +LookinAttrIdentifier const LookinAttr_NSTextView_Basic_Editable = @"NSTextView_Basic_Editable"; +LookinAttrIdentifier const LookinAttr_NSTextView_Basic_Selectable = @"NSTextView_Basic_Selectable"; +LookinAttrIdentifier const LookinAttr_NSTextView_Basic_RichText = @"NSTextView_Basic_RichText"; +LookinAttrIdentifier const LookinAttr_NSTextView_Basic_FieldEditor = @"NSTextView_Basic_FieldEditor"; +LookinAttrIdentifier const LookinAttr_NSTextView_Basic_ImportsGraphics = @"NSTextView_Basic_ImportsGraphics"; +LookinAttrIdentifier const LookinAttr_NSTextView_String_String = @"NSTextView_String_String"; +LookinAttrIdentifier const LookinAttr_NSTextView_TextColor_Color = @"NSTextView_TextColor_Color"; +LookinAttrIdentifier const LookinAttr_NSTextView_Alignment_Alignment = @"NSTextView_Alignment_Alignment"; +LookinAttrIdentifier const LookinAttr_NSTextView_ContainerInset_Inset = @"NSTextView_ContainerInset_Inset"; +LookinAttrIdentifier const LookinAttr_NSTextView_BaseWritingDirection_BaseWritingDirection = @"NSTextView_BaseWritingDirection_BaseWritingDirection"; +LookinAttrIdentifier const LookinAttr_NSTextView_MaxSize_MaxSize = @"NSTextView_MaxSize_MaxSize"; +LookinAttrIdentifier const LookinAttr_NSTextView_MinSize_MinSize = @"NSTextView_MinSize_MinSize"; +LookinAttrIdentifier const LookinAttr_NSTextView_Resizable_Horizontal = @"NSTextView_Resizable_Horizontal"; +LookinAttrIdentifier const LookinAttr_NSTextView_Resizable_Vertical = @"NSTextView_Resizable_Vertical"; +LookinAttrIdentifier const LookinAttr_NSTextField_Bordered_Bordered = @"NSTextField_Bordered_Bordered"; +LookinAttrIdentifier const LookinAttr_NSTextField_Bezeled_Bezeled = @"NSTextField_Bezeled_Bezeled"; +LookinAttrIdentifier const LookinAttr_NSTextField_Editable_Editable = @"NSTextField_Editable_Editable"; +LookinAttrIdentifier const LookinAttr_NSTextField_Selectable_Selectable = @"NSTextField_Selectable_Selectable"; +LookinAttrIdentifier const LookinAttr_NSTextField_DrawsBackground_DrawsBackground = @"NSTextField_DrawsBackground_DrawsBackground"; +LookinAttrIdentifier const LookinAttr_NSTextField_BezelStyle_BezelStyle = @"NSTextField_BezelStyle_BezelStyle"; +LookinAttrIdentifier const LookinAttr_NSTextField_PreferredMaxLayoutWidth_PreferredMaxLayoutWidth = @"NSTextField_PreferredMaxLayoutWidth_PreferredMaxLayoutWidth"; +LookinAttrIdentifier const LookinAttr_NSTextField_MaximumNumberOfLines_MaximumNumberOfLines = @"NSTextField_MaximumNumberOfLines_MaximumNumberOfLines"; +LookinAttrIdentifier const LookinAttr_NSTextField_AllowsDefaultTighteningForTruncation_AllowsDefaultTighteningForTruncation = @"NSTextField_AllowsDefaultTighteningForTruncation_AllowsDefaultTighteningForTruncation"; +LookinAttrIdentifier const LookinAttr_NSTextField_LineBreakStrategy_LineBreakStrategy = @"NSTextField_LineBreakStrategy_LineBreakStrategy"; +LookinAttrIdentifier const LookinAttr_NSTextField_Placeholder_Placeholder = @"NSTextField_Placeholder_Placeholder"; +LookinAttrIdentifier const LookinAttr_NSTextField_TextColor_Color = @"NSTextField_TextColor_Color"; +LookinAttrIdentifier const LookinAttr_NSVisualEffectView_Material_Material = @"NSVisualEffectView_Material_Material"; +LookinAttrIdentifier const LookinAttr_NSVisualEffectView_InteriorBackgroundStyle_InteriorBackgroundStyle = @"NSVisualEffectView_InteriorBackgroundStyle_InteriorBackgroundStyle"; +LookinAttrIdentifier const LookinAttr_NSVisualEffectView_BlendingMode_BlendingMode = @"NSVisualEffectView_BlendingMode_BlendingMode"; +LookinAttrIdentifier const LookinAttr_NSVisualEffectView_State_State = @"NSVisualEffectView_State_State"; +LookinAttrIdentifier const LookinAttr_NSVisualEffectView_Emphasized_Emphasized = @"NSVisualEffectView_Emphasized_Emphasized"; +LookinAttrIdentifier const LookinAttr_NSStackView_Orientation_Orientation = @"NSStackView_Orientation_Orientation"; +LookinAttrIdentifier const LookinAttr_NSStackView_EdgeInsets_EdgeInsets = @"NSStackView_EdgeInsets_EdgeInsets"; +LookinAttrIdentifier const LookinAttr_NSStackView_DetachesHiddenViews_DetachesHiddenViews = @"NSStackView_DetachesHiddenViews_DetachesHiddenViews"; +LookinAttrIdentifier const LookinAttr_NSStackView_Distribution_Distribution = @"NSStackView_Distribution_Distribution"; +LookinAttrIdentifier const LookinAttr_NSStackView_Alignment_Alignment = @"NSStackView_Alignment_Alignment"; +LookinAttrIdentifier const LookinAttr_NSStackView_Spacing_Spacing = @"NSStackView_Spacing_Spacing"; + + #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Shared/LookinAutoLayoutConstraint.h b/Src/Main/Shared/LookinAutoLayoutConstraint.h index 3edf865..4ba4bfa 100644 --- a/Src/Main/Shared/LookinAutoLayoutConstraint.h +++ b/Src/Main/Shared/LookinAutoLayoutConstraint.h @@ -25,9 +25,6 @@ typedef NS_ENUM(NSInteger, LookinConstraintItemType) { @interface LookinAutoLayoutConstraint : NSObject -#if TARGET_OS_IPHONE -+ (instancetype)instanceFromNSConstraint:(NSLayoutConstraint *)constraint isEffective:(BOOL)isEffective firstItemType:(LookinConstraintItemType)firstItemType secondItemType:(LookinConstraintItemType)secondItemType; -#endif @property(nonatomic, assign) BOOL effective; @property(nonatomic, assign) BOOL active; diff --git a/Src/Main/Shared/LookinAutoLayoutConstraint.m b/Src/Main/Shared/LookinAutoLayoutConstraint.m index a8e4520..307ca2b 100644 --- a/Src/Main/Shared/LookinAutoLayoutConstraint.m +++ b/Src/Main/Shared/LookinAutoLayoutConstraint.m @@ -15,27 +15,7 @@ @implementation LookinAutoLayoutConstraint -#if TARGET_OS_IPHONE - -+ (instancetype)instanceFromNSConstraint:(NSLayoutConstraint *)constraint isEffective:(BOOL)isEffective firstItemType:(LookinConstraintItemType)firstItemType secondItemType:(LookinConstraintItemType)secondItemType { - LookinAutoLayoutConstraint *instance = [LookinAutoLayoutConstraint new]; - instance.effective = isEffective; - instance.active = constraint.active; - instance.shouldBeArchived = constraint.shouldBeArchived; - instance.firstItem = [LookinObject instanceWithObject:constraint.firstItem]; - instance.firstItemType = firstItemType; - instance.firstAttribute = constraint.firstAttribute; - instance.relation = constraint.relation; - instance.secondItem = [LookinObject instanceWithObject:constraint.secondItem]; - instance.secondItemType = secondItemType; - instance.secondAttribute = constraint.secondAttribute; - instance.multiplier = constraint.multiplier; - instance.constant = constraint.constant; - instance.priority = constraint.priority; - instance.identifier = constraint.identifier; - - return instance; -} + - (void)setFirstAttribute:(NSInteger)firstAttribute { _firstAttribute = firstAttribute; @@ -57,8 +37,6 @@ - (void)_assertUnknownAttribute:(NSInteger)attribute { } } -#endif - #pragma mark - + (BOOL)supportsSecureCoding { diff --git a/Src/Main/Shared/LookinCustomDisplayItemInfo.m b/Src/Main/Shared/LookinCustomDisplayItemInfo.m index a59778a..26adc5e 100644 --- a/Src/Main/Shared/LookinCustomDisplayItemInfo.m +++ b/Src/Main/Shared/LookinCustomDisplayItemInfo.m @@ -21,7 +21,7 @@ - (id)copyWithZone:(NSZone *)zone { #if TARGET_OS_IPHONE CGRect rect = [self.frameInWindow CGRectValue]; newInstance.frameInWindow = [NSValue valueWithCGRect:rect]; -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX CGRect rect = [self.frameInWindow rectValue]; newInstance.frameInWindow = [NSValue valueWithRect:rect]; #endif diff --git a/Src/Main/Shared/LookinDashboardBlueprint.h b/Src/Main/Shared/LookinDashboardBlueprint.h index 361789a..b4b9cac 100644 --- a/Src/Main/Shared/LookinDashboardBlueprint.h +++ b/Src/Main/Shared/LookinDashboardBlueprint.h @@ -44,6 +44,8 @@ /// 返回某个 LookinAttribute 代表的属性是哪一个类拥有的,比如 LookinAttrSec_UILabel_TextColor 是 UILabel 才有的 + (NSString *)classNameWithAttrID:(LookinAttrIdentifier)attrID; ++ (BOOL)isWindowPropertyWithAttrID:(LookinAttrIdentifier)attrID; + /// 一个 attr 要么属于 UIView 要么属于 CALayer,如果它属于 UIView 那么该方法返回 YES + (BOOL)isUIViewPropertyWithAttrID:(LookinAttrIdentifier)attrID; diff --git a/Src/Main/Shared/LookinDashboardBlueprint.m b/Src/Main/Shared/LookinDashboardBlueprint.m index 3daf035..012fabb 100644 --- a/Src/Main/Shared/LookinDashboardBlueprint.m +++ b/Src/Main/Shared/LookinDashboardBlueprint.m @@ -24,6 +24,7 @@ @implementation LookinDashboardBlueprint LookinAttrGroup_Layout, LookinAttrGroup_AutoLayout, LookinAttrGroup_ViewLayer, +#if TARGET_OS_IPHONE LookinAttrGroup_UIStackView, LookinAttrGroup_UIVisualEffectView, LookinAttrGroup_UIImageView, @@ -34,6 +35,18 @@ @implementation LookinDashboardBlueprint LookinAttrGroup_UITableView, LookinAttrGroup_UITextView, LookinAttrGroup_UITextField +#endif +#if TARGET_OS_OSX + LookinAttrGroup_NSImageView, + LookinAttrGroup_NSControl, + LookinAttrGroup_NSButton, + LookinAttrGroup_NSScrollView, + LookinAttrGroup_NSTableView, + LookinAttrGroup_NSTextView, + LookinAttrGroup_NSTextField, + LookinAttrGroup_NSVisualEffectView, + LookinAttrGroup_NSStackView, +#endif ]; }); return array; @@ -66,11 +79,14 @@ @implementation LookinDashboardBlueprint LookinAttrSec_ViewLayer_Border, LookinAttrSec_ViewLayer_Corner, LookinAttrSec_ViewLayer_Shadow, + LookinAttrSec_ViewLayer_Tag, +#if TARGET_OS_IPHONE LookinAttrSec_ViewLayer_ContentMode, LookinAttrSec_ViewLayer_TintColor, - LookinAttrSec_ViewLayer_Tag +#endif ], +#if TARGET_OS_IPHONE LookinAttrGroup_UIStackView: @[ LookinAttrSec_UIStackView_Axis, LookinAttrSec_UIStackView_Distribution, @@ -139,6 +155,120 @@ @implementation LookinDashboardBlueprint LookinAttrSec_UITextField_Clears, LookinAttrSec_UITextField_CanAdjustFont, LookinAttrSec_UITextField_ClearButtonMode], +#endif +#if TARGET_OS_OSX + LookinAttrGroup_NSImageView: @[ + LookinAttrSec_NSImageView_Name, + LookinAttrSec_NSImageView_Open + ], + + LookinAttrGroup_NSControl: @[ + LookinAttrSec_NSControl_State, + LookinAttrSec_NSControl_ControlSize, + LookinAttrSec_NSControl_Font, + LookinAttrSec_NSControl_Alignment, + LookinAttrSec_NSControl_Misc, + LookinAttrSec_NSControl_Value, + ], + + LookinAttrGroup_NSButton: @[ + LookinAttrSec_NSButton_ButtonType, + LookinAttrSec_NSButton_Title, + LookinAttrSec_NSButton_BezelStyle, + LookinAttrSec_NSButton_Bordered, + LookinAttrSec_NSButton_Transparent, + LookinAttrSec_NSButton_BezelColor, + LookinAttrSec_NSButton_ContentTintColor, + LookinAttrSec_NSButton_Misc, + ], + + LookinAttrGroup_NSScrollView: @[ + LookinAttrSec_NSScrollView_ContentOffset, + LookinAttrSec_NSScrollView_ContentSize, + LookinAttrSec_NSScrollView_ContentInset, + LookinAttrSec_NSScrollView_BorderType, + LookinAttrSec_NSScrollView_Scroller, + LookinAttrSec_NSScrollView_Ruler, + LookinAttrSec_NSScrollView_LineScroll, + LookinAttrSec_NSScrollView_PageScroll, + LookinAttrSec_NSScrollView_ScrollElasiticity, + LookinAttrSec_NSScrollView_Misc, + LookinAttrSec_NSScrollView_Magnification, + ], + + LookinAttrGroup_NSTableView: @[ + LookinAttrSec_NSTableView_RowHeight, + LookinAttrSec_NSTableView_AutomaticRowHeights, + LookinAttrSec_NSTableView_IntercellSpacing, + LookinAttrSec_NSTableView_Style, + LookinAttrSec_NSTableView_ColumnAutoresizingStyle, + LookinAttrSec_NSTableView_GridStyleMask, + LookinAttrSec_NSTableView_SelectionHighlightStyle, + LookinAttrSec_NSTableView_GridColor, + LookinAttrSec_NSTableView_RowSizeStyle, + LookinAttrSec_NSTableView_NumberOfRows, + LookinAttrSec_NSTableView_NumberOfColumns, + LookinAttrSec_NSTableView_UseAlternatingRowBackgroundColors, + LookinAttrSec_NSTableView_AllowsColumnReordering, + LookinAttrSec_NSTableView_AllowsColumnResizing, + LookinAttrSec_NSTableView_AllowsMultipleSelection, + LookinAttrSec_NSTableView_AllowsEmptySelection, + LookinAttrSec_NSTableView_AllowsColumnSelection, + LookinAttrSec_NSTableView_AllowsTypeSelect, + LookinAttrSec_NSTableView_DraggingDestinationFeedbackStyle, + LookinAttrSec_NSTableView_Autosave, + LookinAttrSec_NSTableView_FloatsGroupRows, + LookinAttrSec_NSTableView_RowActionsVisible, + LookinAttrSec_NSTableView_UsesStaticContents, + LookinAttrSec_NSTableView_UserInterfaceLayoutDirection, + LookinAttrSec_NSTableView_VerticalMotionCanBeginDrag, + ], + + LookinAttrGroup_NSTextView: @[ + LookinAttrSec_NSTextView_Font, + LookinAttrSec_NSTextView_Basic, + LookinAttrSec_NSTextView_String, + LookinAttrSec_NSTextView_TextColor, + LookinAttrSec_NSTextView_Alignment, + LookinAttrSec_NSTextView_ContainerInset, + LookinAttrSec_NSTextView_BaseWritingDirection, + LookinAttrSec_NSTextView_Size, + LookinAttrSec_NSTextView_Resizable, + ], + + LookinAttrGroup_NSTextField: @[ + LookinAttrSec_NSTextField_Bordered, + LookinAttrSec_NSTextField_Bezeled, + LookinAttrSec_NSTextField_BezelStyle, + LookinAttrSec_NSTextField_Editable, + LookinAttrSec_NSTextField_Selectable, + LookinAttrSec_NSTextField_DrawsBackground, + LookinAttrSec_NSTextField_PreferredMaxLayoutWidth, + LookinAttrSec_NSTextField_MaximumNumberOfLines, + LookinAttrSec_NSTextField_AllowsDefaultTighteningForTruncation, + LookinAttrSec_NSTextField_LineBreakStrategy, + LookinAttrSec_NSTextField_Placeholder, + LookinAttrSec_NSTextField_TextColor, + ], + + + LookinAttrGroup_NSVisualEffectView: @[ + LookinAttrSec_NSVisualEffectView_Material, + LookinAttrSec_NSVisualEffectView_InteriorBackgroundStyle, + LookinAttrSec_NSVisualEffectView_BlendingMode, + LookinAttrSec_NSVisualEffectView_State, + LookinAttrSec_NSVisualEffectView_Emphasized, + ], + + LookinAttrGroup_NSStackView: @[ + LookinAttrSec_NSStackView_Orientation, + LookinAttrSec_NSStackView_EdgeInsets, + LookinAttrSec_NSStackView_DetachesHiddenViews, + LookinAttrSec_NSStackView_Distribution, + LookinAttrSec_NSStackView_Alignment, + LookinAttrSec_NSStackView_Spacing, + ], +#endif }; }); @@ -170,7 +300,10 @@ @implementation LookinDashboardBlueprint LookinAttrSec_ViewLayer_Visibility: @[LookinAttr_ViewLayer_Visibility_Hidden, LookinAttr_ViewLayer_Visibility_Opacity], - LookinAttrSec_ViewLayer_InterationAndMasks: @[LookinAttr_ViewLayer_InterationAndMasks_Interaction, + LookinAttrSec_ViewLayer_InterationAndMasks:@[ +#if TARGET_OS_IPHONE + LookinAttr_ViewLayer_InterationAndMasks_Interaction, +#endif LookinAttr_ViewLayer_InterationAndMasks_MasksToBounds], LookinAttrSec_ViewLayer_Corner: @[LookinAttr_ViewLayer_Corner_Radius], @@ -185,13 +318,16 @@ @implementation LookinDashboardBlueprint LookinAttr_ViewLayer_Shadow_Radius, LookinAttr_ViewLayer_Shadow_OffsetW, LookinAttr_ViewLayer_Shadow_OffsetH], +#if TARGET_OS_IPHONE LookinAttrSec_ViewLayer_ContentMode: @[LookinAttr_ViewLayer_ContentMode_Mode], LookinAttrSec_ViewLayer_TintColor: @[LookinAttr_ViewLayer_TintColor_Color, LookinAttr_ViewLayer_TintColor_Mode], +#endif LookinAttrSec_ViewLayer_Tag: @[LookinAttr_ViewLayer_Tag_Tag], +#if TARGET_OS_IPHONE LookinAttrSec_UIStackView_Axis: @[LookinAttr_UIStackView_Axis_Axis], @@ -314,6 +450,307 @@ @implementation LookinDashboardBlueprint LookinAttr_UITextField_CanAdjustFont_MinSize], LookinAttrSec_UITextField_ClearButtonMode: @[LookinAttr_UITextField_ClearButtonMode_Mode] +#endif +#if TARGET_OS_OSX + LookinAttrSec_NSImageView_Name:@[ + LookinAttr_NSImageView_Name_Name + ], + LookinAttrSec_NSImageView_Open:@[ + LookinAttr_NSImageView_Open_Open + ], + LookinAttrSec_NSControl_State: @[ + LookinAttr_NSControl_State_Enabled, + LookinAttr_NSControl_State_Highlighted, + LookinAttr_NSControl_State_Continuous, + ], + LookinAttrSec_NSControl_ControlSize: @[ + LookinAttr_NSControl_ControlSize_Size + ], + LookinAttrSec_NSControl_Font: @[ + LookinAttr_NSControl_Font_Name, + LookinAttr_NSControl_Font_Size + ], + LookinAttrSec_NSControl_Alignment: @[ + LookinAttr_NSControl_Alignment_Alignment + ], + LookinAttrSec_NSControl_Misc: @[ + LookinAttr_NSControl_Misc_WritingDirection, + LookinAttr_NSControl_Misc_IgnoresMultiClick, + LookinAttr_NSControl_Misc_UsesSingleLineMode, + LookinAttr_NSControl_Misc_AllowsExpansionToolTips, + ], + LookinAttrSec_NSControl_Value: @[ + LookinAttr_NSControl_Value_StringValue, + LookinAttr_NSControl_Value_IntValue, + LookinAttr_NSControl_Value_IntegerValue, + LookinAttr_NSControl_Value_FloatValue, + LookinAttr_NSControl_Value_DoubleValue, + ], + + LookinAttrSec_NSButton_ButtonType: @[ + LookinAttr_NSButton_ButtonType_ButtonType + ], + LookinAttrSec_NSButton_Title: @[ + LookinAttr_NSButton_Title_Title, + LookinAttr_NSButton_Title_AlernateTitle, + ], + LookinAttrSec_NSButton_BezelStyle: @[LookinAttr_NSButton_BezelStyle_BezelStyle], + LookinAttrSec_NSButton_Bordered: @[LookinAttr_NSButton_Bordered_Bordered], + LookinAttrSec_NSButton_Transparent: @[LookinAttr_NSButton_Transparent_Transparent], + LookinAttrSec_NSButton_BezelColor: @[LookinAttr_NSButton_BezelColor_BezelColor], + LookinAttrSec_NSButton_ContentTintColor: @[LookinAttr_NSButton_ContentTintColor_ContentTintColor], + LookinAttrSec_NSButton_Misc: @[ + LookinAttr_NSButton_Misc_ShowsBorderOnlyWhileMouseInside, + LookinAttr_NSButton_Misc_MaxAcceleratorLevel, + LookinAttr_NSButton_Misc_SpringLoaded, + LookinAttr_NSButton_Misc_HasDestructiveAction, + ], + + + + LookinAttrSec_NSScrollView_ContentOffset: @[ + LookinAttr_NSScrollView_ContentOffset_Offset + ], + LookinAttrSec_NSScrollView_ContentSize: @[ + LookinAttr_NSScrollView_ContentSize_Size + ], + LookinAttrSec_NSScrollView_ContentInset: @[ + LookinAttr_NSScrollView_ContentInset_ContentInset, + LookinAttr_NSScrollView_ContentInset_AutomaticallyAdjustsContentInsets + ], + LookinAttrSec_NSScrollView_BorderType: @[ + LookinAttr_NSScrollView_BorderType_BorderType + ], + LookinAttrSec_NSScrollView_Scroller: @[ + LookinAttr_NSScrollView_Scroller_Horizontal, + LookinAttr_NSScrollView_Scroller_Vertical, + LookinAttr_NSScrollView_Scroller_AutohidesScrollers, + LookinAttr_NSScrollView_Scroller_ScrollerStyle, + LookinAttr_NSScrollView_Scroller_ScrollerKnobStyle, + LookinAttr_NSScrollView_Scroller_ScrollerInsets, + ], + LookinAttrSec_NSScrollView_Ruler: @[ + LookinAttr_NSScrollView_Ruler_Horizontal, + LookinAttr_NSScrollView_Ruler_Vertical, + LookinAttr_NSScrollView_Ruler_Visible, + ], + LookinAttrSec_NSScrollView_LineScroll: @[ + LookinAttr_NSScrollView_LineScroll_Horizontal, + LookinAttr_NSScrollView_LineScroll_Vertical, + LookinAttr_NSScrollView_LineScroll_LineScroll, + ], + LookinAttrSec_NSScrollView_PageScroll: @[ + LookinAttr_NSScrollView_PageScroll_Horizontal, + LookinAttr_NSScrollView_PageScroll_Vertical, + LookinAttr_NSScrollView_PageScroll_PageScroll, + ], + LookinAttrSec_NSScrollView_ScrollElasiticity: @[ + LookinAttr_NSScrollView_ScrollElasiticity_Horizontal, + LookinAttr_NSScrollView_ScrollElasiticity_Vertical, + ], + LookinAttrSec_NSScrollView_Misc: @[ + LookinAttr_NSScrollView_Misc_ScrollsDynamically, + LookinAttr_NSScrollView_Misc_UsesPredominantAxisScrolling, + ], + LookinAttrSec_NSScrollView_Magnification: @[ + LookinAttr_NSScrollView_Magnification_AllowsMagnification, + LookinAttr_NSScrollView_Magnification_Magnification, + LookinAttr_NSScrollView_Magnification_Max, + LookinAttr_NSScrollView_Magnification_Min, + ], + + LookinAttrSec_NSTableView_RowHeight: @[ + LookinAttr_NSTableView_RowHeight_RowHeight, + ], + LookinAttrSec_NSTableView_AutomaticRowHeights: @[ + LookinAttr_NSTableView_AutomaticRowHeights_AutomaticRowHeights, + ], + LookinAttrSec_NSTableView_IntercellSpacing: @[ + LookinAttr_NSTableView_IntercellSpacing_IntercellSpacing + ], + LookinAttrSec_NSTableView_Style: @[ + LookinAttr_NSTableView_Style_Style + ], + LookinAttrSec_NSTableView_ColumnAutoresizingStyle: @[ + LookinAttr_NSTableView_ColumnAutoresizingStyle_ColumnAutoresizingStyle + ], + LookinAttrSec_NSTableView_GridStyleMask: @[ + LookinAttr_NSTableView_GridStyleMask_GridStyleMask + ], + LookinAttrSec_NSTableView_SelectionHighlightStyle: @[ + LookinAttr_NSTableView_SelectionHighlightStyle_SelectionHighlightStyle + ], + LookinAttrSec_NSTableView_GridColor: @[ + LookinAttr_NSTableView_GridColor_GridColor + ], + LookinAttrSec_NSTableView_RowSizeStyle: @[ + LookinAttr_NSTableView_RowSizeStyle_RowSizeStyle + ], + LookinAttrSec_NSTableView_NumberOfRows: @[ + LookinAttr_NSTableView_NumberOfRows_NumberOfRows + ], + LookinAttrSec_NSTableView_NumberOfColumns: @[ + LookinAttr_NSTableView_NumberOfColumns_NumberOfColumns + ], + LookinAttrSec_NSTableView_UseAlternatingRowBackgroundColors: @[ + LookinAttr_NSTableView_UseAlternatingRowBackgroundColors_UseAlternatingRowBackgroundColors + ], + LookinAttrSec_NSTableView_AllowsColumnReordering: @[ + LookinAttr_NSTableView_AllowsColumnReordering_AllowsColumnReordering + ], + LookinAttrSec_NSTableView_AllowsColumnResizing: @[ + LookinAttr_NSTableView_AllowsColumnResizing_AllowsColumnResizing + ], + LookinAttrSec_NSTableView_AllowsMultipleSelection: @[ + LookinAttr_NSTableView_AllowsMultipleSelection_AllowsMultipleSelection + ], + LookinAttrSec_NSTableView_AllowsEmptySelection: @[ + LookinAttr_NSTableView_AllowsEmptySelection_AllowsEmptySelection + ], + LookinAttrSec_NSTableView_AllowsColumnSelection: @[ + LookinAttr_NSTableView_AllowsColumnSelection_AllowsColumnSelection + ], + LookinAttrSec_NSTableView_AllowsTypeSelect: @[ + LookinAttr_NSTableView_AllowsTypeSelect_AllowsTypeSelect + ], + LookinAttrSec_NSTableView_DraggingDestinationFeedbackStyle: @[ + LookinAttr_NSTableView_DraggingDestinationFeedbackStyle_DraggingDestinationFeedbackStyle + ], + LookinAttrSec_NSTableView_Autosave: @[ + LookinAttr_NSTableView_AutosaveName_AutosaveName, + LookinAttr_NSTableView_AutosaveTableColumns_AutosaveTableColumns + ], + LookinAttrSec_NSTableView_FloatsGroupRows: @[ + LookinAttr_NSTableView_FloatsGroupRows_FloatsGroupRows + ], + LookinAttrSec_NSTableView_RowActionsVisible: @[ + LookinAttr_NSTableView_RowActionsVisible_RowActionsVisible + ], + LookinAttrSec_NSTableView_UsesStaticContents: @[ + LookinAttr_NSTableView_UsesStaticContents_UsesStaticContents + ], + LookinAttrSec_NSTableView_UserInterfaceLayoutDirection: @[ + LookinAttr_NSTableView_UserInterfaceLayoutDirection_UserInterfaceLayoutDirection + ], + LookinAttrSec_NSTableView_VerticalMotionCanBeginDrag: @[ + LookinAttr_NSTableView_VerticalMotionCanBeginDrag_VerticalMotionCanBeginDrag + ], + + + + LookinAttrSec_NSTextView_Font: @[ + LookinAttr_NSTextView_Font_Name, + LookinAttr_NSTextView_Font_Size + ], + LookinAttrSec_NSTextView_Basic: @[ + LookinAttr_NSTextView_Basic_Editable, + LookinAttr_NSTextView_Basic_Selectable, + LookinAttr_NSTextView_Basic_RichText, + LookinAttr_NSTextView_Basic_FieldEditor, + LookinAttr_NSTextView_Basic_ImportsGraphics, + ], + LookinAttrSec_NSTextView_String: @[ + LookinAttr_NSTextView_String_String + ], + LookinAttrSec_NSTextView_TextColor: @[ + LookinAttr_NSTextView_TextColor_Color + ], + LookinAttrSec_NSTextView_Alignment: @[ + LookinAttr_NSTextView_Alignment_Alignment + ], + LookinAttrSec_NSTextView_ContainerInset: @[ + LookinAttr_NSTextView_ContainerInset_Inset + ], + LookinAttrSec_NSTextView_BaseWritingDirection: @[ + LookinAttr_NSTextView_BaseWritingDirection_BaseWritingDirection + ], + LookinAttrSec_NSTextView_Size: @[ + LookinAttr_NSTextView_MaxSize_MaxSize, + LookinAttr_NSTextView_MinSize_MinSize, + ], + LookinAttrSec_NSTextView_Resizable: @[ + LookinAttr_NSTextView_Resizable_Horizontal, + LookinAttr_NSTextView_Resizable_Vertical, + ], + + LookinAttrSec_NSTextField_Bordered: @[ + LookinAttr_NSTextField_Bordered_Bordered + ], + LookinAttrSec_NSTextField_Bezeled: @[ + LookinAttr_NSTextField_Bezeled_Bezeled + ], + LookinAttrSec_NSTextField_BezelStyle: @[ + LookinAttr_NSTextField_BezelStyle_BezelStyle + ], + LookinAttrSec_NSTextField_Editable: @[ + LookinAttr_NSTextField_Editable_Editable + ], + LookinAttrSec_NSTextField_Selectable: @[ + LookinAttr_NSTextField_Selectable_Selectable + ], + LookinAttrSec_NSTextField_DrawsBackground: @[ + LookinAttr_NSTextField_DrawsBackground_DrawsBackground + ], + LookinAttrSec_NSTextField_PreferredMaxLayoutWidth: @[ + LookinAttr_NSTextField_PreferredMaxLayoutWidth_PreferredMaxLayoutWidth + ], + LookinAttrSec_NSTextField_MaximumNumberOfLines: @[ + LookinAttr_NSTextField_MaximumNumberOfLines_MaximumNumberOfLines + ], + LookinAttrSec_NSTextField_AllowsDefaultTighteningForTruncation: @[ + LookinAttr_NSTextField_AllowsDefaultTighteningForTruncation_AllowsDefaultTighteningForTruncation + ], + LookinAttrSec_NSTextField_LineBreakStrategy: @[ + LookinAttr_NSTextField_LineBreakStrategy_LineBreakStrategy + ], + LookinAttrSec_NSTextField_Placeholder: @[ + LookinAttr_NSTextField_Placeholder_Placeholder + ], + LookinAttrSec_NSTextField_TextColor: @[ + LookinAttr_NSTextField_TextColor_Color + ], + + + + + LookinAttrSec_NSVisualEffectView_Material: @[ + LookinAttr_NSVisualEffectView_Material_Material + ], + LookinAttrSec_NSVisualEffectView_InteriorBackgroundStyle: @[ + LookinAttr_NSVisualEffectView_InteriorBackgroundStyle_InteriorBackgroundStyle + ], + LookinAttrSec_NSVisualEffectView_BlendingMode: @[ + LookinAttr_NSVisualEffectView_BlendingMode_BlendingMode + ], + LookinAttrSec_NSVisualEffectView_State: @[ + LookinAttr_NSVisualEffectView_State_State + ], + LookinAttrSec_NSVisualEffectView_Emphasized: @[ + LookinAttr_NSVisualEffectView_Emphasized_Emphasized + ], + + + + LookinAttrSec_NSStackView_Orientation:@[ + LookinAttr_NSStackView_Orientation_Orientation + ], + LookinAttrSec_NSStackView_EdgeInsets:@[ + LookinAttr_NSStackView_EdgeInsets_EdgeInsets + ], + LookinAttrSec_NSStackView_DetachesHiddenViews:@[ + LookinAttr_NSStackView_DetachesHiddenViews_DetachesHiddenViews + ], + LookinAttrSec_NSStackView_Distribution:@[ + LookinAttr_NSStackView_Distribution_Distribution + ], + LookinAttrSec_NSStackView_Alignment:@[ + LookinAttr_NSStackView_Alignment_Alignment + ], + LookinAttrSec_NSStackView_Spacing:@[ + LookinAttr_NSStackView_Spacing_Spacing + ], + +#endif }; }); return dict[sectionID]; @@ -363,7 +800,17 @@ + (NSString *)groupTitleWithGroupID:(LookinAttrGroupIdentifier)groupID { LookinAttrGroup_UITextView: @"UITextView", LookinAttrGroup_UITextField: @"UITextField", LookinAttrGroup_UIVisualEffectView: @"UIVisualEffectView", - LookinAttrGroup_UIStackView: @"UIStackView" + LookinAttrGroup_UIStackView: @"UIStackView", + LookinAttrGroup_ViewLayer: @"CALayer / NSView", + LookinAttrGroup_NSImageView: @"NSImageView", + LookinAttrGroup_NSControl: @"NSControl", + LookinAttrGroup_NSButton: @"NSButton", + LookinAttrGroup_NSScrollView: @"NSScrollView", + LookinAttrGroup_NSTableView: @"NSTableView", + LookinAttrGroup_NSTextView: @"NSTextView", + LookinAttrGroup_NSTextField: @"NSTextField", + LookinAttrGroup_NSVisualEffectView: @"NSVisualEffectView", + LookinAttrGroup_NSStackView: @"NSStackView" }; }); NSString *title = rawInfo[groupID]; @@ -388,9 +835,9 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { LookinAttrSec_ViewLayer_BgColor: @"BackgroundColor", LookinAttrSec_ViewLayer_Border: @"Border", LookinAttrSec_ViewLayer_Shadow: @"Shadow", + LookinAttrSec_ViewLayer_Tag: @"Tag", LookinAttrSec_ViewLayer_ContentMode: @"ContentMode", LookinAttrSec_ViewLayer_TintColor: @"TintColor", - LookinAttrSec_ViewLayer_Tag: @"Tag", LookinAttrSec_UIStackView_Axis: @"Axis", LookinAttrSec_UIStackView_Distribution: @"Distribution", LookinAttrSec_UIStackView_Alignment: @"Alignment", @@ -436,6 +883,90 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { LookinAttrSec_UITextView_Font: @"Font", LookinAttrSec_UITextView_ContainerInset: @"ContainerInset", LookinAttrSec_UITextField_ClearButtonMode: @"ClearButtonMode", + LookinAttrSec_NSImageView_Name: @"ImageName", + LookinAttrSec_NSImageView_Open: @"Open", + LookinAttrSec_NSControl_State: @"State", + LookinAttrSec_NSControl_ControlSize: @"ControlSize", + LookinAttrSec_NSControl_Font: @"Font", + LookinAttrSec_NSControl_Alignment: @"Alignment", + LookinAttrSec_NSControl_Misc: @"Misc", + LookinAttrSec_NSControl_Value: @"Value", + LookinAttrSec_NSButton_ButtonType: @"ButtonType", + LookinAttrSec_NSButton_Title: @"Title", + LookinAttrSec_NSButton_BezelStyle: @"BezelStyle", + LookinAttrSec_NSButton_Bordered: @"Bordered", + LookinAttrSec_NSButton_Transparent: @"Transparent", + LookinAttrSec_NSButton_BezelColor: @"BezelColor", + LookinAttrSec_NSButton_ContentTintColor: @"ContentTintColor", + LookinAttrSec_NSButton_Misc: @"Misc", + LookinAttrSec_NSScrollView_ContentOffset: @"ContentOffset", + LookinAttrSec_NSScrollView_ContentSize: @"ContentSize", + LookinAttrSec_NSScrollView_ContentInset: @"ContentInset", + LookinAttrSec_NSScrollView_BorderType: @"BorderType", + LookinAttrSec_NSScrollView_Scroller: @"Scroller", + LookinAttrSec_NSScrollView_Ruler: @"Ruler", + LookinAttrSec_NSScrollView_LineScroll: @"LineScroll", + LookinAttrSec_NSScrollView_PageScroll: @"PageScroll", + LookinAttrSec_NSScrollView_ScrollElasiticity: @"ScrollElasiticity", + LookinAttrSec_NSScrollView_Misc: @"Misc", + LookinAttrSec_NSScrollView_Magnification: @"Magnification", + LookinAttrSec_NSTableView_RowHeight: @"RowHeight", + LookinAttrSec_NSTableView_AutomaticRowHeights: @"AutomaticRowHeights", + LookinAttrSec_NSTableView_IntercellSpacing: @"IntercellSpacing", + LookinAttrSec_NSTableView_Style: @"Style", + LookinAttrSec_NSTableView_ColumnAutoresizingStyle: @"ColumnAutoresizingStyle", + LookinAttrSec_NSTableView_GridStyleMask: @"GridStyleMask", + LookinAttrSec_NSTableView_SelectionHighlightStyle: @"SelectionHighlightStyle", + LookinAttrSec_NSTableView_GridColor: @"GridColor", + LookinAttrSec_NSTableView_RowSizeStyle: @"RowSizeStyle", + LookinAttrSec_NSTableView_NumberOfRows: @"NumberOfRows", + LookinAttrSec_NSTableView_NumberOfColumns: @"NumberOfColumns", + LookinAttrSec_NSTableView_UseAlternatingRowBackgroundColors: @"UseAlternatingRowBackgroundColors", + LookinAttrSec_NSTableView_AllowsColumnReordering: @"AllowsColumnReordering", + LookinAttrSec_NSTableView_AllowsColumnResizing: @"AllowsColumnResizing", + LookinAttrSec_NSTableView_AllowsMultipleSelection: @"AllowsMultipleSelection", + LookinAttrSec_NSTableView_AllowsEmptySelection: @"AllowsEmptySelection", + LookinAttrSec_NSTableView_AllowsColumnSelection: @"AllowsColumnSelection", + LookinAttrSec_NSTableView_AllowsTypeSelect: @"AllowsTypeSelect", + LookinAttrSec_NSTableView_DraggingDestinationFeedbackStyle: @"DraggingDestinationFeedbackStyle", + LookinAttrSec_NSTableView_Autosave: @"Autosave", + LookinAttrSec_NSTableView_FloatsGroupRows: @"FloatsGroupRows", + LookinAttrSec_NSTableView_RowActionsVisible: @"RowActionsVisible", + LookinAttrSec_NSTableView_UsesStaticContents: @"UsesStaticContents", + LookinAttrSec_NSTableView_UserInterfaceLayoutDirection: @"UserInterfaceLayoutDirection", + LookinAttrSec_NSTableView_VerticalMotionCanBeginDrag: @"VerticalMotionCanBeginDrag", + LookinAttrSec_NSTextView_Font: @"Font", + LookinAttrSec_NSTextView_Basic: @"Basic", + LookinAttrSec_NSTextView_String: @"String", + LookinAttrSec_NSTextView_TextColor: @"TextColor", + LookinAttrSec_NSTextView_Alignment: @"Alignment", + LookinAttrSec_NSTextView_ContainerInset: @"ContainerInset", + LookinAttrSec_NSTextView_BaseWritingDirection: @"BaseWritingDirection", + LookinAttrSec_NSTextView_Size: @"Size", + LookinAttrSec_NSTextView_Resizable: @"Resizable", + LookinAttrSec_NSTextField_Bordered: @"Bordered", + LookinAttrSec_NSTextField_Bezeled: @"Bezeled", + LookinAttrSec_NSTextField_BezelStyle: @"BezelStyle", + LookinAttrSec_NSTextField_Editable: @"Editable", + LookinAttrSec_NSTextField_Selectable: @"Selectable", + LookinAttrSec_NSTextField_DrawsBackground: @"DrawsBackground", + LookinAttrSec_NSTextField_PreferredMaxLayoutWidth: @"PreferredMaxLayoutWidth", + LookinAttrSec_NSTextField_MaximumNumberOfLines: @"MaximumNumberOfLines", + LookinAttrSec_NSTextField_AllowsDefaultTighteningForTruncation: @"AllowsDefaultTighteningForTruncation", + LookinAttrSec_NSTextField_LineBreakStrategy: @"LineBreakStrategy", + LookinAttrSec_NSTextField_Placeholder: @"Placeholder", + LookinAttrSec_NSTextField_TextColor: @"TextColor", + LookinAttrSec_NSVisualEffectView_Material: @"Material", + LookinAttrSec_NSVisualEffectView_InteriorBackgroundStyle: @"InteriorBackgroundStyle", + LookinAttrSec_NSVisualEffectView_BlendingMode: @"BlendingMode", + LookinAttrSec_NSVisualEffectView_State: @"State", + LookinAttrSec_NSVisualEffectView_Emphasized: @"Emphasized", + LookinAttrSec_NSStackView_Orientation: @"Orientation", + LookinAttrSec_NSStackView_EdgeInsets: @"EdgeInsets", + LookinAttrSec_NSStackView_DetachesHiddenViews: @"DetachesHiddenViews", + LookinAttrSec_NSStackView_Distribution: @"Distribution", + LookinAttrSec_NSStackView_Alignment: @"Alignment", + LookinAttrSec_NSStackView_Spacing: @"Spacing", }; }); return rawInfo[secID]; @@ -499,6 +1030,12 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"setterString": @"", @"osVersion": @(11) }, + LookinAttr_Layout_SafeArea_SafeArea: @{ + @"className": @"NSView", + @"fullTitle": @"SafeAreaInsets", + @"setterString": @"", + @"osVersion": @(11) + }, LookinAttr_Layout_Position_Position: @{ @"className": @"CALayer", @"fullTitle": @"Position", @@ -509,7 +1046,6 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"fullTitle": @"AnchorPoint", @"patch": @(YES) }, - LookinAttr_AutoLayout_Hugging_Hor: @{ @"className": @"UIView", @"fullTitle": @"ContentHuggingPriority(Horizontal)", @@ -554,7 +1090,89 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"fullTitle": @"IntrinsicContentSize", @"setterString": @"" }, + LookinAttr_AutoLayout_Hugging_Hor: @{ + @"className": @"NSView", + @"fullTitle": @"ContentHuggingPriority(Horizontal)", + @"getterString": @"lks_horizontalContentHuggingPriority", + @"setterString": @"setLks_horizontalContentHuggingPriority:", + @"briefTitle": @"H", + @"patch": @(YES) + }, + LookinAttr_AutoLayout_Hugging_Ver: @{ + @"className": @"NSView", + @"fullTitle": @"ContentHuggingPriority(Vertical)", + @"getterString": @"lks_verticalContentHuggingPriority", + @"setterString": @"setLks_verticalContentHuggingPriority:", + @"briefTitle": @"V", + @"patch": @(YES) + }, + LookinAttr_AutoLayout_Resistance_Hor: @{ + @"className": @"NSView", + @"fullTitle": @"ContentCompressionResistancePriority(Horizontal)", + @"getterString": @"lks_horizontalContentCompressionResistancePriority", + @"setterString": @"setLks_horizontalContentCompressionResistancePriority:", + @"briefTitle": @"H", + @"patch": @(YES) + }, + LookinAttr_AutoLayout_Resistance_Ver: @{ + @"className": @"NSView", + @"fullTitle": @"ContentCompressionResistancePriority(Vertical)", + @"getterString": @"lks_verticalContentCompressionResistancePriority", + @"setterString": @"setLks_verticalContentCompressionResistancePriority:", + @"briefTitle": @"V", + @"patch": @(YES) + }, + LookinAttr_AutoLayout_Constraints_Constraints: @{ + @"className": @"NSView", + @"getterString": @"lks_constraints", + @"setterString": @"", + @"typeIfObj": @(LookinAttrTypeCustomObj), + @"hideIfNil": @(YES) + }, + LookinAttr_AutoLayout_IntrinsicSize_Size: @{ + @"className": @"NSView", + @"fullTitle": @"IntrinsicContentSize", + @"setterString": @"" + }, + + LookinAttr_ViewLayer_InterationAndMasks_Interaction: @{ + @"className": @"UIView", + @"fullTitle": @"UserInteractionEnabled", + @"getterString": @"isUserInteractionEnabled", + @"patch": @(NO) + }, + + LookinAttr_ViewLayer_ContentMode_Mode: @{ + @"className": @"UIView", + @"fullTitle": @"ContentMode", + @"enumList": @"UIViewContentMode", + @"patch": @(YES) + }, + LookinAttr_ViewLayer_TintColor_Color: @{ + @"className": @"UIView", + @"fullTitle": @"TintColor", + @"typeIfObj": @(LookinAttrTypeUIColor), + @"patch": @(YES) + }, + LookinAttr_ViewLayer_TintColor_Mode: @{ + @"className": @"UIView", + @"fullTitle": @"TintAdjustmentMode", + @"enumList": @"UIViewTintAdjustmentMode", + @"patch": @(YES) + }, + LookinAttr_ViewLayer_Tag_Tag: @{ + @"className": @"UIView", + @"fullTitle": @"Tag", + @"briefTitle": @"", + @"patch": @(NO) + }, + LookinAttr_ViewLayer_Tag_Tag: @{ + @"className": @"NSView", + @"fullTitle": @"Tag", + @"briefTitle": @"", + @"patch": @(NO) + }, LookinAttr_ViewLayer_Visibility_Hidden: @{ @"className": @"CALayer", @"fullTitle": @"Hidden", @@ -568,12 +1186,6 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"getterString": @"opacity", @"patch": @(YES) }, - LookinAttr_ViewLayer_InterationAndMasks_Interaction: @{ - @"className": @"UIView", - @"fullTitle": @"UserInteractionEnabled", - @"getterString": @"isUserInteractionEnabled", - @"patch": @(NO) - }, LookinAttr_ViewLayer_InterationAndMasks_MasksToBounds: @{ @"className": @"CALayer", @"fullTitle": @"MasksToBounds / ClipsToBounds", @@ -645,30 +1257,6 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"getterString": @"lks_shadowOffsetHeight", @"patch": @(YES) }, - LookinAttr_ViewLayer_ContentMode_Mode: @{ - @"className": @"UIView", - @"fullTitle": @"ContentMode", - @"enumList": @"UIViewContentMode", - @"patch": @(YES) - }, - LookinAttr_ViewLayer_TintColor_Color: @{ - @"className": @"UIView", - @"fullTitle": @"TintColor", - @"typeIfObj": @(LookinAttrTypeUIColor), - @"patch": @(YES) - }, - LookinAttr_ViewLayer_TintColor_Mode: @{ - @"className": @"UIView", - @"fullTitle": @"TintAdjustmentMode", - @"enumList": @"UIViewTintAdjustmentMode", - @"patch": @(YES) - }, - LookinAttr_ViewLayer_Tag_Tag: @{ - @"className": @"UIView", - @"fullTitle": @"Tag", - @"briefTitle": @"", - @"patch": @(NO) - }, LookinAttr_UIStackView_Axis_Axis: @{ @"className": @"UIStackView", @@ -1088,34 +1676,744 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"enumList": @"UITextFieldViewMode", @"patch": @(NO) }, - }; - }); - - NSDictionary *targetInfo = dict[attrID]; - return targetInfo; -} - -+ (LookinAttrType)objectAttrTypeWithAttrID:(LookinAttrIdentifier)attrID { - NSDictionary *attrInfo = [self _infoForAttrID:attrID]; - NSNumber *typeIfObj = attrInfo[@"typeIfObj"]; - return [typeIfObj integerValue]; -} - -+ (NSString *)classNameWithAttrID:(LookinAttrIdentifier)attrID { - NSDictionary *attrInfo = [self _infoForAttrID:attrID]; - NSString *className = attrInfo[@"className"]; - - NSAssert(className.length > 0, @""); - - return className; -} - -+ (BOOL)isUIViewPropertyWithAttrID:(LookinAttrIdentifier)attrID { - NSString *className = [self classNameWithAttrID:attrID]; - - if ([className isEqualToString:@"CALayer"]) { - return NO; - } + LookinAttr_NSImageView_Name_Name: @{ + @"className": @"NSImageView", + @"fullTitle": @"ImageName", + @"setterString": @"", + @"getterString": @"lks_imageSourceName", + @"typeIfObj": @(LookinAttrTypeNSString), + @"hideIfNil": @(YES) + }, + LookinAttr_NSImageView_Open_Open: @{ + @"className": @"NSImageView", + @"setterString": @"", + @"getterString": @"lks_imageViewOidIfHasImage", + @"typeIfObj": @(LookinAttrTypeCustomObj), + @"hideIfNil": @(YES) + }, + LookinAttr_NSControl_State_Enabled: @{ + @"className": @"NSControl", + @"fullTitle": @"Enabled", + @"getterString": @"isEnabled", + @"patch": @(YES) + }, + LookinAttr_NSControl_State_Highlighted: @{ + @"className": @"NSControl", + @"fullTitle": @"Highlighted", + @"getterString": @"isHighlighted", + @"patch": @(YES) + }, + LookinAttr_NSControl_State_Continuous: @{ + @"className": @"NSControl", + @"fullTitle": @"Continuous", + @"getterString": @"isContinuous", + @"patch": @(NO) + }, + LookinAttr_NSControl_ControlSize_Size: @{ + @"className": @"NSControl", + @"fullTitle": @"ControlSize", + @"enumList": @"NSControlSize", + @"patch": @(YES) + }, + LookinAttr_NSControl_Font_Name: @{ + @"className": @"NSControl", + @"fullTitle": @"FontName", + @"setterString": @"", + @"getterString": @"lks_fontName", + @"typeIfObj": @(LookinAttrTypeNSString), + @"patch": @(NO) + }, + LookinAttr_NSControl_Font_Size: @{ + @"className": @"NSControl", + @"fullTitle": @"FontSize", + @"setterString": @"setLks_fontSize:", + @"getterString": @"lks_fontSize", + @"patch": @(YES) + }, + LookinAttr_NSControl_Alignment_Alignment: @{ + @"className": @"NSControl", + @"fullTitle": @"Alignment", + @"enumList": @"NSTextAlignment_AppKit", + @"patch": @(YES) + }, + LookinAttr_NSControl_Misc_WritingDirection: @{ + @"className": @"NSControl", + @"fullTitle": @"BaseWritingDirection", + @"enumList": @"NSWritingDirection", + @"patch": @(NO) + }, + LookinAttr_NSControl_Misc_IgnoresMultiClick: @{ + @"className": @"NSControl", + @"fullTitle": @"IgnoresMultiClick", + @"patch": @(NO) + }, + LookinAttr_NSControl_Misc_UsesSingleLineMode: @{ + @"className": @"NSControl", + @"fullTitle": @"UsesSingleLineMode", + @"patch": @(NO) + }, + LookinAttr_NSControl_Misc_AllowsExpansionToolTips: @{ + @"className": @"NSControl", + @"fullTitle": @"AllowsExpansionToolTips", + @"patch": @(NO) + }, + LookinAttr_NSControl_Value_StringValue: @{ + @"className": @"NSControl", + @"fullTitle": @"StringValue", + @"typeIfObj": @(LookinAttrTypeNSString), + @"patch": @(YES) + }, + LookinAttr_NSControl_Value_IntValue: @{ + @"className": @"NSControl", + @"fullTitle": @"IntValue", + @"patch": @(YES) + }, + LookinAttr_NSControl_Value_IntegerValue: @{ + @"className": @"NSControl", + @"fullTitle": @"IntegerValue", + @"patch": @(YES) + }, + LookinAttr_NSControl_Value_FloatValue: @{ + @"className": @"NSControl", + @"fullTitle": @"FloatValue", + @"patch": @(YES) + }, + LookinAttr_NSControl_Value_DoubleValue: @{ + @"className": @"NSControl", + @"fullTitle": @"DoubleValue", + @"patch": @(YES) + }, + LookinAttr_NSButton_ButtonType_ButtonType: @{ + @"className": @"NSButton", + @"fullTitle": @"ButtonType", + @"getterString": @"lks_buttonType", + @"enumList": @"NSButtonType", + @"patch": @(YES) + }, + LookinAttr_NSButton_Title_Title: @{ + @"className": @"NSButton", + @"fullTitle": @"Title", + @"typeIfObj": @(LookinAttrTypeNSString), + @"patch": @(YES) + }, + LookinAttr_NSButton_Title_AlernateTitle: @{ + @"className": @"NSButton", + @"fullTitle": @"AlternateTitle", + @"typeIfObj": @(LookinAttrTypeNSString), + @"patch": @(YES) + }, + LookinAttr_NSButton_BezelStyle_BezelStyle: @{ + @"className": @"NSButton", + @"fullTitle": @"BezelStyle", + @"enumList": @"NSBezelStyle", + @"patch": @(YES) + }, + LookinAttr_NSButton_Bordered_Bordered: @{ + @"className": @"NSButton", + @"fullTitle": @"Bordered", + @"getterString": @"isBordered", + @"patch": @(YES) + }, + LookinAttr_NSButton_Transparent_Transparent: @{ + @"className": @"NSButton", + @"fullTitle": @"Transparent", + @"getterString": @"isTransparent", + @"patch": @(YES) + }, + LookinAttr_NSButton_BezelColor_BezelColor: @{ + @"className": @"NSButton", + @"fullTitle": @"BezelColor", + @"typeIfObj": @(LookinAttrTypeUIColor), + @"patch": @(YES) + }, + LookinAttr_NSButton_ContentTintColor_ContentTintColor: @{ + @"className": @"NSButton", + @"fullTitle": @"ContentTintColor", + @"typeIfObj": @(LookinAttrTypeUIColor), + @"patch": @(YES) + }, + LookinAttr_NSButton_Misc_ShowsBorderOnlyWhileMouseInside: @{ + @"className": @"NSButton", + @"fullTitle": @"ShowsBorderOnlyWhileMouseInside", + @"patch": @(YES) + }, + LookinAttr_NSButton_Misc_MaxAcceleratorLevel: @{ + @"className": @"NSButton", + @"fullTitle": @"MaxAcceleratorLevel", + @"patch": @(YES) + }, + LookinAttr_NSButton_Misc_SpringLoaded: @{ + @"className": @"NSButton", + @"fullTitle": @"SpringLoaded", + @"patch": @(YES) + }, + LookinAttr_NSButton_Misc_HasDestructiveAction: @{ + @"className": @"NSButton", + @"fullTitle": @"HasDestructiveAction", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_ContentOffset_Offset: @{ + @"className": @"NSScrollView", + @"fullTitle": @"ContentOffset", + @"setterString": @"lks_setContentOffset:", + @"getterString": @"lks_contentOffset", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_ContentSize_Size: @{ + @"className": @"NSScrollView", + @"fullTitle": @"ContentSize", + @"setterString": @"lks_setContentSize:", + @"getterString": @"lks_contentSize", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_ContentInset_ContentInset: @{ + @"className": @"NSScrollView", + @"fullTitle": @"ContentInset", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_ContentInset_AutomaticallyAdjustsContentInsets: @{ + @"className": @"NSScrollView", + @"fullTitle": @"AutomaticallyAdjustsContentInsets", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_BorderType_BorderType: @{ + @"className": @"NSScrollView", + @"fullTitle": @"BorderType", + @"enumList": @"NSBorderType", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_Scroller_Horizontal: @{ + @"className": @"NSScrollView", + @"fullTitle": @"HasHorizontalScroller", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_Scroller_Vertical: @{ + @"className": @"NSScrollView", + @"fullTitle": @"HasVerticalScroller", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_Scroller_AutohidesScrollers: @{ + @"className": @"NSScrollView", + @"fullTitle": @"AutohidesScrollers", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_Scroller_ScrollerStyle: @{ + @"className": @"NSScrollView", + @"fullTitle": @"ScrollerStyle", + @"enumList": @"NSScrollerStyle", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_Scroller_ScrollerKnobStyle: @{ + @"className": @"NSScrollView", + @"fullTitle": @"ScrollerKnobStyle", + @"enumList": @"NSScrollerKnobStyle", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_Scroller_ScrollerInsets: @{ + @"className": @"NSScrollView", + @"fullTitle": @"ScrollerInsets", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_Ruler_Horizontal: @{ + @"className": @"NSScrollView", + @"fullTitle": @"HasHorizontalRuler", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_Ruler_Vertical: @{ + @"className": @"NSScrollView", + @"fullTitle": @"HasVerticalRuler", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_Ruler_Visible: @{ + @"className": @"NSScrollView", + @"fullTitle": @"RulersVisible", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_LineScroll_Horizontal: @{ + @"className": @"NSScrollView", + @"fullTitle": @"HorizontalLineScroll", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_LineScroll_Vertical: @{ + @"className": @"NSScrollView", + @"fullTitle": @"VerticalLineScroll", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_LineScroll_LineScroll: @{ + @"className": @"NSScrollView", + @"fullTitle": @"LineScroll", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_PageScroll_Horizontal: @{ + @"className": @"NSScrollView", + @"fullTitle": @"HorizontalPageScroll", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_PageScroll_Vertical: @{ + @"className": @"NSScrollView", + @"fullTitle": @"VerticalPageScroll", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_PageScroll_PageScroll: @{ + @"className": @"NSScrollView", + @"fullTitle": @"PageScroll", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_ScrollElasiticity_Horizontal: @{ + @"className": @"NSScrollView", + @"fullTitle": @"HorizontalScrollElasticity", + @"enumList": @"NSScrollElasticity", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_ScrollElasiticity_Vertical: @{ + @"className": @"NSScrollView", + @"fullTitle": @"VerticalScrollElasticity", + @"enumList": @"NSScrollElasticity", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_Misc_ScrollsDynamically: @{ + @"className": @"NSScrollView", + @"fullTitle": @"ScrollsDynamically", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_Misc_UsesPredominantAxisScrolling: @{ + @"className": @"NSScrollView", + @"fullTitle": @"UsesPredominantAxisScrolling", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_Magnification_AllowsMagnification: @{ + @"className": @"NSScrollView", + @"fullTitle": @"AllowsMagnification", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_Magnification_Magnification: @{ + @"className": @"NSScrollView", + @"fullTitle": @"Magnification", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_Magnification_Max: @{ + @"className": @"NSScrollView", + @"fullTitle": @"MaximunMagnification", + @"patch": @(YES) + }, + LookinAttr_NSScrollView_Magnification_Min: @{ + @"className": @"NSScrollView", + @"fullTitle": @"MinimumMagnification", + @"patch": @(YES) + }, + LookinAttr_NSTableView_AllowsColumnReordering_AllowsColumnReordering: @{ + @"className": @"NSTableView", + @"fullTitle": @"AllowsColumnReordering", + @"patch": @(YES) + }, + LookinAttr_NSTableView_AllowsColumnResizing_AllowsColumnResizing: @{ + @"className": @"NSTableView", + @"fullTitle": @"AllowsColumnResizing", + @"patch": @(YES) + }, + LookinAttr_NSTableView_ColumnAutoresizingStyle_ColumnAutoresizingStyle: @{ + @"className": @"NSTableView", + @"fullTitle": @"ColumnAutoresizingStyle", + @"enumList": @"NSTableViewColumnAutoresizingStyle", + @"patch": @(YES) + }, + LookinAttr_NSTableView_GridStyleMask_GridStyleMask: @{ + @"className": @"NSTableView", + @"fullTitle": @"GridStyleMask", + @"enumList": @"NSTableViewGridLineStyle", + @"patch": @(YES) + }, + LookinAttr_NSTableView_IntercellSpacing_IntercellSpacing: @{ + @"className": @"NSTableView", + @"fullTitle": @"IntercellSpacing", + @"patch": @(YES) + }, + LookinAttr_NSTableView_UseAlternatingRowBackgroundColors_UseAlternatingRowBackgroundColors: @{ + @"className": @"NSTableView", + @"fullTitle": @"UsesAlternatingRowBackgroundColors", + @"patch": @(YES) + }, + LookinAttr_NSTableView_GridColor_GridColor: @{ + @"className": @"NSTableView", + @"fullTitle": @"GridColor", + @"typeIfObj": @(LookinAttrTypeUIColor), + @"patch": @(YES) + }, + LookinAttr_NSTableView_RowSizeStyle_RowSizeStyle: @{ + @"className": @"NSTableView", + @"fullTitle": @"RowSizeStyle", + @"enumList": @"NSTableViewRowSizeStyle", + @"patch": @(YES) + }, + LookinAttr_NSTableView_RowHeight_RowHeight: @{ + @"className": @"NSTableView", + @"fullTitle": @"RowHeight", + @"patch": @(YES) + }, + LookinAttr_NSTableView_NumberOfRows_NumberOfRows: @{ + @"className": @"NSTableView", + @"fullTitle": @"NumberOfRows", + @"setterString": @"", + @"patch": @(YES) + }, + LookinAttr_NSTableView_NumberOfColumns_NumberOfColumns: @{ + @"className": @"NSTableView", + @"fullTitle": @"NumberOfColumns", + @"setterString": @"", + @"patch": @(YES) + }, + LookinAttr_NSTableView_VerticalMotionCanBeginDrag_VerticalMotionCanBeginDrag: @{ + @"className": @"NSTableView", + @"fullTitle": @"VerticalMotionCanBeginDrag", + @"patch": @(YES) + }, + LookinAttr_NSTableView_AllowsMultipleSelection_AllowsMultipleSelection: @{ + @"className": @"NSTableView", + @"fullTitle": @"AllowsMultipleSelection", + @"patch": @(YES) + }, + LookinAttr_NSTableView_AllowsEmptySelection_AllowsEmptySelection: @{ + @"className": @"NSTableView", + @"fullTitle": @"AllowsEmptySelection", + @"patch": @(YES) + }, + LookinAttr_NSTableView_AllowsColumnSelection_AllowsColumnSelection: @{ + @"className": @"NSTableView", + @"fullTitle": @"AllowsColumnSelection", + @"patch": @(YES) + }, + LookinAttr_NSTableView_AllowsTypeSelect_AllowsTypeSelect: @{ + @"className": @"NSTableView", + @"fullTitle": @"AllowsTypeSelect", + @"patch": @(YES) + }, + LookinAttr_NSTableView_SelectionHighlightStyle_SelectionHighlightStyle: @{ + @"className": @"NSTableView", + @"fullTitle": @"SelectionHighlightStyle", + @"enumList": @"NSTableViewSelectionHighlightStyle", + @"patch": @(YES) + }, + LookinAttr_NSTableView_DraggingDestinationFeedbackStyle_DraggingDestinationFeedbackStyle: @{ + @"className": @"NSTableView", + @"fullTitle": @"DraggingDestinationFeedbackStyle", + @"enumList": @"NSTableViewDraggingDestinationFeedbackStyle", + @"patch": @(YES) + }, + LookinAttr_NSTableView_AutomaticRowHeights_AutomaticRowHeights: @{ + @"className": @"NSTableView", + @"fullTitle": @"AutomaticRowHeights", + @"patch": @(YES) + }, + LookinAttr_NSTableView_AutosaveName_AutosaveName: @{ + @"className": @"NSTableView", + @"fullTitle": @"AutosaveName", + @"patch": @(YES) + }, + LookinAttr_NSTableView_AutosaveTableColumns_AutosaveTableColumns: @{ + @"className": @"NSTableView", + @"fullTitle": @"AutosaveTableColumns", + @"patch": @(YES) + }, + LookinAttr_NSTableView_FloatsGroupRows_FloatsGroupRows: @{ + @"className": @"NSTableView", + @"fullTitle": @"FloatsGroupRows", + @"patch": @(YES) + }, + LookinAttr_NSTableView_RowActionsVisible_RowActionsVisible: @{ + @"className": @"NSTableView", + @"fullTitle": @"RowActionsVisible", + @"patch": @(YES) + }, + LookinAttr_NSTableView_UsesStaticContents_UsesStaticContents: @{ + @"className": @"NSTableView", + @"fullTitle": @"UsesStaticContents", + @"patch": @(YES) + }, + LookinAttr_NSTableView_UserInterfaceLayoutDirection_UserInterfaceLayoutDirection: @{ + @"className": @"NSTableView", + @"fullTitle": @"UserInterfaceLayoutDirection", + @"enumList": @"NSUserInterfaceLayoutDirection", + @"patch": @(YES) + }, + LookinAttr_NSTableView_Style_Style: @{ + @"className": @"NSTableView", + @"fullTitle": @"Style", + @"enumList": @"NSTableViewStyle", + @"patch": @(YES) + }, + LookinAttr_NSTextView_Font_Name: @{ + @"className": @"NSTextView", + @"fullTitle": @"FontName", + @"setterString": @"", + @"getterString": @"lks_fontName", + @"typeIfObj": @(LookinAttrTypeNSString), + @"patch": @(NO) + }, + LookinAttr_NSTextView_Font_Size: @{ + @"className": @"NSTextView", + @"fullTitle": @"FontSize", + @"setterString": @"setLks_fontSize:", + @"getterString": @"lks_fontSize", + @"patch": @(YES) + }, + LookinAttr_NSTextView_Basic_Editable: @{ + @"className": @"NSTextView", + @"fullTitle": @"Editable", + @"getterString": @"isEditable", + @"patch": @(NO) + }, + LookinAttr_NSTextView_Basic_Selectable: @{ + @"className": @"NSTextView", + @"fullTitle": @"Selectable", + @"getterString": @"isSelectable", + @"patch": @(NO) + }, + LookinAttr_NSTextView_Basic_RichText: @{ + @"className": @"NSTextView", + @"fullTitle": @"RichText", + @"getterString": @"isRichText", + @"patch": @(NO) + }, + LookinAttr_NSTextView_Basic_FieldEditor: @{ + @"className": @"NSTextView", + @"fullTitle": @"FieldEditor", + @"getterString": @"isFieldEditor", + @"patch": @(NO) + }, + LookinAttr_NSTextView_Basic_ImportsGraphics: @{ + @"className": @"NSTextView", + @"fullTitle": @"ImportsGraphics", + @"patch": @(NO) + }, + LookinAttr_NSTextView_String_String: @{ + @"className": @"NSTextView", + @"fullTitle": @"String", + @"typeIfObj": @(LookinAttrTypeNSString), + @"patch": @(YES) + }, + LookinAttr_NSTextView_TextColor_Color: @{ + @"className": @"NSTextView", + @"fullTitle": @"TextColor", + @"typeIfObj": @(LookinAttrTypeUIColor), + @"patch": @(YES) + }, + LookinAttr_NSTextView_Alignment_Alignment: @{ + @"className": @"NSTextView", + @"fullTitle": @"Alignment", + @"enumList": @"NSTextAlignment_AppKit", + @"patch": @(YES) + }, + LookinAttr_NSTextView_ContainerInset_Inset: @{ + @"className": @"NSTextView", + @"fullTitle": @"TextContainerInset", + @"patch": @(YES) + }, + LookinAttr_NSTextView_BaseWritingDirection_BaseWritingDirection: @{ + @"className": @"NSTextView", + @"fullTitle": @"BaseWritingDirection", + @"enumList": @"NSWritingDirection", + @"patch": @(NO) + }, + LookinAttr_NSTextView_MaxSize_MaxSize: @{ + @"className": @"NSTextView", + @"fullTitle": @"MaxSize", + @"patch": @(YES) + }, + LookinAttr_NSTextView_MinSize_MinSize: @{ + @"className": @"NSTextView", + @"fullTitle": @"MinSize", + @"patch": @(YES) + }, + LookinAttr_NSTextView_Resizable_Horizontal: @{ + @"className": @"NSTextView", + @"fullTitle": @"HorizontallyResizable", + @"patch": @(NO) + }, + LookinAttr_NSTextView_Resizable_Vertical: @{ + @"className": @"NSTextView", + @"fullTitle": @"VerticallyResizable", + @"patch": @(NO) + }, + LookinAttr_NSTextField_Bordered_Bordered: @{ + @"className": @"NSTextField", + @"fullTitle": @"Bordered", + @"getterString": @"isBordered", + @"patch": @(NO) + }, + LookinAttr_NSTextField_Bezeled_Bezeled: @{ + @"className": @"NSTextField", + @"fullTitle": @"Bezeled", + @"getterString": @"isBezeled", + @"patch": @(NO) + }, + LookinAttr_NSTextField_Editable_Editable: @{ + @"className": @"NSTextField", + @"fullTitle": @"Editable", + @"getterString": @"isEditable", + @"patch": @(NO) + }, + LookinAttr_NSTextField_Selectable_Selectable: @{ + @"className": @"NSTextField", + @"fullTitle": @"Selectable", + @"getterString": @"isSelectable", + @"patch": @(NO) + }, + LookinAttr_NSTextField_DrawsBackground_DrawsBackground: @{ + @"className": @"NSTextField", + @"fullTitle": @"DrawsBackground", + @"patch": @(YES) + }, + LookinAttr_NSTextField_BezelStyle_BezelStyle: @{ + @"className": @"NSTextField", + @"fullTitle": @"BezelStyle", + @"enumList": @"NSTextFieldBezelStyle", + @"patch": @(YES) + }, + LookinAttr_NSTextField_PreferredMaxLayoutWidth_PreferredMaxLayoutWidth: @{ + @"className": @"NSTextField", + @"fullTitle": @"PreferredMaxLayoutWidth", + @"patch": @(YES) + }, + LookinAttr_NSTextField_MaximumNumberOfLines_MaximumNumberOfLines: @{ + @"className": @"NSTextField", + @"fullTitle": @"MaximumNumberOfLines", + @"patch": @(YES) + }, + LookinAttr_NSTextField_AllowsDefaultTighteningForTruncation_AllowsDefaultTighteningForTruncation: @{ + @"className": @"NSTextField", + @"fullTitle": @"AllowsDefaultTighteningForTruncation", + @"patch": @(YES) + }, + LookinAttr_NSTextField_LineBreakStrategy_LineBreakStrategy: @{ + @"className": @"NSTextField", + @"fullTitle": @"LineBreakStrategy", + @"enumList": @"NSLineBreakStrategy", + @"patch": @(YES) + }, + LookinAttr_NSTextField_Placeholder_Placeholder: @{ + @"className": @"NSTextField", + @"fullTitle": @"Placeholder", + @"typeIfObj": @(LookinAttrTypeNSString), + @"patch": @(YES) + }, + LookinAttr_NSTextField_TextColor_Color: @{ + @"className": @"NSTextField", + @"fullTitle": @"TextColor", + @"typeIfObj": @(LookinAttrTypeUIColor), + @"patch": @(YES) + }, + LookinAttr_NSVisualEffectView_Material_Material: @{ + @"className": @"NSVisualEffectView", + @"fullTitle": @"Material", + @"enumList": @"NSVisualEffectMaterial", + @"patch": @(YES) + }, + LookinAttr_NSVisualEffectView_InteriorBackgroundStyle_InteriorBackgroundStyle: @{ + @"className": @"NSVisualEffectView", + @"fullTitle": @"InteriorBackgroundStyle", + @"enumList": @"NSBackgroundStyle", + @"patch": @(YES) + }, + LookinAttr_NSVisualEffectView_BlendingMode_BlendingMode: @{ + @"className": @"NSVisualEffectView", + @"fullTitle": @"BlendingMode", + @"enumList": @"NSVisualEffectBlendingMode", + @"patch": @(YES) + }, + LookinAttr_NSVisualEffectView_State_State: @{ + @"className": @"NSVisualEffectView", + @"fullTitle": @"State", + @"enumList": @"NSVisualEffectState", + @"patch": @(YES) + }, + LookinAttr_NSVisualEffectView_Emphasized_Emphasized: @{ + @"className": @"NSVisualEffectView", + @"fullTitle": @"Emphasized", + @"getterString": @"isEmphasized", + @"patch": @(YES) + }, + LookinAttr_NSStackView_Orientation_Orientation: @{ + @"className": @"NSStackView", + @"fullTitle": @"Orientation", + @"enumList": @"NSUserInterfaceLayoutOrientation", + @"patch": @(YES) + }, + LookinAttr_NSStackView_EdgeInsets_EdgeInsets: @{ + @"className": @"NSStackView", + @"fullTitle": @"EdgeInsets", + @"patch": @(YES) + }, + LookinAttr_NSStackView_DetachesHiddenViews_DetachesHiddenViews: @{ + @"className": @"NSStackView", + @"fullTitle": @"DetachesHiddenViews", + @"patch": @(YES) + }, + LookinAttr_NSStackView_Distribution_Distribution: @{ + @"className": @"NSStackView", + @"fullTitle": @"Distribution", + @"enumList": @"NSStackViewDistribution", + @"patch": @(YES) + }, + LookinAttr_NSStackView_Alignment_Alignment: @{ + @"className": @"NSStackView", + @"fullTitle": @"Alignment", + @"enumList": @"NSLayoutAttribute", + @"patch": @(YES) + }, + LookinAttr_NSStackView_Spacing_Spacing: @{ + @"className": @"NSStackView", + @"fullTitle": @"Spacing", + @"patch": @(YES) + }, + }; + }); + + NSDictionary *targetInfo = dict[attrID]; + return targetInfo; +} + ++ (LookinAttrType)objectAttrTypeWithAttrID:(LookinAttrIdentifier)attrID { + NSDictionary *attrInfo = [self _infoForAttrID:attrID]; + NSNumber *typeIfObj = attrInfo[@"typeIfObj"]; + return [typeIfObj integerValue]; +} + ++ (NSString *)classNameWithAttrID:(LookinAttrIdentifier)attrID { + NSDictionary *attrInfo = [self _infoForAttrID:attrID]; + NSString *className = attrInfo[@"className"]; + + NSAssert(className.length > 0, @""); + + return className; +} + ++ (BOOL)isWindowPropertyWithAttrID:(LookinAttrIdentifier)attrID { + NSString *className = [self classNameWithAttrID:attrID]; + if ([className isEqualToString:@"UIWindowScene"]) { + return YES; + } + + if ([className isEqualToString:@"NSWindow"]) { + return YES; + } + return NO; +} + ++ (BOOL)isUIViewPropertyWithAttrID:(LookinAttrIdentifier)attrID { + NSString *className = [self classNameWithAttrID:attrID]; + + if ([className isEqualToString:@"CALayer"]) { + return NO; + } + + if ([className isEqualToString:@"UIWindowScene"]) { + return NO; + } + + if ([className isEqualToString:@"NSWindow"]) { + return NO; + } + return YES; } diff --git a/Src/Main/Shared/LookinDefines.h b/Src/Main/Shared/LookinDefines.h index f00540d..ba85f26 100644 --- a/Src/Main/Shared/LookinDefines.h +++ b/Src/Main/Shared/LookinDefines.h @@ -11,7 +11,7 @@ #import "TargetConditionals.h" #if TARGET_OS_IPHONE #import -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX #import #endif @@ -144,10 +144,48 @@ enum { #define LookinColor UIColor #define LookinInsets UIEdgeInsets #define LookinImage UIImage -#elif TARGET_OS_MAC +#define LookinWindow UIWindow +#define LookinApplication UIApplication +#define LookinImageView UIImageView +#define LookinView UIView +#define LookinViewController UIViewController +#define LookinFont UIFont +#define LookinResponder UIResponder +#define LookinLayoutConstraintAxisHorizontal UILayoutConstraintAxisHorizontal +#define LookinLayoutConstraintAxisVertical UILayoutConstraintAxisVertical +#define LookinLayoutGuide UILayoutGuide +#define LookinGestureRecognizer UIGestureRecognizer +#define LookinControl UIControl +#define LookinCollectionView UICollectionView +#define LookinCollectionElementKindSectionHeader UICollectionElementKindSectionHeader +#define LookinCollectionElementKindSectionFooter UICollectionElementKindSectionFooter +#define LookinTextField UITextField +#define LookinTextView UITextView +#define LookinViewString @"UIView" +#define LookinViewControllerString @"UIViewController" +#elif TARGET_OS_OSX #define LookinColor NSColor #define LookinInsets NSEdgeInsets #define LookinImage NSImage +#define LookinWindow NSWindow +#define LookinApplication NSApplication +#define LookinImageView NSImageView +#define LookinView NSView +#define LookinViewController NSViewController +#define LookinFont NSFont +#define LookinResponder NSResponder +#define LookinLayoutConstraintAxisHorizontal NSLayoutConstraintOrientationHorizontal +#define LookinLayoutConstraintAxisVertical NSLayoutConstraintOrientationVertical +#define LookinLayoutGuide NSLayoutGuide +#define LookinGestureRecognizer NSGestureRecognizer +#define LookinControl NSControl +#define LookinCollectionView NSCollectionView +#define LookinCollectionElementKindSectionHeader NSCollectionElementKindSectionHeader +#define LookinCollectionElementKindSectionFooter NSCollectionElementKindSectionFooter +#define LookinTextField NSTextField +#define LookinTextView NSTextView +#define LookinViewString @"NSView" +#define LookinViewControllerString @"NSViewController" #endif #define LookinColorRGBAMake(r, g, b, a) [LookinColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a] diff --git a/Src/Main/Shared/LookinDisplayItem.h b/Src/Main/Shared/LookinDisplayItem.h index cea7247..d7d2b33 100644 --- a/Src/Main/Shared/LookinDisplayItem.h +++ b/Src/Main/Shared/LookinDisplayItem.h @@ -14,7 +14,7 @@ #import "LookinCustomDisplayItemInfo.h" #if TARGET_OS_IPHONE #import -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX #import #endif @@ -75,11 +75,15 @@ typedef NS_ENUM(NSUInteger, LookinDisplayItemProperty) { @property(nonatomic, assign) CGRect bounds; +/// 只在 macOS 上有效, iOS 总是为 NO +@property(nonatomic, assign, getter=isFlipped) BOOL flipped; + /// 不存在 subitems 时,该属性的值为 nil @property(nonatomic, strong) LookinImage *soloScreenshot; /// 无论是否存在 subitems,该属性始终存在 @property(nonatomic, strong) LookinImage *groupScreenshot; +@property(nonatomic, strong) LookinObject *windowObject; @property(nonatomic, strong) LookinObject *viewObject; @property(nonatomic, strong) LookinObject *layerObject; @property(nonatomic, strong) LookinObject *hostViewControllerObject; diff --git a/Src/Main/Shared/LookinDisplayItem.m b/Src/Main/Shared/LookinDisplayItem.m index 82ef8d9..fceaed2 100644 --- a/Src/Main/Shared/LookinDisplayItem.m +++ b/Src/Main/Shared/LookinDisplayItem.m @@ -22,7 +22,7 @@ #if TARGET_OS_IPHONE #import "UIColor+LookinServer.h" #import "UIImage+LookinServer.h" -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX #endif @interface LookinDisplayItem () @@ -50,10 +50,14 @@ - (id)copyWithZone:(NSZone *)zone { newDisplayItem.alpha = self.alpha; newDisplayItem.frame = self.frame; newDisplayItem.bounds = self.bounds; +#if TARGET_OS_OSX + newDisplayItem.flipped = self.isFlipped; +#endif newDisplayItem.soloScreenshot = self.soloScreenshot; newDisplayItem.groupScreenshot = self.groupScreenshot; newDisplayItem.viewObject = self.viewObject.copy; newDisplayItem.layerObject = self.layerObject.copy; + newDisplayItem.windowObject = self.windowObject.copy; newDisplayItem.hostViewControllerObject = self.hostViewControllerObject.copy; newDisplayItem.attributesGroupList = [self.attributesGroupList lookin_map:^id(NSUInteger idx, LookinAttributesGroup *value) { return value.copy; @@ -78,8 +82,12 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:self.subitems forKey:@"subitems"]; [aCoder encodeBool:self.isHidden forKey:@"hidden"]; [aCoder encodeFloat:self.alpha forKey:@"alpha"]; +#if TARGET_OS_OSX + [aCoder encodeBool:self.isFlipped forKey:@"isFlipped"]; +#endif [aCoder encodeObject:self.viewObject forKey:@"viewObject"]; [aCoder encodeObject:self.layerObject forKey:@"layerObject"]; + [aCoder encodeObject:self.windowObject forKey:@"windowObject"]; [aCoder encodeObject:self.hostViewControllerObject forKey:@"hostViewControllerObject"]; [aCoder encodeObject:self.attributesGroupList forKey:@"attributesGroupList"]; [aCoder encodeObject:self.customAttrGroupList forKey:@"customAttrGroupList"]; @@ -99,8 +107,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeCGRect:self.frame forKey:@"frame"]; [aCoder encodeCGRect:self.bounds forKey:@"bounds"]; [aCoder encodeObject:self.backgroundColor.lks_rgbaComponents forKey:@"backgroundColor"]; - -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX [aCoder encodeRect:self.frame forKey:@"frame"]; [aCoder encodeRect:self.bounds forKey:@"bounds"]; [aCoder encodeObject:self.backgroundColor.lookin_rgbaComponents forKey:@"backgroundColor"]; @@ -113,6 +120,10 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder { self.subitems = [aDecoder decodeObjectForKey:@"subitems"]; self.isHidden = [aDecoder decodeBoolForKey:@"hidden"]; self.alpha = [aDecoder decodeFloatForKey:@"alpha"]; +#if TARGET_OS_OSX + self.flipped = [aDecoder decodeBoolForKey:@"isFlipped"]; +#endif + self.windowObject = [aDecoder decodeObjectForKey:@"windowObject"]; self.viewObject = [aDecoder decodeObjectForKey:@"viewObject"]; self.layerObject = [aDecoder decodeObjectForKey:@"layerObject"]; self.hostViewControllerObject = [aDecoder decodeObjectForKey:@"hostViewControllerObject"]; @@ -151,7 +162,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder { self.frame = [aDecoder decodeCGRectForKey:@"frame"]; self.bounds = [aDecoder decodeCGRectForKey:@"bounds"]; self.backgroundColor = [UIColor lks_colorFromRGBAComponents:[aDecoder decodeObjectForKey:@"backgroundColor"]]; -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX self.frame = [aDecoder decodeRectForKey:@"frame"]; self.bounds = [aDecoder decodeRectForKey:@"bounds"]; self.backgroundColor = [NSColor lookin_colorFromRGBAComponents:[aDecoder decodeObjectForKey:@"backgroundColor"]]; @@ -175,7 +186,7 @@ - (instancetype)init { } - (LookinObject *)displayingObject { - return self.viewObject ? : self.layerObject; + return self.windowObject ? : self.viewObject ? : self.layerObject; } - (void)setAttributesGroupList:(NSArray *)attributesGroupList { @@ -342,6 +353,8 @@ - (NSString *)description { return self.viewObject.rawClassName; } else if (self.layerObject) { return self.layerObject.rawClassName; + } else if (self.windowObject) { + return self.windowObject.rawClassName; } else { return [super description]; } @@ -445,6 +458,15 @@ - (void)setHighlightedSearchString:(NSString *)highlightedSearchString { // NSLog(@"moss dealloc -%@", self); //} + +#if TARGET_OS_IPHONE +- (void)setFlipped:(BOOL)flipped {} + +- (BOOL)isFlipped { + return NO; +} +#endif + @end #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Shared/LookinHierarchyInfo.h b/Src/Main/Shared/LookinHierarchyInfo.h index 048d2f6..12bae0b 100644 --- a/Src/Main/Shared/LookinHierarchyInfo.h +++ b/Src/Main/Shared/LookinHierarchyInfo.h @@ -14,7 +14,7 @@ #import "TargetConditionals.h" #if TARGET_OS_IPHONE #import -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX #import #endif @@ -22,14 +22,7 @@ @interface LookinHierarchyInfo : NSObject -#if TARGET_OS_IPHONE - -/// version 可能为 nil,此时说明 Client 版本号 < 1.0.4 -+ (instancetype)staticInfoWithLookinVersion:(NSString *)version; -+ (instancetype)exportedInfo; - -#endif /// 这里其实就是顶端的那几个 UIWindow @property(nonatomic, copy) NSArray *displayItems; diff --git a/Src/Main/Shared/LookinHierarchyInfo.m b/Src/Main/Shared/LookinHierarchyInfo.m index 1048260..f1ef4d3 100644 --- a/Src/Main/Shared/LookinHierarchyInfo.m +++ b/Src/Main/Shared/LookinHierarchyInfo.m @@ -16,45 +16,8 @@ #import "NSArray+Lookin.h" #import "NSString+Lookin.h" -#if TARGET_OS_IPHONE -#import "LKS_HierarchyDisplayItemsMaker.h" -#import "LKSConfigManager.h" -#import "LKS_CustomAttrSetterManager.h" -#endif - @implementation LookinHierarchyInfo -#if TARGET_OS_IPHONE - -+ (instancetype)staticInfoWithLookinVersion:(NSString *)version { - BOOL readCustomInfo = NO; - // Client 1.0.4 开始支持 customInfo - if (version && [version lookin_numbericOSVersion] >= 10004) { - readCustomInfo = YES; - } - - [[LKS_CustomAttrSetterManager sharedInstance] removeAll]; - - LookinHierarchyInfo *info = [LookinHierarchyInfo new]; - info.serverVersion = LOOKIN_SERVER_VERSION; - info.displayItems = [LKS_HierarchyDisplayItemsMaker itemsWithScreenshots:NO attrList:NO lowImageQuality:NO readCustomInfo:readCustomInfo saveCustomSetter:YES]; - info.appInfo = [LookinAppInfo currentInfoWithScreenshot:NO icon:YES localIdentifiers:nil]; - info.collapsedClassList = [LKSConfigManager collapsedClassList]; - info.colorAlias = [LKSConfigManager colorAlias]; - return info; -} - -+ (instancetype)exportedInfo { - LookinHierarchyInfo *info = [LookinHierarchyInfo new]; - info.serverVersion = LOOKIN_SERVER_VERSION; - info.displayItems = [LKS_HierarchyDisplayItemsMaker itemsWithScreenshots:YES attrList:YES lowImageQuality:YES readCustomInfo:YES saveCustomSetter:NO]; - info.appInfo = [LookinAppInfo currentInfoWithScreenshot:NO icon:YES localIdentifiers:nil]; - info.collapsedClassList = [LKSConfigManager collapsedClassList]; - info.colorAlias = [LKSConfigManager colorAlias]; - return info; -} - -#endif #pragma mark - diff --git a/Src/Main/Shared/LookinObject.h b/Src/Main/Shared/LookinObject.h index 285749d..2881793 100644 --- a/Src/Main/Shared/LookinObject.h +++ b/Src/Main/Shared/LookinObject.h @@ -16,9 +16,6 @@ @interface LookinObject : NSObject -#if TARGET_OS_IPHONE -+ (instancetype)instanceWithObject:(NSObject *)object; -#endif @property(nonatomic, assign) unsigned long oid; diff --git a/Src/Main/Shared/LookinObject.m b/Src/Main/Shared/LookinObject.m index 89d8fed..6b7a328 100644 --- a/Src/Main/Shared/LookinObject.m +++ b/Src/Main/Shared/LookinObject.m @@ -13,26 +13,8 @@ #import "NSArray+Lookin.h" #import "NSString+Lookin.h" -#if TARGET_OS_IPHONE -#import "NSObject+LookinServer.h" -#endif - @implementation LookinObject -#if TARGET_OS_IPHONE -+ (instancetype)instanceWithObject:(NSObject *)object { - LookinObject *lookinObj = [LookinObject new]; - lookinObj.oid = [object lks_registerOid]; - - lookinObj.memoryAddress = [NSString stringWithFormat:@"%p", object]; - lookinObj.classChainList = [object lks_classChainList]; - - lookinObj.specialTrace = object.lks_specialTrace; - lookinObj.ivarTraces = object.lks_ivarTraces; - - return lookinObj; -} -#endif #pragma mark - diff --git a/Src/Swift/LKS_SwiftTraceManager.swift b/Src/Swift/LKS_SwiftTraceManager.swift index f1b5fdc..cd1257d 100644 --- a/Src/Swift/LKS_SwiftTraceManager.swift +++ b/Src/Swift/LKS_SwiftTraceManager.swift @@ -8,7 +8,19 @@ // import Foundation +#if canImport(AppKit) && !targetEnvironment(macCatalyst) +import AppKit +private typealias LookinView = NSView +private typealias LookinViewController = NSViewController +private typealias LookinGestureRecognizer = NSGestureRecognizer +#endif + +#if canImport(UIKit) import UIKit +private typealias LookinView = UIView +private typealias LookinViewController = UIViewController +private typealias LookinGestureRecognizer = UIGestureRecognizer +#endif #if SPM_LOOKIN_SERVER_ENABLED import LookinServerBase #endif @@ -25,7 +37,7 @@ public class LKS_SwiftTraceManager: NSObject { let label: String? = child.label?.replacingOccurrences(of: "$__lazy_storage_$_", with: "") let value = child.value - guard (value is UIView) || (value is CALayer) || (value is UIViewController) || (value is UIGestureRecognizer) else { + guard (value is LookinView) || (value is CALayer) || (value is LookinViewController) || (value is LookinGestureRecognizer) else { return } @@ -42,11 +54,11 @@ public class LKS_SwiftTraceManager: NSObject { if (value === hostObject) { ivarTrace.relation = LookinIvarTraceRelationValue_Self - } else if let hostView = hostObject as? UIView { + } else if let hostView = hostObject as? LookinView { var ivarLayer: CALayer? = nil if let layer = value as? CALayer { ivarLayer = layer - } else if let view = value as? UIView { + } else if let view = value as? LookinView { ivarLayer = view.layer } if let layer = ivarLayer, layer.superlayer === hostView.layer {