-
Notifications
You must be signed in to change notification settings - Fork 41
Add initial rendering support for NSHostingView #291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// OpenSwiftUI+NSView.h | ||
// COpenSwiftUI | ||
// | ||
// Audited for macOS 15.0 | ||
// Status: WIP | ||
|
||
#ifndef OpenSwiftUI_NSView_h | ||
#define OpenSwiftUI_NSView_h | ||
|
||
#include "OpenSwiftUIBase.h" | ||
|
||
#if OPENSWIFTUI_TARGET_OS_OSX | ||
|
||
#import <AppKit/AppKit.h> | ||
|
||
OPENSWIFTUI_ASSUME_NONNULL_BEGIN | ||
|
||
@interface NSView (OpenSwiftUI) | ||
|
||
@property (strong, nullable) NSView *maskView; | ||
|
||
- (void)setFlipped:(BOOL)flipped; | ||
|
||
@end | ||
|
||
OPENSWIFTUI_ASSUME_NONNULL_END | ||
|
||
#endif /* OPENSWIFTUI_TARGET_OS_OSX */ | ||
|
||
#endif /* OpenSwiftUI_NSView_h */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// OpenSwiftUI+NSView.m | ||
// COpenSwiftUI | ||
// | ||
// Audited for macOS 15.0 | ||
// Status: WIP | ||
|
||
#import "OpenSwiftUI+NSView.h" | ||
|
||
#if OPENSWIFTUI_TARGET_OS_OSX | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// CAChameleonLayer.h | ||
// COpenSwiftUI | ||
// | ||
// Audited for macOS 15.0 | ||
// Status: WIP | ||
|
||
#include "OpenSwiftUIBase.h" | ||
|
||
#if OPENSWIFTUI_TARGET_OS_OSX | ||
|
||
#import <QuartzCore/QuartzCore.h> | ||
|
||
OPENSWIFTUI_ASSUME_NONNULL_BEGIN | ||
|
||
@interface CAChameleonLayer : CALayer | ||
|
||
@end | ||
|
||
OPENSWIFTUI_ASSUME_NONNULL_END | ||
|
||
#endif /* OPENSWIFTUI_TARGET_OS_OSX */ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// | ||
// CAChameleonLayer.m | ||
// COpenSwiftUI | ||
// | ||
// Audited for macOS 15.0 | ||
// Status: WIP | ||
|
||
#import "CAChameleonLayer.h" | ||
|
27 changes: 27 additions & 0 deletions
27
Sources/OpenSwiftUI/Integration/Hosting/AppKit/View/NSGraphicsView.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// NSGraphicsView.swift | ||
// OpenSwiftUI | ||
// | ||
// Audited for macOS 15.0 | ||
// Status: WIP | ||
|
||
#if os(macOS) | ||
|
||
import OpenSwiftUI_SPI | ||
import AppKit | ||
|
||
final class _NSGraphicsView: NSView { | ||
var recursiveIgnoreHitTest: Bool = false | ||
|
||
var customAcceptsFirstMouse: Bool? | ||
|
||
override init(frame frameRect: NSRect) { | ||
super.init(frame: frameRect) | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
super.init(coder: coder) | ||
} | ||
} | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
Sources/OpenSwiftUI/Integration/Hosting/AppKit/View/NSInheritedView.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// NSInheritedView.swift | ||
// OpenSwiftUI | ||
// | ||
// Audited for macOS 15.0 | ||
// Status: WIP | ||
|
||
#if os(macOS) | ||
|
||
import OpenSwiftUI_SPI | ||
import AppKit | ||
|
||
final class _NSInheritedView: NSView { | ||
var hitTestsAsOpaque: Bool = false | ||
|
||
override init(frame frameRect: NSRect) { | ||
super.init(frame: frameRect) | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
super.init(coder: coder) | ||
} | ||
} | ||
|
||
#endif |
26 changes: 26 additions & 0 deletions
26
Sources/OpenSwiftUI/Integration/Hosting/AppKit/View/NSProjectionView.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// NSProjectionView.swift | ||
// OpenSwiftUI | ||
// | ||
// Audited for macOS 15.0 | ||
// Status: WIP | ||
|
||
#if os(macOS) | ||
|
||
import OpenSwiftUI_SPI | ||
import AppKit | ||
|
||
final class _NSProjectionView: NSView { | ||
|
||
override var wantsUpdateLayer: Bool { true } | ||
|
||
override init(frame frameRect: NSRect) { | ||
super.init(frame: frameRect) | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
super.init(coder: coder) | ||
} | ||
} | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -139,8 +139,14 @@ private struct LeafDisplayList<V>: StatefulRule, CustomStringConvertible where V | |||||||||||||||||
) | ||||||||||||||||||
item.canonicalize(options: options) | ||||||||||||||||||
#if _OPENSWIFTUI_SWIFTUI_RENDER | ||||||||||||||||||
|
||||||||||||||||||
// FIXME: Remove me after Layout system is implemented | ||||||||||||||||||
#if os(macOS) | ||||||||||||||||||
item.frame = CGRect(x: 0, y: 0, width: 500, height: 300) | ||||||||||||||||||
#elseif os(iOS) | ||||||||||||||||||
item.frame = CGRect(x: 0, y: 100.333, width: 402, height: 739) | ||||||||||||||||||
Comment on lines
+145
to
147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The temporary hard-coded frame values may hinder adaptability across different screen sizes. Consider deferring to the layout system or using configurable parameters once implemented.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||
#endif | ||||||||||||||||||
|
||||||||||||||||||
#endif | ||||||||||||||||||
value = DisplayList(item) | ||||||||||||||||||
} | ||||||||||||||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The nested render() function increases the complexity of renderDisplayList. Consider extracting it into a separate method to improve readability and maintainability.
Copilot uses AI. Check for mistakes.