unify
This commit is contained in:
1 parent
7bcdb28867
commit
79c9e1dfbf
6 files changed
+13
-13
No files matched your search
@@ -15,15 +15,13 @@ func renderRecreateSurface(_ vm: RenderVM) {
|
||||
glbriMakeCurrentContext(&vm.glView.st)
|
||||
}
|
||||
|
||||
func renderSetupWinUISignals(_ view: RenderGLView, acceptsPointerInput: Bool) {
|
||||
func renderSetupWinUISignals(_ view: RenderGLView) {
|
||||
view.loaded.addHandler { [weak view] _, _ in view?.onLoaded() }
|
||||
view.sizeChanged.addHandler { [weak view] _, _ in view?.onSizeChanged() }
|
||||
view.unloaded.addHandler { [weak view] _, _ in view?.onUnloaded() }
|
||||
|
||||
if acceptsPointerInput {
|
||||
view.pointerPressed.addHandler { [weak view] _, event in
|
||||
view?.onPointerDown(event)
|
||||
}
|
||||
view.pointerPressed.addHandler { [weak view] _, event in
|
||||
view?.onPointerDown(event)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,14 +6,13 @@ final class RenderGLView: FrameworkElement {
|
||||
var rootChanged: EventCleanup?
|
||||
var st = GLBriState()
|
||||
|
||||
init(acceptsPointerInput: Bool) {
|
||||
override init() {
|
||||
// swift-winui does not project SwapChainPanel, so wrap its native WinRT instance
|
||||
let panel: WindowsFoundation.IInspectable = try! RoActivateInstance(
|
||||
HString("Microsoft.UI.Xaml.Controls.SwapChainPanel")
|
||||
)
|
||||
super.init(fromAbi: panel)
|
||||
isHitTestVisible = acceptsPointerInput
|
||||
renderSetupWinUISignals(self, acceptsPointerInput: acceptsPointerInput)
|
||||
renderSetupWinUISignals(self)
|
||||
}
|
||||
|
||||
func onLoaded() {
|
||||
|
||||
@@ -942,8 +942,9 @@ through RoActivateInstance and wraps its IInspectable in FrameworkElement.
|
||||
The RenderView WinUIElementRepresentable returns that same VM-owned object.
|
||||
Its sizeThatFits accepts the offered dimensions because the empty panel has no
|
||||
intrinsic content size; WindowGroup.defaultSize supplies the initial proposal.
|
||||
HRBApp places it first in ZStack and the shared title second. The panel disables
|
||||
hit testing to leave input to the overlaid UI.
|
||||
HRBApp places it first in ZStack and the shared title second. The panel uses
|
||||
WinUI's default hit testing and registers the same pointer handler as
|
||||
hello-selection. HRB has no rule that reacts to those presses.
|
||||
|
||||
Loaded dispatches didPrepareWindowsGL. Its shared YAML rule emits didPrepareGL;
|
||||
the existing generated effects call renderInit, set VM.didPrepareGL and start
|
||||
|
||||
@@ -393,7 +393,9 @@ The Swift WinUI projection used here does not expose SwapChainPanel directly.
|
||||
RenderGLView activates `Microsoft.UI.Xaml.Controls.SwapChainPanel` through
|
||||
`RoActivateInstance` and wraps its IInspectable as FrameworkElement. The
|
||||
`WinRTInternal` SPI exposes `init(fromAbi:)` and `_getABI()` for that integration.
|
||||
The native panel disables hit testing, leaving overlaid UI available for input.
|
||||
The native panel uses WinUI's default hit testing and shares its primary mouse
|
||||
press handler with hello-selection. In hello-raylib, `mouseDownPos` has no
|
||||
effect on the title or rendering.
|
||||
|
||||
`Loaded` dispatches Windows preparation and an initial resize, and subscribes to
|
||||
`XamlRoot.Changed`. Subsequent SizeChanged/root events dispatch resize while the
|
||||
|
||||
@@ -5,7 +5,7 @@ final class RenderVM: ObservableObject {
|
||||
var didPrepareGL = false
|
||||
var frameCallback: EventCleanup?
|
||||
// WinUI controls must be created after the XAML runtime starts
|
||||
lazy var glView = RenderGLView(acceptsPointerInput: false)
|
||||
lazy var glView = RenderGLView()
|
||||
var pixelSize = [Int]()
|
||||
|
||||
static private(set) weak var shared: RenderVM?
|
||||
|
||||
@@ -7,7 +7,7 @@ final class RenderVM: ObservableObject {
|
||||
var didPrepareGL = false
|
||||
var frameCallback: EventCleanup?
|
||||
// WinUI controls must be created after the XAML runtime starts
|
||||
lazy var glView = RenderGLView(acceptsPointerInput: true)
|
||||
lazy var glView = RenderGLView()
|
||||
var items = [HSTItem]()
|
||||
var pixelSize = [Int]()
|
||||
var selectedItemId = -1
|
||||
|
||||
Reference in new issue
Block a user