From 7d197583d33d384c17491357e2087fbd36967774 Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Sat, 17 Feb 2024 22:28:56 +0800 Subject: [PATCH 01/21] Create or update Upstream Sync workflow file. --- .github/workflows/UpstreamSync.yml | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/UpstreamSync.yml diff --git a/.github/workflows/UpstreamSync.yml b/.github/workflows/UpstreamSync.yml new file mode 100644 index 0000000..406e6ae --- /dev/null +++ b/.github/workflows/UpstreamSync.yml @@ -0,0 +1,39 @@ +name: Upstream Sync + +permissions: + contents: write + +on: + schedule: + - cron: "0 0 * * *" # every day + workflow_dispatch: + +jobs: + sync_latest_from_upstream: + name: Sync latest commits from upstream repo + runs-on: ubuntu-latest + if: ${{ github.event.repository.fork }} + + steps: + # Step 1: run a standard checkout action + - name: Checkout target repo + uses: actions/checkout@v3 + + # Step 2: run the sync action + - name: Sync upstream changes + id: sync + uses: aormsby/Fork-Sync-With-Upstream-action@v3.4 + with: + upstream_sync_repo: QMUI/LookinServer + upstream_sync_branch: develop + target_sync_branch: develop + target_repo_token: ${{ secrets.GITHUB_TOKEN }} # automatically generated, no need to set + + # Set test_mode true to run tests instead of the true action!! + test_mode: false + + - name: Sync check + if: failure() + run: | + echo "::error::Due to insufficient permissions, synchronization failed (as expected). Please go to the repository homepage and manually perform [Sync fork]." + exit 1 \ No newline at end of file From d3356c202810595ae8924e7f490455072ad0fb43 Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Fri, 1 Nov 2024 16:08:08 +0800 Subject: [PATCH 02/21] Support MacCatalyst --- .../OC_Pod/LookinDemoOC.xcodeproj/project.pbxproj | 14 ++++++++++++-- .../OC_Pod/LookinDemoOC/LookinDemoOC.entitlements | 12 ++++++++++++ LookinDemo/OC_Pod/Podfile.lock | 10 +++++----- Src/Base/LookinIvarTrace.h | 2 +- Src/Main/Shared/Category/Color+Lookin.h | 2 +- Src/Main/Shared/Category/Color+Lookin.m | 2 +- Src/Main/Shared/Category/Image+Lookin.h | 2 +- Src/Main/Shared/Category/Image+Lookin.m | 2 +- Src/Main/Shared/Category/NSObject+Lookin.m | 8 ++++---- Src/Main/Shared/Category/NSSet+Lookin.h | 2 +- Src/Main/Shared/Category/NSString+Lookin.m | 2 +- Src/Main/Shared/LookinAppInfo.h | 2 +- Src/Main/Shared/LookinAppInfo.m | 4 ++-- Src/Main/Shared/LookinAutoLayoutConstraint.h | 2 +- Src/Main/Shared/LookinAutoLayoutConstraint.m | 2 +- Src/Main/Shared/LookinCustomDisplayItemInfo.m | 4 ++-- Src/Main/Shared/LookinDefines.h | 4 ++-- Src/Main/Shared/LookinDisplayItem.h | 2 +- Src/Main/Shared/LookinDisplayItem.m | 6 +++--- Src/Main/Shared/LookinDisplayItemDetail.m | 2 +- Src/Main/Shared/LookinHierarchyInfo.h | 4 ++-- Src/Main/Shared/LookinHierarchyInfo.m | 4 ++-- Src/Main/Shared/LookinObject.h | 2 +- Src/Main/Shared/LookinObject.m | 4 ++-- 24 files changed, 61 insertions(+), 39 deletions(-) create mode 100644 LookinDemo/OC_Pod/LookinDemoOC/LookinDemoOC.entitlements 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..181debb 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: 1b2b61c6402ae29fa22182d48f5cd067b4e99e80 PODFILE CHECKSUM: c1b5f203c9e81bcbf3888ba95a03c31e2435a4f7 -COCOAPODS: 1.13.0 +COCOAPODS: 1.15.2 diff --git a/Src/Base/LookinIvarTrace.h b/Src/Base/LookinIvarTrace.h index 3904385..0a127d1 100644 --- a/Src/Base/LookinIvarTrace.h +++ b/Src/Base/LookinIvarTrace.h @@ -25,7 +25,7 @@ extern NSString *const LookinIvarTraceRelationValue_Self; #pragma mark - No Coding -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST @property(nonatomic, weak) id hostObject; #endif diff --git a/Src/Main/Shared/Category/Color+Lookin.h b/Src/Main/Shared/Category/Color+Lookin.h index 9a49ab9..18a040e 100644 --- a/Src/Main/Shared/Category/Color+Lookin.h +++ b/Src/Main/Shared/Category/Color+Lookin.h @@ -9,7 +9,7 @@ #import -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #elif TARGET_OS_MAC diff --git a/Src/Main/Shared/Category/Color+Lookin.m b/Src/Main/Shared/Category/Color+Lookin.m index 4f5ede1..f0fd4ff 100644 --- a/Src/Main/Shared/Category/Color+Lookin.m +++ b/Src/Main/Shared/Category/Color+Lookin.m @@ -9,7 +9,7 @@ #import "Image+Lookin.h" -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #elif TARGET_OS_MAC diff --git a/Src/Main/Shared/Category/Image+Lookin.h b/Src/Main/Shared/Category/Image+Lookin.h index 7fe33c8..5b807e3 100644 --- a/Src/Main/Shared/Category/Image+Lookin.h +++ b/Src/Main/Shared/Category/Image+Lookin.h @@ -9,7 +9,7 @@ #import -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #elif TARGET_OS_MAC diff --git a/Src/Main/Shared/Category/Image+Lookin.m b/Src/Main/Shared/Category/Image+Lookin.m index d285d54..1cb4aba 100644 --- a/Src/Main/Shared/Category/Image+Lookin.m +++ b/Src/Main/Shared/Category/Image+Lookin.m @@ -9,7 +9,7 @@ #import "Image+Lookin.h" -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #elif TARGET_OS_MAC diff --git a/Src/Main/Shared/Category/NSObject+Lookin.m b/Src/Main/Shared/Category/NSObject+Lookin.m index d206613..9851fba 100644 --- a/Src/Main/Shared/Category/NSObject+Lookin.m +++ b/Src/Main/Shared/Category/NSObject+Lookin.m @@ -115,7 +115,7 @@ - (long)lookin_getBindLongForKey:(NSString *)key { } - (void)lookin_bindPoint:(CGPoint)pointValue forKey:(NSString *)key { -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST [self lookin_bindObject:[NSValue valueWithCGPoint:pointValue] forKey:key]; #elif TARGET_OS_MAC NSPoint nsPoint = NSMakePoint(pointValue.x, pointValue.y); @@ -126,7 +126,7 @@ - (void)lookin_bindPoint:(CGPoint)pointValue forKey:(NSString *)key { - (CGPoint)lookin_getBindPointForKey:(NSString *)key { id object = [self lookin_getBindObjectForKey:key]; if ([object isKindOfClass:[NSValue class]]) { -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST CGPoint pointValue = [(NSValue *)object CGPointValue]; #elif TARGET_OS_MAC NSPoint nsPointValue = [(NSValue *)object pointValue]; @@ -150,7 +150,7 @@ - (id)lookin_encodedObjectWithType:(LookinCodingValueType)type { if (type == LookinCodingValueTypeColor) { if ([self isKindOfClass:[LookinColor class]]) { CGFloat r, g, b, a; -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST CGFloat white; if ([(UIColor *)self getRed:&r green:&g blue:&b alpha:&a]) { // valid @@ -178,7 +178,7 @@ - (id)lookin_encodedObjectWithType:(LookinCodingValueType)type { } } else if (type == LookinCodingValueTypeImage) { -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST if ([self isKindOfClass:[UIImage class]]) { UIImage *image = (UIImage *)self; return UIImagePNGRepresentation(image); diff --git a/Src/Main/Shared/Category/NSSet+Lookin.h b/Src/Main/Shared/Category/NSSet+Lookin.h index f09a704..1b4371d 100644 --- a/Src/Main/Shared/Category/NSSet+Lookin.h +++ b/Src/Main/Shared/Category/NSSet+Lookin.h @@ -13,7 +13,7 @@ #import "TargetConditionals.h" -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #import #elif TARGET_OS_MAC #import diff --git a/Src/Main/Shared/Category/NSString+Lookin.m b/Src/Main/Shared/Category/NSString+Lookin.m index 9b76fb5..2e80ab3 100644 --- a/Src/Main/Shared/Category/NSString+Lookin.m +++ b/Src/Main/Shared/Category/NSString+Lookin.m @@ -62,7 +62,7 @@ + (NSString *)lookin_rgbaStringFromColor:(LookinColor *)color { return @"nil"; } -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST UIColor *rgbColor = color; #elif TARGET_OS_MAC NSColor *rgbColor = [color colorUsingColorSpace:NSColorSpace.sRGBColorSpace]; diff --git a/Src/Main/Shared/LookinAppInfo.h b/Src/Main/Shared/LookinAppInfo.h index 1082d12..303cee3 100644 --- a/Src/Main/Shared/LookinAppInfo.h +++ b/Src/Main/Shared/LookinAppInfo.h @@ -57,7 +57,7 @@ typedef NS_ENUM(NSInteger, LookinAppInfoDevice) { - (BOOL)isEqualToAppInfo:(LookinAppInfo *)info; -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST + (LookinAppInfo *)currentInfoWithScreenshot:(BOOL)hasScreenshot icon:(BOOL)hasIcon localIdentifiers:(NSArray *)localIdentifiers; diff --git a/Src/Main/Shared/LookinAppInfo.m b/Src/Main/Shared/LookinAppInfo.m index 1e61d7a..c41c9a3 100644 --- a/Src/Main/Shared/LookinAppInfo.m +++ b/Src/Main/Shared/LookinAppInfo.m @@ -71,7 +71,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:self.serverReadableVersion forKey:@"serverReadableVersion"]; [aCoder encodeInt:self.swiftEnabledInLookinServer forKey:@"swiftEnabledInLookinServer"]; -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST NSData *screenshotData = UIImagePNGRepresentation(self.screenshot); [aCoder encodeObject:screenshotData forKey:CodingKey_Screenshot]; @@ -129,7 +129,7 @@ - (BOOL)isEqualToAppInfo:(LookinAppInfo *)info { return NO; } -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST + (LookinAppInfo *)currentInfoWithScreenshot:(BOOL)hasScreenshot icon:(BOOL)hasIcon localIdentifiers:(NSArray *)localIdentifiers { NSInteger selfIdentifier = [self getAppInfoIdentifier]; diff --git a/Src/Main/Shared/LookinAutoLayoutConstraint.h b/Src/Main/Shared/LookinAutoLayoutConstraint.h index 3edf865..a219073 100644 --- a/Src/Main/Shared/LookinAutoLayoutConstraint.h +++ b/Src/Main/Shared/LookinAutoLayoutConstraint.h @@ -25,7 +25,7 @@ typedef NS_ENUM(NSInteger, LookinConstraintItemType) { @interface LookinAutoLayoutConstraint : NSObject -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST + (instancetype)instanceFromNSConstraint:(NSLayoutConstraint *)constraint isEffective:(BOOL)isEffective firstItemType:(LookinConstraintItemType)firstItemType secondItemType:(LookinConstraintItemType)secondItemType; #endif diff --git a/Src/Main/Shared/LookinAutoLayoutConstraint.m b/Src/Main/Shared/LookinAutoLayoutConstraint.m index a8e4520..a173269 100644 --- a/Src/Main/Shared/LookinAutoLayoutConstraint.m +++ b/Src/Main/Shared/LookinAutoLayoutConstraint.m @@ -15,7 +15,7 @@ @implementation LookinAutoLayoutConstraint -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST + (instancetype)instanceFromNSConstraint:(NSLayoutConstraint *)constraint isEffective:(BOOL)isEffective firstItemType:(LookinConstraintItemType)firstItemType secondItemType:(LookinConstraintItemType)secondItemType { LookinAutoLayoutConstraint *instance = [LookinAutoLayoutConstraint new]; diff --git a/Src/Main/Shared/LookinCustomDisplayItemInfo.m b/Src/Main/Shared/LookinCustomDisplayItemInfo.m index a59778a..fb164dc 100644 --- a/Src/Main/Shared/LookinCustomDisplayItemInfo.m +++ b/Src/Main/Shared/LookinCustomDisplayItemInfo.m @@ -8,7 +8,7 @@ // #import "LookinCustomDisplayItemInfo.h" -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #import #endif @@ -18,7 +18,7 @@ - (id)copyWithZone:(NSZone *)zone { LookinCustomDisplayItemInfo *newInstance = [[LookinCustomDisplayItemInfo allocWithZone:zone] init]; if (self.frameInWindow) { -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST CGRect rect = [self.frameInWindow CGRectValue]; newInstance.frameInWindow = [NSValue valueWithCGRect:rect]; #elif TARGET_OS_MAC diff --git a/Src/Main/Shared/LookinDefines.h b/Src/Main/Shared/LookinDefines.h index f00540d..c41d1bb 100644 --- a/Src/Main/Shared/LookinDefines.h +++ b/Src/Main/Shared/LookinDefines.h @@ -9,7 +9,7 @@ // #import "TargetConditionals.h" -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #import #elif TARGET_OS_MAC #import @@ -140,7 +140,7 @@ enum { #pragma mark - Colors -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #define LookinColor UIColor #define LookinInsets UIEdgeInsets #define LookinImage UIImage diff --git a/Src/Main/Shared/LookinDisplayItem.h b/Src/Main/Shared/LookinDisplayItem.h index cea7247..ca5fd12 100644 --- a/Src/Main/Shared/LookinDisplayItem.h +++ b/Src/Main/Shared/LookinDisplayItem.h @@ -12,7 +12,7 @@ #import "LookinObject.h" #import "LookinDefines.h" #import "LookinCustomDisplayItemInfo.h" -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #import #elif TARGET_OS_MAC #import diff --git a/Src/Main/Shared/LookinDisplayItem.m b/Src/Main/Shared/LookinDisplayItem.m index 82ef8d9..b5d10d1 100644 --- a/Src/Main/Shared/LookinDisplayItem.m +++ b/Src/Main/Shared/LookinDisplayItem.m @@ -19,7 +19,7 @@ #import "NSObject+Lookin.h" #import "LookinDashboardBlueprint.h" -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #import "UIColor+LookinServer.h" #import "UIImage+LookinServer.h" #elif TARGET_OS_MAC @@ -95,7 +95,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { } [aCoder encodeObject:self.customDisplayTitle forKey:@"customDisplayTitle"]; [aCoder encodeObject:self.danceuiSource forKey:@"danceuiSource"]; -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST [aCoder encodeCGRect:self.frame forKey:@"frame"]; [aCoder encodeCGRect:self.bounds forKey:@"bounds"]; [aCoder encodeObject:self.backgroundColor.lks_rgbaComponents forKey:@"backgroundColor"]; @@ -147,7 +147,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder { self.shouldCaptureImage = [aDecoder containsValueForKey:@"shouldCaptureImage"] ? [aDecoder decodeBoolForKey:@"shouldCaptureImage"] : YES; self.customDisplayTitle = [aDecoder decodeObjectForKey:@"customDisplayTitle"]; self.danceuiSource = [aDecoder decodeObjectForKey:@"danceuiSource"]; -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST self.frame = [aDecoder decodeCGRectForKey:@"frame"]; self.bounds = [aDecoder decodeCGRectForKey:@"bounds"]; self.backgroundColor = [UIColor lks_colorFromRGBAComponents:[aDecoder decodeObjectForKey:@"backgroundColor"]]; diff --git a/Src/Main/Shared/LookinDisplayItemDetail.m b/Src/Main/Shared/LookinDisplayItemDetail.m index 195c03c..26bea29 100644 --- a/Src/Main/Shared/LookinDisplayItemDetail.m +++ b/Src/Main/Shared/LookinDisplayItemDetail.m @@ -11,7 +11,7 @@ #import "LookinDisplayItemDetail.h" #import "Image+Lookin.h" -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #import "UIImage+LookinServer.h" #endif diff --git a/Src/Main/Shared/LookinHierarchyInfo.h b/Src/Main/Shared/LookinHierarchyInfo.h index 048d2f6..b39a9a3 100644 --- a/Src/Main/Shared/LookinHierarchyInfo.h +++ b/Src/Main/Shared/LookinHierarchyInfo.h @@ -12,7 +12,7 @@ #import "LookinDefines.h" #import "TargetConditionals.h" -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #import #elif TARGET_OS_MAC #import @@ -22,7 +22,7 @@ @interface LookinHierarchyInfo : NSObject -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST /// version 可能为 nil,此时说明 Client 版本号 < 1.0.4 + (instancetype)staticInfoWithLookinVersion:(NSString *)version; diff --git a/Src/Main/Shared/LookinHierarchyInfo.m b/Src/Main/Shared/LookinHierarchyInfo.m index 1048260..f025c2e 100644 --- a/Src/Main/Shared/LookinHierarchyInfo.m +++ b/Src/Main/Shared/LookinHierarchyInfo.m @@ -16,7 +16,7 @@ #import "NSArray+Lookin.h" #import "NSString+Lookin.h" -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #import "LKS_HierarchyDisplayItemsMaker.h" #import "LKSConfigManager.h" #import "LKS_CustomAttrSetterManager.h" @@ -24,7 +24,7 @@ @implementation LookinHierarchyInfo -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST + (instancetype)staticInfoWithLookinVersion:(NSString *)version { BOOL readCustomInfo = NO; diff --git a/Src/Main/Shared/LookinObject.h b/Src/Main/Shared/LookinObject.h index 285749d..775d739 100644 --- a/Src/Main/Shared/LookinObject.h +++ b/Src/Main/Shared/LookinObject.h @@ -16,7 +16,7 @@ @interface LookinObject : NSObject -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST + (instancetype)instanceWithObject:(NSObject *)object; #endif diff --git a/Src/Main/Shared/LookinObject.m b/Src/Main/Shared/LookinObject.m index 89d8fed..cd44772 100644 --- a/Src/Main/Shared/LookinObject.m +++ b/Src/Main/Shared/LookinObject.m @@ -13,13 +13,13 @@ #import "NSArray+Lookin.h" #import "NSString+Lookin.h" -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #import "NSObject+LookinServer.h" #endif @implementation LookinObject -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST + (instancetype)instanceWithObject:(NSObject *)object { LookinObject *lookinObj = [LookinObject new]; lookinObj.oid = [object lks_registerOid]; From f87a53b33f6ecb29618f72f1003ad7b9ade85c04 Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Tue, 5 Nov 2024 18:06:04 +0800 Subject: [PATCH 03/21] AppKit Support --- .../AppKitDemo.xcodeproj/project.pbxproj | 421 ++++++++++ .../contents.xcworkspacedata | 7 + .../contents.xcworkspacedata | 10 + .../AppKitDemo/AppKitDemo/AppDelegate.swift | 30 + .../AppKitDemo/AppKitDemo.entitlements | 14 + .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 58 ++ .../AppKitDemo/Assets.xcassets/Contents.json | 6 + .../AppKitDemo/Base.lproj/Main.storyboard | 717 ++++++++++++++++++ .../AppKitDemo/ViewController.swift | 26 + LookinDemo/AppKitDemo/Podfile | 5 + LookinDemo/AppKitDemo/Podfile.lock | 18 + LookinDemo/OC_Pod/Podfile.lock | 2 +- LookinServer.podspec | 6 +- Src/Base/LookinIvarTrace.h | 2 - .../Server/Category/CALayer+LookinServer.h | 22 +- .../Server/Category/CALayer+LookinServer.m | 88 ++- .../Category/UIBlurEffect+LookinServer.h | 4 + .../Category/UIBlurEffect+LookinServer.m | 4 + .../Server/Category/UIColor+LookinServer.h | 12 +- .../Server/Category/UIColor+LookinServer.m | 16 +- .../Server/Category/UIImage+LookinServer.h | 10 +- .../Server/Category/UIImage+LookinServer.m | 29 +- .../Category/UIImageView+LookinServer.h | 10 +- .../Category/UIImageView+LookinServer.m | 2 +- .../Server/Category/UILabel+LookinServer.h | 5 + .../Server/Category/UILabel+LookinServer.m | 5 + .../Category/UITableView+LookinServer.h | 5 + .../Category/UITableView+LookinServer.m | 5 + .../Category/UITextField+LookinServer.h | 5 + .../Category/UITextField+LookinServer.m | 5 + .../Server/Category/UITextView+LookinServer.h | 5 + .../Server/Category/UITextView+LookinServer.m | 5 + .../Server/Category/UIView+LookinServer.h | 12 +- .../Server/Category/UIView+LookinServer.m | 105 ++- .../Category/UIViewController+LookinServer.h | 12 +- .../Category/UIViewController+LookinServer.m | 35 +- .../UIVisualEffectView+LookinServer.h | 5 + .../UIVisualEffectView+LookinServer.m | 5 + .../Server/Connection/LKS_ConnectionManager.h | 4 + .../Server/Connection/LKS_ConnectionManager.m | 19 + .../Server/Connection/LKS_RequestHandler.m | 23 +- .../LKS_CustomAttrModificationHandler.m | 6 +- .../LKS_HierarchyDetailsHandler.m | 8 +- .../LKS_InbuiltAttrModificationHandler.m | 16 +- Src/Main/Server/Others/LKSConfigManager.h | 10 +- Src/Main/Server/Others/LKSConfigManager.m | 16 +- Src/Main/Server/Others/LKS_AttrGroupsMaker.m | 14 +- .../Server/Others/LKS_CustomAttrGroupsMaker.m | 12 +- .../Others/LKS_CustomAttrSetterManager.h | 12 +- .../Others/LKS_CustomDisplayItemsMaker.h | 8 + .../Others/LKS_CustomDisplayItemsMaker.m | 4 +- .../Server/Others/LKS_EventHandlerMaker.h | 2 +- .../Server/Others/LKS_EventHandlerMaker.m | 141 +++- Src/Main/Server/Others/LKS_ExportManager.m | 11 +- .../Others/LKS_GestureTargetActionsSearcher.h | 10 +- .../Others/LKS_GestureTargetActionsSearcher.m | 2 +- .../Others/LKS_HierarchyDisplayItemsMaker.m | 22 +- .../Server/Others/LKS_MultiplatformAdapter.h | 12 +- .../Server/Others/LKS_MultiplatformAdapter.m | 33 +- Src/Main/Server/Others/LKS_TraceManager.m | 136 +++- Src/Main/Shared/Category/NSValue+Lookin.h | 40 + Src/Main/Shared/Category/NSValue+Lookin.m | 87 +++ Src/Main/Shared/LookinAppInfo.h | 6 - Src/Main/Shared/LookinAppInfo.m | 56 +- Src/Main/Shared/LookinAutoLayoutConstraint.h | 2 - Src/Main/Shared/LookinAutoLayoutConstraint.m | 4 - Src/Main/Shared/LookinDefines.h | 38 +- Src/Main/Shared/LookinHierarchyInfo.h | 4 - Src/Main/Shared/LookinHierarchyInfo.m | 7 - Src/Main/Shared/LookinObject.h | 2 - Src/Main/Shared/LookinObject.m | 5 - 72 files changed, 2269 insertions(+), 247 deletions(-) create mode 100644 LookinDemo/AppKitDemo/AppKitDemo.xcodeproj/project.pbxproj create mode 100644 LookinDemo/AppKitDemo/AppKitDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 LookinDemo/AppKitDemo/AppKitDemo.xcworkspace/contents.xcworkspacedata create mode 100644 LookinDemo/AppKitDemo/AppKitDemo/AppDelegate.swift create mode 100644 LookinDemo/AppKitDemo/AppKitDemo/AppKitDemo.entitlements create mode 100644 LookinDemo/AppKitDemo/AppKitDemo/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 LookinDemo/AppKitDemo/AppKitDemo/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 LookinDemo/AppKitDemo/AppKitDemo/Assets.xcassets/Contents.json create mode 100644 LookinDemo/AppKitDemo/AppKitDemo/Base.lproj/Main.storyboard create mode 100644 LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift create mode 100644 LookinDemo/AppKitDemo/Podfile create mode 100644 LookinDemo/AppKitDemo/Podfile.lock create mode 100644 Src/Main/Shared/Category/NSValue+Lookin.h create mode 100644 Src/Main/Shared/Category/NSValue+Lookin.m 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..40b639e --- /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..99f7fe7 --- /dev/null +++ b/LookinDemo/AppKitDemo/AppKitDemo/Base.lproj/Main.storyboard @@ -0,0 +1,717 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..1a31dd1 --- /dev/null +++ b/LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift @@ -0,0 +1,26 @@ +// +// ViewController.swift +// AppKitDemo +// +// Created by JH on 2024/11/5. +// + +import Cocoa + +class ViewController: NSViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + override var representedObject: Any? { + didSet { + // Update the view, if already loaded. + } + } + + +} + 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..1be7b26 --- /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: 1035f6880a1ccdada647fbd1f59b44ddd005fdf4 + +PODFILE CHECKSUM: 0eea96142f9864079641953fac183889175edfb2 + +COCOAPODS: 1.15.2 diff --git a/LookinDemo/OC_Pod/Podfile.lock b/LookinDemo/OC_Pod/Podfile.lock index 181debb..c109a67 100644 --- a/LookinDemo/OC_Pod/Podfile.lock +++ b/LookinDemo/OC_Pod/Podfile.lock @@ -11,7 +11,7 @@ EXTERNAL SOURCES: :path: "../../" SPEC CHECKSUMS: - LookinServer: 1b2b61c6402ae29fa22182d48f5cd067b4e99e80 + LookinServer: 1035f6880a1ccdada647fbd1f59b44ddd005fdf4 PODFILE CHECKSUM: c1b5f203c9e81bcbf3888ba95a03c31e2435a4f7 diff --git a/LookinServer.podspec b/LookinServer.podspec index c5ce5fc..33f9c43 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.osx.deployment_target = "10.13" 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.osx.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/Src/Base/LookinIvarTrace.h b/Src/Base/LookinIvarTrace.h index 0a127d1..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 || TARGET_OS_MACCATALYST @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..a10436b 100644 --- a/Src/Main/Server/Category/CALayer+LookinServer.h +++ b/Src/Main/Server/Category/CALayer+LookinServer.h @@ -10,29 +10,35 @@ #import "LookinDefines.h" #import "TargetConditionals.h" +#if TARGET_OS_IPHONE #import +#endif + +#if TARGET_OS_OSX +#import +#endif @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..596fa86 100644 --- a/Src/Main/Server/Category/CALayer+LookinServer.m +++ b/Src/Main/Server/Category/CALayer+LookinServer.m @@ -20,36 +20,43 @@ @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; + } else if ([hostView isKindOfClass:[LookinWindow class]]) { + return (LookinWindow *)hostView; } 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]; +#endif + +#if TARGET_OS_OSX + CGRect rectInSelfWindow = [selfWindow.contentView.layer convertRect:self.frame fromLayer:self.superlayer]; + CGRect rectInWindow = [window.contentView convertRect:rectInSelfWindow fromView:selfWindow.contentView]; +#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 +66,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 +88,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 +99,19 @@ - (UIImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality { UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; +#endif + +#if TARGET_OS_OSX + NSImage *image = [NSImage imageWithSize:contextSize flipped:YES drawingHandler:^BOOL(NSRect dstRect) { + CGContextRef context = NSGraphicsContext.currentContext.CGContext; + [self renderInContext:context]; + return YES; + }]; + return image; +#endif } -- (UIImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { +- (LookinImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { if (!self.sublayers.count) { return nil; } @@ -129,6 +147,7 @@ - (UIImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { return nil; } +#if TARGET_OS_IPHONE UIGraphicsBeginImageContextWithOptions(contextSize, NO, renderScale); CGContextRef context = UIGraphicsGetCurrentContext(); if (self.lks_hostView && !self.lks_hostView.lks_isChildrenViewOfTabBar) { @@ -139,16 +158,26 @@ - (UIImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); + +#endif + +#if TARGET_OS_OSX + NSImage *image = [NSImage imageWithSize:contextSize flipped:YES drawingHandler:^BOOL(NSRect dstRect) { + CGContextRef context = NSGraphicsContext.currentContext.CGContext; + [self renderInContext:context]; + return YES; + }]; +#endif [visibleSublayers enumerateObjectsUsingBlock:^(CALayer * _Nonnull sublayer, NSUInteger idx, BOOL * _Nonnull stop) { sublayer.hidden = NO; }]; - return image; } return nil; } - (NSArray *> *)lks_relatedClassChainList { +#if TARGET_OS_IPHONE NSMutableArray *array = [NSMutableArray arrayWithCapacity:2]; if (self.lks_hostView) { [array addObject:[CALayer lks_getClassListOfObject:self.lks_hostView endingClass:@"UIView"]]; @@ -160,6 +189,21 @@ - (UIImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { [array addObject:[CALayer lks_getClassListOfObject:self endingClass:@"CALayer"]]; } return array.copy; +#endif + +#if TARGET_OS_OSX + NSMutableArray *array = [NSMutableArray arrayWithCapacity:2]; + if (self.lks_hostView) { + [array addObject:[CALayer lks_getClassListOfObject:self.lks_hostView endingClass:@"NSView"]]; + NSViewController* vc = [self.lks_hostView lks_findHostViewController]; + if (vc) { + [array addObject:[CALayer lks_getClassListOfObject:vc endingClass:@"NSViewController"]]; + } + } else { + [array addObject:[CALayer lks_getClassListOfObject:self endingClass:@"CALayer"]]; + } + return array.copy; +#endif } + (NSArray *)lks_getClassListOfObject:(id)object endingClass:(NSString *)endingClass { @@ -175,7 +219,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 +237,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/UIBlurEffect+LookinServer.h b/Src/Main/Server/Category/UIBlurEffect+LookinServer.h index 1623a8d..1f80d87 100644 --- a/Src/Main/Server/Category/UIBlurEffect+LookinServer.h +++ b/Src/Main/Server/Category/UIBlurEffect+LookinServer.h @@ -8,6 +8,8 @@ // https://lookin.work // +#if TARGET_OS_IPHONE + #import @interface UIBlurEffect (LookinServer) @@ -18,4 +20,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..6c466fa 100644 --- a/Src/Main/Server/Category/UIBlurEffect+LookinServer.m +++ b/Src/Main/Server/Category/UIBlurEffect+LookinServer.m @@ -8,6 +8,8 @@ // https://lookin.work // +#if TARGET_OS_IPHONE + #import "UIBlurEffect+LookinServer.h" #import "NSObject+Lookin.h" #import @@ -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..eab0dcf 100644 --- a/Src/Main/Server/Category/UIColor+LookinServer.h +++ b/Src/Main/Server/Category/UIColor+LookinServer.h @@ -8,9 +8,17 @@ // https://lookin.work // +#if TARGET_OS_IPHONE #import +#endif -@interface UIColor (LookinServer) +#if TARGET_OS_OSX +#import +#endif + +#import "LookinDefines.h" + +@interface LookinColor (LookinServer) - (NSArray *)lks_rgbaComponents; + (instancetype)lks_colorFromRGBAComponents:(NSArray *)components; @@ -19,7 +27,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..9308059 100644 --- a/Src/Main/Server/Category/UIImage+LookinServer.h +++ b/Src/Main/Server/Category/UIImage+LookinServer.h @@ -8,9 +8,17 @@ // https://lookin.work // +#if TARGET_OS_IPHONE #import +#endif -@interface UIImage (LookinServer) +#if TARGET_OS_OSX +#import +#endif + +#import "LookinDefines.h" + +@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..cd6fc1c 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 self.TIFFRepresentation; +#endif } @end diff --git a/Src/Main/Server/Category/UIImageView+LookinServer.h b/Src/Main/Server/Category/UIImageView+LookinServer.h index 6da9028..da6a8fc 100644 --- a/Src/Main/Server/Category/UIImageView+LookinServer.h +++ b/Src/Main/Server/Category/UIImageView+LookinServer.h @@ -8,9 +8,17 @@ // https://lookin.work // +#if TARGET_OS_IPHONE #import +#endif -@interface UIImageView (LookinServer) +#if TARGET_OS_OSX +#import +#endif + +#import "LookinDefines.h" + +@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..fd899af 100644 --- a/Src/Main/Server/Category/UILabel+LookinServer.h +++ b/Src/Main/Server/Category/UILabel+LookinServer.h @@ -8,6 +8,7 @@ // https://lookin.work // +#if TARGET_OS_IPHONE #import @interface UILabel (LookinServer) @@ -17,5 +18,9 @@ - (NSString *)lks_fontName; @end +#endif + +#if TARGET_OS_OSX +#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..dedc470 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,9 @@ - (NSString *)lks_fontName { } @end +#endif + +#if TARGET_OS_OSX +#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..f9d8cf7 100644 --- a/Src/Main/Server/Category/UITableView+LookinServer.h +++ b/Src/Main/Server/Category/UITableView+LookinServer.h @@ -8,6 +8,7 @@ // https://lookin.work // +#if TARGET_OS_IPHONE #import @interface UITableView (LookinServer) @@ -15,5 +16,9 @@ - (NSArray *)lks_numberOfRows; @end +#endif + +#if TARGET_OS_OSX +#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..6768428 100644 --- a/Src/Main/Server/Category/UITextField+LookinServer.h +++ b/Src/Main/Server/Category/UITextField+LookinServer.h @@ -8,6 +8,7 @@ // https://lookin.work // +#if TARGET_OS_IPHONE #import @interface UITextField (LookinServer) @@ -17,5 +18,9 @@ - (NSString *)lks_fontName; @end +#endif + +#if TARGET_OS_OSX +#endif #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..203d75d 100644 --- a/Src/Main/Server/Category/UITextField+LookinServer.m +++ b/Src/Main/Server/Category/UITextField+LookinServer.m @@ -8,6 +8,7 @@ // https://lookin.work // +#if TARGET_OS_IPHONE #import "UITextField+LookinServer.h" @implementation UITextField (LookinServer) @@ -25,5 +26,9 @@ - (NSString *)lks_fontName { } @end +#endif + +#if TARGET_OS_OSX +#endif #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Category/UITextView+LookinServer.h b/Src/Main/Server/Category/UITextView+LookinServer.h index e36b2ab..db28a62 100644 --- a/Src/Main/Server/Category/UITextView+LookinServer.h +++ b/Src/Main/Server/Category/UITextView+LookinServer.h @@ -8,6 +8,7 @@ // https://lookin.work // +#if TARGET_OS_IPHONE #import @interface UITextView (LookinServer) @@ -17,5 +18,9 @@ - (NSString *)lks_fontName; @end +#endif + +#if TARGET_OS_OSX +#endif #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Category/UITextView+LookinServer.m b/Src/Main/Server/Category/UITextView+LookinServer.m index bd81a8b..37452b4 100644 --- a/Src/Main/Server/Category/UITextView+LookinServer.m +++ b/Src/Main/Server/Category/UITextView+LookinServer.m @@ -8,6 +8,7 @@ // https://lookin.work // +#if TARGET_OS_IPHONE #import "UITextView+LookinServer.h" @implementation UITextView (LookinServer) @@ -25,5 +26,9 @@ - (NSString *)lks_fontName { } @end +#endif + +#if TARGET_OS_OSX +#endif #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Category/UIView+LookinServer.h b/Src/Main/Server/Category/UIView+LookinServer.h index eca36a1..6b9356e 100644 --- a/Src/Main/Server/Category/UIView+LookinServer.h +++ b/Src/Main/Server/Category/UIView+LookinServer.h @@ -9,18 +9,24 @@ // #import "LookinDefines.h" +#if TARGET_OS_IPHONE #import +#endif -@interface UIView (LookinServer) +#if TARGET_OS_OSX +#import +#endif + +@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; diff --git a/Src/Main/Server/Category/UIView+LookinServer.m b/Src/Main/Server/Category/UIView+LookinServer.m index 9cfa5f3..1081163 100644 --- a/Src/Main/Server/Category/UIView+LookinServer.m +++ b/Src/Main/Server/Category/UIView+LookinServer.m @@ -15,24 +15,49 @@ #import "LookinServerDefines.h" #import "LKS_MultiplatformAdapter.h" -@implementation UIView (LookinServer) +@implementation LookinView (LookinServer) -- (UIViewController *)lks_findHostViewController { - UIResponder *responder = [self nextResponder]; +#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 + +- (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 +65,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 +83,17 @@ - (UIView *)lks_subviewAtPoint:(CGPoint)point preferredClasses:(NSArray * } - (CGSize)lks_bestSize { +#if TARGET_OS_IPHONE return [self sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)]; +#endif + +#if TARGET_OS_OSX + if ([self isKindOfClass:[NSControl class]]) { + return [((NSControl *)self) sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)]; + } else { + return self.bounds.size; + } +#endif } - (CGFloat)lks_bestWidth { @@ -77,54 +112,66 @@ - (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]; +#endif + +#if TARGET_OS_OSX + [self lks_removeInvolvedRawConstraintsForViewsRootedByView:window.contentView]; +#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]; +#endif + +#if TARGET_OS_OSX + [self lks_addInvolvedRawConstraintsForViewsRootedByView:window.contentView]; +#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 +179,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 +208,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,7 +239,7 @@ - (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; } } @@ -202,7 +249,7 @@ - (LookinConstraintItemType)_lks_constraintItemTypeForItem:(id)item { return LookinConstraintItemTypeLayoutGuide; } - if ([item isKindOfClass:[UIView class]]) { + if ([item isKindOfClass:[LookinView class]]) { return LookinConstraintItemTypeView; } diff --git a/Src/Main/Server/Category/UIViewController+LookinServer.h b/Src/Main/Server/Category/UIViewController+LookinServer.h index 1cab2a6..b28af81 100644 --- a/Src/Main/Server/Category/UIViewController+LookinServer.h +++ b/Src/Main/Server/Category/UIViewController+LookinServer.h @@ -8,11 +8,19 @@ // https://lookin.work // +#if TARGET_OS_IPHONE #import +#endif -@interface UIViewController (LookinServer) +#if TARGET_OS_OSX +#import +#endif -+ (UIViewController *)lks_visibleViewController; +#import "LookinDefines.h" + +@interface LookinViewController (LookinServer) + ++ (LookinViewController *)lks_visibleViewController; @end diff --git a/Src/Main/Server/Category/UIViewController+LookinServer.m b/Src/Main/Server/Category/UIViewController+LookinServer.m index 2833eab..1ee54da 100644 --- a/Src/Main/Server/Category/UIViewController+LookinServer.m +++ b/Src/Main/Server/Category/UIViewController+LookinServer.m @@ -13,17 +13,27 @@ #import #import "LKS_MultiplatformAdapter.h" -@implementation UIViewController (LookinServer) +@implementation LookinViewController (LookinServer) -+ (nullable UIViewController *)lks_visibleViewController { ++ (nullable LookinViewController *)lks_visibleViewController { +#if TARGET_OS_IPHONE - UIViewController *rootViewController = [LKS_MultiplatformAdapter keyWindow].rootViewController; - UIViewController *visibleViewController = [rootViewController lks_visibleViewControllerIfExist]; + LookinViewController *rootViewController = [LKS_MultiplatformAdapter keyWindow].rootViewController; + LookinViewController *visibleViewController = [rootViewController lks_visibleViewControllerIfExist]; return visibleViewController; +#endif + +#if TARGET_OS_OSX + + 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 +51,21 @@ - (UIViewController *)lks_visibleViewControllerIfExist { } else { return nil; } +#endif + +#if TARGET_OS_OSX + if (self.presentedViewControllers) { + for (NSViewController *presentedViewController in self.presentedViewControllers) { + return [self.presentingViewController 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..164ef45 100644 --- a/Src/Main/Server/Category/UIVisualEffectView+LookinServer.h +++ b/Src/Main/Server/Category/UIVisualEffectView+LookinServer.h @@ -8,6 +8,7 @@ // https://lookin.work // +#if TARGET_OS_IPHONE #import @interface UIVisualEffectView (LookinServer) @@ -17,5 +18,9 @@ - (NSNumber *)lks_blurEffectStyleNumber; @end +#endif + +#if TARGET_OS_OSX +#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..48cb793 100644 --- a/Src/Main/Server/Connection/LKS_ConnectionManager.h +++ b/Src/Main/Server/Connection/LKS_ConnectionManager.h @@ -8,7 +8,11 @@ // https://lookin.work // +#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #import +#elif TARGET_OS_MAC +#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..c1bb1d2 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,15 @@ - (void)_handleLocalInspect:(NSNotification *)note { UIViewController *rootViewController = [keyWindow rootViewController]; [rootViewController presentViewController:alertController animated:YES completion:nil]; +#endif + +#if 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..af29fcc 100644 --- a/Src/Main/Server/Connection/LKS_RequestHandler.m +++ b/Src/Main/Server/Connection/LKS_RequestHandler.m @@ -26,6 +26,7 @@ #import "LKS_AttrModificationPatchHandler.h" #import "LKS_HierarchyDetailsHandler.h" #import "LookinStaticAsyncUpdateTask.h" +#import "NSValue+Lookin.h" @interface LKS_RequestHandler () @@ -249,16 +250,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 +272,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 +503,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_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..c7bea77 100644 --- a/Src/Main/Server/Connection/RequestHandler/LKS_HierarchyDetailsHandler.m +++ b/Src/Main/Server/Connection/RequestHandler/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]; } @@ -82,10 +82,10 @@ - (void)_dequeueAndHandlePackage { 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; } diff --git a/Src/Main/Server/Connection/RequestHandler/LKS_InbuiltAttrModificationHandler.m b/Src/Main/Server/Connection/RequestHandler/LKS_InbuiltAttrModificationHandler.m index 7911609..37afdce 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; @@ -240,10 +242,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..6cbddb1 100644 --- a/Src/Main/Server/Others/LKSConfigManager.h +++ b/Src/Main/Server/Others/LKSConfigManager.h @@ -7,7 +7,15 @@ // Created by likai.123 on 2023/1/10. // +#if TARGET_OS_IPHONE #import +#endif + +#if TARGET_OS_OSX +#import +#endif + +#import "LookinDefines.h" NS_ASSUME_NONNULL_BEGIN @@ -15,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN + (NSArray *)collapsedClassList; -+ (NSDictionary *)colorAlias; ++ (NSDictionary *)colorAlias; + (BOOL)shouldCaptureScreenshotOfLayer:(CALayer *)layer; diff --git a/Src/Main/Server/Others/LKSConfigManager.m b/Src/Main/Server/Others/LKSConfigManager.m index 830866a..672db21 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; } @@ -155,7 +155,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.m b/Src/Main/Server/Others/LKS_AttrGroupsMaker.m index c140f21..4f2fb27 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 { @@ -251,18 +251,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 valueWithEdgeInsets: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 +278,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.m b/Src/Main/Server/Others/LKS_CustomAttrGroupsMaker.m index 428b683..4fa1d6f 100644 --- a/Src/Main/Server/Others/LKS_CustomAttrGroupsMaker.m +++ b/Src/Main/Server/Others/LKS_CustomAttrGroupsMaker.m @@ -54,7 +54,7 @@ - (void)execute { for (NSString *name in selectors) { [self makeAttrsForViewOrLayer:self.layer selectorName:name]; - UIView *view = self.layer.lks_hostView; + LookinView *view = self.layer.lks_hostView; if (view) { [self makeAttrsForViewOrLayer:view selectorName:name]; } @@ -91,7 +91,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 +239,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 +372,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..887d171 100644 --- a/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.h +++ b/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.h @@ -7,7 +7,15 @@ // Created by likai.123 on 2023/11/1. // +#if TARGET_OS_IPHONE #import +#endif + +#if TARGET_OS_OSX +#import +#endif + +#import "LookinDefines.h" @class LookinDisplayItem; diff --git a/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.m b/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.m index bdffcfc..9d911f8 100644 --- a/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.m +++ b/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.m @@ -46,7 +46,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 +63,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..b949783 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,6 +113,15 @@ + (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 #endif }); @@ -135,17 +143,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)]; } +#endif +#if 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; +#endif + +#if TARGET_OS_OSX + NSSet *allTargets = control.target; +#endif if (!allTargets.count) { return nil; @@ -153,9 +209,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 +232,23 @@ + (NSString *)_inheritedRecognizerNameForRecognizer:(UIGestureRecognizer *)recog [handlers addObject:handler]; } }]; +#endif + +#if 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: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 +278,58 @@ + (NSString *)_nameFromControlEvent:(UIControlEvents)event { NSString *name = eventsAndNames[@(event)]; return name; } +#endif + +#if 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..a7889aa 100644 --- a/Src/Main/Server/Others/LKS_ExportManager.m +++ b/Src/Main/Server/Others/LKS_ExportManager.m @@ -16,6 +16,7 @@ #import "LookinServerDefines.h" #import "LKS_MultiplatformAdapter.h" +#if TARGET_OS_IPHONE @interface LKS_ExportManagerMaskView : UIView @property(nonatomic, strong) UIView *tipsView; @@ -87,15 +88,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 +119,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..9f1026a 100644 --- a/Src/Main/Server/Others/LKS_GestureTargetActionsSearcher.h +++ b/Src/Main/Server/Others/LKS_GestureTargetActionsSearcher.h @@ -7,7 +7,15 @@ // Created by likai.123 on 2023/9/11. // +#if TARGET_OS_IPHONE #import +#endif + +#if TARGET_OS_OSX +#import +#endif + +#import "LookinDefines.h" @class LookinTwoTuple; @@ -17,7 +25,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.m b/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m index 4207a43..127cd51 100644 --- a/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m +++ b/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m @@ -20,17 +20,23 @@ #import "LKS_CustomDisplayItemsMaker.h" #import "LKS_CustomAttrSetterManager.h" #import "LKS_MultiplatformAdapter.h" - +#import "NSValue+Lookin.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]; +#endif + +#if TARGET_OS_OSX + LookinDisplayItem *item = [self _displayItemWithLayer:window.contentView.layer screenshots:hasScreenshots attrList:hasAttrList lowImageQuality:lowQuality readCustomInfo:readCustomInfo saveCustomSetter:saveCustomSetter]; +#endif item.representedAsKeyWindow = window.isKeyWindow; if (item) { [resultArray addObject:item]; @@ -47,7 +53,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]; } @@ -79,17 +85,17 @@ + (LookinDisplayItem *)_displayItemWithLayer:(CALayer *)layer screenshots:(BOOL) item.shouldCaptureImage = [LKSConfigManager shouldCaptureScreenshotOfLayer:layer]; if (layer.lks_hostView) { - UIView *view = layer.lks_hostView; + LookinView *view = layer.lks_hostView; 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]; + item.backgroundColor = [LookinColor lks_colorWithCGColor:layer.backgroundColor]; } if (layer.sublayers.count) { diff --git a/Src/Main/Server/Others/LKS_MultiplatformAdapter.h b/Src/Main/Server/Others/LKS_MultiplatformAdapter.h index dc13f64..e40fcde 100644 --- a/Src/Main/Server/Others/LKS_MultiplatformAdapter.h +++ b/Src/Main/Server/Others/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; diff --git a/Src/Main/Server/Others/LKS_MultiplatformAdapter.m b/Src/Main/Server/Others/LKS_MultiplatformAdapter.m index 8c04b98..e3589ec 100644 --- a/Src/Main/Server/Others/LKS_MultiplatformAdapter.m +++ b/Src/Main/Server/Others/LKS_MultiplatformAdapter.m @@ -7,11 +7,19 @@ // #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,21 +29,34 @@ + (BOOL)isiPad { }); return s_isiPad; +#endif + +#if TARGET_OS_OSX + return NO; +#endif } + (CGRect)mainScreenBounds { #if TARGET_OS_VISION return [LKS_MultiplatformAdapter getFirstActiveWindowScene].coordinateSpace.bounds; -#else +#elif TARGET_OS_IPHONE return [UIScreen mainScreen].bounds; +#elif TARGET_OS_OSX + return [NSScreen mainScreen].frame; +#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 } @@ -54,15 +75,15 @@ + (UIWindowScene *)getFirstActiveWindowScene { } #endif -+ (UIWindow *)keyWindow { ++ (LookinWindow *)keyWindow { #if TARGET_OS_VISION return [self getFirstActiveWindowScene].keyWindow; #else - return [UIApplication sharedApplication].keyWindow; + return [LookinApplication sharedApplication].keyWindow; #endif } -+ (NSArray *)allWindows { ++ (NSArray *)allWindows { #if TARGET_OS_VISION NSMutableArray *windows = [NSMutableArray new]; for (UIScene *scene in @@ -83,7 +104,7 @@ + (UIWindow *)keyWindow { return [windows copy]; #else - return [[UIApplication sharedApplication].windows copy]; + return [[LookinApplication sharedApplication].windows copy]; #endif } diff --git a/Src/Main/Server/Others/LKS_TraceManager.m b/Src/Main/Server/Others/LKS_TraceManager.m index b90fdf3..23b429d 100644 --- a/Src/Main/Server/Others/LKS_TraceManager.m +++ b/Src/Main/Server/Others/LKS_TraceManager.m @@ -75,13 +75,20 @@ - (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]; +#endif + +#if TARGET_OS_OSX + [self _addTraceForInterfaceObject:window]; +#endif }]; } +#if TARGET_OS_IPHONE - (void)_addTraceForLayersRootedByLayer:(CALayer *)layer { - UIView *view = layer.lks_hostView; + LookinView *view = layer.lks_hostView; if ([view.superview lks_isChildrenViewOfTabBar]) { view.lks_isChildrenViewOfTabBar = YES; @@ -91,7 +98,7 @@ - (void)_addTraceForLayersRootedByLayer:(CALayer *)layer { if (view) { [self _markIVarsInAllClassLevelsOfObject:view]; - UIViewController* vc = [view lks_findHostViewController]; + LookinViewController* vc = [view lks_findHostViewController]; if (vc) { [self _markIVarsInAllClassLevelsOfObject:vc]; } @@ -105,14 +112,46 @@ - (void)_addTraceForLayersRootedByLayer:(CALayer *)layer { [self _addTraceForLayersRootedByLayer:sublayer]; }]; } +#endif + +#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:(UIView *)view { - UIViewController* vc = [view lks_findHostViewController]; +- (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_OSX + } 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 +161,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 +183,45 @@ - (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"; +#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)]; }]; +#endif - } else if ([view isKindOfClass:[UITableViewHeaderFooterView class]]) { - UITableViewHeaderFooterView *headerFooterView = (UITableViewHeaderFooterView *)view; - headerFooterView.textLabel.lks_specialTrace = @"sectionHeaderFooter.textLabel"; - headerFooterView.detailTextLabel.lks_specialTrace = @"sectionHeaderFooter.detailTextLabel"; +#if 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 +237,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 +255,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 +278,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"; } } @@ -300,6 +353,31 @@ - (NSString *)makeDisplayClassNameWithSuper:(Class)superClass childClass:(Class) trace.ivarName = @"_parentViewController"; trace; })]; + + [set addObject:({ + LookinIvarTrace *trace = [LookinIvarTrace new]; + trace.hostClassName = @"NSView"; + trace.ivarName = @"_window"; + trace; + })]; + [set addObject:({ + LookinIvarTrace *trace = [LookinIvarTrace new]; + trace.hostClassName = @"NSViewController"; + trace.ivarName = @"_view"; + trace; + })]; + [set addObject:({ + LookinIvarTrace *trace = [LookinIvarTrace new]; + trace.hostClassName = @"NSView"; + trace.ivarName = @"_viewDelegate"; + trace; + })]; + [set addObject:({ + LookinIvarTrace *trace = [LookinIvarTrace new]; + trace.hostClassName = @"NSViewController"; + trace.ivarName = @"_parentViewController"; + trace; + })]; list = set.copy; }); return list; diff --git a/Src/Main/Shared/Category/NSValue+Lookin.h b/Src/Main/Shared/Category/NSValue+Lookin.h new file mode 100644 index 0000000..fe5e6ee --- /dev/null +++ b/Src/Main/Shared/Category/NSValue+Lookin.h @@ -0,0 +1,40 @@ +// +// 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..f719fe9 --- /dev/null +++ b/Src/Main/Shared/Category/NSValue+Lookin.m @@ -0,0 +1,87 @@ +// +// 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}", insets.top, insets.left, insets.bottom, insets.right]; +} +#if TARGET_OS_OSX +NSString *NSStringFromCGAffineTransform(CGAffineTransform transform) { + return [NSString stringWithFormat:@"[%.*g, %.*g, %.*g, %.*g, %.*g, %.*g]", transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty]; +} +NSString *NSStringFromCGVector(CGVector vector) { + return [NSString stringWithFormat:@"{%.*g, %.*g}", vector.dx, 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}", insets.top, insets.leading, insets.bottom, 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 { + return [self valueWithEdgeInsets:insets]; +} + +- (LookinInsets)InsetsValue { + return [self edgeInsetsValue]; +} + +@end diff --git a/Src/Main/Shared/LookinAppInfo.h b/Src/Main/Shared/LookinAppInfo.h index 303cee3..01623ba 100644 --- a/Src/Main/Shared/LookinAppInfo.h +++ b/Src/Main/Shared/LookinAppInfo.h @@ -57,16 +57,10 @@ typedef NS_ENUM(NSInteger, LookinAppInfoDevice) { - (BOOL)isEqualToAppInfo:(LookinAppInfo *)info; -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST - + (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 c41c9a3..93d5d4c 100644 --- a/Src/Main/Shared/LookinAppInfo.m +++ b/Src/Main/Shared/LookinAppInfo.m @@ -129,7 +129,6 @@ - (BOOL)isEqualToAppInfo:(LookinAppInfo *)info { return NO; } -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST + (LookinAppInfo *)currentInfoWithScreenshot:(BOOL)hasScreenshot icon:(BOOL)hasIcon localIdentifiers:(NSArray *)localIdentifiers { NSInteger selfIdentifier = [self getAppInfoIdentifier]; @@ -149,7 +148,13 @@ + (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 = [NSProcessInfo processInfo].hostName; +#endif info.appBundleIdentifier = [[NSBundle mainBundle] bundleIdentifier]; if ([self isSimulator]) { info.deviceType = LookinAppInfoDeviceSimulator; @@ -159,10 +164,17 @@ + (LookinAppInfo *)currentInfoWithScreenshot:(BOOL)hasScreenshot icon:(BOOL)hasI info.deviceType = LookinAppInfoDeviceOthers; } +#if TARGET_OS_IPHONE info.osDescription = [UIDevice currentDevice].systemVersion; - NSString *mainVersionStr = [[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."].firstObject; info.osMainVersion = [mainVersionStr integerValue]; +#endif + +#if TARGET_OS_OSX + info.osDescription = [NSProcessInfo processInfo].operatingSystemVersionString; + info.osMainVersion = [NSProcessInfo processInfo].operatingSystemVersion.majorVersion; +#endif + CGSize screenSize = [LKS_MultiplatformAdapter mainScreenBounds].size; info.screenWidth = screenSize.width; @@ -186,10 +198,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 +217,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 +239,34 @@ + (UIImage *)screenshotImage { [window drawViewHierarchyInRect:window.bounds afterScreenUpdates:YES]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); +#endif + +#if TARGET_OS_OSX + NSView *view = window.contentView; + if (!window || !view) { + return nil; + } + + NSRect rect = view.bounds; + rect = [view convertRect:rect toView:nil]; + rect = [window convertRectToScreen:rect]; + +// Adjust for titlebar; kTitleUtility = 16, kTitleNormal = 22 +#define kTitleUtility 16 +#define kTitleNormal 22 + + CGFloat delta = ([window styleMask] & NSWindowStyleMaskUtilityWindow) ? kTitleUtility : kTitleNormal; + rect.origin.y += delta; + rect.size.height += delta * 2; + + CGImageRef cgImage = CGWindowListCreateImage(rect, + kCGWindowListOptionIncludingWindow, + (CGWindowID)[window windowNumber], + kCGWindowImageBestResolution); + + NSImage *image = [[NSImage alloc] initWithCGImage:cgImage size:rect.size]; + CGImageRelease(cgImage); +#endif return image; } @@ -235,7 +278,6 @@ + (BOOL)isSimulator { return NO; } -#endif + (NSInteger)getAppInfoIdentifier { static dispatch_once_t onceToken; diff --git a/Src/Main/Shared/LookinAutoLayoutConstraint.h b/Src/Main/Shared/LookinAutoLayoutConstraint.h index a219073..6fadf74 100644 --- a/Src/Main/Shared/LookinAutoLayoutConstraint.h +++ b/Src/Main/Shared/LookinAutoLayoutConstraint.h @@ -25,9 +25,7 @@ typedef NS_ENUM(NSInteger, LookinConstraintItemType) { @interface LookinAutoLayoutConstraint : NSObject -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST + (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 a173269..c6ddd34 100644 --- a/Src/Main/Shared/LookinAutoLayoutConstraint.m +++ b/Src/Main/Shared/LookinAutoLayoutConstraint.m @@ -15,8 +15,6 @@ @implementation LookinAutoLayoutConstraint -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST - + (instancetype)instanceFromNSConstraint:(NSLayoutConstraint *)constraint isEffective:(BOOL)isEffective firstItemType:(LookinConstraintItemType)firstItemType secondItemType:(LookinConstraintItemType)secondItemType { LookinAutoLayoutConstraint *instance = [LookinAutoLayoutConstraint new]; instance.effective = isEffective; @@ -57,8 +55,6 @@ - (void)_assertUnknownAttribute:(NSInteger)attribute { } } -#endif - #pragma mark - + (BOOL)supportsSecureCoding { diff --git a/Src/Main/Shared/LookinDefines.h b/Src/Main/Shared/LookinDefines.h index c41d1bb..8b6bc7d 100644 --- a/Src/Main/Shared/LookinDefines.h +++ b/Src/Main/Shared/LookinDefines.h @@ -9,9 +9,9 @@ // #import "TargetConditionals.h" -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE #import -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX #import #endif @@ -140,14 +140,44 @@ enum { #pragma mark - Colors -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE #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 +#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 #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/LookinHierarchyInfo.h b/Src/Main/Shared/LookinHierarchyInfo.h index b39a9a3..d310e87 100644 --- a/Src/Main/Shared/LookinHierarchyInfo.h +++ b/Src/Main/Shared/LookinHierarchyInfo.h @@ -22,15 +22,11 @@ @interface LookinHierarchyInfo : NSObject -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST - /// 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 f025c2e..10c19c7 100644 --- a/Src/Main/Shared/LookinHierarchyInfo.m +++ b/Src/Main/Shared/LookinHierarchyInfo.m @@ -15,17 +15,12 @@ #import "LookinAppInfo.h" #import "NSArray+Lookin.h" #import "NSString+Lookin.h" - -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #import "LKS_HierarchyDisplayItemsMaker.h" #import "LKSConfigManager.h" #import "LKS_CustomAttrSetterManager.h" -#endif @implementation LookinHierarchyInfo -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST - + (instancetype)staticInfoWithLookinVersion:(NSString *)version { BOOL readCustomInfo = NO; // Client 1.0.4 开始支持 customInfo @@ -54,8 +49,6 @@ + (instancetype)exportedInfo { return info; } -#endif - #pragma mark - static NSString * const LookinHierarchyInfoCodingKey_DisplayItems = @"1"; diff --git a/Src/Main/Shared/LookinObject.h b/Src/Main/Shared/LookinObject.h index 775d739..a0173b1 100644 --- a/Src/Main/Shared/LookinObject.h +++ b/Src/Main/Shared/LookinObject.h @@ -16,9 +16,7 @@ @interface LookinObject : NSObject -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST + (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 cd44772..2fed676 100644 --- a/Src/Main/Shared/LookinObject.m +++ b/Src/Main/Shared/LookinObject.m @@ -12,14 +12,10 @@ #import "LookinIvarTrace.h" #import "NSArray+Lookin.h" #import "NSString+Lookin.h" - -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #import "NSObject+LookinServer.h" -#endif @implementation LookinObject -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST + (instancetype)instanceWithObject:(NSObject *)object { LookinObject *lookinObj = [LookinObject new]; lookinObj.oid = [object lks_registerOid]; @@ -32,7 +28,6 @@ + (instancetype)instanceWithObject:(NSObject *)object { return lookinObj; } -#endif #pragma mark - From b47b1a4b51279add1f79b4706ee3a536f0daa397 Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Tue, 5 Nov 2024 18:29:26 +0800 Subject: [PATCH 04/21] Updates --- LookinServer.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LookinServer.podspec b/LookinServer.podspec index 33f9c43..c1b6219 100644 --- a/LookinServer.podspec +++ b/LookinServer.podspec @@ -6,13 +6,13 @@ Pod::Spec.new do |spec| spec.homepage = "https://lookin.work" spec.license = "GPL-3.0" spec.author = { "Li Kai" => "lookin@lookin.work" } - spec.osx.deployment_target = "10.13" + 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.osx.framework = "AppKit" + spec.macos.framework = "AppKit" spec.ios.framework = "UIKit" spec.tvos.framework = "UIKit" spec.visionos.framework = "UIKit" From 47867fcaf1037adbbd175b358adddc309201cdff Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Tue, 5 Nov 2024 19:10:19 +0800 Subject: [PATCH 05/21] [WIP] AppKit Support --- .../AppKitDemo/AppKitDemo.entitlements | 2 +- LookinDemo/AppKitDemo/Podfile.lock | 2 +- .../Server/Category/UIView+LookinServer.m | 2 +- .../Category/UIViewController+LookinServer.m | 2 +- .../Server/Connection/LKS_ConnectionManager.m | 2 +- .../Server/Connection/LKS_RequestHandler.m | 2 + .../Server/Others/LKS_EventHandlerMaker.m | 5 +- .../Others/LKS_HierarchyDisplayItemsMaker.m | 2 + .../LookinAutoLayoutConstraint+LookinServer.h | 17 +++++++ .../LookinAutoLayoutConstraint+LookinServer.m | 31 ++++++++++++ .../Others/LookinHierarchyInfo+LookinServer.h | 19 ++++++++ .../Others/LookinHierarchyInfo+LookinServer.m | 47 +++++++++++++++++++ .../Server/Others/LookinObject+LookinServer.h | 17 +++++++ .../Server/Others/LookinObject+LookinServer.m | 26 ++++++++++ .../LKS_MultiplatformAdapter.h | 0 .../LKS_MultiplatformAdapter.m | 0 Src/Main/Shared/LookinAutoLayoutConstraint.h | 1 - Src/Main/Shared/LookinAutoLayoutConstraint.m | 20 +------- Src/Main/Shared/LookinHierarchyInfo.h | 3 -- Src/Main/Shared/LookinHierarchyInfo.m | 30 ------------ Src/Main/Shared/LookinObject.h | 1 - Src/Main/Shared/LookinObject.m | 13 ----- 22 files changed, 171 insertions(+), 73 deletions(-) create mode 100644 Src/Main/Server/Others/LookinAutoLayoutConstraint+LookinServer.h create mode 100644 Src/Main/Server/Others/LookinAutoLayoutConstraint+LookinServer.m create mode 100644 Src/Main/Server/Others/LookinHierarchyInfo+LookinServer.h create mode 100644 Src/Main/Server/Others/LookinHierarchyInfo+LookinServer.m create mode 100644 Src/Main/Server/Others/LookinObject+LookinServer.h create mode 100644 Src/Main/Server/Others/LookinObject+LookinServer.m rename Src/Main/{Server/Others => Shared}/LKS_MultiplatformAdapter.h (100%) rename Src/Main/{Server/Others => Shared}/LKS_MultiplatformAdapter.m (100%) diff --git a/LookinDemo/AppKitDemo/AppKitDemo/AppKitDemo.entitlements b/LookinDemo/AppKitDemo/AppKitDemo/AppKitDemo.entitlements index 40b639e..997a18c 100644 --- a/LookinDemo/AppKitDemo/AppKitDemo/AppKitDemo.entitlements +++ b/LookinDemo/AppKitDemo/AppKitDemo/AppKitDemo.entitlements @@ -3,7 +3,7 @@ com.apple.security.app-sandbox - + com.apple.security.files.user-selected.read-only com.apple.security.network.client diff --git a/LookinDemo/AppKitDemo/Podfile.lock b/LookinDemo/AppKitDemo/Podfile.lock index 1be7b26..dd54fbf 100644 --- a/LookinDemo/AppKitDemo/Podfile.lock +++ b/LookinDemo/AppKitDemo/Podfile.lock @@ -11,7 +11,7 @@ EXTERNAL SOURCES: :path: "../../" SPEC CHECKSUMS: - LookinServer: 1035f6880a1ccdada647fbd1f59b44ddd005fdf4 + LookinServer: 32e176f3ef9dfbda52026e2d9e18b7204c141272 PODFILE CHECKSUM: 0eea96142f9864079641953fac183889175edfb2 diff --git a/Src/Main/Server/Category/UIView+LookinServer.m b/Src/Main/Server/Category/UIView+LookinServer.m index 1081163..eebdc1a 100644 --- a/Src/Main/Server/Category/UIView+LookinServer.m +++ b/Src/Main/Server/Category/UIView+LookinServer.m @@ -14,7 +14,7 @@ #import "LookinAutoLayoutConstraint.h" #import "LookinServerDefines.h" #import "LKS_MultiplatformAdapter.h" - +#import "LookinAutoLayoutConstraint+LookinServer.h" @implementation LookinView (LookinServer) #if TARGET_OS_OSX diff --git a/Src/Main/Server/Category/UIViewController+LookinServer.m b/Src/Main/Server/Category/UIViewController+LookinServer.m index 1ee54da..f448941 100644 --- a/Src/Main/Server/Category/UIViewController+LookinServer.m +++ b/Src/Main/Server/Category/UIViewController+LookinServer.m @@ -56,7 +56,7 @@ - (LookinViewController *)lks_visibleViewControllerIfExist { #if TARGET_OS_OSX if (self.presentedViewControllers) { for (NSViewController *presentedViewController in self.presentedViewControllers) { - return [self.presentingViewController lks_visibleViewControllerIfExist]; + return [presentedViewController lks_visibleViewControllerIfExist]; } } diff --git a/Src/Main/Server/Connection/LKS_ConnectionManager.m b/Src/Main/Server/Connection/LKS_ConnectionManager.m index c1bb1d2..ca9ff87 100644 --- a/Src/Main/Server/Connection/LKS_ConnectionManager.m +++ b/Src/Main/Server/Connection/LKS_ConnectionManager.m @@ -54,7 +54,7 @@ - (instancetype)init { #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]; +// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleWillResignActiveNotification) name:NSApplicationWillResignActiveNotification object:nil]; #endif [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleLocalInspect:) name:@"Lookin_2D" object:nil]; diff --git a/Src/Main/Server/Connection/LKS_RequestHandler.m b/Src/Main/Server/Connection/LKS_RequestHandler.m index af29fcc..103f5a4 100644 --- a/Src/Main/Server/Connection/LKS_RequestHandler.m +++ b/Src/Main/Server/Connection/LKS_RequestHandler.m @@ -27,6 +27,8 @@ #import "LKS_HierarchyDetailsHandler.h" #import "LookinStaticAsyncUpdateTask.h" #import "NSValue+Lookin.h" +#import "LookinHierarchyInfo+LookinServer.h" +#import "LookinObject+LookinServer.h" @interface LKS_RequestHandler () diff --git a/Src/Main/Server/Others/LKS_EventHandlerMaker.m b/Src/Main/Server/Others/LKS_EventHandlerMaker.m index b949783..b5bdf0c 100644 --- a/Src/Main/Server/Others/LKS_EventHandlerMaker.m +++ b/Src/Main/Server/Others/LKS_EventHandlerMaker.m @@ -200,7 +200,10 @@ + (NSString *)_inheritedRecognizerNameForRecognizer:(LookinGestureRecognizer *)r #endif #if TARGET_OS_OSX - NSSet *allTargets = control.target; + NSMutableSet *allTargets = [NSMutableSet set]; + if (control.target) { + [allTargets addObject:control.target]; + } #endif if (!allTargets.count) { diff --git a/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m b/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m index 127cd51..23b7572 100644 --- a/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m +++ b/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m @@ -21,6 +21,8 @@ #import "LKS_CustomAttrSetterManager.h" #import "LKS_MultiplatformAdapter.h" #import "NSValue+Lookin.h" +#import "LookinObject+LookinServer.h" + @implementation LKS_HierarchyDisplayItemsMaker + (NSArray *)itemsWithScreenshots:(BOOL)hasScreenshots attrList:(BOOL)hasAttrList lowImageQuality:(BOOL)lowQuality readCustomInfo:(BOOL)readCustomInfo saveCustomSetter:(BOOL)saveCustomSetter { 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/Server/Others/LKS_MultiplatformAdapter.h b/Src/Main/Shared/LKS_MultiplatformAdapter.h similarity index 100% rename from Src/Main/Server/Others/LKS_MultiplatformAdapter.h rename to Src/Main/Shared/LKS_MultiplatformAdapter.h diff --git a/Src/Main/Server/Others/LKS_MultiplatformAdapter.m b/Src/Main/Shared/LKS_MultiplatformAdapter.m similarity index 100% rename from Src/Main/Server/Others/LKS_MultiplatformAdapter.m rename to Src/Main/Shared/LKS_MultiplatformAdapter.m diff --git a/Src/Main/Shared/LookinAutoLayoutConstraint.h b/Src/Main/Shared/LookinAutoLayoutConstraint.h index 6fadf74..4ba4bfa 100644 --- a/Src/Main/Shared/LookinAutoLayoutConstraint.h +++ b/Src/Main/Shared/LookinAutoLayoutConstraint.h @@ -25,7 +25,6 @@ typedef NS_ENUM(NSInteger, LookinConstraintItemType) { @interface LookinAutoLayoutConstraint : NSObject -+ (instancetype)instanceFromNSConstraint:(NSLayoutConstraint *)constraint isEffective:(BOOL)isEffective firstItemType:(LookinConstraintItemType)firstItemType secondItemType:(LookinConstraintItemType)secondItemType; @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 c6ddd34..307ca2b 100644 --- a/Src/Main/Shared/LookinAutoLayoutConstraint.m +++ b/Src/Main/Shared/LookinAutoLayoutConstraint.m @@ -15,25 +15,7 @@ @implementation LookinAutoLayoutConstraint -+ (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; diff --git a/Src/Main/Shared/LookinHierarchyInfo.h b/Src/Main/Shared/LookinHierarchyInfo.h index d310e87..1fe718d 100644 --- a/Src/Main/Shared/LookinHierarchyInfo.h +++ b/Src/Main/Shared/LookinHierarchyInfo.h @@ -22,10 +22,7 @@ @interface LookinHierarchyInfo : NSObject -/// version 可能为 nil,此时说明 Client 版本号 < 1.0.4 -+ (instancetype)staticInfoWithLookinVersion:(NSString *)version; -+ (instancetype)exportedInfo; /// 这里其实就是顶端的那几个 UIWindow @property(nonatomic, copy) NSArray *displayItems; diff --git a/Src/Main/Shared/LookinHierarchyInfo.m b/Src/Main/Shared/LookinHierarchyInfo.m index 10c19c7..f1ef4d3 100644 --- a/Src/Main/Shared/LookinHierarchyInfo.m +++ b/Src/Main/Shared/LookinHierarchyInfo.m @@ -15,39 +15,9 @@ #import "LookinAppInfo.h" #import "NSArray+Lookin.h" #import "NSString+Lookin.h" -#import "LKS_HierarchyDisplayItemsMaker.h" -#import "LKSConfigManager.h" -#import "LKS_CustomAttrSetterManager.h" @implementation LookinHierarchyInfo -+ (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; -} #pragma mark - diff --git a/Src/Main/Shared/LookinObject.h b/Src/Main/Shared/LookinObject.h index a0173b1..2881793 100644 --- a/Src/Main/Shared/LookinObject.h +++ b/Src/Main/Shared/LookinObject.h @@ -16,7 +16,6 @@ @interface LookinObject : NSObject -+ (instancetype)instanceWithObject:(NSObject *)object; @property(nonatomic, assign) unsigned long oid; diff --git a/Src/Main/Shared/LookinObject.m b/Src/Main/Shared/LookinObject.m index 2fed676..6b7a328 100644 --- a/Src/Main/Shared/LookinObject.m +++ b/Src/Main/Shared/LookinObject.m @@ -12,22 +12,9 @@ #import "LookinIvarTrace.h" #import "NSArray+Lookin.h" #import "NSString+Lookin.h" -#import "NSObject+LookinServer.h" @implementation LookinObject -+ (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; -} #pragma mark - From fb752f537e61336bec53fdbc66a05cf373ed26c0 Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Wed, 6 Nov 2024 01:09:53 +0800 Subject: [PATCH 06/21] [WIP] AppKit Support --- .../AppKitDemo/ViewController.swift | 9 +- .../Server/Category/CALayer+LookinServer.m | 23 ++- .../Server/Category/NSWindow+LookinServer.h | 22 +++ .../Server/Category/NSWindow+LookinServer.m | 20 +++ .../Server/Category/UIView+LookinServer.h | 13 +- .../Server/Category/UIView+LookinServer.m | 111 ++++++++++++-- .../Server/Connection/LKS_ConnectionManager.m | 4 +- .../LKS_AttrModificationPatchHandler.m | 17 ++- .../LKS_HierarchyDetailsHandler.m | 48 +++++- .../LKS_InbuiltAttrModificationHandler.m | 17 +++ Src/Main/Server/Others/LKSConfigManager.h | 4 +- Src/Main/Server/Others/LKSConfigManager.m | 19 +++ Src/Main/Server/Others/LKS_AttrGroupsMaker.h | 4 +- Src/Main/Server/Others/LKS_AttrGroupsMaker.m | 71 +++++++++ .../Server/Others/LKS_CustomAttrGroupsMaker.h | 4 +- .../Server/Others/LKS_CustomAttrGroupsMaker.m | 41 +++++- .../Others/LKS_CustomDisplayItemsMaker.h | 3 + .../Others/LKS_CustomDisplayItemsMaker.m | 43 +++++- .../Server/Others/LKS_EventHandlerMaker.m | 30 ++-- .../Others/LKS_HierarchyDisplayItemsMaker.h | 4 +- .../Others/LKS_HierarchyDisplayItemsMaker.m | 139 ++++++++++++++++-- Src/Main/Shared/LookinAppInfo.m | 25 ++-- 22 files changed, 586 insertions(+), 85 deletions(-) create mode 100644 Src/Main/Server/Category/NSWindow+LookinServer.h create mode 100644 Src/Main/Server/Category/NSWindow+LookinServer.m diff --git a/LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift b/LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift index 1a31dd1..25795ab 100644 --- a/LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift +++ b/LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift @@ -11,7 +11,7 @@ class ViewController: NSViewController { override func viewDidLoad() { super.viewDidLoad() - + print(view.layer) // Do any additional setup after loading the view. } @@ -22,5 +22,12 @@ class ViewController: NSViewController { } + override func viewDidAppear() { + super.viewDidAppear() + + print(view.layer) + print(view.superview?.layer) + } + } diff --git a/Src/Main/Server/Category/CALayer+LookinServer.m b/Src/Main/Server/Category/CALayer+LookinServer.m index 596fa86..20c5962 100644 --- a/Src/Main/Server/Category/CALayer+LookinServer.m +++ b/Src/Main/Server/Category/CALayer+LookinServer.m @@ -17,7 +17,7 @@ #import "LookinServerDefines.h" #import "UIColor+LookinServer.h" #import "LKS_MultiplatformAdapter.h" - +#import "NSWindow+LookinServer.h" @implementation CALayer (LookinServer) - (LookinWindow *)lks_window { @@ -26,8 +26,10 @@ - (LookinWindow *)lks_window { LookinView *hostView = layer.lks_hostView; if (hostView.window) { return hostView.window; +#if !TARGET_OS_OSX } else if ([hostView isKindOfClass:[LookinWindow class]]) { return (LookinWindow *)hostView; +#endif } layer = layer.superlayer; } @@ -43,11 +45,10 @@ - (CGRect)lks_frameInWindow:(LookinWindow *)window { #if TARGET_OS_IPHONE CGRect rectInSelfWindow = [selfWindow.layer convertRect:self.frame fromLayer:self.superlayer]; CGRect rectInWindow = [window convertRect:rectInSelfWindow fromWindow:selfWindow]; -#endif +#elif TARGET_OS_OSX -#if TARGET_OS_OSX - CGRect rectInSelfWindow = [selfWindow.contentView.layer convertRect:self.frame fromLayer:self.superlayer]; - CGRect rectInWindow = [window.contentView convertRect:rectInSelfWindow fromView:selfWindow.contentView]; + 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; } @@ -99,9 +100,7 @@ - (LookinImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality { UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; -#endif - -#if TARGET_OS_OSX +#elif TARGET_OS_OSX NSImage *image = [NSImage imageWithSize:contextSize flipped:YES drawingHandler:^BOOL(NSRect dstRect) { CGContextRef context = NSGraphicsContext.currentContext.CGContext; [self renderInContext:context]; @@ -159,9 +158,7 @@ - (LookinImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { UIGraphicsEndImageContext(); -#endif - -#if TARGET_OS_OSX +#elif TARGET_OS_OSX NSImage *image = [NSImage imageWithSize:contextSize flipped:YES drawingHandler:^BOOL(NSRect dstRect) { CGContextRef context = NSGraphicsContext.currentContext.CGContext; [self renderInContext:context]; @@ -189,9 +186,7 @@ - (LookinImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { [array addObject:[CALayer lks_getClassListOfObject:self endingClass:@"CALayer"]]; } return array.copy; -#endif - -#if TARGET_OS_OSX +#elif TARGET_OS_OSX NSMutableArray *array = [NSMutableArray arrayWithCapacity:2]; if (self.lks_hostView) { [array addObject:[CALayer lks_getClassListOfObject:self.lks_hostView endingClass:@"NSView"]]; diff --git a/Src/Main/Server/Category/NSWindow+LookinServer.h b/Src/Main/Server/Category/NSWindow+LookinServer.h new file mode 100644 index 0000000..93683f9 --- /dev/null +++ b/Src/Main/Server/Category/NSWindow+LookinServer.h @@ -0,0 +1,22 @@ +// +// NSWindow+LookinServer.h +// LookinServer +// +// Created by JH on 11/5/24. +// + +#if TARGET_OS_OSX + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface NSWindow (LookinServer) +// NSWindow 的 rootView 是 contentView 的 superview,例如 NSThemeFrame +@property (nonatomic, readonly) NSView *lks_rootView; + +@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..fb26f62 --- /dev/null +++ b/Src/Main/Server/Category/NSWindow+LookinServer.m @@ -0,0 +1,20 @@ +// +// 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; +} + +@end + +#endif diff --git a/Src/Main/Server/Category/UIView+LookinServer.h b/Src/Main/Server/Category/UIView+LookinServer.h index 6b9356e..8bad50c 100644 --- a/Src/Main/Server/Category/UIView+LookinServer.h +++ b/Src/Main/Server/Category/UIView+LookinServer.h @@ -8,15 +8,14 @@ // https://lookin.work // -#import "LookinDefines.h" #if TARGET_OS_IPHONE #import -#endif - -#if TARGET_OS_OSX +#elif TARGET_OS_OSX #import #endif +#import "LookinDefines.h" + @interface LookinView (LookinServer) /// 如果 myViewController.view = myView,则可以通过 myView 的 lks_findHostViewController 方法找到 myViewController @@ -45,6 +44,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 eebdc1a..d08b1ba 100644 --- a/Src/Main/Server/Category/UIView+LookinServer.m +++ b/Src/Main/Server/Category/UIView+LookinServer.m @@ -15,6 +15,7 @@ #import "LookinServerDefines.h" #import "LKS_MultiplatformAdapter.h" #import "LookinAutoLayoutConstraint+LookinServer.h" +#import "NSWindow+LookinServer.h" @implementation LookinView (LookinServer) #if TARGET_OS_OSX @@ -85,9 +86,7 @@ - (LookinView *)lks_subviewAtPoint:(CGPoint)point preferredClasses:(NSArray 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:self.bounds.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:self.bounds.size]; + + [image addRepresentation:rep]; + [visibleSubviews enumerateObjectsUsingBlock:^(NSView * _Nonnull subview, NSUInteger idx, BOOL * _Nonnull stop) { + subview.hidden = NO; + }]; + return image; + } + return nil; +} + @end #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Connection/LKS_ConnectionManager.m b/Src/Main/Server/Connection/LKS_ConnectionManager.m index ca9ff87..f03b2c7 100644 --- a/Src/Main/Server/Connection/LKS_ConnectionManager.m +++ b/Src/Main/Server/Connection/LKS_ConnectionManager.m @@ -246,9 +246,7 @@ - (void)_handleLocalInspect:(NSNotification *)note { UIViewController *rootViewController = [keyWindow rootViewController]; [rootViewController presentViewController:alertController animated:YES completion:nil]; -#endif - -#if TARGET_OS_OSX +#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."; diff --git a/Src/Main/Server/Connection/RequestHandler/LKS_AttrModificationPatchHandler.m b/Src/Main/Server/Connection/RequestHandler/LKS_AttrModificationPatchHandler.m index bc1cbcd..5416ab6 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]; +#if TARGET_OS_OSX + id object = [NSObject lks_objectWithOid:oid]; + 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_HierarchyDetailsHandler.m b/Src/Main/Server/Connection/RequestHandler/LKS_HierarchyDetailsHandler.m index c7bea77..529b8e2 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 @@ -74,13 +74,56 @@ - (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) { LookinImage *image = [layer lks_soloScreenshotWithLowQuality:NO]; itemDetail.soloScreenshot = image; @@ -103,7 +146,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 37afdce..a6b2892 100644 --- a/Src/Main/Server/Connection/RequestHandler/LKS_InbuiltAttrModificationHandler.m +++ b/Src/Main/Server/Connection/RequestHandler/LKS_InbuiltAttrModificationHandler.m @@ -235,6 +235,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; diff --git a/Src/Main/Server/Others/LKSConfigManager.h b/Src/Main/Server/Others/LKSConfigManager.h index 6cbddb1..689418f 100644 --- a/Src/Main/Server/Others/LKSConfigManager.h +++ b/Src/Main/Server/Others/LKSConfigManager.h @@ -26,7 +26,9 @@ NS_ASSUME_NONNULL_BEGIN + (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 672db21..5f75360 100644 --- a/Src/Main/Server/Others/LKSConfigManager.m +++ b/Src/Main/Server/Others/LKSConfigManager.m @@ -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; 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 4f2fb27..4c68ff3 100644 --- a/Src/Main/Server/Others/LKS_AttrGroupsMaker.m +++ b/Src/Main/Server/Others/LKS_AttrGroupsMaker.m @@ -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, @""); 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 4fa1d6f..e68b6b2 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,21 @@ - (void)execute { } for (NSString *name in selectors) { - [self makeAttrsForViewOrLayer:self.layer selectorName:name]; - - LookinView *view = self.layer.lks_hostView; - if (view) { - [self makeAttrsForViewOrLayer:view selectorName:name]; + 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; + } + if (self.layer) { + [self makeAttrsForViewOrLayer:self.layer selectorName:name]; + + LookinView *view = self.layer.lks_hostView; + if (view) { + [self makeAttrsForViewOrLayer:view selectorName:name]; + } } } diff --git a/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.h b/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.h index 887d171..a16a35a 100644 --- a/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.h +++ b/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.h @@ -22,6 +22,9 @@ @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 9d911f8..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; diff --git a/Src/Main/Server/Others/LKS_EventHandlerMaker.m b/Src/Main/Server/Others/LKS_EventHandlerMaker.m index b5bdf0c..34e8ed0 100644 --- a/Src/Main/Server/Others/LKS_EventHandlerMaker.m +++ b/Src/Main/Server/Others/LKS_EventHandlerMaker.m @@ -114,19 +114,24 @@ + (NSString *)_inheritedRecognizerNameForRecognizer:(LookinGestureRecognizer *)r [UIPinchGestureRecognizer class], [UITapGestureRecognizer class]]; #elif TARGET_OS_OSX - baseRecognizers = @[ - [NSClickGestureRecognizer class], + baseRecognizers = @[[NSClickGestureRecognizer class], [NSMagnificationGestureRecognizer class], [NSPanGestureRecognizer class], [NSPressGestureRecognizer class], - [NSRotationGestureRecognizer 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 @@ -152,8 +157,7 @@ + (NSString *)_inheritedRecognizerNameForRecognizer:(LookinGestureRecognizer *)r if (@available(iOS 9.0, *)) { allEvents = [allEvents arrayByAddingObject:@(UIControlEventPrimaryActionTriggered)]; } -#endif -#if TARGET_OS_OSX +#elif TARGET_OS_OSX allEvents = @[ @(NSEventMaskLeftMouseDown), @(NSEventMaskLeftMouseUp), @@ -197,9 +201,7 @@ + (NSString *)_inheritedRecognizerNameForRecognizer:(LookinGestureRecognizer *)r #if TARGET_OS_IPHONE NSSet *allTargets = control.allTargets; -#endif - -#if TARGET_OS_OSX +#elif TARGET_OS_OSX NSMutableSet *allTargets = [NSMutableSet set]; if (control.target) { [allTargets addObject:control.target]; @@ -235,15 +237,13 @@ + (NSString *)_inheritedRecognizerNameForRecognizer:(LookinGestureRecognizer *)r [handlers addObject:handler]; } }]; -#endif - -#if TARGET_OS_OSX +#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:control.target second:NSStringFromSelector(control.action)]]; + handler.targetActions = @[[LookinStringTwoTuple tupleWithFirst:[LKS_Helper descriptionOfObject:control.target] second:NSStringFromSelector(control.action)]]; [handlers addObject:handler]; } #endif @@ -281,9 +281,7 @@ + (NSString *)_nameFromControlEvent:(UIControlEvents)event { NSString *name = eventsAndNames[@(event)]; return name; } -#endif - -#if TARGET_OS_OSX +#elif TARGET_OS_OSX + (NSString *)_nameFromEventMask:(NSEventMask)eventMask { static dispatch_once_t onceToken; static NSDictionary *eventsAndNames = nil; 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 23b7572..8f5e935 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 @@ -22,7 +22,7 @@ #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 { @@ -34,10 +34,14 @@ @implementation LKS_HierarchyDisplayItemsMaker [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]; -#endif - -#if TARGET_OS_OSX - LookinDisplayItem *item = [self _displayItemWithLayer:window.contentView.layer screenshots:hasScreenshots attrList:hasAttrList lowImageQuality:lowQuality readCustomInfo:readCustomInfo saveCustomSetter:saveCustomSetter]; +#elif TARGET_OS_OSX + CALayer *rootLayer = window.lks_rootView.layer; + LookinDisplayItem *item = nil; + if (rootLayer) { + item = [self _displayItemWithLayer:rootLayer screenshots:hasScreenshots attrList:hasAttrList lowImageQuality:lowQuality readCustomInfo:readCustomInfo saveCustomSetter:saveCustomSetter]; + } else { + item = [self _displayItemWithView:window.lks_rootView screenshots:hasScreenshots attrList:hasAttrList lowImageQuality:lowQuality readCustomInfo:readCustomInfo saveCustomSetter:saveCustomSetter]; + } #endif item.representedAsKeyWindow = window.isKeyWindow; if (item) { @@ -119,7 +123,7 @@ + (LookinDisplayItem *)_displayItemWithLayer:(CALayer *)layer screenshots:(BOOL) } else { item.subitems = customSubitems; } - } + } } return item; @@ -132,7 +136,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]; @@ -140,7 +144,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]; @@ -149,6 +153,123 @@ + (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; + 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/Shared/LookinAppInfo.m b/Src/Main/Shared/LookinAppInfo.m index 93d5d4c..d20b1aa 100644 --- a/Src/Main/Shared/LookinAppInfo.m +++ b/Src/Main/Shared/LookinAppInfo.m @@ -71,13 +71,13 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:self.serverReadableVersion forKey:@"serverReadableVersion"]; [aCoder encodeInt:self.swiftEnabledInLookinServer forKey:@"swiftEnabledInLookinServer"]; -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE NSData *screenshotData = UIImagePNGRepresentation(self.screenshot); [aCoder encodeObject:screenshotData forKey:CodingKey_Screenshot]; 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]; @@ -153,7 +153,7 @@ + (LookinAppInfo *)currentInfoWithScreenshot:(BOOL)hasScreenshot icon:(BOOL)hasI #endif #if TARGET_OS_OSX - info.deviceDescription = [NSProcessInfo processInfo].hostName; + info.deviceDescription = [NSHost currentHost].localizedName; #endif info.appBundleIdentifier = [[NSBundle mainBundle] bundleIdentifier]; if ([self isSimulator]) { @@ -168,11 +168,14 @@ + (LookinAppInfo *)currentInfoWithScreenshot:(BOOL)hasScreenshot icon:(BOOL)hasI info.osDescription = [UIDevice currentDevice].systemVersion; NSString *mainVersionStr = [[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."].firstObject; info.osMainVersion = [mainVersionStr integerValue]; -#endif - -#if TARGET_OS_OSX - info.osDescription = [NSProcessInfo processInfo].operatingSystemVersionString; - info.osMainVersion = [NSProcessInfo processInfo].operatingSystemVersion.majorVersion; +#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 @@ -239,10 +242,8 @@ + (LookinImage *)screenshotImage { [window drawViewHierarchyInRect:window.bounds afterScreenUpdates:YES]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); -#endif - -#if TARGET_OS_OSX - NSView *view = window.contentView; +#elif TARGET_OS_OSX + NSView *view = window.contentView.superview; if (!window || !view) { return nil; } From da3c43c9ab7d1d286ded49086ad48d492328b6da Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Wed, 6 Nov 2024 18:01:02 +0800 Subject: [PATCH 07/21] [WIP] AppKit Support --- .../AppKitDemo/Base.lproj/Main.storyboard | 13 ++--- .../AppKitDemo/ViewController.swift | 10 +--- .../Server/Category/CALayer+LookinServer.m | 48 +++++++++++++++---- .../Server/Category/UIView+LookinServer.m | 6 +-- .../Server/Connection/LKS_ConnectionManager.h | 2 +- .../LKS_HierarchyDetailsHandler.m | 3 -- Src/Main/Server/Others/LKS_AttrGroupsMaker.m | 2 +- .../Others/LKS_HierarchyDisplayItemsMaker.m | 4 +- Src/Main/Server/Others/LKS_TraceManager.m | 20 +++----- Src/Main/Shared/Category/Color+Lookin.h | 2 +- Src/Main/Shared/Category/Image+Lookin.h | 2 +- Src/Main/Shared/Category/NSSet+Lookin.h | 2 - Src/Main/Shared/Category/NSString+Lookin.h | 2 - Src/Main/Shared/Category/NSValue+Lookin.h | 1 - Src/Main/Shared/Category/NSValue+Lookin.m | 8 ++-- Src/Main/Shared/LKS_MultiplatformAdapter.h | 2 + Src/Main/Shared/LKS_MultiplatformAdapter.m | 19 ++++++-- Src/Main/Shared/LookinAppInfo.h | 3 +- Src/Main/Shared/LookinAppInfo.m | 2 + Src/Main/Shared/LookinCustomDisplayItemInfo.m | 4 +- Src/Main/Shared/LookinDisplayItem.h | 2 +- Src/Main/Shared/LookinDisplayItem.m | 4 +- 22 files changed, 92 insertions(+), 69 deletions(-) diff --git a/LookinDemo/AppKitDemo/AppKitDemo/Base.lproj/Main.storyboard b/LookinDemo/AppKitDemo/AppKitDemo/Base.lproj/Main.storyboard index 99f7fe7..4f242db 100644 --- a/LookinDemo/AppKitDemo/AppKitDemo/Base.lproj/Main.storyboard +++ b/LookinDemo/AppKitDemo/AppKitDemo/Base.lproj/Main.storyboard @@ -1,7 +1,8 @@ - - + + - + + @@ -673,7 +674,7 @@ - + @@ -703,8 +704,8 @@ - - + + diff --git a/LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift b/LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift index 25795ab..b0eca7d 100644 --- a/LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift +++ b/LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift @@ -8,26 +8,18 @@ import Cocoa class ViewController: NSViewController { - override func viewDidLoad() { super.viewDidLoad() - print(view.layer) // Do any additional setup after loading the view. } override var representedObject: Any? { didSet { - // Update the view, if already loaded. + // Update the view, if already loaded. } } - override func viewDidAppear() { super.viewDidAppear() - - print(view.layer) - print(view.superview?.layer) } - } - diff --git a/Src/Main/Server/Category/CALayer+LookinServer.m b/Src/Main/Server/Category/CALayer+LookinServer.m index 20c5962..1a4e36f 100644 --- a/Src/Main/Server/Category/CALayer+LookinServer.m +++ b/Src/Main/Server/Category/CALayer+LookinServer.m @@ -101,11 +101,25 @@ - (LookinImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality { UIGraphicsEndImageContext(); return image; #elif TARGET_OS_OSX - NSImage *image = [NSImage imageWithSize:contextSize flipped:YES drawingHandler:^BOOL(NSRect dstRect) { - CGContextRef context = NSGraphicsContext.currentContext.CGContext; - [self renderInContext:context]; - return YES; - }]; + 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:contextSize]; + + [image addRepresentation:representation]; + } else { + image = [NSImage imageWithSize:contextSize flipped:NO drawingHandler:^BOOL(NSRect dstRect) { + CGContextRef context = NSGraphicsContext.currentContext.CGContext; + [self renderInContext:context]; + return YES; + }]; + } return image; #endif } @@ -159,11 +173,25 @@ - (LookinImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { #elif TARGET_OS_OSX - NSImage *image = [NSImage imageWithSize:contextSize flipped:YES drawingHandler:^BOOL(NSRect dstRect) { - CGContextRef context = NSGraphicsContext.currentContext.CGContext; - [self renderInContext:context]; - return YES; - }]; + 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:contextSize]; + + [image addRepresentation:representation]; + } else { + image = [NSImage imageWithSize:contextSize flipped:NO drawingHandler:^BOOL(NSRect dstRect) { + CGContextRef context = NSGraphicsContext.currentContext.CGContext; + [self renderInContext:context]; + return YES; + }]; + } #endif [visibleSublayers enumerateObjectsUsingBlock:^(CALayer * _Nonnull sublayer, NSUInteger idx, BOOL * _Nonnull stop) { sublayer.hidden = NO; diff --git a/Src/Main/Server/Category/UIView+LookinServer.m b/Src/Main/Server/Category/UIView+LookinServer.m index d08b1ba..bb47376 100644 --- a/Src/Main/Server/Category/UIView+LookinServer.m +++ b/Src/Main/Server/Category/UIView+LookinServer.m @@ -90,7 +90,7 @@ - (CGSize)lks_bestSize { if ([self isKindOfClass:[NSControl class]]) { return [((NSControl *)self) sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)]; } else { - return self.bounds.size; + return self.fittingSize; } #endif } @@ -286,7 +286,7 @@ - (LookinImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality { } [self cacheDisplayInRect:self.bounds toBitmapImageRep:rep]; - NSImage *image = [[NSImage alloc] initWithSize:self.bounds.size]; + NSImage *image = [[NSImage alloc] initWithSize:contextSize]; [image addRepresentation:rep]; @@ -335,7 +335,7 @@ - (LookinImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { } [self cacheDisplayInRect:self.bounds toBitmapImageRep:rep]; - NSImage *image = [[NSImage alloc] initWithSize:self.bounds.size]; + NSImage *image = [[NSImage alloc] initWithSize:contextSize]; [image addRepresentation:rep]; [visibleSubviews enumerateObjectsUsingBlock:^(NSView * _Nonnull subview, NSUInteger idx, BOOL * _Nonnull stop) { diff --git a/Src/Main/Server/Connection/LKS_ConnectionManager.h b/Src/Main/Server/Connection/LKS_ConnectionManager.h index 48cb793..cf3b048 100644 --- a/Src/Main/Server/Connection/LKS_ConnectionManager.h +++ b/Src/Main/Server/Connection/LKS_ConnectionManager.h @@ -8,7 +8,7 @@ // https://lookin.work // -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE #import #elif TARGET_OS_MAC #import diff --git a/Src/Main/Server/Connection/RequestHandler/LKS_HierarchyDetailsHandler.m b/Src/Main/Server/Connection/RequestHandler/LKS_HierarchyDetailsHandler.m index 529b8e2..b4bef1e 100644 --- a/Src/Main/Server/Connection/RequestHandler/LKS_HierarchyDetailsHandler.m +++ b/Src/Main/Server/Connection/RequestHandler/LKS_HierarchyDetailsHandler.m @@ -78,8 +78,6 @@ - (void)_dequeueAndHandlePackage { #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; @@ -116,7 +114,6 @@ - (void)_dequeueAndHandlePackage { return itemDetail; } #endif - if (!object || ![object isKindOfClass:[CALayer class]]) { itemDetail.failureCode = -1; return itemDetail; diff --git a/Src/Main/Server/Others/LKS_AttrGroupsMaker.m b/Src/Main/Server/Others/LKS_AttrGroupsMaker.m index 4c68ff3..b529341 100644 --- a/Src/Main/Server/Others/LKS_AttrGroupsMaker.m +++ b/Src/Main/Server/Others/LKS_AttrGroupsMaker.m @@ -326,7 +326,7 @@ + (LookinAttribute *)_attributeWithIdentifer:(LookinAttrIdentifier)identifier ta LookinInsets targetValue; [invocation getReturnValue:&targetValue]; attribute.attrType = LookinAttrTypeUIEdgeInsets; - attribute.value = [NSValue valueWithEdgeInsets:targetValue]; + attribute.value = [NSValue valueWithInsets:targetValue]; #if !TARGET_OS_OSX } else if (strcmp(returnType, @encode(UIOffset)) == 0) { UIOffset targetValue; diff --git a/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m b/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m index 8f5e935..045880c 100644 --- a/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m +++ b/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m @@ -90,8 +90,8 @@ + (LookinDisplayItem *)_displayItemWithLayer:(CALayer *)layer screenshots:(BOOL) item.layerObject = [LookinObject instanceWithObject:layer]; item.shouldCaptureImage = [LKSConfigManager shouldCaptureScreenshotOfLayer:layer]; - if (layer.lks_hostView) { - LookinView *view = layer.lks_hostView; + LookinView *view = layer.lks_hostView; + if (view) { item.viewObject = [LookinObject instanceWithObject:view]; item.eventHandlers = [LKS_EventHandlerMaker makeForView:view]; item.backgroundColor = [view valueForKeyPath:@"backgroundColor"]; diff --git a/Src/Main/Server/Others/LKS_TraceManager.m b/Src/Main/Server/Others/LKS_TraceManager.m index 23b429d..850df1e 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() @@ -78,24 +78,23 @@ - (void)reload { [[LKS_MultiplatformAdapter allWindows] enumerateObjectsUsingBlock:^(__kindof LookinWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) { #if TARGET_OS_IPHONE [self _addTraceForLayersRootedByLayer:window.layer]; -#endif - -#if TARGET_OS_OSX - [self _addTraceForInterfaceObject:window]; +#elif TARGET_OS_OSX + [self _addTraceForLayersRootedByLayer:window.lks_rootView.layer]; #endif }]; } -#if TARGET_OS_IPHONE - (void)_addTraceForLayersRootedByLayer:(CALayer *)layer { 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]; LookinViewController* vc = [view lks_findHostViewController]; @@ -112,7 +111,6 @@ - (void)_addTraceForLayersRootedByLayer:(CALayer *)layer { [self _addTraceForLayersRootedByLayer:sublayer]; }]; } -#endif #if TARGET_OS_OSX - (void)_addTraceForInterfaceObject:(id)interfaceObject { @@ -139,8 +137,6 @@ - (void)_addTraceForInterfaceObject:(id)interfaceObject { [self _addTraceForInterfaceObject:subview]; }]; } - - } #endif @@ -149,7 +145,7 @@ - (void)_buildSpecialTraceForView:(LookinView *)view { if (vc) { view.lks_specialTrace = [NSString stringWithFormat:@"%@.view", NSStringFromClass(vc.class)]; -#if !TARGET_OS_OSX +#if TARGET_OS_IPHONE } else if ([view isKindOfClass:[LookinWindow class]]) { CGFloat currentWindowLevel = ((LookinWindow *)view).windowLevel; @@ -206,9 +202,7 @@ - (void)_buildSpecialTraceForView:(LookinView *)view { NSIndexPath *indexPath = [collectionView indexPathForCell:cell]; cell.lks_specialTrace = [NSString stringWithFormat:@"{ item:%@, sec:%@ }", @(indexPath.item), @(indexPath.section)]; }]; -#endif - -#if TARGET_OS_OSX +#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)]; diff --git a/Src/Main/Shared/Category/Color+Lookin.h b/Src/Main/Shared/Category/Color+Lookin.h index 18a040e..9a49ab9 100644 --- a/Src/Main/Shared/Category/Color+Lookin.h +++ b/Src/Main/Shared/Category/Color+Lookin.h @@ -9,7 +9,7 @@ #import -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE #elif TARGET_OS_MAC diff --git a/Src/Main/Shared/Category/Image+Lookin.h b/Src/Main/Shared/Category/Image+Lookin.h index 5b807e3..7fe33c8 100644 --- a/Src/Main/Shared/Category/Image+Lookin.h +++ b/Src/Main/Shared/Category/Image+Lookin.h @@ -9,7 +9,7 @@ #import -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE #elif TARGET_OS_MAC diff --git a/Src/Main/Shared/Category/NSSet+Lookin.h b/Src/Main/Shared/Category/NSSet+Lookin.h index 1b4371d..5d40660 100644 --- a/Src/Main/Shared/Category/NSSet+Lookin.h +++ b/Src/Main/Shared/Category/NSSet+Lookin.h @@ -10,8 +10,6 @@ #import "LookinDefines.h" - - #import "TargetConditionals.h" #if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #import 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/NSValue+Lookin.h b/Src/Main/Shared/Category/NSValue+Lookin.h index fe5e6ee..ca8603d 100644 --- a/Src/Main/Shared/Category/NSValue+Lookin.h +++ b/Src/Main/Shared/Category/NSValue+Lookin.h @@ -10,7 +10,6 @@ NS_ASSUME_NONNULL_BEGIN - NSString *NSStringFromInsets(LookinInsets insets); #if TARGET_OS_OSX NSString *NSStringFromCGAffineTransform(CGAffineTransform transform); diff --git a/Src/Main/Shared/Category/NSValue+Lookin.m b/Src/Main/Shared/Category/NSValue+Lookin.m index f719fe9..43edcfa 100644 --- a/Src/Main/Shared/Category/NSValue+Lookin.m +++ b/Src/Main/Shared/Category/NSValue+Lookin.m @@ -8,14 +8,14 @@ #import "NSValue+Lookin.h" NSString *NSStringFromInsets(LookinInsets insets) { - return [NSString stringWithFormat:@"{%.*g, %.*g, %.*g, %.*g}", insets.top, insets.left, insets.bottom, insets.right]; + 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]", transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty]; + 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}", vector.dx, vector.dy]; + return [NSString stringWithFormat:@"{%.*g, %.*g}", 17, vector.dx, 17, vector.dy]; } NSString *NSStringFromCGRect(CGRect rect) { return NSStringFromRect(rect); @@ -27,7 +27,7 @@ return NSStringFromSize(size); } NSString *NSStringFromDirectionalEdgeInsets(NSDirectionalEdgeInsets insets) { - return [NSString stringWithFormat:@"{%.*g, %.*g, %.*g, %.*g}", insets.top, insets.leading, insets.bottom, insets.trailing]; + return [NSString stringWithFormat:@"{%.*g, %.*g, %.*g, %.*g}", 17, insets.top, 17, insets.leading, 17, insets.bottom, 17, insets.trailing]; } #endif @implementation NSValue (Lookin) diff --git a/Src/Main/Shared/LKS_MultiplatformAdapter.h b/Src/Main/Shared/LKS_MultiplatformAdapter.h index e40fcde..2b7875d 100644 --- a/Src/Main/Shared/LKS_MultiplatformAdapter.h +++ b/Src/Main/Shared/LKS_MultiplatformAdapter.h @@ -31,6 +31,8 @@ NS_ASSUME_NONNULL_BEGIN + (BOOL)isiPad; ++ (BOOL)isMac; + @end NS_ASSUME_NONNULL_END diff --git a/Src/Main/Shared/LKS_MultiplatformAdapter.m b/Src/Main/Shared/LKS_MultiplatformAdapter.m index e3589ec..a09490a 100644 --- a/Src/Main/Shared/LKS_MultiplatformAdapter.m +++ b/Src/Main/Shared/LKS_MultiplatformAdapter.m @@ -1,7 +1,7 @@ #ifdef SHOULD_COMPILE_LOOKIN_SERVER // // LKS_MultiplatformAdapter.m -// +// // // Created by nixjiang on 2024/3/12. // @@ -29,9 +29,15 @@ + (BOOL)isiPad { }); return s_isiPad; +#else + return NO; #endif - +} + ++ (BOOL)isMac { #if TARGET_OS_OSX + return YES; +#else return NO; #endif } @@ -42,7 +48,8 @@ + (CGRect)mainScreenBounds { #elif TARGET_OS_IPHONE return [UIScreen mainScreen].bounds; #elif TARGET_OS_OSX - return [NSScreen mainScreen].frame; + // 这里不能返回屏幕的bounds,因为在macOS上,窗口可以不全屏显示,Lookin的设计是基于窗口的,一般iOS中屏幕的bounds就是窗口的bounds,所以这里直接返回窗口的bounds + return NSApplication.sharedApplication.windows.firstObject.contentView.bounds; #else return CGRectZero; #endif @@ -78,8 +85,12 @@ + (UIWindowScene *)getFirstActiveWindowScene { + (LookinWindow *)keyWindow { #if TARGET_OS_VISION return [self getFirstActiveWindowScene].keyWindow; -#else +#elif TARGET_OS_IPHONE return [LookinApplication sharedApplication].keyWindow; +#elif TARGET_OS_OSX + return [LookinApplication sharedApplication].windows.firstObject; +#else + return nil; #endif } diff --git a/Src/Main/Shared/LookinAppInfo.h b/Src/Main/Shared/LookinAppInfo.h index 01623ba..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 diff --git a/Src/Main/Shared/LookinAppInfo.m b/Src/Main/Shared/LookinAppInfo.m index d20b1aa..24c776f 100644 --- a/Src/Main/Shared/LookinAppInfo.m +++ b/Src/Main/Shared/LookinAppInfo.m @@ -160,6 +160,8 @@ + (LookinAppInfo *)currentInfoWithScreenshot:(BOOL)hasScreenshot icon:(BOOL)hasI info.deviceType = LookinAppInfoDeviceSimulator; } else if ([LKS_MultiplatformAdapter isiPad]) { info.deviceType = LookinAppInfoDeviceIPad; + } else if ([LKS_MultiplatformAdapter isMac]) { + info.deviceType = LookinAppInfoDeviceMac; } else { info.deviceType = LookinAppInfoDeviceOthers; } diff --git a/Src/Main/Shared/LookinCustomDisplayItemInfo.m b/Src/Main/Shared/LookinCustomDisplayItemInfo.m index fb164dc..a59778a 100644 --- a/Src/Main/Shared/LookinCustomDisplayItemInfo.m +++ b/Src/Main/Shared/LookinCustomDisplayItemInfo.m @@ -8,7 +8,7 @@ // #import "LookinCustomDisplayItemInfo.h" -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE #import #endif @@ -18,7 +18,7 @@ - (id)copyWithZone:(NSZone *)zone { LookinCustomDisplayItemInfo *newInstance = [[LookinCustomDisplayItemInfo allocWithZone:zone] init]; if (self.frameInWindow) { -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE CGRect rect = [self.frameInWindow CGRectValue]; newInstance.frameInWindow = [NSValue valueWithCGRect:rect]; #elif TARGET_OS_MAC diff --git a/Src/Main/Shared/LookinDisplayItem.h b/Src/Main/Shared/LookinDisplayItem.h index ca5fd12..cea7247 100644 --- a/Src/Main/Shared/LookinDisplayItem.h +++ b/Src/Main/Shared/LookinDisplayItem.h @@ -12,7 +12,7 @@ #import "LookinObject.h" #import "LookinDefines.h" #import "LookinCustomDisplayItemInfo.h" -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE #import #elif TARGET_OS_MAC #import diff --git a/Src/Main/Shared/LookinDisplayItem.m b/Src/Main/Shared/LookinDisplayItem.m index b5d10d1..d28266c 100644 --- a/Src/Main/Shared/LookinDisplayItem.m +++ b/Src/Main/Shared/LookinDisplayItem.m @@ -19,7 +19,7 @@ #import "NSObject+Lookin.h" #import "LookinDashboardBlueprint.h" -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE #import "UIColor+LookinServer.h" #import "UIImage+LookinServer.h" #elif TARGET_OS_MAC @@ -147,7 +147,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder { self.shouldCaptureImage = [aDecoder containsValueForKey:@"shouldCaptureImage"] ? [aDecoder decodeBoolForKey:@"shouldCaptureImage"] : YES; self.customDisplayTitle = [aDecoder decodeObjectForKey:@"customDisplayTitle"]; self.danceuiSource = [aDecoder decodeObjectForKey:@"danceuiSource"]; -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE self.frame = [aDecoder decodeCGRectForKey:@"frame"]; self.bounds = [aDecoder decodeCGRectForKey:@"bounds"]; self.backgroundColor = [UIColor lks_colorFromRGBAComponents:[aDecoder decodeObjectForKey:@"backgroundColor"]]; From cde704375cdd1f59d16414ca7d75a708f142dcf7 Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Wed, 6 Nov 2024 18:21:02 +0800 Subject: [PATCH 08/21] Fix errors --- LookinDemo/OC_Pod/Podfile.lock | 2 +- .../Server/Category/UIView+LookinServer.m | 2 ++ .../LKS_AttrModificationPatchHandler.m | 2 +- .../Server/Others/LKS_CustomAttrGroupsMaker.m | 2 ++ Src/Main/Server/Others/LKS_ExportManager.m | 1 + Src/Main/Shared/Category/NSValue+Lookin.m | 12 +++++++++ Src/Main/Shared/LKS_MultiplatformAdapter.m | 4 +-- Src/Main/Shared/LookinAppInfo.m | 26 +++---------------- 8 files changed, 25 insertions(+), 26 deletions(-) diff --git a/LookinDemo/OC_Pod/Podfile.lock b/LookinDemo/OC_Pod/Podfile.lock index c109a67..8e47ade 100644 --- a/LookinDemo/OC_Pod/Podfile.lock +++ b/LookinDemo/OC_Pod/Podfile.lock @@ -11,7 +11,7 @@ EXTERNAL SOURCES: :path: "../../" SPEC CHECKSUMS: - LookinServer: 1035f6880a1ccdada647fbd1f59b44ddd005fdf4 + LookinServer: 32e176f3ef9dfbda52026e2d9e18b7204c141272 PODFILE CHECKSUM: c1b5f203c9e81bcbf3888ba95a03c31e2435a4f7 diff --git a/Src/Main/Server/Category/UIView+LookinServer.m b/Src/Main/Server/Category/UIView+LookinServer.m index bb47376..d2d4f86 100644 --- a/Src/Main/Server/Category/UIView+LookinServer.m +++ b/Src/Main/Server/Category/UIView+LookinServer.m @@ -257,6 +257,7 @@ - (LookinConstraintItemType)_lks_constraintItemTypeForItem:(id)item { #pragma mark - Screenshot +#if TARGET_OS_OSX - (LookinImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality { CGFloat screenScale = [LKS_MultiplatformAdapter mainScreenScale]; @@ -345,6 +346,7 @@ - (LookinImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { } return nil; } +#endif @end diff --git a/Src/Main/Server/Connection/RequestHandler/LKS_AttrModificationPatchHandler.m b/Src/Main/Server/Connection/RequestHandler/LKS_AttrModificationPatchHandler.m index 5416ab6..b018868 100644 --- a/Src/Main/Server/Connection/RequestHandler/LKS_AttrModificationPatchHandler.m +++ b/Src/Main/Server/Connection/RequestHandler/LKS_AttrModificationPatchHandler.m @@ -29,8 +29,8 @@ + (void)handleLayerOids:(NSArray *)oids lowImageQuality:(BOOL)lowIma LookinDisplayItemDetail *detail = [LookinDisplayItemDetail new]; detail.displayItemOid = oid; -#if TARGET_OS_OSX id object = [NSObject lks_objectWithOid:oid]; +#if TARGET_OS_OSX NSView *view = object; if (view && [view isKindOfClass:[NSView class]] && !view.layer) { if (idx == 0) { diff --git a/Src/Main/Server/Others/LKS_CustomAttrGroupsMaker.m b/Src/Main/Server/Others/LKS_CustomAttrGroupsMaker.m index e68b6b2..89df56b 100644 --- a/Src/Main/Server/Others/LKS_CustomAttrGroupsMaker.m +++ b/Src/Main/Server/Others/LKS_CustomAttrGroupsMaker.m @@ -71,6 +71,7 @@ - (void)execute { } for (NSString *name in selectors) { +#if TARGET_OS_OSX if (self.view && !self.view.layer) { [self makeAttrsForViewOrLayer:self.view selectorName:name]; CALayer *layer = self.view.layer; @@ -79,6 +80,7 @@ - (void)execute { } continue; } +#endif if (self.layer) { [self makeAttrsForViewOrLayer:self.layer selectorName:name]; diff --git a/Src/Main/Server/Others/LKS_ExportManager.m b/Src/Main/Server/Others/LKS_ExportManager.m index a7889aa..0c423ef 100644 --- a/Src/Main/Server/Others/LKS_ExportManager.m +++ b/Src/Main/Server/Others/LKS_ExportManager.m @@ -15,6 +15,7 @@ #import "LookinAppInfo.h" #import "LookinServerDefines.h" #import "LKS_MultiplatformAdapter.h" +#import "LookinHierarchyInfo+LookinServer.h" #if TARGET_OS_IPHONE @interface LKS_ExportManagerMaskView : UIView diff --git a/Src/Main/Shared/Category/NSValue+Lookin.m b/Src/Main/Shared/Category/NSValue+Lookin.m index 43edcfa..50871fd 100644 --- a/Src/Main/Shared/Category/NSValue+Lookin.m +++ b/Src/Main/Shared/Category/NSValue+Lookin.m @@ -77,11 +77,23 @@ - (CGSize)CGSizeValue { } #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/Shared/LKS_MultiplatformAdapter.m b/Src/Main/Shared/LKS_MultiplatformAdapter.m index a09490a..8b33303 100644 --- a/Src/Main/Shared/LKS_MultiplatformAdapter.m +++ b/Src/Main/Shared/LKS_MultiplatformAdapter.m @@ -43,7 +43,7 @@ + (BOOL)isMac { } + (CGRect)mainScreenBounds { -#if TARGET_OS_VISION +#if TARGET_OS_VISION || TARGET_OS_MACCATALYST return [LKS_MultiplatformAdapter getFirstActiveWindowScene].coordinateSpace.bounds; #elif TARGET_OS_IPHONE return [UIScreen mainScreen].bounds; @@ -67,7 +67,7 @@ + (CGFloat)mainScreenScale { #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]) { diff --git a/Src/Main/Shared/LookinAppInfo.m b/Src/Main/Shared/LookinAppInfo.m index 24c776f..14ab857 100644 --- a/Src/Main/Shared/LookinAppInfo.m +++ b/Src/Main/Shared/LookinAppInfo.m @@ -167,7 +167,7 @@ + (LookinAppInfo *)currentInfoWithScreenshot:(BOOL)hasScreenshot icon:(BOOL)hasI } #if TARGET_OS_IPHONE - info.osDescription = [UIDevice currentDevice].systemVersion; + info.osDescription = [NSString stringWithFormat:@"iOS %@", [UIDevice currentDevice].systemVersion]; NSString *mainVersionStr = [[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."].firstObject; info.osMainVersion = [mainVersionStr integerValue]; #elif TARGET_OS_OSX @@ -245,29 +245,11 @@ + (LookinImage *)screenshotImage { UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); #elif TARGET_OS_OSX - NSView *view = window.contentView.superview; - if (!window || !view) { + if (!window) { return nil; } - - NSRect rect = view.bounds; - rect = [view convertRect:rect toView:nil]; - rect = [window convertRectToScreen:rect]; - -// Adjust for titlebar; kTitleUtility = 16, kTitleNormal = 22 -#define kTitleUtility 16 -#define kTitleNormal 22 - - CGFloat delta = ([window styleMask] & NSWindowStyleMaskUtilityWindow) ? kTitleUtility : kTitleNormal; - rect.origin.y += delta; - rect.size.height += delta * 2; - - CGImageRef cgImage = CGWindowListCreateImage(rect, - kCGWindowListOptionIncludingWindow, - (CGWindowID)[window windowNumber], - kCGWindowImageBestResolution); - - NSImage *image = [[NSImage alloc] initWithCGImage:cgImage size:rect.size]; + CGImageRef cgImage = CGWindowListCreateImage(CGRectZero, kCGWindowListOptionIncludingWindow, (int)window.windowNumber, kCGWindowImageBoundsIgnoreFraming); + NSImage *image = [[NSImage alloc] initWithCGImage:cgImage size:window.frame.size]; CGImageRelease(cgImage); #endif From a3bbccc9c7eeb4b9e3adcfa433ef32d7be57a57f Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Wed, 6 Nov 2024 23:51:41 +0800 Subject: [PATCH 09/21] [WIP] AppKit Support --- .../Server/Category/UILabel+LookinServer.h | 3 +- .../Server/Category/UILabel+LookinServer.m | 3 - .../Category/UITextField+LookinServer.h | 11 +- .../Category/UITextField+LookinServer.m | 10 +- .../Server/Category/UITextView+LookinServer.h | 11 +- .../Server/Category/UITextView+LookinServer.m | 10 +- Src/Main/Shared/LookinAttrIdentifiers.h | 214 ++++++++++++++- Src/Main/Shared/LookinAttrIdentifiers.m | 2 + Src/Main/Shared/LookinDashboardBlueprint.m | 250 +++++++++++++++--- Src/Main/Shared/LookinDefines.h | 4 + 10 files changed, 457 insertions(+), 61 deletions(-) diff --git a/Src/Main/Server/Category/UILabel+LookinServer.h b/Src/Main/Server/Category/UILabel+LookinServer.h index fd899af..62bf12a 100644 --- a/Src/Main/Server/Category/UILabel+LookinServer.h +++ b/Src/Main/Server/Category/UILabel+LookinServer.h @@ -9,6 +9,7 @@ // #if TARGET_OS_IPHONE + #import @interface UILabel (LookinServer) @@ -18,9 +19,7 @@ - (NSString *)lks_fontName; @end -#endif -#if TARGET_OS_OSX #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 dedc470..e00d492 100644 --- a/Src/Main/Server/Category/UILabel+LookinServer.m +++ b/Src/Main/Server/Category/UILabel+LookinServer.m @@ -28,7 +28,4 @@ - (NSString *)lks_fontName { @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 6768428..603d7a7 100644 --- a/Src/Main/Server/Category/UITextField+LookinServer.h +++ b/Src/Main/Server/Category/UITextField+LookinServer.h @@ -8,19 +8,22 @@ // https://lookin.work // + #if TARGET_OS_IPHONE #import +#elif TARGET_OS_OSX +#import +#endif + +#import "LookinDefines.h" -@interface UITextField (LookinServer) +@interface LookinTextField (LookinServer) @property(nonatomic, assign) CGFloat lks_fontSize; - (NSString *)lks_fontName; @end -#endif -#if TARGET_OS_OSX -#endif #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Category/UITextField+LookinServer.m b/Src/Main/Server/Category/UITextField+LookinServer.m index 203d75d..5b37cd5 100644 --- a/Src/Main/Server/Category/UITextField+LookinServer.m +++ b/Src/Main/Server/Category/UITextField+LookinServer.m @@ -8,16 +8,16 @@ // https://lookin.work // -#if TARGET_OS_IPHONE + #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; } @@ -26,9 +26,5 @@ - (NSString *)lks_fontName { } @end -#endif - -#if TARGET_OS_OSX -#endif #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Category/UITextView+LookinServer.h b/Src/Main/Server/Category/UITextView+LookinServer.h index db28a62..2e0a963 100644 --- a/Src/Main/Server/Category/UITextView+LookinServer.h +++ b/Src/Main/Server/Category/UITextView+LookinServer.h @@ -10,17 +10,18 @@ #if TARGET_OS_IPHONE #import +#elif TARGET_OS_OSX +#import +#endif + +#import "LookinDefines.h" -@interface UITextView (LookinServer) +@interface LookinTextView (LookinServer) @property(nonatomic, assign) CGFloat lks_fontSize; - (NSString *)lks_fontName; @end -#endif - -#if TARGET_OS_OSX -#endif #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Category/UITextView+LookinServer.m b/Src/Main/Server/Category/UITextView+LookinServer.m index 37452b4..7d1538c 100644 --- a/Src/Main/Server/Category/UITextView+LookinServer.m +++ b/Src/Main/Server/Category/UITextView+LookinServer.m @@ -8,16 +8,16 @@ // https://lookin.work // -#if TARGET_OS_IPHONE + #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; } @@ -26,9 +26,5 @@ - (NSString *)lks_fontName { } @end -#endif - -#if TARGET_OS_OSX -#endif #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Shared/LookinAttrIdentifiers.h b/Src/Main/Shared/LookinAttrIdentifiers.h index 577d532..3987159 100644 --- a/Src/Main/Shared/LookinAttrIdentifiers.h +++ b/Src/Main/Shared/LookinAttrIdentifiers.h @@ -22,6 +22,8 @@ extern LookinAttrGroupIdentifier const LookinAttrGroup_Relation; extern LookinAttrGroupIdentifier const LookinAttrGroup_Layout; extern LookinAttrGroupIdentifier const LookinAttrGroup_AutoLayout; extern LookinAttrGroupIdentifier const LookinAttrGroup_ViewLayer; + +#if TARGET_OS_IPHONE extern LookinAttrGroupIdentifier const LookinAttrGroup_UIImageView; extern LookinAttrGroupIdentifier const LookinAttrGroup_UILabel; extern LookinAttrGroupIdentifier const LookinAttrGroup_UIControl; @@ -32,6 +34,19 @@ extern LookinAttrGroupIdentifier const LookinAttrGroup_UITextView; extern LookinAttrGroupIdentifier const LookinAttrGroup_UITextField; extern LookinAttrGroupIdentifier const LookinAttrGroup_UIVisualEffectView; extern LookinAttrGroupIdentifier const LookinAttrGroup_UIStackView; +#endif + +#if TARGET_OS_OSX +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; +#endif extern LookinAttrGroupIdentifier const LookinAttrGroup_UserCustom; @@ -64,9 +79,12 @@ 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; + +#if TARGET_OS_IPHONE + 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; @@ -131,6 +149,73 @@ extern LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Axis; extern LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Distribution; extern LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Alignment; extern LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Spacing; +#endif + +#if TARGET_OS_OSX + +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_NSTextField_Text; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Font; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_NumberOfLines; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_TextColor; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_BreakMode; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Alignment; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_CanAdjustFont; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Placeholder; + +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_Style; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_SectionsNumber; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_RowsNumber; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_SeparatorStyle; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_SeparatorColor; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_SeparatorInset; + +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_Basic; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_Text; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_Font; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_TextColor; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_Alignment; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_ContainerInset; + +extern LookinAttrSectionIdentifier const LookinAttrSec_NSVisualEffectView_Style; + +extern LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Axis; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Distribution; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Alignment; +extern LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Spacing; +#endif #pragma mark - Attr @@ -176,6 +261,8 @@ extern LookinAttrIdentifier const LookinAttr_ViewLayer_TintColor_Color; extern LookinAttrIdentifier const LookinAttr_ViewLayer_TintColor_Mode; extern LookinAttrIdentifier const LookinAttr_ViewLayer_Tag_Tag; +#if TARGET_OS_IPHONE + extern LookinAttrIdentifier const LookinAttr_UIImageView_Name_Name; extern LookinAttrIdentifier const LookinAttr_UIImageView_Open_Open; @@ -253,5 +340,130 @@ extern LookinAttrIdentifier const LookinAttr_UIStackView_Axis_Axis; extern LookinAttrIdentifier const LookinAttr_UIStackView_Distribution_Distribution; extern LookinAttrIdentifier const LookinAttr_UIStackView_Alignment_Alignment; extern LookinAttrIdentifier const LookinAttr_UIStackView_Spacing_Spacing; +#endif + +#if TARGET_OS_OSX + +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_Text_Text; +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_NSTextField_Text_Text; +extern LookinAttrIdentifier const LookinAttr_NSTextField_Placeholder_Placeholder; +extern LookinAttrIdentifier const LookinAttr_NSTextField_Font_Name; +extern LookinAttrIdentifier const LookinAttr_NSTextField_Font_Size; +extern LookinAttrIdentifier const LookinAttr_NSTextField_TextColor_Color; +extern LookinAttrIdentifier const LookinAttr_NSTextField_Alignment_Alignment; + +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 #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Shared/LookinAttrIdentifiers.m b/Src/Main/Shared/LookinAttrIdentifiers.m index 29a1f98..7635a5e 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"; +#if TARGET_OS_IPHONE LookinAttrGroupIdentifier const LookinAttrGroup_UIImageView = @"i"; LookinAttrGroupIdentifier const LookinAttrGroup_UILabel = @"la"; LookinAttrGroupIdentifier const LookinAttrGroup_UIControl = @"co"; @@ -33,6 +34,7 @@ LookinAttrGroupIdentifier const LookinAttrGroup_UITextField = @"tf"; LookinAttrGroupIdentifier const LookinAttrGroup_UIVisualEffectView = @"ve"; LookinAttrGroupIdentifier const LookinAttrGroup_UIStackView = @"UIStackView"; +#endif LookinAttrGroupIdentifier const LookinAttrGroup_UserCustom = @"guc"; // user custom diff --git a/Src/Main/Shared/LookinDashboardBlueprint.m b/Src/Main/Shared/LookinDashboardBlueprint.m index 3daf035..595f7f6 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,81 @@ @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_Style, + LookinAttrSec_NSTableView_SectionsNumber, + LookinAttrSec_NSTableView_RowsNumber, + LookinAttrSec_NSTableView_SeparatorStyle, + LookinAttrSec_NSTableView_SeparatorColor, + LookinAttrSec_NSTableView_SeparatorInset + ], + + LookinAttrGroup_NSTextView: @[ + LookinAttrSec_NSTextView_Basic, + LookinAttrSec_NSTextView_Text, + LookinAttrSec_NSTextView_Font, + LookinAttrSec_NSTextView_TextColor, + LookinAttrSec_NSTextView_Alignment, + LookinAttrSec_NSTextView_ContainerInset + ], + + LookinAttrGroup_NSTextField: @[ + LookinAttrSec_NSTextField_Text, + LookinAttrSec_NSTextField_Font, + LookinAttrSec_NSTextField_NumberOfLines, + LookinAttrSec_NSTextField_TextColor, + LookinAttrSec_NSTextField_BreakMode, + LookinAttrSec_NSTextField_Alignment, + LookinAttrSec_NSTextField_CanAdjustFont, + LookinAttrSec_NSTextField_Placeholder, + ], + + + LookinAttrGroup_NSVisualEffectView: @[ + LookinAttrSec_NSVisualEffectView_Style, + ], +#endif }; }); @@ -185,13 +276,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 +408,10 @@ @implementation LookinDashboardBlueprint LookinAttr_UITextField_CanAdjustFont_MinSize], LookinAttrSec_UITextField_ClearButtonMode: @[LookinAttr_UITextField_ClearButtonMode_Mode] +#endif +#if TARGET_OS_OSX + +#endif }; }); return dict[sectionID]; @@ -353,6 +451,7 @@ + (NSString *)groupTitleWithGroupID:(LookinAttrGroupIdentifier)groupID { LookinAttrGroup_Relation: @"Relation", LookinAttrGroup_Layout: @"Layout", LookinAttrGroup_AutoLayout: @"AutoLayout", +#if TARGET_OS_IPHONE LookinAttrGroup_ViewLayer: @"CALayer / UIView", LookinAttrGroup_UIImageView: @"UIImageView", LookinAttrGroup_UILabel: @"UILabel", @@ -364,6 +463,19 @@ + (NSString *)groupTitleWithGroupID:(LookinAttrGroupIdentifier)groupID { LookinAttrGroup_UITextField: @"UITextField", LookinAttrGroup_UIVisualEffectView: @"UIVisualEffectView", LookinAttrGroup_UIStackView: @"UIStackView" +#endif +#if TARGET_OS_OSX + 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" +#endif }; }); NSString *title = rawInfo[groupID]; @@ -388,9 +500,10 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { LookinAttrSec_ViewLayer_BgColor: @"BackgroundColor", LookinAttrSec_ViewLayer_Border: @"Border", LookinAttrSec_ViewLayer_Shadow: @"Shadow", + LookinAttrSec_ViewLayer_Tag: @"Tag", +#if TARGET_OS_IPHONE 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 +549,7 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { LookinAttrSec_UITextView_Font: @"Font", LookinAttrSec_UITextView_ContainerInset: @"ContainerInset", LookinAttrSec_UITextField_ClearButtonMode: @"ClearButtonMode", +#endif }; }); return rawInfo[secID]; @@ -493,12 +607,22 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"fullTitle": @"Bounds", @"patch": @(YES) }, +#if TARGET_OS_IPHONE LookinAttr_Layout_SafeArea_SafeArea: @{ @"className": @"UIView", @"fullTitle": @"SafeAreaInsets", @"setterString": @"", @"osVersion": @(11) }, +#endif +#if TARGET_OS_OSX + LookinAttr_Layout_SafeArea_SafeArea: @{ + @"className": @"NSView", + @"fullTitle": @"SafeAreaInsets", + @"setterString": @"", + @"osVersion": @(11) + }, +#endif LookinAttr_Layout_Position_Position: @{ @"className": @"CALayer", @"fullTitle": @"Position", @@ -510,6 +634,7 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"patch": @(YES) }, +#if TARGET_OS_IPHONE LookinAttr_AutoLayout_Hugging_Hor: @{ @"className": @"UIView", @"fullTitle": @"ContentHuggingPriority(Horizontal)", @@ -554,7 +679,96 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"fullTitle": @"IntrinsicContentSize", @"setterString": @"" }, +#endif +#if TARGET_OS_OSX + 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": @"" + }, +#endif +#if TARGET_OS_IPHONE + 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) + }, +#endif +#if TARGET_OS_OSX + + LookinAttr_ViewLayer_Tag_Tag: @{ + @"className": @"NSView", + @"fullTitle": @"Tag", + @"briefTitle": @"", + @"patch": @(NO) + }, +#endif LookinAttr_ViewLayer_Visibility_Hidden: @{ @"className": @"CALayer", @"fullTitle": @"Hidden", @@ -568,12 +782,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 +853,7 @@ + (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) - }, +#if TARGET_OS_IPHONE LookinAttr_UIStackView_Axis_Axis: @{ @"className": @"UIStackView", @@ -1088,6 +1273,7 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"enumList": @"UITextFieldViewMode", @"patch": @(NO) }, +#endif }; }); diff --git a/Src/Main/Shared/LookinDefines.h b/Src/Main/Shared/LookinDefines.h index 8b6bc7d..c5b460f 100644 --- a/Src/Main/Shared/LookinDefines.h +++ b/Src/Main/Shared/LookinDefines.h @@ -159,6 +159,8 @@ enum { #define LookinCollectionView UICollectionView #define LookinCollectionElementKindSectionHeader UICollectionElementKindSectionHeader #define LookinCollectionElementKindSectionFooter UICollectionElementKindSectionFooter +#define LookinTextField UITextField +#define LookinTextView UITextView #elif TARGET_OS_OSX #define LookinColor NSColor #define LookinInsets NSEdgeInsets @@ -178,6 +180,8 @@ enum { #define LookinCollectionView NSCollectionView #define LookinCollectionElementKindSectionHeader NSCollectionElementKindSectionHeader #define LookinCollectionElementKindSectionFooter NSCollectionElementKindSectionFooter +#define LookinTextField NSTextField +#define LookinTextView NSTextView #endif #define LookinColorRGBAMake(r, g, b, a) [LookinColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a] From 1dcecc7153b51b5b426e46230f85fb9906fe0d6c Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Thu, 7 Nov 2024 17:34:12 +0800 Subject: [PATCH 10/21] [WIP] AppKit Support --- .../Server/Category/NSButton+LookinServer.h | 18 + .../Server/Category/NSButton+LookinServer.m | 16 + .../Category/NSScrollView+LookinServer.h | 21 + .../Category/NSScrollView+LookinServer.m | 30 + Src/Main/Shared/LookinAttrIdentifiers.h | 104 +- Src/Main/Shared/LookinAttrIdentifiers.m | 235 ++++ Src/Main/Shared/LookinDashboardBlueprint.m | 1146 ++++++++++++++++- 7 files changed, 1521 insertions(+), 49 deletions(-) create mode 100644 Src/Main/Server/Category/NSButton+LookinServer.h create mode 100644 Src/Main/Server/Category/NSButton+LookinServer.m create mode 100644 Src/Main/Server/Category/NSScrollView+LookinServer.h create mode 100644 Src/Main/Server/Category/NSScrollView+LookinServer.m diff --git a/Src/Main/Server/Category/NSButton+LookinServer.h b/Src/Main/Server/Category/NSButton+LookinServer.h new file mode 100644 index 0000000..322ed02 --- /dev/null +++ b/Src/Main/Server/Category/NSButton+LookinServer.h @@ -0,0 +1,18 @@ +// +// NSButton+LookinServer.h +// LookinServer +// +// Created by JH on 2024/11/7. +// + +#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..44353f9 --- /dev/null +++ b/Src/Main/Server/Category/NSScrollView+LookinServer.h @@ -0,0 +1,21 @@ +// +// NSScrollView+LookinServer.h +// LookinServer +// +// Created by JH on 2024/11/7. +// + +#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..e86442a --- /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. +// + +#if TARGET_OS_OSX +#import "NSScrollView+LookinServer.h" + +@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/Shared/LookinAttrIdentifiers.h b/Src/Main/Shared/LookinAttrIdentifiers.h index 3987159..7337355 100644 --- a/Src/Main/Shared/LookinAttrIdentifiers.h +++ b/Src/Main/Shared/LookinAttrIdentifiers.h @@ -185,36 +185,69 @@ extern LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_ScrollElasit extern LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_Misc; extern LookinAttrSectionIdentifier const LookinAttrSec_NSScrollView_Magnification; - -extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Text; -extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Font; -extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_NumberOfLines; -extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_TextColor; -extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_BreakMode; -extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Alignment; -extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_CanAdjustFont; -extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextField_Placeholder; - +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_SectionsNumber; -extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_RowsNumber; -extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_SeparatorStyle; -extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_SeparatorColor; -extern LookinAttrSectionIdentifier const LookinAttrSec_NSTableView_SeparatorInset; +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_Basic; -extern LookinAttrSectionIdentifier const LookinAttrSec_NSTextView_Text; 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_Style; +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_Axis; +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; + #endif #pragma mark - Attr @@ -364,8 +397,6 @@ 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; @@ -378,7 +409,6 @@ extern LookinAttrIdentifier const LookinAttr_NSButton_Misc_ShowsBorderOnlyWhileM 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; @@ -407,8 +437,6 @@ extern LookinAttrIdentifier const LookinAttr_NSScrollView_Magnification_AllowsMa 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; @@ -435,29 +463,39 @@ extern LookinAttrIdentifier const LookinAttr_NSTableView_RowActionsVisible_RowAc 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_Text_Text; +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_NSTextField_Text_Text; +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_Font_Name; -extern LookinAttrIdentifier const LookinAttr_NSTextField_Font_Size; extern LookinAttrIdentifier const LookinAttr_NSTextField_TextColor_Color; -extern LookinAttrIdentifier const LookinAttr_NSTextField_Alignment_Alignment; - 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; diff --git a/Src/Main/Shared/LookinAttrIdentifiers.m b/Src/Main/Shared/LookinAttrIdentifiers.m index 7635a5e..ea94425 100644 --- a/Src/Main/Shared/LookinAttrIdentifiers.m +++ b/Src/Main/Shared/LookinAttrIdentifiers.m @@ -36,6 +36,21 @@ LookinAttrGroupIdentifier const LookinAttrGroup_UIStackView = @"UIStackView"; #endif +#if TARGET_OS_OSX +#if TARGET_OS_OSX +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"; +#endif + +#endif + LookinAttrGroupIdentifier const LookinAttrGroup_UserCustom = @"guc"; // user custom #pragma mark - Section @@ -69,6 +84,8 @@ LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_TintColor = @"v_t"; LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_Tag = @"v_ta"; +#if TARGET_OS_IPHONE + LookinAttrSectionIdentifier const LookinAttrSec_UIImageView_Name = @"i_n"; LookinAttrSectionIdentifier const LookinAttrSec_UIImageView_Open = @"i_o"; @@ -132,6 +149,94 @@ LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Distribution = @"usv_dis"; LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Alignment = @"usv_align"; LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Spacing = @"usv_spa"; +#endif + +#if TARGET_OS_OSX +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"; +#endif #pragma mark - Attr @@ -174,6 +279,8 @@ LookinAttrIdentifier const LookinAttr_ViewLayer_TintColor_Mode = @"vl_t_m"; LookinAttrIdentifier const LookinAttr_ViewLayer_Tag_Tag = @"vl_t_t"; +#if TARGET_OS_IPHONE + LookinAttrIdentifier const LookinAttr_UIImageView_Name_Name = @"iv_n_n"; LookinAttrIdentifier const LookinAttr_UIImageView_Open_Open = @"iv_o_o"; @@ -251,5 +358,133 @@ LookinAttrIdentifier const LookinAttr_UIStackView_Distribution_Distribution = @"usv_dis_dis"; LookinAttrIdentifier const LookinAttr_UIStackView_Alignment_Alignment = @"usv_ali_ali"; LookinAttrIdentifier const LookinAttr_UIStackView_Spacing_Spacing = @"usv_spa_spa"; +#endif + +#if TARGET_OS_OSX +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 + #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Shared/LookinDashboardBlueprint.m b/Src/Main/Shared/LookinDashboardBlueprint.m index 595f7f6..ebd45b8 100644 --- a/Src/Main/Shared/LookinDashboardBlueprint.m +++ b/Src/Main/Shared/LookinDashboardBlueprint.m @@ -197,37 +197,76 @@ @implementation LookinDashboardBlueprint ], LookinAttrGroup_NSTableView: @[ + LookinAttrSec_NSTableView_RowHeight, + LookinAttrSec_NSTableView_AutomaticRowHeights, + LookinAttrSec_NSTableView_IntercellSpacing, LookinAttrSec_NSTableView_Style, - LookinAttrSec_NSTableView_SectionsNumber, - LookinAttrSec_NSTableView_RowsNumber, - LookinAttrSec_NSTableView_SeparatorStyle, - LookinAttrSec_NSTableView_SeparatorColor, - LookinAttrSec_NSTableView_SeparatorInset + 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_Basic, - LookinAttrSec_NSTextView_Text, LookinAttrSec_NSTextView_Font, + LookinAttrSec_NSTextView_Basic, + LookinAttrSec_NSTextView_String, LookinAttrSec_NSTextView_TextColor, LookinAttrSec_NSTextView_Alignment, - LookinAttrSec_NSTextView_ContainerInset + LookinAttrSec_NSTextView_ContainerInset, + LookinAttrSec_NSTextView_BaseWritingDirection, + LookinAttrSec_NSTextView_Size, + LookinAttrSec_NSTextView_Resizable, ], LookinAttrGroup_NSTextField: @[ - LookinAttrSec_NSTextField_Text, - LookinAttrSec_NSTextField_Font, - LookinAttrSec_NSTextField_NumberOfLines, - LookinAttrSec_NSTextField_TextColor, - LookinAttrSec_NSTextField_BreakMode, - LookinAttrSec_NSTextField_Alignment, - LookinAttrSec_NSTextField_CanAdjustFont, + 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_Style, + 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 @@ -410,6 +449,303 @@ @implementation LookinDashboardBlueprint 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 }; @@ -549,6 +885,94 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { LookinAttrSec_UITextView_Font: @"Font", LookinAttrSec_UITextView_ContainerInset: @"ContainerInset", LookinAttrSec_UITextField_ClearButtonMode: @"ClearButtonMode", +#endif + +#if TARGET_OS_OSX + 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", + #endif }; }); @@ -1273,6 +1697,696 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"enumList": @"UITextFieldViewMode", @"patch": @(NO) }, +#elif TARGET_OS_OSX + 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", + @"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", + @"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) + }, #endif }; }); From 5cb640b2656ff9227907085f3f26ac2f4155f3a3 Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Thu, 7 Nov 2024 17:46:43 +0800 Subject: [PATCH 11/21] [WIP] AppKit Support --- Package.swift | 2 +- .../Server/Category/NSButton+LookinServer.h | 2 ++ .../Category/NSScrollView+LookinServer.h | 2 ++ .../Category/NSScrollView+LookinServer.m | 2 +- .../Server/Category/NSWindow+LookinServer.h | 2 ++ .../Category/UIBlurEffect+LookinServer.h | 2 ++ .../Category/UIBlurEffect+LookinServer.m | 4 ++-- .../Server/Category/UIColor+LookinServer.h | 2 ++ .../Server/Category/UIImage+LookinServer.h | 2 ++ .../Server/Category/UIImageView+LookinServer.h | 2 ++ .../Server/Category/UILabel+LookinServer.h | 2 ++ .../Server/Category/UITableView+LookinServer.h | 2 ++ .../Server/Category/UITextField+LookinServer.h | 1 + .../Server/Category/UITextView+LookinServer.h | 2 ++ Src/Main/Server/Category/UIView+LookinServer.h | 2 ++ .../Category/UIViewController+LookinServer.h | 2 ++ .../Category/UIVisualEffectView+LookinServer.h | 2 ++ .../Server/Connection/LKS_ConnectionManager.h | 4 +++- Src/Main/Server/Others/LKSConfigManager.h | 2 ++ .../Others/LKS_CustomDisplayItemsMaker.h | 2 ++ .../Others/LKS_GestureTargetActionsSearcher.h | 2 ++ Src/Main/Shared/Category/Color+Lookin.h | 2 +- Src/Main/Shared/Category/Color+Lookin.m | 2 +- Src/Main/Shared/Category/Image+Lookin.h | 2 ++ Src/Main/Shared/Category/Image+Lookin.m | 2 +- Src/Swift/LKS_SwiftTraceManager.swift | 18 +++++++++++++++--- 26 files changed, 60 insertions(+), 11 deletions(-) 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/Main/Server/Category/NSButton+LookinServer.h b/Src/Main/Server/Category/NSButton+LookinServer.h index 322ed02..ec20a92 100644 --- a/Src/Main/Server/Category/NSButton+LookinServer.h +++ b/Src/Main/Server/Category/NSButton+LookinServer.h @@ -5,6 +5,8 @@ // Created by JH on 2024/11/7. // +#import "TargetConditionals.h" + #if TARGET_OS_OSX #import diff --git a/Src/Main/Server/Category/NSScrollView+LookinServer.h b/Src/Main/Server/Category/NSScrollView+LookinServer.h index 44353f9..84ca964 100644 --- a/Src/Main/Server/Category/NSScrollView+LookinServer.h +++ b/Src/Main/Server/Category/NSScrollView+LookinServer.h @@ -5,6 +5,8 @@ // Created by JH on 2024/11/7. // +#import "TargetConditionals.h" + #if TARGET_OS_OSX #import diff --git a/Src/Main/Server/Category/NSScrollView+LookinServer.m b/Src/Main/Server/Category/NSScrollView+LookinServer.m index e86442a..dd9441e 100644 --- a/Src/Main/Server/Category/NSScrollView+LookinServer.m +++ b/Src/Main/Server/Category/NSScrollView+LookinServer.m @@ -5,8 +5,8 @@ // Created by JH on 2024/11/7. // -#if TARGET_OS_OSX #import "NSScrollView+LookinServer.h" +#if TARGET_OS_OSX @implementation NSScrollView (LookinServer) diff --git a/Src/Main/Server/Category/NSWindow+LookinServer.h b/Src/Main/Server/Category/NSWindow+LookinServer.h index 93683f9..f0a2a39 100644 --- a/Src/Main/Server/Category/NSWindow+LookinServer.h +++ b/Src/Main/Server/Category/NSWindow+LookinServer.h @@ -5,6 +5,8 @@ // Created by JH on 11/5/24. // +#import "TargetConditionals.h" + #if TARGET_OS_OSX #import diff --git a/Src/Main/Server/Category/UIBlurEffect+LookinServer.h b/Src/Main/Server/Category/UIBlurEffect+LookinServer.h index 1f80d87..aae7010 100644 --- a/Src/Main/Server/Category/UIBlurEffect+LookinServer.h +++ b/Src/Main/Server/Category/UIBlurEffect+LookinServer.h @@ -8,6 +8,8 @@ // https://lookin.work // +#import "TargetConditionals.h" + #if TARGET_OS_IPHONE #import diff --git a/Src/Main/Server/Category/UIBlurEffect+LookinServer.m b/Src/Main/Server/Category/UIBlurEffect+LookinServer.m index 6c466fa..e02f6fb 100644 --- a/Src/Main/Server/Category/UIBlurEffect+LookinServer.m +++ b/Src/Main/Server/Category/UIBlurEffect+LookinServer.m @@ -8,12 +8,12 @@ // https://lookin.work // -#if TARGET_OS_IPHONE - #import "UIBlurEffect+LookinServer.h" #import "NSObject+Lookin.h" #import +#if TARGET_OS_IPHONE + @implementation UIBlurEffect (LookinServer) #ifdef LOOKIN_SERVER_DISABLE_HOOK diff --git a/Src/Main/Server/Category/UIColor+LookinServer.h b/Src/Main/Server/Category/UIColor+LookinServer.h index eab0dcf..1812d1c 100644 --- a/Src/Main/Server/Category/UIColor+LookinServer.h +++ b/Src/Main/Server/Category/UIColor+LookinServer.h @@ -8,6 +8,8 @@ // https://lookin.work // +#import "TargetConditionals.h" + #if TARGET_OS_IPHONE #import #endif diff --git a/Src/Main/Server/Category/UIImage+LookinServer.h b/Src/Main/Server/Category/UIImage+LookinServer.h index 9308059..c683530 100644 --- a/Src/Main/Server/Category/UIImage+LookinServer.h +++ b/Src/Main/Server/Category/UIImage+LookinServer.h @@ -8,6 +8,8 @@ // https://lookin.work // +#import "TargetConditionals.h" + #if TARGET_OS_IPHONE #import #endif diff --git a/Src/Main/Server/Category/UIImageView+LookinServer.h b/Src/Main/Server/Category/UIImageView+LookinServer.h index da6a8fc..2302d79 100644 --- a/Src/Main/Server/Category/UIImageView+LookinServer.h +++ b/Src/Main/Server/Category/UIImageView+LookinServer.h @@ -8,6 +8,8 @@ // https://lookin.work // +#import "TargetConditionals.h" + #if TARGET_OS_IPHONE #import #endif diff --git a/Src/Main/Server/Category/UILabel+LookinServer.h b/Src/Main/Server/Category/UILabel+LookinServer.h index 62bf12a..9325178 100644 --- a/Src/Main/Server/Category/UILabel+LookinServer.h +++ b/Src/Main/Server/Category/UILabel+LookinServer.h @@ -8,6 +8,8 @@ // https://lookin.work // +#import "TargetConditionals.h" + #if TARGET_OS_IPHONE #import diff --git a/Src/Main/Server/Category/UITableView+LookinServer.h b/Src/Main/Server/Category/UITableView+LookinServer.h index f9d8cf7..a4ce10b 100644 --- a/Src/Main/Server/Category/UITableView+LookinServer.h +++ b/Src/Main/Server/Category/UITableView+LookinServer.h @@ -8,6 +8,8 @@ // https://lookin.work // +#import "TargetConditionals.h" + #if TARGET_OS_IPHONE #import diff --git a/Src/Main/Server/Category/UITextField+LookinServer.h b/Src/Main/Server/Category/UITextField+LookinServer.h index 603d7a7..5f7de03 100644 --- a/Src/Main/Server/Category/UITextField+LookinServer.h +++ b/Src/Main/Server/Category/UITextField+LookinServer.h @@ -8,6 +8,7 @@ // https://lookin.work // +#import "TargetConditionals.h" #if TARGET_OS_IPHONE #import diff --git a/Src/Main/Server/Category/UITextView+LookinServer.h b/Src/Main/Server/Category/UITextView+LookinServer.h index 2e0a963..8ccbbcd 100644 --- a/Src/Main/Server/Category/UITextView+LookinServer.h +++ b/Src/Main/Server/Category/UITextView+LookinServer.h @@ -8,6 +8,8 @@ // https://lookin.work // +#import "TargetConditionals.h" + #if TARGET_OS_IPHONE #import #elif TARGET_OS_OSX diff --git a/Src/Main/Server/Category/UIView+LookinServer.h b/Src/Main/Server/Category/UIView+LookinServer.h index 8bad50c..25932d1 100644 --- a/Src/Main/Server/Category/UIView+LookinServer.h +++ b/Src/Main/Server/Category/UIView+LookinServer.h @@ -8,6 +8,8 @@ // https://lookin.work // +#import "TargetConditionals.h" + #if TARGET_OS_IPHONE #import #elif TARGET_OS_OSX diff --git a/Src/Main/Server/Category/UIViewController+LookinServer.h b/Src/Main/Server/Category/UIViewController+LookinServer.h index b28af81..c524d32 100644 --- a/Src/Main/Server/Category/UIViewController+LookinServer.h +++ b/Src/Main/Server/Category/UIViewController+LookinServer.h @@ -8,6 +8,8 @@ // https://lookin.work // +#import "TargetConditionals.h" + #if TARGET_OS_IPHONE #import #endif diff --git a/Src/Main/Server/Category/UIVisualEffectView+LookinServer.h b/Src/Main/Server/Category/UIVisualEffectView+LookinServer.h index 164ef45..c1338a6 100644 --- a/Src/Main/Server/Category/UIVisualEffectView+LookinServer.h +++ b/Src/Main/Server/Category/UIVisualEffectView+LookinServer.h @@ -8,6 +8,8 @@ // https://lookin.work // +#import "TargetConditionals.h" + #if TARGET_OS_IPHONE #import diff --git a/Src/Main/Server/Connection/LKS_ConnectionManager.h b/Src/Main/Server/Connection/LKS_ConnectionManager.h index cf3b048..841fc02 100644 --- a/Src/Main/Server/Connection/LKS_ConnectionManager.h +++ b/Src/Main/Server/Connection/LKS_ConnectionManager.h @@ -8,9 +8,11 @@ // https://lookin.work // +#import "TargetConditionals.h" + #if TARGET_OS_IPHONE #import -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX #import #endif diff --git a/Src/Main/Server/Others/LKSConfigManager.h b/Src/Main/Server/Others/LKSConfigManager.h index 689418f..766de88 100644 --- a/Src/Main/Server/Others/LKSConfigManager.h +++ b/Src/Main/Server/Others/LKSConfigManager.h @@ -7,6 +7,8 @@ // Created by likai.123 on 2023/1/10. // +#import + #if TARGET_OS_IPHONE #import #endif diff --git a/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.h b/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.h index a16a35a..888beb3 100644 --- a/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.h +++ b/Src/Main/Server/Others/LKS_CustomDisplayItemsMaker.h @@ -7,6 +7,8 @@ // Created by likai.123 on 2023/11/1. // +#import + #if TARGET_OS_IPHONE #import #endif diff --git a/Src/Main/Server/Others/LKS_GestureTargetActionsSearcher.h b/Src/Main/Server/Others/LKS_GestureTargetActionsSearcher.h index 9f1026a..37c9461 100644 --- a/Src/Main/Server/Others/LKS_GestureTargetActionsSearcher.h +++ b/Src/Main/Server/Others/LKS_GestureTargetActionsSearcher.h @@ -7,6 +7,8 @@ // Created by likai.123 on 2023/9/11. // +#import + #if TARGET_OS_IPHONE #import #endif diff --git a/Src/Main/Shared/Category/Color+Lookin.h b/Src/Main/Shared/Category/Color+Lookin.h index 9a49ab9..5d1329f 100644 --- a/Src/Main/Shared/Category/Color+Lookin.h +++ b/Src/Main/Shared/Category/Color+Lookin.h @@ -12,7 +12,7 @@ #if TARGET_OS_IPHONE #elif TARGET_OS_MAC - +#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 f0fd4ff..34b2960 100644 --- a/Src/Main/Shared/Category/Color+Lookin.m +++ b/Src/Main/Shared/Category/Color+Lookin.m @@ -12,7 +12,7 @@ #if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #elif TARGET_OS_MAC - +#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..39c4a76 100644 --- a/Src/Main/Shared/Category/Image+Lookin.h +++ b/Src/Main/Shared/Category/Image+Lookin.h @@ -13,6 +13,8 @@ #elif TARGET_OS_MAC +#import + @interface NSImage (LookinClient) - (NSData *)lookin_data; diff --git a/Src/Main/Shared/Category/Image+Lookin.m b/Src/Main/Shared/Category/Image+Lookin.m index 1cb4aba..5f2feef 100644 --- a/Src/Main/Shared/Category/Image+Lookin.m +++ b/Src/Main/Shared/Category/Image+Lookin.m @@ -12,7 +12,7 @@ #if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST #elif TARGET_OS_MAC - +#import @implementation NSImage (LookinClient) - (NSData *)lookin_data { 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 { From 8c5e8151d63c4336a143938d0d03fabd59cfa64f Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Thu, 7 Nov 2024 17:52:23 +0800 Subject: [PATCH 12/21] [WIP] AppKit Support --- Src/Main/Shared/LookinAttrIdentifiers.h | 15 --------------- Src/Main/Shared/LookinAttrIdentifiers.m | 19 ++++--------------- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/Src/Main/Shared/LookinAttrIdentifiers.h b/Src/Main/Shared/LookinAttrIdentifiers.h index 7337355..f66c1d6 100644 --- a/Src/Main/Shared/LookinAttrIdentifiers.h +++ b/Src/Main/Shared/LookinAttrIdentifiers.h @@ -23,7 +23,6 @@ extern LookinAttrGroupIdentifier const LookinAttrGroup_Layout; extern LookinAttrGroupIdentifier const LookinAttrGroup_AutoLayout; extern LookinAttrGroupIdentifier const LookinAttrGroup_ViewLayer; -#if TARGET_OS_IPHONE extern LookinAttrGroupIdentifier const LookinAttrGroup_UIImageView; extern LookinAttrGroupIdentifier const LookinAttrGroup_UILabel; extern LookinAttrGroupIdentifier const LookinAttrGroup_UIControl; @@ -34,9 +33,7 @@ extern LookinAttrGroupIdentifier const LookinAttrGroup_UITextView; extern LookinAttrGroupIdentifier const LookinAttrGroup_UITextField; extern LookinAttrGroupIdentifier const LookinAttrGroup_UIVisualEffectView; extern LookinAttrGroupIdentifier const LookinAttrGroup_UIStackView; -#endif -#if TARGET_OS_OSX extern LookinAttrGroupIdentifier const LookinAttrGroup_NSImageView; extern LookinAttrGroupIdentifier const LookinAttrGroup_NSControl; extern LookinAttrGroupIdentifier const LookinAttrGroup_NSButton; @@ -46,7 +43,6 @@ extern LookinAttrGroupIdentifier const LookinAttrGroup_NSTextView; extern LookinAttrGroupIdentifier const LookinAttrGroup_NSTextField; extern LookinAttrGroupIdentifier const LookinAttrGroup_NSVisualEffectView; extern LookinAttrGroupIdentifier const LookinAttrGroup_NSStackView; -#endif extern LookinAttrGroupIdentifier const LookinAttrGroup_UserCustom; @@ -81,8 +77,6 @@ extern LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_Border; extern LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_Shadow; extern LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_Tag; -#if TARGET_OS_IPHONE - extern LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_ContentMode; extern LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_TintColor; @@ -149,9 +143,6 @@ extern LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Axis; extern LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Distribution; extern LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Alignment; extern LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Spacing; -#endif - -#if TARGET_OS_OSX extern LookinAttrSectionIdentifier const LookinAttrSec_NSImageView_Name; extern LookinAttrSectionIdentifier const LookinAttrSec_NSImageView_Open; @@ -294,8 +285,6 @@ extern LookinAttrIdentifier const LookinAttr_ViewLayer_TintColor_Color; extern LookinAttrIdentifier const LookinAttr_ViewLayer_TintColor_Mode; extern LookinAttrIdentifier const LookinAttr_ViewLayer_Tag_Tag; -#if TARGET_OS_IPHONE - extern LookinAttrIdentifier const LookinAttr_UIImageView_Name_Name; extern LookinAttrIdentifier const LookinAttr_UIImageView_Open_Open; @@ -373,9 +362,6 @@ extern LookinAttrIdentifier const LookinAttr_UIStackView_Axis_Axis; extern LookinAttrIdentifier const LookinAttr_UIStackView_Distribution_Distribution; extern LookinAttrIdentifier const LookinAttr_UIStackView_Alignment_Alignment; extern LookinAttrIdentifier const LookinAttr_UIStackView_Spacing_Spacing; -#endif - -#if TARGET_OS_OSX extern LookinAttrIdentifier const LookinAttr_NSImageView_Name_Name; extern LookinAttrIdentifier const LookinAttr_NSImageView_Open_Open; @@ -502,6 +488,5 @@ extern LookinAttrIdentifier const LookinAttr_NSStackView_DetachesHiddenViews_Det extern LookinAttrIdentifier const LookinAttr_NSStackView_Distribution_Distribution; extern LookinAttrIdentifier const LookinAttr_NSStackView_Alignment_Alignment; extern LookinAttrIdentifier const LookinAttr_NSStackView_Spacing_Spacing; -#endif #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Shared/LookinAttrIdentifiers.m b/Src/Main/Shared/LookinAttrIdentifiers.m index ea94425..2a13640 100644 --- a/Src/Main/Shared/LookinAttrIdentifiers.m +++ b/Src/Main/Shared/LookinAttrIdentifiers.m @@ -23,7 +23,7 @@ LookinAttrGroupIdentifier const LookinAttrGroup_Layout = @"l"; LookinAttrGroupIdentifier const LookinAttrGroup_AutoLayout = @"a"; LookinAttrGroupIdentifier const LookinAttrGroup_ViewLayer = @"vl"; -#if TARGET_OS_IPHONE + LookinAttrGroupIdentifier const LookinAttrGroup_UIImageView = @"i"; LookinAttrGroupIdentifier const LookinAttrGroup_UILabel = @"la"; LookinAttrGroupIdentifier const LookinAttrGroup_UIControl = @"co"; @@ -34,10 +34,9 @@ LookinAttrGroupIdentifier const LookinAttrGroup_UITextField = @"tf"; LookinAttrGroupIdentifier const LookinAttrGroup_UIVisualEffectView = @"ve"; LookinAttrGroupIdentifier const LookinAttrGroup_UIStackView = @"UIStackView"; -#endif -#if TARGET_OS_OSX -#if TARGET_OS_OSX + + LookinAttrGroupIdentifier const LookinAttrGroup_NSImageView = @"NSImageView"; LookinAttrGroupIdentifier const LookinAttrGroup_NSControl = @"NSControl"; LookinAttrGroupIdentifier const LookinAttrGroup_NSButton = @"NSButton"; @@ -47,9 +46,7 @@ LookinAttrGroupIdentifier const LookinAttrGroup_NSTextField = @"NSTextField"; LookinAttrGroupIdentifier const LookinAttrGroup_NSVisualEffectView = @"NSVisualEffectView"; LookinAttrGroupIdentifier const LookinAttrGroup_NSStackView = @"NSStackView"; -#endif -#endif LookinAttrGroupIdentifier const LookinAttrGroup_UserCustom = @"guc"; // user custom @@ -84,7 +81,7 @@ LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_TintColor = @"v_t"; LookinAttrSectionIdentifier const LookinAttrSec_ViewLayer_Tag = @"v_ta"; -#if TARGET_OS_IPHONE + LookinAttrSectionIdentifier const LookinAttrSec_UIImageView_Name = @"i_n"; LookinAttrSectionIdentifier const LookinAttrSec_UIImageView_Open = @"i_o"; @@ -149,9 +146,7 @@ LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Distribution = @"usv_dis"; LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Alignment = @"usv_align"; LookinAttrSectionIdentifier const LookinAttrSec_UIStackView_Spacing = @"usv_spa"; -#endif -#if TARGET_OS_OSX LookinAttrSectionIdentifier const LookinAttrSec_NSImageView_Name = @"NSImageView_Name"; LookinAttrSectionIdentifier const LookinAttrSec_NSImageView_Open = @"NSImageView_Open"; LookinAttrSectionIdentifier const LookinAttrSec_NSControl_State = @"NSControl_State"; @@ -236,7 +231,6 @@ LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Distribution = @"NSStackView_Distribution"; LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Alignment = @"NSStackView_Alignment"; LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Spacing = @"NSStackView_Spacing"; -#endif #pragma mark - Attr @@ -279,8 +273,6 @@ LookinAttrIdentifier const LookinAttr_ViewLayer_TintColor_Mode = @"vl_t_m"; LookinAttrIdentifier const LookinAttr_ViewLayer_Tag_Tag = @"vl_t_t"; -#if TARGET_OS_IPHONE - LookinAttrIdentifier const LookinAttr_UIImageView_Name_Name = @"iv_n_n"; LookinAttrIdentifier const LookinAttr_UIImageView_Open_Open = @"iv_o_o"; @@ -358,9 +350,7 @@ LookinAttrIdentifier const LookinAttr_UIStackView_Distribution_Distribution = @"usv_dis_dis"; LookinAttrIdentifier const LookinAttr_UIStackView_Alignment_Alignment = @"usv_ali_ali"; LookinAttrIdentifier const LookinAttr_UIStackView_Spacing_Spacing = @"usv_spa_spa"; -#endif -#if TARGET_OS_OSX 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"; @@ -484,7 +474,6 @@ 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 #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ From 44f1947326c6afc373e833dd87e28b469655858c Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Thu, 7 Nov 2024 17:53:16 +0800 Subject: [PATCH 13/21] [WIP] AppKit Support --- Src/Main/Shared/LookinAttrIdentifiers.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Src/Main/Shared/LookinAttrIdentifiers.h b/Src/Main/Shared/LookinAttrIdentifiers.h index f66c1d6..53025eb 100644 --- a/Src/Main/Shared/LookinAttrIdentifiers.h +++ b/Src/Main/Shared/LookinAttrIdentifiers.h @@ -239,7 +239,6 @@ extern LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Distribution; extern LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Alignment; extern LookinAttrSectionIdentifier const LookinAttrSec_NSStackView_Spacing; -#endif #pragma mark - Attr From ea2ab5c9e13b487f74b1cecc44126e843b6d61d1 Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Thu, 7 Nov 2024 18:08:15 +0800 Subject: [PATCH 14/21] [WIP] AppKit Support --- Src/Main/Shared/LookinDashboardBlueprint.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Src/Main/Shared/LookinDashboardBlueprint.m b/Src/Main/Shared/LookinDashboardBlueprint.m index ebd45b8..115ec45 100644 --- a/Src/Main/Shared/LookinDashboardBlueprint.m +++ b/Src/Main/Shared/LookinDashboardBlueprint.m @@ -300,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], From bf1610fe2b6183c693d96e3754d4337d973a7c48 Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Thu, 7 Nov 2024 18:48:21 +0800 Subject: [PATCH 15/21] [WIP] AppKit Support --- Src/Main/Shared/Category/NSObject+Lookin.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Src/Main/Shared/Category/NSObject+Lookin.m b/Src/Main/Shared/Category/NSObject+Lookin.m index 9851fba..f1a2341 100644 --- a/Src/Main/Shared/Category/NSObject+Lookin.m +++ b/Src/Main/Shared/Category/NSObject+Lookin.m @@ -150,7 +150,7 @@ - (id)lookin_encodedObjectWithType:(LookinCodingValueType)type { if (type == LookinCodingValueTypeColor) { if ([self isKindOfClass:[LookinColor class]]) { CGFloat r, g, b, a; -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE CGFloat white; if ([(UIColor *)self getRed:&r green:&g blue:&b alpha:&a]) { // valid @@ -178,7 +178,7 @@ - (id)lookin_encodedObjectWithType:(LookinCodingValueType)type { } } else if (type == LookinCodingValueTypeImage) { -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE if ([self isKindOfClass:[UIImage class]]) { UIImage *image = (UIImage *)self; return UIImagePNGRepresentation(image); From 8d31d9f534d0f6ea0ffcbb7938ba938f7df64553 Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Thu, 7 Nov 2024 23:02:55 +0800 Subject: [PATCH 16/21] [WIP] AppKit Support --- .../Server/Category/CALayer+LookinServer.m | 28 ++++++++----------- Src/Main/Shared/LookinDisplayItemDetail.m | 14 ++++++++++ 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Src/Main/Server/Category/CALayer+LookinServer.m b/Src/Main/Server/Category/CALayer+LookinServer.m index 1a4e36f..5969cbd 100644 --- a/Src/Main/Server/Category/CALayer+LookinServer.m +++ b/Src/Main/Server/Category/CALayer+LookinServer.m @@ -18,6 +18,7 @@ #import "UIColor+LookinServer.h" #import "LKS_MultiplatformAdapter.h" #import "NSWindow+LookinServer.h" + @implementation CALayer (LookinServer) - (LookinWindow *)lks_window { @@ -109,12 +110,12 @@ - (LookinImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality { return nil; } [view cacheDisplayInRect:view.bounds toBitmapImageRep:representation]; - - image = [[NSImage alloc] initWithSize:contextSize]; - + image = [[NSImage alloc] initWithSize:CGSizeMake(contextSize.width / renderScale, contextSize.height / renderScale)]; [image addRepresentation:representation]; + return image; + } else { - image = [NSImage imageWithSize:contextSize flipped:NO drawingHandler:^BOOL(NSRect dstRect) { + image = [NSImage imageWithSize:CGSizeMake(contextSize.width / renderScale, contextSize.height / renderScale) flipped:NO drawingHandler:^BOOL(NSRect dstRect) { CGContextRef context = NSGraphicsContext.currentContext.CGContext; [self renderInContext:context]; return YES; @@ -143,7 +144,11 @@ - (LookinImage *)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]; @@ -153,13 +158,6 @@ - (LookinImage *)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(); @@ -181,12 +179,10 @@ - (LookinImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { return nil; } [view cacheDisplayInRect:view.bounds toBitmapImageRep:representation]; - - image = [[NSImage alloc] initWithSize:contextSize]; - + image = [[NSImage alloc] initWithSize:CGSizeMake(contextSize.width / renderScale, contextSize.height / renderScale)]; [image addRepresentation:representation]; } else { - image = [NSImage imageWithSize:contextSize flipped:NO drawingHandler:^BOOL(NSRect dstRect) { + image = [NSImage imageWithSize:CGSizeMake(contextSize.width / renderScale, contextSize.height / renderScale) flipped:NO drawingHandler:^BOOL(NSRect dstRect) { CGContextRef context = NSGraphicsContext.currentContext.CGContext; [self renderInContext:context]; return YES; diff --git a/Src/Main/Shared/LookinDisplayItemDetail.m b/Src/Main/Shared/LookinDisplayItemDetail.m index 26bea29..90e152f 100644 --- a/Src/Main/Shared/LookinDisplayItemDetail.m +++ b/Src/Main/Shared/LookinDisplayItemDetail.m @@ -19,8 +19,16 @@ @implementation LookinDisplayItemDetail - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:@(self.displayItemOid) forKey:@"displayItemOid"]; +#if TARGET_OS_IPHONE [aCoder encodeObject:self.groupScreenshot.lookin_data forKey:@"groupScreenshot"]; [aCoder encodeObject:self.soloScreenshot.lookin_data forKey:@"soloScreenshot"]; +#endif +#if TARGET_OS_OSX + + + [aCoder encodeObject:[NSKeyedArchiver archivedDataWithRootObject:self.groupScreenshot requiringSecureCoding:YES error:nil] forKey:@"groupScreenshot"]; + [aCoder encodeObject:[NSKeyedArchiver archivedDataWithRootObject:self.soloScreenshot requiringSecureCoding:YES error:nil] forKey:@"soloScreenshot"]; +#endif [aCoder encodeObject:self.frameValue forKey:@"frameValue"]; [aCoder encodeObject:self.boundsValue forKey:@"boundsValue"]; [aCoder encodeObject:self.hiddenValue forKey:@"hiddenValue"]; @@ -38,8 +46,14 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { - (instancetype)initWithCoder:(NSCoder *)aDecoder { if (self = [super init]) { self.displayItemOid = [[aDecoder decodeObjectForKey:@"displayItemOid"] unsignedLongValue]; +#if TARGET_OS_IPHONE self.groupScreenshot = [[LookinImage alloc] initWithData:[aDecoder decodeObjectForKey:@"groupScreenshot"]]; self.soloScreenshot = [[LookinImage alloc] initWithData:[aDecoder decodeObjectForKey:@"soloScreenshot"]]; +#endif +#if TARGET_OS_OSX + self.groupScreenshot = [NSKeyedUnarchiver unarchivedObjectOfClass:[NSImage class] fromData:[aDecoder decodeObjectForKey:@"groupScreenshot"] error:nil]; + self.soloScreenshot = [NSKeyedUnarchiver unarchivedObjectOfClass:[NSImage class] fromData:[aDecoder decodeObjectForKey:@"soloScreenshot"] error:nil]; +#endif self.frameValue = [aDecoder decodeObjectForKey:@"frameValue"]; self.boundsValue = [aDecoder decodeObjectForKey:@"boundsValue"]; self.hiddenValue = [aDecoder decodeObjectForKey:@"hiddenValue"]; From 59a6f0dc23871b8c75b21127fb67aacfe6d2e8ff Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:37:37 +0800 Subject: [PATCH 17/21] [WIP] AppKit Support --- .../AppKitDemo/ViewController.swift | 34 +++++++++- .../Server/Category/CALayer+LookinServer.h | 8 --- .../Server/Category/CALayer+LookinServer.m | 42 +++++-------- .../Server/Category/NSButton+LookinServer.h | 2 + .../Category/NSScrollView+LookinServer.h | 1 + .../Server/Category/UIColor+LookinServer.h | 10 --- .../Server/Category/UIImage+LookinServer.h | 10 --- .../Server/Category/UIImage+LookinServer.m | 2 +- .../Category/UIImageView+LookinServer.h | 10 --- .../Category/UITableView+LookinServer.h | 3 - .../Category/UITextField+LookinServer.h | 8 --- .../Server/Category/UITextView+LookinServer.h | 8 --- .../Server/Category/UIView+LookinServer.h | 8 --- .../Server/Category/UIView+LookinServer.m | 4 +- .../Category/UIViewController+LookinServer.h | 10 --- .../Category/UIViewController+LookinServer.m | 1 - .../UIVisualEffectView+LookinServer.h | 3 - .../LKS_InbuiltAttrModificationHandler.m | 1 + .../Others/LKS_HierarchyDisplayItemsMaker.m | 7 +++ Src/Main/Server/Others/LKS_TraceManager.m | 63 ++++++++++--------- Src/Main/Shared/Category/Color+Lookin.h | 2 +- Src/Main/Shared/Category/Color+Lookin.m | 4 +- Src/Main/Shared/Category/Image+Lookin.h | 2 +- Src/Main/Shared/Category/Image+Lookin.m | 6 +- Src/Main/Shared/Category/NSObject+Lookin.m | 15 ++--- Src/Main/Shared/Category/NSSet+Lookin.h | 4 +- Src/Main/Shared/Category/NSString+Lookin.m | 4 +- Src/Main/Shared/LookinCustomDisplayItemInfo.m | 2 +- Src/Main/Shared/LookinDashboardBlueprint.m | 28 +-------- Src/Main/Shared/LookinDefines.h | 4 ++ Src/Main/Shared/LookinDisplayItem.h | 5 +- Src/Main/Shared/LookinDisplayItem.m | 27 ++++++-- Src/Main/Shared/LookinDisplayItemDetail.m | 16 +---- Src/Main/Shared/LookinHierarchyInfo.h | 4 +- 34 files changed, 150 insertions(+), 208 deletions(-) diff --git a/LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift b/LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift index b0eca7d..31803e0 100644 --- a/LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift +++ b/LookinDemo/AppKitDemo/AppKitDemo/ViewController.swift @@ -7,10 +7,42 @@ 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() - // Do any additional setup after loading the view. + + 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? { diff --git a/Src/Main/Server/Category/CALayer+LookinServer.h b/Src/Main/Server/Category/CALayer+LookinServer.h index a10436b..9117148 100644 --- a/Src/Main/Server/Category/CALayer+LookinServer.h +++ b/Src/Main/Server/Category/CALayer+LookinServer.h @@ -9,14 +9,6 @@ // #import "LookinDefines.h" -#import "TargetConditionals.h" -#if TARGET_OS_IPHONE -#import -#endif - -#if TARGET_OS_OSX -#import -#endif @interface CALayer (LookinServer) diff --git a/Src/Main/Server/Category/CALayer+LookinServer.m b/Src/Main/Server/Category/CALayer+LookinServer.m index 5969cbd..a86a13a 100644 --- a/Src/Main/Server/Category/CALayer+LookinServer.m +++ b/Src/Main/Server/Category/CALayer+LookinServer.m @@ -110,16 +110,16 @@ - (LookinImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality { return nil; } [view cacheDisplayInRect:view.bounds toBitmapImageRep:representation]; - image = [[NSImage alloc] initWithSize:CGSizeMake(contextSize.width / renderScale, contextSize.height / renderScale)]; + image = [[NSImage alloc] initWithSize:representation.size]; [image addRepresentation:representation]; return image; } else { - image = [NSImage imageWithSize:CGSizeMake(contextSize.width / renderScale, contextSize.height / renderScale) flipped:NO drawingHandler:^BOOL(NSRect dstRect) { - CGContextRef context = NSGraphicsContext.currentContext.CGContext; - [self renderInContext:context]; - return YES; - }]; + image = [[NSImage alloc] initWithSize:contextSize]; + [image lockFocusFlipped:self.isGeometryFlipped]; + CGContextRef context = NSGraphicsContext.currentContext.CGContext; + [self renderInContext:context]; + [image unlockFocus]; } return image; #endif @@ -179,14 +179,14 @@ - (LookinImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { return nil; } [view cacheDisplayInRect:view.bounds toBitmapImageRep:representation]; - image = [[NSImage alloc] initWithSize:CGSizeMake(contextSize.width / renderScale, contextSize.height / renderScale)]; + image = [[NSImage alloc] initWithSize:representation.size]; [image addRepresentation:representation]; } else { - image = [NSImage imageWithSize:CGSizeMake(contextSize.width / renderScale, contextSize.height / renderScale) flipped:NO drawingHandler:^BOOL(NSRect dstRect) { - CGContextRef context = NSGraphicsContext.currentContext.CGContext; - [self renderInContext:context]; - return YES; - }]; + 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) { @@ -198,31 +198,17 @@ - (LookinImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { } - (NSArray *> *)lks_relatedClassChainList { -#if TARGET_OS_IPHONE 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]; - if (vc) { - [array addObject:[CALayer lks_getClassListOfObject:vc endingClass:@"UIViewController"]]; - } - } else { - [array addObject:[CALayer lks_getClassListOfObject:self endingClass:@"CALayer"]]; - } - return array.copy; -#elif TARGET_OS_OSX - NSMutableArray *array = [NSMutableArray arrayWithCapacity:2]; - if (self.lks_hostView) { - [array addObject:[CALayer lks_getClassListOfObject:self.lks_hostView endingClass:@"NSView"]]; + [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:@"NSViewController"]]; + [array addObject:[CALayer lks_getClassListOfObject:vc endingClass:LookinViewControllerString]]; } } else { [array addObject:[CALayer lks_getClassListOfObject:self endingClass:@"CALayer"]]; } return array.copy; -#endif } + (NSArray *)lks_getClassListOfObject:(id)object endingClass:(NSString *)endingClass { diff --git a/Src/Main/Server/Category/NSButton+LookinServer.h b/Src/Main/Server/Category/NSButton+LookinServer.h index ec20a92..89005dd 100644 --- a/Src/Main/Server/Category/NSButton+LookinServer.h +++ b/Src/Main/Server/Category/NSButton+LookinServer.h @@ -8,6 +8,7 @@ #import "TargetConditionals.h" #if TARGET_OS_OSX + #import NS_ASSUME_NONNULL_BEGIN @@ -17,4 +18,5 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END + #endif diff --git a/Src/Main/Server/Category/NSScrollView+LookinServer.h b/Src/Main/Server/Category/NSScrollView+LookinServer.h index 84ca964..6ee3c9b 100644 --- a/Src/Main/Server/Category/NSScrollView+LookinServer.h +++ b/Src/Main/Server/Category/NSScrollView+LookinServer.h @@ -20,4 +20,5 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END + #endif diff --git a/Src/Main/Server/Category/UIColor+LookinServer.h b/Src/Main/Server/Category/UIColor+LookinServer.h index 1812d1c..c11196c 100644 --- a/Src/Main/Server/Category/UIColor+LookinServer.h +++ b/Src/Main/Server/Category/UIColor+LookinServer.h @@ -8,16 +8,6 @@ // https://lookin.work // -#import "TargetConditionals.h" - -#if TARGET_OS_IPHONE -#import -#endif - -#if TARGET_OS_OSX -#import -#endif - #import "LookinDefines.h" @interface LookinColor (LookinServer) diff --git a/Src/Main/Server/Category/UIImage+LookinServer.h b/Src/Main/Server/Category/UIImage+LookinServer.h index c683530..442f5ea 100644 --- a/Src/Main/Server/Category/UIImage+LookinServer.h +++ b/Src/Main/Server/Category/UIImage+LookinServer.h @@ -8,16 +8,6 @@ // https://lookin.work // -#import "TargetConditionals.h" - -#if TARGET_OS_IPHONE -#import -#endif - -#if TARGET_OS_OSX -#import -#endif - #import "LookinDefines.h" @interface LookinImage (LookinServer) diff --git a/Src/Main/Server/Category/UIImage+LookinServer.m b/Src/Main/Server/Category/UIImage+LookinServer.m index cd6fc1c..7029ce2 100644 --- a/Src/Main/Server/Category/UIImage+LookinServer.m +++ b/Src/Main/Server/Category/UIImage+LookinServer.m @@ -101,7 +101,7 @@ - (NSData *)lookin_data { #endif #if TARGET_OS_OSX - return self.TIFFRepresentation; + return [NSBitmapImageRep representationOfImageRepsInArray:self.representations usingType:(NSBitmapImageFileTypePNG) properties:@{}];; #endif } diff --git a/Src/Main/Server/Category/UIImageView+LookinServer.h b/Src/Main/Server/Category/UIImageView+LookinServer.h index 2302d79..5f74fa0 100644 --- a/Src/Main/Server/Category/UIImageView+LookinServer.h +++ b/Src/Main/Server/Category/UIImageView+LookinServer.h @@ -8,16 +8,6 @@ // https://lookin.work // -#import "TargetConditionals.h" - -#if TARGET_OS_IPHONE -#import -#endif - -#if TARGET_OS_OSX -#import -#endif - #import "LookinDefines.h" @interface LookinImageView (LookinServer) diff --git a/Src/Main/Server/Category/UITableView+LookinServer.h b/Src/Main/Server/Category/UITableView+LookinServer.h index a4ce10b..0c004b4 100644 --- a/Src/Main/Server/Category/UITableView+LookinServer.h +++ b/Src/Main/Server/Category/UITableView+LookinServer.h @@ -20,7 +20,4 @@ @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 5f7de03..62cdfc3 100644 --- a/Src/Main/Server/Category/UITextField+LookinServer.h +++ b/Src/Main/Server/Category/UITextField+LookinServer.h @@ -8,14 +8,6 @@ // https://lookin.work // -#import "TargetConditionals.h" - -#if TARGET_OS_IPHONE -#import -#elif TARGET_OS_OSX -#import -#endif - #import "LookinDefines.h" @interface LookinTextField (LookinServer) diff --git a/Src/Main/Server/Category/UITextView+LookinServer.h b/Src/Main/Server/Category/UITextView+LookinServer.h index 8ccbbcd..d7ba596 100644 --- a/Src/Main/Server/Category/UITextView+LookinServer.h +++ b/Src/Main/Server/Category/UITextView+LookinServer.h @@ -8,14 +8,6 @@ // https://lookin.work // -#import "TargetConditionals.h" - -#if TARGET_OS_IPHONE -#import -#elif TARGET_OS_OSX -#import -#endif - #import "LookinDefines.h" @interface LookinTextView (LookinServer) diff --git a/Src/Main/Server/Category/UIView+LookinServer.h b/Src/Main/Server/Category/UIView+LookinServer.h index 25932d1..e4c8bc6 100644 --- a/Src/Main/Server/Category/UIView+LookinServer.h +++ b/Src/Main/Server/Category/UIView+LookinServer.h @@ -8,14 +8,6 @@ // https://lookin.work // -#import "TargetConditionals.h" - -#if TARGET_OS_IPHONE -#import -#elif TARGET_OS_OSX -#import -#endif - #import "LookinDefines.h" @interface LookinView (LookinServer) diff --git a/Src/Main/Server/Category/UIView+LookinServer.m b/Src/Main/Server/Category/UIView+LookinServer.m index d2d4f86..c579724 100644 --- a/Src/Main/Server/Category/UIView+LookinServer.m +++ b/Src/Main/Server/Category/UIView+LookinServer.m @@ -287,7 +287,7 @@ - (LookinImage *)lks_groupScreenshotWithLowQuality:(BOOL)lowQuality { } [self cacheDisplayInRect:self.bounds toBitmapImageRep:rep]; - NSImage *image = [[NSImage alloc] initWithSize:contextSize]; + NSImage *image = [[NSImage alloc] initWithSize:rep.size]; [image addRepresentation:rep]; @@ -336,7 +336,7 @@ - (LookinImage *)lks_soloScreenshotWithLowQuality:(BOOL)lowQuality { } [self cacheDisplayInRect:self.bounds toBitmapImageRep:rep]; - NSImage *image = [[NSImage alloc] initWithSize:contextSize]; + NSImage *image = [[NSImage alloc] initWithSize:rep.size]; [image addRepresentation:rep]; [visibleSubviews enumerateObjectsUsingBlock:^(NSView * _Nonnull subview, NSUInteger idx, BOOL * _Nonnull stop) { diff --git a/Src/Main/Server/Category/UIViewController+LookinServer.h b/Src/Main/Server/Category/UIViewController+LookinServer.h index c524d32..8a1976c 100644 --- a/Src/Main/Server/Category/UIViewController+LookinServer.h +++ b/Src/Main/Server/Category/UIViewController+LookinServer.h @@ -8,16 +8,6 @@ // https://lookin.work // -#import "TargetConditionals.h" - -#if TARGET_OS_IPHONE -#import -#endif - -#if TARGET_OS_OSX -#import -#endif - #import "LookinDefines.h" @interface LookinViewController (LookinServer) diff --git a/Src/Main/Server/Category/UIViewController+LookinServer.m b/Src/Main/Server/Category/UIViewController+LookinServer.m index f448941..1988229 100644 --- a/Src/Main/Server/Category/UIViewController+LookinServer.m +++ b/Src/Main/Server/Category/UIViewController+LookinServer.m @@ -17,7 +17,6 @@ @implementation LookinViewController (LookinServer) + (nullable LookinViewController *)lks_visibleViewController { #if TARGET_OS_IPHONE - LookinViewController *rootViewController = [LKS_MultiplatformAdapter keyWindow].rootViewController; LookinViewController *visibleViewController = [rootViewController lks_visibleViewControllerIfExist]; return visibleViewController; diff --git a/Src/Main/Server/Category/UIVisualEffectView+LookinServer.h b/Src/Main/Server/Category/UIVisualEffectView+LookinServer.h index c1338a6..82edcc0 100644 --- a/Src/Main/Server/Category/UIVisualEffectView+LookinServer.h +++ b/Src/Main/Server/Category/UIVisualEffectView+LookinServer.h @@ -22,7 +22,4 @@ @end #endif -#if TARGET_OS_OSX -#endif - #endif /* SHOULD_COMPILE_LOOKIN_SERVER */ diff --git a/Src/Main/Server/Connection/RequestHandler/LKS_InbuiltAttrModificationHandler.m b/Src/Main/Server/Connection/RequestHandler/LKS_InbuiltAttrModificationHandler.m index a6b2892..455f2b0 100644 --- a/Src/Main/Server/Connection/RequestHandler/LKS_InbuiltAttrModificationHandler.m +++ b/Src/Main/Server/Connection/RequestHandler/LKS_InbuiltAttrModificationHandler.m @@ -221,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); }); } diff --git a/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m b/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m index 045880c..ec57680 100644 --- a/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m +++ b/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m @@ -92,6 +92,9 @@ + (LookinDisplayItem *)_displayItemWithLayer:(CALayer *)layer screenshots:(BOOL) 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 valueForKeyPath:@"backgroundColor"]; @@ -101,6 +104,9 @@ + (LookinDisplayItem *)_displayItemWithLayer:(CALayer *)layer screenshots:(BOOL) item.hostViewControllerObject = [LookinObject instanceWithObject:vc]; } } else { +#if TARGET_OS_OSX + item.flipped = layer.isGeometryFlipped; +#endif item.backgroundColor = [LookinColor lks_colorWithCGColor:layer.backgroundColor]; } @@ -172,6 +178,7 @@ + (LookinDisplayItem *)_displayItemWithView:(NSView *)view screenshots:(BOOL)has 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]; diff --git a/Src/Main/Server/Others/LKS_TraceManager.m b/Src/Main/Server/Others/LKS_TraceManager.m index 850df1e..31632e0 100644 --- a/Src/Main/Server/Others/LKS_TraceManager.m +++ b/Src/Main/Server/Others/LKS_TraceManager.m @@ -183,6 +183,38 @@ - (void)_buildSpecialTraceForView:(LookinView *)view { 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; @@ -325,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; })]; @@ -343,32 +375,7 @@ - (NSString *)makeDisplayClassNameWithSuper:(Class)superClass childClass:(Class) })]; [set addObject:({ LookinIvarTrace *trace = [LookinIvarTrace new]; - trace.hostClassName = @"UIViewController"; - trace.ivarName = @"_parentViewController"; - trace; - })]; - - [set addObject:({ - LookinIvarTrace *trace = [LookinIvarTrace new]; - trace.hostClassName = @"NSView"; - trace.ivarName = @"_window"; - trace; - })]; - [set addObject:({ - LookinIvarTrace *trace = [LookinIvarTrace new]; - trace.hostClassName = @"NSViewController"; - trace.ivarName = @"_view"; - trace; - })]; - [set addObject:({ - LookinIvarTrace *trace = [LookinIvarTrace new]; - trace.hostClassName = @"NSView"; - trace.ivarName = @"_viewDelegate"; - trace; - })]; - [set addObject:({ - LookinIvarTrace *trace = [LookinIvarTrace new]; - trace.hostClassName = @"NSViewController"; + trace.hostClassName = LookinViewControllerString; trace.ivarName = @"_parentViewController"; trace; })]; diff --git a/Src/Main/Shared/Category/Color+Lookin.h b/Src/Main/Shared/Category/Color+Lookin.h index 5d1329f..f6b57d1 100644 --- a/Src/Main/Shared/Category/Color+Lookin.h +++ b/Src/Main/Shared/Category/Color+Lookin.h @@ -11,7 +11,7 @@ #if TARGET_OS_IPHONE -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX #import @interface NSColor (Lookin) diff --git a/Src/Main/Shared/Category/Color+Lookin.m b/Src/Main/Shared/Category/Color+Lookin.m index 34b2960..5b9a310 100644 --- a/Src/Main/Shared/Category/Color+Lookin.m +++ b/Src/Main/Shared/Category/Color+Lookin.m @@ -9,9 +9,9 @@ #import "Image+Lookin.h" -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX #import @implementation NSColor (Lookin) diff --git a/Src/Main/Shared/Category/Image+Lookin.h b/Src/Main/Shared/Category/Image+Lookin.h index 39c4a76..b3a1d48 100644 --- a/Src/Main/Shared/Category/Image+Lookin.h +++ b/Src/Main/Shared/Category/Image+Lookin.h @@ -11,7 +11,7 @@ #if TARGET_OS_IPHONE -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX #import diff --git a/Src/Main/Shared/Category/Image+Lookin.m b/Src/Main/Shared/Category/Image+Lookin.m index 5f2feef..cc7b9cd 100644 --- a/Src/Main/Shared/Category/Image+Lookin.m +++ b/Src/Main/Shared/Category/Image+Lookin.m @@ -9,14 +9,14 @@ #import "Image+Lookin.h" -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#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 f1a2341..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) @@ -115,9 +116,9 @@ - (long)lookin_getBindLongForKey:(NSString *)key { } - (void)lookin_bindPoint:(CGPoint)pointValue forKey:(NSString *)key { -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#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 @@ -126,9 +127,9 @@ - (void)lookin_bindPoint:(CGPoint)pointValue forKey:(NSString *)key { - (CGPoint)lookin_getBindPointForKey:(NSString *)key { id object = [self lookin_getBindObjectForKey:key]; if ([object isKindOfClass:[NSValue class]]) { -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#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 5d40660..58038c3 100644 --- a/Src/Main/Shared/Category/NSSet+Lookin.h +++ b/Src/Main/Shared/Category/NSSet+Lookin.h @@ -11,9 +11,9 @@ #import "LookinDefines.h" #import "TargetConditionals.h" -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE #import -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX #import #endif diff --git a/Src/Main/Shared/Category/NSString+Lookin.m b/Src/Main/Shared/Category/NSString+Lookin.m index 2e80ab3..3e297cc 100644 --- a/Src/Main/Shared/Category/NSString+Lookin.m +++ b/Src/Main/Shared/Category/NSString+Lookin.m @@ -62,9 +62,9 @@ + (NSString *)lookin_rgbaStringFromColor:(LookinColor *)color { return @"nil"; } -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#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/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.m b/Src/Main/Shared/LookinDashboardBlueprint.m index 115ec45..aa942e5 100644 --- a/Src/Main/Shared/LookinDashboardBlueprint.m +++ b/Src/Main/Shared/LookinDashboardBlueprint.m @@ -790,7 +790,6 @@ + (NSString *)groupTitleWithGroupID:(LookinAttrGroupIdentifier)groupID { LookinAttrGroup_Relation: @"Relation", LookinAttrGroup_Layout: @"Layout", LookinAttrGroup_AutoLayout: @"AutoLayout", -#if TARGET_OS_IPHONE LookinAttrGroup_ViewLayer: @"CALayer / UIView", LookinAttrGroup_UIImageView: @"UIImageView", LookinAttrGroup_UILabel: @"UILabel", @@ -801,9 +800,7 @@ + (NSString *)groupTitleWithGroupID:(LookinAttrGroupIdentifier)groupID { LookinAttrGroup_UITextView: @"UITextView", LookinAttrGroup_UITextField: @"UITextField", LookinAttrGroup_UIVisualEffectView: @"UIVisualEffectView", - LookinAttrGroup_UIStackView: @"UIStackView" -#endif -#if TARGET_OS_OSX + LookinAttrGroup_UIStackView: @"UIStackView", LookinAttrGroup_ViewLayer: @"CALayer / NSView", LookinAttrGroup_NSImageView: @"NSImageView", LookinAttrGroup_NSControl: @"NSControl", @@ -814,7 +811,6 @@ + (NSString *)groupTitleWithGroupID:(LookinAttrGroupIdentifier)groupID { LookinAttrGroup_NSTextField: @"NSTextField", LookinAttrGroup_NSVisualEffectView: @"NSVisualEffectView", LookinAttrGroup_NSStackView: @"NSStackView" -#endif }; }); NSString *title = rawInfo[groupID]; @@ -840,7 +836,6 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { LookinAttrSec_ViewLayer_Border: @"Border", LookinAttrSec_ViewLayer_Shadow: @"Shadow", LookinAttrSec_ViewLayer_Tag: @"Tag", -#if TARGET_OS_IPHONE LookinAttrSec_ViewLayer_ContentMode: @"ContentMode", LookinAttrSec_ViewLayer_TintColor: @"TintColor", LookinAttrSec_UIStackView_Axis: @"Axis", @@ -888,9 +883,6 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { LookinAttrSec_UITextView_Font: @"Font", LookinAttrSec_UITextView_ContainerInset: @"ContainerInset", LookinAttrSec_UITextField_ClearButtonMode: @"ClearButtonMode", -#endif - -#if TARGET_OS_OSX LookinAttrSec_NSImageView_Name: @"ImageName", LookinAttrSec_NSImageView_Open: @"Open", LookinAttrSec_NSControl_State: @"State", @@ -975,8 +967,6 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { LookinAttrSec_NSStackView_Distribution: @"Distribution", LookinAttrSec_NSStackView_Alignment: @"Alignment", LookinAttrSec_NSStackView_Spacing: @"Spacing", - -#endif }; }); return rawInfo[secID]; @@ -1034,22 +1024,18 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"fullTitle": @"Bounds", @"patch": @(YES) }, -#if TARGET_OS_IPHONE LookinAttr_Layout_SafeArea_SafeArea: @{ @"className": @"UIView", @"fullTitle": @"SafeAreaInsets", @"setterString": @"", @"osVersion": @(11) }, -#endif -#if TARGET_OS_OSX LookinAttr_Layout_SafeArea_SafeArea: @{ @"className": @"NSView", @"fullTitle": @"SafeAreaInsets", @"setterString": @"", @"osVersion": @(11) }, -#endif LookinAttr_Layout_Position_Position: @{ @"className": @"CALayer", @"fullTitle": @"Position", @@ -1060,8 +1046,6 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"fullTitle": @"AnchorPoint", @"patch": @(YES) }, - -#if TARGET_OS_IPHONE LookinAttr_AutoLayout_Hugging_Hor: @{ @"className": @"UIView", @"fullTitle": @"ContentHuggingPriority(Horizontal)", @@ -1106,8 +1090,6 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"fullTitle": @"IntrinsicContentSize", @"setterString": @"" }, -#endif -#if TARGET_OS_OSX LookinAttr_AutoLayout_Hugging_Hor: @{ @"className": @"NSView", @"fullTitle": @"ContentHuggingPriority(Horizontal)", @@ -1152,8 +1134,6 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"fullTitle": @"IntrinsicContentSize", @"setterString": @"" }, -#endif -#if TARGET_OS_IPHONE LookinAttr_ViewLayer_InterationAndMasks_Interaction: @{ @"className": @"UIView", @@ -1186,8 +1166,6 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"briefTitle": @"", @"patch": @(NO) }, -#endif -#if TARGET_OS_OSX LookinAttr_ViewLayer_Tag_Tag: @{ @"className": @"NSView", @@ -1195,7 +1173,6 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"briefTitle": @"", @"patch": @(NO) }, -#endif LookinAttr_ViewLayer_Visibility_Hidden: @{ @"className": @"CALayer", @"fullTitle": @"Hidden", @@ -1280,7 +1257,6 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"getterString": @"lks_shadowOffsetHeight", @"patch": @(YES) }, -#if TARGET_OS_IPHONE LookinAttr_UIStackView_Axis_Axis: @{ @"className": @"UIStackView", @@ -1700,7 +1676,6 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"enumList": @"UITextFieldViewMode", @"patch": @(NO) }, -#elif TARGET_OS_OSX LookinAttr_NSImageView_Name_Name: @{ @"className": @"NSImageView", @"fullTitle": @"ImageName", @@ -2390,7 +2365,6 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { @"fullTitle": @"Spacing", @"patch": @(YES) }, -#endif }; }); diff --git a/Src/Main/Shared/LookinDefines.h b/Src/Main/Shared/LookinDefines.h index c5b460f..ba85f26 100644 --- a/Src/Main/Shared/LookinDefines.h +++ b/Src/Main/Shared/LookinDefines.h @@ -161,6 +161,8 @@ enum { #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 @@ -182,6 +184,8 @@ enum { #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..159a7ef 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,6 +75,9 @@ typedef NS_ENUM(NSUInteger, LookinDisplayItemProperty) { @property(nonatomic, assign) CGRect bounds; +/// iOS 总是为 NO +@property(nonatomic, assign, getter=isFlipped) BOOL flipped; + /// 不存在 subitems 时,该属性的值为 nil @property(nonatomic, strong) LookinImage *soloScreenshot; /// 无论是否存在 subitems,该属性始终存在 diff --git a/Src/Main/Shared/LookinDisplayItem.m b/Src/Main/Shared/LookinDisplayItem.m index d28266c..7dac59b 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,6 +50,9 @@ - (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; @@ -78,6 +81,9 @@ - (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.hostViewControllerObject forKey:@"hostViewControllerObject"]; @@ -95,12 +101,11 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { } [aCoder encodeObject:self.customDisplayTitle forKey:@"customDisplayTitle"]; [aCoder encodeObject:self.danceuiSource forKey:@"danceuiSource"]; -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE [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 +118,9 @@ - (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.viewObject = [aDecoder decodeObjectForKey:@"viewObject"]; self.layerObject = [aDecoder decodeObjectForKey:@"layerObject"]; self.hostViewControllerObject = [aDecoder decodeObjectForKey:@"hostViewControllerObject"]; @@ -151,7 +159,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"]]; @@ -445,6 +453,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/LookinDisplayItemDetail.m b/Src/Main/Shared/LookinDisplayItemDetail.m index 90e152f..195c03c 100644 --- a/Src/Main/Shared/LookinDisplayItemDetail.m +++ b/Src/Main/Shared/LookinDisplayItemDetail.m @@ -11,7 +11,7 @@ #import "LookinDisplayItemDetail.h" #import "Image+Lookin.h" -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE #import "UIImage+LookinServer.h" #endif @@ -19,16 +19,8 @@ @implementation LookinDisplayItemDetail - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:@(self.displayItemOid) forKey:@"displayItemOid"]; -#if TARGET_OS_IPHONE [aCoder encodeObject:self.groupScreenshot.lookin_data forKey:@"groupScreenshot"]; [aCoder encodeObject:self.soloScreenshot.lookin_data forKey:@"soloScreenshot"]; -#endif -#if TARGET_OS_OSX - - - [aCoder encodeObject:[NSKeyedArchiver archivedDataWithRootObject:self.groupScreenshot requiringSecureCoding:YES error:nil] forKey:@"groupScreenshot"]; - [aCoder encodeObject:[NSKeyedArchiver archivedDataWithRootObject:self.soloScreenshot requiringSecureCoding:YES error:nil] forKey:@"soloScreenshot"]; -#endif [aCoder encodeObject:self.frameValue forKey:@"frameValue"]; [aCoder encodeObject:self.boundsValue forKey:@"boundsValue"]; [aCoder encodeObject:self.hiddenValue forKey:@"hiddenValue"]; @@ -46,14 +38,8 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { - (instancetype)initWithCoder:(NSCoder *)aDecoder { if (self = [super init]) { self.displayItemOid = [[aDecoder decodeObjectForKey:@"displayItemOid"] unsignedLongValue]; -#if TARGET_OS_IPHONE self.groupScreenshot = [[LookinImage alloc] initWithData:[aDecoder decodeObjectForKey:@"groupScreenshot"]]; self.soloScreenshot = [[LookinImage alloc] initWithData:[aDecoder decodeObjectForKey:@"soloScreenshot"]]; -#endif -#if TARGET_OS_OSX - self.groupScreenshot = [NSKeyedUnarchiver unarchivedObjectOfClass:[NSImage class] fromData:[aDecoder decodeObjectForKey:@"groupScreenshot"] error:nil]; - self.soloScreenshot = [NSKeyedUnarchiver unarchivedObjectOfClass:[NSImage class] fromData:[aDecoder decodeObjectForKey:@"soloScreenshot"] error:nil]; -#endif self.frameValue = [aDecoder decodeObjectForKey:@"frameValue"]; self.boundsValue = [aDecoder decodeObjectForKey:@"boundsValue"]; self.hiddenValue = [aDecoder decodeObjectForKey:@"hiddenValue"]; diff --git a/Src/Main/Shared/LookinHierarchyInfo.h b/Src/Main/Shared/LookinHierarchyInfo.h index 1fe718d..12bae0b 100644 --- a/Src/Main/Shared/LookinHierarchyInfo.h +++ b/Src/Main/Shared/LookinHierarchyInfo.h @@ -12,9 +12,9 @@ #import "LookinDefines.h" #import "TargetConditionals.h" -#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST +#if TARGET_OS_IPHONE #import -#elif TARGET_OS_MAC +#elif TARGET_OS_OSX #import #endif From ef0cfdcc96063759852b8357d29404f50e61dee9 Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Fri, 8 Nov 2024 18:52:39 +0800 Subject: [PATCH 18/21] [WIP] AppKit Support --- .../Others/LKS_HierarchyDisplayItemsMaker.m | 12 ++++++++--- Src/Main/Shared/LookinDashboardBlueprint.h | 2 ++ Src/Main/Shared/LookinDashboardBlueprint.m | 21 +++++++++++++++++++ Src/Main/Shared/LookinDisplayItem.h | 3 ++- Src/Main/Shared/LookinDisplayItem.m | 7 ++++++- 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m b/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m index ec57680..41f25c8 100644 --- a/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m +++ b/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m @@ -36,11 +36,17 @@ @implementation LKS_HierarchyDisplayItemsMaker 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 = nil; + LookinDisplayItem *item = [LookinDisplayItem new]; + item.windowObject = [LookinObject instanceWithObject:window]; + item.frame = window.frame; + item.bounds = window.frame; + item.backgroundColor = window.backgroundColor; + item.shouldCaptureImage = YES; + item.alpha = window.alphaValue; if (rootLayer) { - item = [self _displayItemWithLayer:rootLayer screenshots:hasScreenshots attrList:hasAttrList lowImageQuality:lowQuality readCustomInfo:readCustomInfo saveCustomSetter:saveCustomSetter]; + item.subitems = @[[self _displayItemWithLayer:rootLayer screenshots:hasScreenshots attrList:hasAttrList lowImageQuality:lowQuality readCustomInfo:readCustomInfo saveCustomSetter:saveCustomSetter]]; } else { - item = [self _displayItemWithView:window.lks_rootView screenshots:hasScreenshots attrList:hasAttrList lowImageQuality:lowQuality readCustomInfo:readCustomInfo saveCustomSetter:saveCustomSetter]; + item.subitems = @[[self _displayItemWithView:window.lks_rootView screenshots:hasScreenshots attrList:hasAttrList lowImageQuality:lowQuality readCustomInfo:readCustomInfo saveCustomSetter:saveCustomSetter]]; } #endif item.representedAsKeyWindow = window.isKeyWindow; 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 aa942e5..0596746 100644 --- a/Src/Main/Shared/LookinDashboardBlueprint.m +++ b/Src/Main/Shared/LookinDashboardBlueprint.m @@ -2387,12 +2387,33 @@ + (NSString *)classNameWithAttrID:(LookinAttrIdentifier)attrID { 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/LookinDisplayItem.h b/Src/Main/Shared/LookinDisplayItem.h index 159a7ef..d7d2b33 100644 --- a/Src/Main/Shared/LookinDisplayItem.h +++ b/Src/Main/Shared/LookinDisplayItem.h @@ -75,7 +75,7 @@ typedef NS_ENUM(NSUInteger, LookinDisplayItemProperty) { @property(nonatomic, assign) CGRect bounds; -/// iOS 总是为 NO +/// 只在 macOS 上有效, iOS 总是为 NO @property(nonatomic, assign, getter=isFlipped) BOOL flipped; /// 不存在 subitems 时,该属性的值为 nil @@ -83,6 +83,7 @@ typedef NS_ENUM(NSUInteger, LookinDisplayItemProperty) { /// 无论是否存在 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 7dac59b..fceaed2 100644 --- a/Src/Main/Shared/LookinDisplayItem.m +++ b/Src/Main/Shared/LookinDisplayItem.m @@ -57,6 +57,7 @@ - (id)copyWithZone:(NSZone *)zone { 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; @@ -86,6 +87,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { #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"]; @@ -121,6 +123,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder { #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"]; @@ -183,7 +186,7 @@ - (instancetype)init { } - (LookinObject *)displayingObject { - return self.viewObject ? : self.layerObject; + return self.windowObject ? : self.viewObject ? : self.layerObject; } - (void)setAttributesGroupList:(NSArray *)attributesGroupList { @@ -350,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]; } From 3129a94870bf9e82b0ecda114c9557d82f9bf281 Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Fri, 8 Nov 2024 22:05:24 +0800 Subject: [PATCH 19/21] [WIP] AppKit Support --- .github/workflows/UpstreamSync.yml | 39 ------------------- .../Server/Category/CALayer+LookinServer.m | 1 - .../Server/Category/NSWindow+LookinServer.h | 4 ++ .../Server/Category/NSWindow+LookinServer.m | 13 +++++++ .../Others/LKS_HierarchyDisplayItemsMaker.m | 7 +++- Src/Main/Shared/LKS_MultiplatformAdapter.m | 4 +- 6 files changed, 25 insertions(+), 43 deletions(-) delete mode 100644 .github/workflows/UpstreamSync.yml diff --git a/.github/workflows/UpstreamSync.yml b/.github/workflows/UpstreamSync.yml deleted file mode 100644 index 406e6ae..0000000 --- a/.github/workflows/UpstreamSync.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Upstream Sync - -permissions: - contents: write - -on: - schedule: - - cron: "0 0 * * *" # every day - workflow_dispatch: - -jobs: - sync_latest_from_upstream: - name: Sync latest commits from upstream repo - runs-on: ubuntu-latest - if: ${{ github.event.repository.fork }} - - steps: - # Step 1: run a standard checkout action - - name: Checkout target repo - uses: actions/checkout@v3 - - # Step 2: run the sync action - - name: Sync upstream changes - id: sync - uses: aormsby/Fork-Sync-With-Upstream-action@v3.4 - with: - upstream_sync_repo: QMUI/LookinServer - upstream_sync_branch: develop - target_sync_branch: develop - target_repo_token: ${{ secrets.GITHUB_TOKEN }} # automatically generated, no need to set - - # Set test_mode true to run tests instead of the true action!! - test_mode: false - - - name: Sync check - if: failure() - run: | - echo "::error::Due to insufficient permissions, synchronization failed (as expected). Please go to the repository homepage and manually perform [Sync fork]." - exit 1 \ No newline at end of file diff --git a/Src/Main/Server/Category/CALayer+LookinServer.m b/Src/Main/Server/Category/CALayer+LookinServer.m index a86a13a..65488dc 100644 --- a/Src/Main/Server/Category/CALayer+LookinServer.m +++ b/Src/Main/Server/Category/CALayer+LookinServer.m @@ -47,7 +47,6 @@ - (CGRect)lks_frameInWindow:(LookinWindow *)window { 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 diff --git a/Src/Main/Server/Category/NSWindow+LookinServer.h b/Src/Main/Server/Category/NSWindow+LookinServer.h index f0a2a39..0ce2c75 100644 --- a/Src/Main/Server/Category/NSWindow+LookinServer.h +++ b/Src/Main/Server/Category/NSWindow+LookinServer.h @@ -17,6 +17,10 @@ NS_ASSUME_NONNULL_BEGIN // NSWindow 的 rootView 是 contentView 的 superview,例如 NSThemeFrame @property (nonatomic, readonly) NSView *lks_rootView; +- (NSImage *)lks_snapshotImage; + +- (CGRect)lks_bounds; + @end NS_ASSUME_NONNULL_END diff --git a/Src/Main/Server/Category/NSWindow+LookinServer.m b/Src/Main/Server/Category/NSWindow+LookinServer.m index fb26f62..829e589 100644 --- a/Src/Main/Server/Category/NSWindow+LookinServer.m +++ b/Src/Main/Server/Category/NSWindow+LookinServer.m @@ -15,6 +15,19 @@ - (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/Others/LKS_HierarchyDisplayItemsMaker.m b/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m index 41f25c8..58ff98a 100644 --- a/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m +++ b/Src/Main/Server/Others/LKS_HierarchyDisplayItemsMaker.m @@ -38,11 +38,14 @@ @implementation LKS_HierarchyDisplayItemsMaker CALayer *rootLayer = window.lks_rootView.layer; LookinDisplayItem *item = [LookinDisplayItem new]; item.windowObject = [LookinObject instanceWithObject:window]; - item.frame = window.frame; - item.bounds = window.frame; + 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 { diff --git a/Src/Main/Shared/LKS_MultiplatformAdapter.m b/Src/Main/Shared/LKS_MultiplatformAdapter.m index 8b33303..16a2ef1 100644 --- a/Src/Main/Shared/LKS_MultiplatformAdapter.m +++ b/Src/Main/Shared/LKS_MultiplatformAdapter.m @@ -49,7 +49,9 @@ + (CGRect)mainScreenBounds { return [UIScreen mainScreen].bounds; #elif TARGET_OS_OSX // 这里不能返回屏幕的bounds,因为在macOS上,窗口可以不全屏显示,Lookin的设计是基于窗口的,一般iOS中屏幕的bounds就是窗口的bounds,所以这里直接返回窗口的bounds - return NSApplication.sharedApplication.windows.firstObject.contentView.bounds; + CGRect frame = NSApplication.sharedApplication.windows.firstObject.frame; + frame.origin = CGPointZero; + return frame; #else return CGRectZero; #endif From 5c8559dd8fe8c6b4ebec90014977117f9ebde1ff Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Sun, 10 Nov 2024 23:02:28 +0800 Subject: [PATCH 20/21] [WIP] AppKit Support --- Src/Main/Shared/LookinDashboardBlueprint.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Src/Main/Shared/LookinDashboardBlueprint.m b/Src/Main/Shared/LookinDashboardBlueprint.m index 0596746..012fabb 100644 --- a/Src/Main/Shared/LookinDashboardBlueprint.m +++ b/Src/Main/Shared/LookinDashboardBlueprint.m @@ -1733,7 +1733,7 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { LookinAttr_NSControl_Alignment_Alignment: @{ @"className": @"NSControl", @"fullTitle": @"Alignment", - @"enumList": @"NSTextAlignment", + @"enumList": @"NSTextAlignment_AppKit", @"patch": @(YES) }, LookinAttr_NSControl_Misc_WritingDirection: @{ @@ -2200,7 +2200,7 @@ + (NSString *)sectionTitleWithSectionID:(LookinAttrSectionIdentifier)secID { LookinAttr_NSTextView_Alignment_Alignment: @{ @"className": @"NSTextView", @"fullTitle": @"Alignment", - @"enumList": @"NSTextAlignment", + @"enumList": @"NSTextAlignment_AppKit", @"patch": @(YES) }, LookinAttr_NSTextView_ContainerInset_Inset: @{ From 0c687d76572db397c432a419dd5ad4a80ad1d9ae Mon Sep 17 00:00:00 2001 From: Mx-Iris <61279231+Mx-Iris@users.noreply.github.com> Date: Fri, 22 Nov 2024 18:11:21 +0800 Subject: [PATCH 21/21] Updates --- Src/Main/Shared/LKS_MultiplatformAdapter.m | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Src/Main/Shared/LKS_MultiplatformAdapter.m b/Src/Main/Shared/LKS_MultiplatformAdapter.m index 16a2ef1..5646566 100644 --- a/Src/Main/Shared/LKS_MultiplatformAdapter.m +++ b/Src/Main/Shared/LKS_MultiplatformAdapter.m @@ -49,9 +49,15 @@ + (CGRect)mainScreenBounds { return [UIScreen mainScreen].bounds; #elif TARGET_OS_OSX // 这里不能返回屏幕的bounds,因为在macOS上,窗口可以不全屏显示,Lookin的设计是基于窗口的,一般iOS中屏幕的bounds就是窗口的bounds,所以这里直接返回窗口的bounds - CGRect frame = NSApplication.sharedApplication.windows.firstObject.frame; - frame.origin = CGPointZero; - return frame; + 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