react-native-windows 0.74.20 → 0.74.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Microsoft.ReactNative/ComponentView.idl +44 -32
- package/Microsoft.ReactNative/Composition.Input.idl +3 -0
- package/Microsoft.ReactNative/CompositionComponentView.idl +43 -24
- package/Microsoft.ReactNative/CompositionSwitcher.idl +3 -0
- package/Microsoft.ReactNative/Fabric/AbiEventEmitter.cpp +21 -0
- package/Microsoft.ReactNative/Fabric/AbiEventEmitter.h +23 -0
- package/Microsoft.ReactNative/Fabric/AbiShadowNode.cpp +7 -0
- package/Microsoft.ReactNative/Fabric/AbiShadowNode.h +3 -0
- package/Microsoft.ReactNative/Fabric/ComponentView.cpp +334 -65
- package/Microsoft.ReactNative/Fabric/ComponentView.h +162 -38
- package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.cpp +2 -2
- package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.cpp +3 -0
- package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +29 -7
- package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +23 -4
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +44 -13
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +118 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +12 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +147 -119
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +4 -8
- package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +129 -106
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +31 -54
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +133 -0
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +61 -0
- package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +9 -8
- package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.h +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/FocusManager.cpp +20 -6
- package/Microsoft.ReactNative/Fabric/Composition/FocusManager.h +13 -6
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +1 -4
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +3 -5
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +1 -6
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +0 -1
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +108 -18
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +33 -5
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +137 -56
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +21 -4
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +45 -10
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +9 -2
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +209 -189
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +2 -5
- package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +22 -10
- package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +4 -5
- package/Microsoft.ReactNative/Fabric/Composition/TextDrawing.cpp +1 -2
- package/Microsoft.ReactNative/Fabric/Composition/TextDrawing.h +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +115 -168
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +11 -14
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +14 -11
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h +4 -4
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.cpp +0 -13
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.h +0 -3
- package/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +12 -4
- package/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp +338 -0
- package/Microsoft.ReactNative/Fabric/Composition/TooltipService.h +66 -0
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +56 -4
- package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +7 -0
- package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +2 -4
- package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.h +1 -2
- package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +40 -9
- package/Microsoft.ReactNative/Fabric/ReactTaggedView.h +4 -0
- package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp +1 -3
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.cpp +25 -1
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.h +4 -1
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +1 -1
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +9 -2
- package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +13 -3
- package/Microsoft.ReactNative/IReactViewComponentBuilder.idl +64 -4
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -1
- package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +9 -0
- package/Microsoft.ReactNative/Modules/LogBoxModule.h +2 -0
- package/Microsoft.ReactNative/Modules/SampleTurboModule.cpp +104 -0
- package/Microsoft.ReactNative/Modules/SampleTurboModule.h +78 -0
- package/Microsoft.ReactNative/ReactCoreInjection.h +0 -1
- package/Microsoft.ReactNative/ReactHost/MsoReactContext.cpp +0 -7
- package/Microsoft.ReactNative/ReactHost/MsoReactContext.h +0 -5
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +17 -1
- package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.cpp +59 -0
- package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.h +23 -0
- package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +179 -0
- package/Microsoft.ReactNative/ReactNativeAppBuilder.h +35 -0
- package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +69 -0
- package/Microsoft.ReactNative/ReactNativeIsland.idl +5 -0
- package/Microsoft.ReactNative/ReactNativeWin32App.cpp +82 -0
- package/Microsoft.ReactNative/ReactNativeWin32App.h +38 -0
- package/Microsoft.ReactNative/Timer.idl +1 -1
- package/Microsoft.ReactNative/packages.lock.json +0 -10
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/PropertySheets/WinUI.props +1 -1
- package/Shared/Shared.vcxitems +43 -0
- package/Shared/Shared.vcxitems.filters +3 -0
- package/Shared/TurboModuleManager.cpp +0 -3
- package/just-task.js +1 -1
- package/package.json +3 -3
- package/templates/cpp-app/windows/MyApp/MyApp.cpp +1 -0
|
@@ -42,7 +42,7 @@ struct ScrollBarComponent {
|
|
|
42
42
|
const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
|
|
43
43
|
winrt::Microsoft::ReactNative::ReactContext const &reactContext,
|
|
44
44
|
bool vertical)
|
|
45
|
-
:
|
|
45
|
+
: m_wkOuter(outer), m_compContext(compContext), m_reactContext(reactContext), m_vertical(vertical) {
|
|
46
46
|
m_rootVisual = m_compContext.CreateSpriteVisual();
|
|
47
47
|
m_trackVisual = m_compContext.CreateRoundedRectangleVisual();
|
|
48
48
|
m_thumbVisual = m_compContext.CreateRoundedRectangleVisual();
|
|
@@ -73,9 +73,11 @@ struct ScrollBarComponent {
|
|
|
73
73
|
updateHighlight(ScrollbarHitRegion::ArrowLast);
|
|
74
74
|
updateHighlight(ScrollbarHitRegion::Thumb);
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
if (auto outer = m_wkOuter.get()) {
|
|
77
|
+
m_trackVisual.Brush(
|
|
78
|
+
winrt::get_self<winrt::Microsoft::ReactNative::Composition::implementation::Theme>(outer.Theme())
|
|
79
|
+
->InternalPlatformBrush(L"ScrollBarTrackFill"));
|
|
80
|
+
}
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
void ContentSize(winrt::Windows::Foundation::Size contentSize) noexcept {
|
|
@@ -293,19 +295,21 @@ struct ScrollBarComponent {
|
|
|
293
295
|
}
|
|
294
296
|
|
|
295
297
|
void OnPointerReleased(const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) {
|
|
296
|
-
if (
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
298
|
+
if (auto outer = m_wkOuter.get()) {
|
|
299
|
+
if (!m_visible)
|
|
300
|
+
return;
|
|
301
|
+
auto pt = args.GetCurrentPoint(outer.Tag());
|
|
302
|
+
if (m_nTrackInputOffset != -1 &&
|
|
303
|
+
pt.PointerDeviceType() == winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType::Mouse &&
|
|
304
|
+
pt.Properties().PointerUpdateKind() ==
|
|
305
|
+
winrt::Microsoft::ReactNative::Composition::Input::PointerUpdateKind::LeftButtonReleased) {
|
|
306
|
+
handleMoveThumb(args);
|
|
307
|
+
stopTrackingThumb();
|
|
308
|
+
outer.ReleasePointerCapture(args.Pointer());
|
|
309
|
+
|
|
310
|
+
auto reg = HitTest(pt.Position());
|
|
311
|
+
updateShy(reg == ScrollbarHitRegion::Unknown);
|
|
312
|
+
}
|
|
309
313
|
}
|
|
310
314
|
}
|
|
311
315
|
|
|
@@ -318,78 +322,85 @@ struct ScrollBarComponent {
|
|
|
318
322
|
}
|
|
319
323
|
|
|
320
324
|
void handleMoveThumb(const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) {
|
|
321
|
-
auto
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
325
|
+
if (auto outer = m_wkOuter.get()) {
|
|
326
|
+
auto pt = args.GetCurrentPoint(outer.Tag());
|
|
327
|
+
auto pos = pt.Position();
|
|
328
|
+
|
|
329
|
+
auto newTrackingPosition = static_cast<int>((m_vertical ? pos.Y : pos.X) * m_scaleFactor) - m_nTrackInputOffset;
|
|
330
|
+
winrt::get_self<ScrollViewComponentView>(outer)->scrollTo(
|
|
331
|
+
m_vertical ? winrt::Windows::Foundation::Numerics::
|
|
332
|
+
float3{m_offset.x, scrollOffsetFromThumbPos(newTrackingPosition), m_offset.z}
|
|
333
|
+
: winrt::Windows::Foundation::Numerics::
|
|
334
|
+
float3{scrollOffsetFromThumbPos(newTrackingPosition), m_offset.y, m_offset.z},
|
|
335
|
+
false);
|
|
336
|
+
}
|
|
331
337
|
args.Handled(true);
|
|
332
338
|
}
|
|
333
339
|
|
|
334
340
|
void OnPointerPressed(const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) {
|
|
335
|
-
if (
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
+
if (auto outer = m_wkOuter.get()) {
|
|
342
|
+
if (!m_visible)
|
|
343
|
+
return;
|
|
344
|
+
auto pt = args.GetCurrentPoint(outer.Tag());
|
|
345
|
+
if (pt.PointerDeviceType() == winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType::Mouse) {
|
|
346
|
+
auto pos = pt.Position();
|
|
347
|
+
auto reg = HitTest(pos);
|
|
341
348
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
349
|
+
switch (reg) {
|
|
350
|
+
case ScrollbarHitRegion::ArrowFirst:
|
|
351
|
+
if (m_vertical) {
|
|
352
|
+
winrt::get_self<ScrollViewComponentView>(outer)->lineUp(false);
|
|
353
|
+
} else {
|
|
354
|
+
winrt::get_self<ScrollViewComponentView>(outer)->lineLeft(false);
|
|
355
|
+
}
|
|
356
|
+
args.Handled(true);
|
|
357
|
+
break;
|
|
358
|
+
case ScrollbarHitRegion::ArrowLast:
|
|
359
|
+
if (m_vertical) {
|
|
360
|
+
winrt::get_self<ScrollViewComponentView>(outer)->lineDown(false);
|
|
361
|
+
} else {
|
|
362
|
+
winrt::get_self<ScrollViewComponentView>(outer)->lineRight(false);
|
|
363
|
+
}
|
|
364
|
+
args.Handled(true);
|
|
365
|
+
break;
|
|
366
|
+
case ScrollbarHitRegion::PageUp:
|
|
367
|
+
if (m_vertical) {
|
|
368
|
+
winrt::get_self<ScrollViewComponentView>(outer)->pageUp(false);
|
|
369
|
+
}
|
|
370
|
+
args.Handled(true);
|
|
371
|
+
break;
|
|
372
|
+
case ScrollbarHitRegion::PageDown:
|
|
373
|
+
if (m_vertical) {
|
|
374
|
+
winrt::get_self<ScrollViewComponentView>(outer)->pageDown(false);
|
|
375
|
+
}
|
|
376
|
+
args.Handled(true);
|
|
377
|
+
break;
|
|
378
|
+
case ScrollbarHitRegion::Thumb: {
|
|
379
|
+
outer.CapturePointer(args.Pointer());
|
|
380
|
+
m_nTrackInputOffset = static_cast<int>((m_vertical ? pos.Y : pos.X) * m_scaleFactor) - m_thumbPos;
|
|
381
|
+
m_thumbVisual.AnimationClass(
|
|
382
|
+
winrt::Microsoft::ReactNative::Composition::Experimental::AnimationClass::None);
|
|
383
|
+
handleMoveThumb(args);
|
|
368
384
|
}
|
|
369
|
-
args.Handled(true);
|
|
370
|
-
break;
|
|
371
|
-
case ScrollbarHitRegion::Thumb: {
|
|
372
|
-
m_outer.CapturePointer(args.Pointer());
|
|
373
|
-
m_nTrackInputOffset = static_cast<int>((m_vertical ? pos.Y : pos.X) * m_scaleFactor) - m_thumbPos;
|
|
374
|
-
m_thumbVisual.AnimationClass(winrt::Microsoft::ReactNative::Composition::Experimental::AnimationClass::None);
|
|
375
|
-
handleMoveThumb(args);
|
|
376
385
|
}
|
|
377
386
|
}
|
|
378
387
|
}
|
|
379
388
|
}
|
|
380
389
|
|
|
381
390
|
void OnPointerMoved(const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) {
|
|
382
|
-
if (
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
if (
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
391
|
+
if (auto outer = m_wkOuter.get()) {
|
|
392
|
+
if (!m_visible)
|
|
393
|
+
return;
|
|
394
|
+
auto pt = args.GetCurrentPoint(outer.Tag());
|
|
395
|
+
if (pt.PointerDeviceType() == winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType::Mouse) {
|
|
396
|
+
if (m_nTrackInputOffset != -1) {
|
|
397
|
+
handleMoveThumb(args);
|
|
398
|
+
} else {
|
|
399
|
+
auto pos = pt.Position();
|
|
400
|
+
auto reg = HitTest(pos);
|
|
401
|
+
updateShy(reg == ScrollbarHitRegion::Unknown);
|
|
402
|
+
setHighlightedRegion(reg);
|
|
403
|
+
}
|
|
393
404
|
}
|
|
394
405
|
}
|
|
395
406
|
}
|
|
@@ -427,122 +438,126 @@ struct ScrollBarComponent {
|
|
|
427
438
|
|
|
428
439
|
// Renders the text into our composition surface
|
|
429
440
|
void drawArrow(ScrollbarHitRegion region, bool disabled, bool hovered) noexcept {
|
|
430
|
-
auto
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
drawingSurface
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
441
|
+
if (auto outer = m_wkOuter.get()) {
|
|
442
|
+
auto &drawingSurface =
|
|
443
|
+
(region == ScrollbarHitRegion::ArrowFirst) ? m_arrowFirstDrawingSurface : m_arrowLastDrawingSurface;
|
|
444
|
+
if (!drawingSurface) {
|
|
445
|
+
drawingSurface = m_compContext.CreateDrawingSurfaceBrush(
|
|
446
|
+
{m_arrowSize, m_arrowSize},
|
|
447
|
+
winrt::Windows::Graphics::DirectX::DirectXPixelFormat::B8G8R8A8UIntNormalized,
|
|
448
|
+
winrt::Windows::Graphics::DirectX::DirectXAlphaMode::Premultiplied);
|
|
449
|
+
}
|
|
438
450
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
451
|
+
if (winrt::get_self<ScrollViewComponentView>(outer)->theme()->IsEmpty()) {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
442
454
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
455
|
+
winrt::com_ptr<IDWriteTextFormat> spTextFormat;
|
|
456
|
+
winrt::check_hresult(::Microsoft::ReactNative::DWriteFactory()->CreateTextFormat(
|
|
457
|
+
L"Segoe Fluent Icons",
|
|
458
|
+
nullptr, // Font collection (nullptr sets it to use the system font collection).
|
|
459
|
+
DWRITE_FONT_WEIGHT_REGULAR,
|
|
460
|
+
DWRITE_FONT_STYLE_NORMAL,
|
|
461
|
+
DWRITE_FONT_STRETCH_NORMAL,
|
|
462
|
+
8, // Xaml resource: ScrollBarButtonArrowIconFontSize
|
|
463
|
+
L"",
|
|
464
|
+
spTextFormat.put()));
|
|
465
|
+
|
|
466
|
+
winrt::check_hresult(spTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER));
|
|
467
|
+
|
|
468
|
+
winrt::com_ptr<IDWriteTextLayout> spTextLayout;
|
|
469
|
+
winrt::check_hresult(::Microsoft::ReactNative::DWriteFactory()->CreateTextLayout(
|
|
470
|
+
m_vertical ? ((region == ScrollbarHitRegion::ArrowFirst) ? L"\uEDDB" : L"\uEDDC")
|
|
471
|
+
: ((region == ScrollbarHitRegion::ArrowFirst) ? L"\uEDD9" : L"\uEDDA"),
|
|
472
|
+
1, // The length of the string.
|
|
473
|
+
spTextFormat.get(), // The text format to apply to the string (contains font information, etc).
|
|
474
|
+
(m_arrowSize / m_scaleFactor), // The width of the layout box.
|
|
475
|
+
(m_arrowSize / m_scaleFactor), // The height of the layout box.
|
|
476
|
+
spTextLayout.put() // The IDWriteTextLayout interface pointer.
|
|
477
|
+
));
|
|
478
|
+
|
|
479
|
+
POINT offset;
|
|
480
|
+
{
|
|
481
|
+
::Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(drawingSurface, m_scaleFactor, &offset);
|
|
482
|
+
if (auto d2dDeviceContext = autoDraw.GetRenderTarget()) {
|
|
483
|
+
d2dDeviceContext->Clear(D2D1::ColorF(D2D1::ColorF::Black, 0.0f));
|
|
484
|
+
assert(d2dDeviceContext->GetUnitMode() == D2D1_UNIT_MODE_DIPS);
|
|
485
|
+
|
|
486
|
+
// Create a solid color brush for the text. A more sophisticated application might want
|
|
487
|
+
// to cache and reuse a brush across all text elements instead, taking care to recreate
|
|
488
|
+
// it in the event of device removed.
|
|
489
|
+
winrt::com_ptr<ID2D1SolidColorBrush> brush;
|
|
490
|
+
|
|
491
|
+
D2D1::ColorF color{0};
|
|
492
|
+
if (disabled) {
|
|
493
|
+
color = winrt::get_self<ScrollViewComponentView>(outer)->theme()->D2DPlatformColor(
|
|
494
|
+
"ScrollBarButtonArrowForegroundDisabled");
|
|
495
|
+
} else if (hovered) {
|
|
496
|
+
color = winrt::get_self<ScrollViewComponentView>(outer)->theme()->D2DPlatformColor(
|
|
497
|
+
"ScrollBarButtonArrowForegroundPointerOver");
|
|
498
|
+
} else {
|
|
499
|
+
color = winrt::get_self<ScrollViewComponentView>(outer)->theme()->D2DPlatformColor(
|
|
500
|
+
"ScrollBarButtonArrowForeground");
|
|
501
|
+
}
|
|
502
|
+
winrt::check_hresult(d2dDeviceContext->CreateSolidColorBrush(color, brush.put()));
|
|
491
503
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
504
|
+
{
|
|
505
|
+
DWRITE_TEXT_METRICS dtm{};
|
|
506
|
+
winrt::check_hresult(spTextLayout->GetMetrics(&dtm));
|
|
507
|
+
offset.y += static_cast<int>((m_arrowSize - dtm.height) / 2.0f);
|
|
508
|
+
}
|
|
497
509
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
510
|
+
// Draw the line of text at the specified offset, which corresponds to the top-left
|
|
511
|
+
// corner of our drawing surface. Notice we don't call BeginDraw on the D2D device
|
|
512
|
+
// context; this has already been done for us by the composition API.
|
|
513
|
+
d2dDeviceContext->DrawTextLayout(
|
|
514
|
+
D2D1::Point2F(
|
|
515
|
+
static_cast<FLOAT>((offset.x) / m_scaleFactor), static_cast<FLOAT>((offset.y) / m_scaleFactor)),
|
|
516
|
+
spTextLayout.get(),
|
|
517
|
+
brush.get(),
|
|
518
|
+
D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
if (drawingSurface) {
|
|
522
|
+
drawingSurface.HorizontalAlignmentRatio(0.0f);
|
|
523
|
+
drawingSurface.VerticalAlignmentRatio(0.0f);
|
|
524
|
+
drawingSurface.Stretch(winrt::Microsoft::ReactNative::Composition::Experimental::CompositionStretch::None);
|
|
507
525
|
}
|
|
508
|
-
}
|
|
509
|
-
if (drawingSurface) {
|
|
510
|
-
drawingSurface.HorizontalAlignmentRatio(0.0f);
|
|
511
|
-
drawingSurface.VerticalAlignmentRatio(0.0f);
|
|
512
|
-
drawingSurface.Stretch(winrt::Microsoft::ReactNative::Composition::Experimental::CompositionStretch::None);
|
|
513
|
-
}
|
|
514
526
|
|
|
515
|
-
|
|
516
|
-
|
|
527
|
+
auto &arrowVisual = (region == ScrollbarHitRegion::ArrowFirst) ? m_arrowVisualFirst : m_arrowVisualLast;
|
|
528
|
+
arrowVisual.Brush(drawingSurface);
|
|
529
|
+
}
|
|
517
530
|
}
|
|
518
531
|
|
|
519
532
|
void updateHighlight(ScrollbarHitRegion region) noexcept {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
533
|
+
if (auto outer = m_wkOuter.get()) {
|
|
534
|
+
switch (region) {
|
|
535
|
+
case ScrollbarHitRegion::ArrowFirst:
|
|
536
|
+
case ScrollbarHitRegion::ArrowLast: {
|
|
537
|
+
auto disabled = !std::static_pointer_cast<const facebook::react::ScrollViewProps>(
|
|
538
|
+
winrt::get_self<ScrollViewComponentView>(outer)->viewProps())
|
|
539
|
+
->scrollEnabled;
|
|
540
|
+
drawArrow(region, disabled, m_highlightedRegion == region);
|
|
541
|
+
}
|
|
542
|
+
case ScrollbarHitRegion::Thumb: {
|
|
543
|
+
if (!std::static_pointer_cast<const facebook::react::ScrollViewProps>(
|
|
544
|
+
winrt::get_self<ScrollViewComponentView>(outer)->viewProps())
|
|
545
|
+
->scrollEnabled) {
|
|
546
|
+
m_thumbVisual.Brush(
|
|
547
|
+
winrt::get_self<Theme>(outer.Theme())->InternalPlatformBrush(L"ScrollBarThumbFillDisabled"));
|
|
548
|
+
} else if (m_highlightedRegion == region) {
|
|
549
|
+
m_thumbVisual.Brush(
|
|
550
|
+
winrt::get_self<Theme>(outer.Theme())->InternalPlatformBrush(L"ScrollBarThumbFillPointerOver"));
|
|
551
|
+
} else {
|
|
552
|
+
m_thumbVisual.Brush(winrt::get_self<Theme>(outer.Theme())->InternalPlatformBrush(L"ScrollBarThumbFill"));
|
|
553
|
+
}
|
|
539
554
|
}
|
|
540
555
|
}
|
|
541
556
|
}
|
|
542
557
|
}
|
|
543
558
|
|
|
544
559
|
private:
|
|
545
|
-
winrt::Microsoft::ReactNative::Composition::ScrollViewComponentView
|
|
560
|
+
winrt::weak_ref<winrt::Microsoft::ReactNative::Composition::ScrollViewComponentView> m_wkOuter;
|
|
546
561
|
winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext m_compContext;
|
|
547
562
|
winrt::Microsoft::ReactNative::ReactContext m_reactContext;
|
|
548
563
|
const bool m_vertical;
|
|
@@ -593,8 +608,7 @@ ScrollViewComponentView::ScrollViewComponentView(
|
|
|
593
608
|
compContext,
|
|
594
609
|
tag,
|
|
595
610
|
reactContext,
|
|
596
|
-
ComponentViewFeatures::Default & ~ComponentViewFeatures::Background
|
|
597
|
-
false) {
|
|
611
|
+
ComponentViewFeatures::Default & ~ComponentViewFeatures::Background) {
|
|
598
612
|
// m_element.Content(m_contentPanel);
|
|
599
613
|
|
|
600
614
|
/*
|
|
@@ -872,6 +886,12 @@ void ScrollViewComponentView::OnPointerPressed(
|
|
|
872
886
|
m_verticalScrollbarComponent->OnPointerPressed(args);
|
|
873
887
|
m_horizontalScrollbarComponent->OnPointerPressed(args);
|
|
874
888
|
Super::OnPointerPressed(args);
|
|
889
|
+
|
|
890
|
+
if (!args.Handled()) {
|
|
891
|
+
auto f = args.Pointer();
|
|
892
|
+
auto g = f.PointerDeviceType();
|
|
893
|
+
m_scrollVisual.OnPointerPressed(args);
|
|
894
|
+
}
|
|
875
895
|
}
|
|
876
896
|
|
|
877
897
|
void ScrollViewComponentView::OnPointerReleased(
|
|
@@ -895,7 +915,6 @@ void ScrollViewComponentView::OnPointerCaptureLost() noexcept {
|
|
|
895
915
|
}
|
|
896
916
|
|
|
897
917
|
void ScrollViewComponentView::OnKeyDown(
|
|
898
|
-
const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
|
|
899
918
|
const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept {
|
|
900
919
|
switch (args.Key()) {
|
|
901
920
|
case winrt::Windows::System::VirtualKey::End:
|
|
@@ -924,7 +943,7 @@ void ScrollViewComponentView::OnKeyDown(
|
|
|
924
943
|
break;
|
|
925
944
|
}
|
|
926
945
|
|
|
927
|
-
base_type::OnKeyDown(
|
|
946
|
+
base_type::OnKeyDown(args);
|
|
928
947
|
}
|
|
929
948
|
|
|
930
949
|
bool ScrollViewComponentView::scrollToEnd(bool animate) noexcept {
|
|
@@ -1032,13 +1051,16 @@ bool ScrollViewComponentView::scrollRight(float delta, bool animate) noexcept {
|
|
|
1032
1051
|
return true;
|
|
1033
1052
|
}
|
|
1034
1053
|
|
|
1035
|
-
void ScrollViewComponentView::HandleCommand(
|
|
1036
|
-
|
|
1037
|
-
|
|
1054
|
+
void ScrollViewComponentView::HandleCommand(const winrt::Microsoft::ReactNative::HandleCommandArgs &args) noexcept {
|
|
1055
|
+
Super::HandleCommand(args);
|
|
1056
|
+
if (args.Handled())
|
|
1057
|
+
return;
|
|
1058
|
+
|
|
1059
|
+
auto commandName = args.CommandName();
|
|
1038
1060
|
if (commandName == L"scrollTo") {
|
|
1039
1061
|
double x, y;
|
|
1040
1062
|
bool animate;
|
|
1041
|
-
winrt::Microsoft::ReactNative::ReadArgs(args, x, y, animate);
|
|
1063
|
+
winrt::Microsoft::ReactNative::ReadArgs(args.CommandArgs(), x, y, animate);
|
|
1042
1064
|
scrollTo(
|
|
1043
1065
|
{static_cast<float>(x) * m_layoutMetrics.pointScaleFactor,
|
|
1044
1066
|
static_cast<float>(y) * m_layoutMetrics.pointScaleFactor,
|
|
@@ -1048,12 +1070,10 @@ void ScrollViewComponentView::HandleCommand(
|
|
|
1048
1070
|
// No-op for now
|
|
1049
1071
|
} else if (commandName == L"scrollToEnd") {
|
|
1050
1072
|
bool animate;
|
|
1051
|
-
winrt::Microsoft::ReactNative::ReadArgs(args, animate);
|
|
1073
|
+
winrt::Microsoft::ReactNative::ReadArgs(args.CommandArgs(), animate);
|
|
1052
1074
|
scrollToEnd(animate);
|
|
1053
1075
|
} else if (commandName == L"zoomToRect") {
|
|
1054
1076
|
// No-op for now
|
|
1055
|
-
} else {
|
|
1056
|
-
Super::HandleCommand(commandName, args);
|
|
1057
1077
|
}
|
|
1058
1078
|
}
|
|
1059
1079
|
|
|
@@ -72,12 +72,9 @@ struct ScrollInteractionTrackerOwner : public winrt::implements<
|
|
|
72
72
|
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
73
73
|
facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept override;
|
|
74
74
|
void prepareForRecycle() noexcept override;
|
|
75
|
-
void OnKeyDown(
|
|
76
|
-
const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
|
|
77
|
-
const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept override;
|
|
75
|
+
void OnKeyDown(const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept override;
|
|
78
76
|
|
|
79
|
-
void HandleCommand(
|
|
80
|
-
override;
|
|
77
|
+
void HandleCommand(const winrt::Microsoft::ReactNative::HandleCommandArgs &args) noexcept override;
|
|
81
78
|
facebook::react::Tag hitTest(facebook::react::Point pt, facebook::react::Point &localPt, bool ignorePointerEvents)
|
|
82
79
|
const noexcept override;
|
|
83
80
|
facebook::react::Point getClientOffset() const noexcept override;
|
|
@@ -33,8 +33,7 @@ SwitchComponentView::SwitchComponentView(
|
|
|
33
33
|
compContext,
|
|
34
34
|
tag,
|
|
35
35
|
reactContext,
|
|
36
|
-
ComponentViewFeatures::Default & ~ComponentViewFeatures::Background
|
|
37
|
-
false) {}
|
|
36
|
+
ComponentViewFeatures::Default & ~ComponentViewFeatures::Background) {}
|
|
38
37
|
|
|
39
38
|
winrt::Microsoft::ReactNative::ComponentView SwitchComponentView::Create(
|
|
40
39
|
const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
|
|
@@ -57,14 +56,14 @@ void SwitchComponentView::UnmountChildComponentView(
|
|
|
57
56
|
base_type::UnmountChildComponentView(childComponentView, index);
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
void SwitchComponentView::HandleCommand(
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
void SwitchComponentView::HandleCommand(const winrt::Microsoft::ReactNative::HandleCommandArgs &args) noexcept {
|
|
60
|
+
Super::HandleCommand(args);
|
|
61
|
+
if (args.Handled())
|
|
62
|
+
return;
|
|
63
|
+
auto commandName = args.CommandName();
|
|
63
64
|
if (commandName == L"setValue") {
|
|
64
65
|
// TODO - Current implementation always aligns with JS value
|
|
65
66
|
// This will be needed when we move to using WinUI controls
|
|
66
|
-
} else {
|
|
67
|
-
Super::HandleCommand(commandName, args);
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
|
|
@@ -262,7 +261,7 @@ void SwitchComponentView::OnPointerPressed(
|
|
|
262
261
|
m_supressAnimationForNextFrame = true;
|
|
263
262
|
|
|
264
263
|
if (auto root = rootComponentView()) {
|
|
265
|
-
root->TrySetFocusedComponent(*get_strong());
|
|
264
|
+
root->TrySetFocusedComponent(*get_strong(), winrt::Microsoft::ReactNative::FocusNavigationDirection::None);
|
|
266
265
|
}
|
|
267
266
|
|
|
268
267
|
updateVisuals();
|
|
@@ -304,14 +303,13 @@ void SwitchComponentView::OnPointerExited(
|
|
|
304
303
|
}
|
|
305
304
|
|
|
306
305
|
void SwitchComponentView::OnKeyUp(
|
|
307
|
-
const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
|
|
308
306
|
const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept {
|
|
309
307
|
if (args.Key() == winrt::Windows::System::VirtualKey::Space) {
|
|
310
308
|
if (toggle()) {
|
|
311
309
|
args.Handled(true);
|
|
312
310
|
}
|
|
313
311
|
}
|
|
314
|
-
Super::OnKeyUp(
|
|
312
|
+
Super::OnKeyUp(args);
|
|
315
313
|
}
|
|
316
314
|
|
|
317
315
|
bool SwitchComponentView::toggle() noexcept {
|
|
@@ -341,4 +339,18 @@ const facebook::react::SwitchProps &SwitchComponentView::switchProps() const noe
|
|
|
341
339
|
return *std::static_pointer_cast<const facebook::react::SwitchProps>(viewProps());
|
|
342
340
|
}
|
|
343
341
|
|
|
342
|
+
// getToggleState method for IToggleProvider
|
|
343
|
+
ToggleState SwitchComponentView::getToggleState() noexcept {
|
|
344
|
+
if (switchProps().value) {
|
|
345
|
+
return ToggleState::ToggleState_On;
|
|
346
|
+
} else {
|
|
347
|
+
return ToggleState::ToggleState_Off;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// Toggle method for IToggleProvider
|
|
352
|
+
void SwitchComponentView::Toggle() noexcept {
|
|
353
|
+
toggle();
|
|
354
|
+
}
|
|
355
|
+
|
|
344
356
|
} // namespace winrt::Microsoft::ReactNative::Composition::implementation
|
|
@@ -27,8 +27,7 @@ struct SwitchComponentView : SwitchComponentViewT<SwitchComponentView, ViewCompo
|
|
|
27
27
|
void UnmountChildComponentView(
|
|
28
28
|
const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
|
|
29
29
|
uint32_t index) noexcept override;
|
|
30
|
-
void HandleCommand(
|
|
31
|
-
override;
|
|
30
|
+
void HandleCommand(const winrt::Microsoft::ReactNative::HandleCommandArgs &args) noexcept override;
|
|
32
31
|
void updateProps(facebook::react::Props::Shared const &props, facebook::react::Props::Shared const &oldProps) noexcept
|
|
33
32
|
override;
|
|
34
33
|
void updateState(facebook::react::State::Shared const &state, facebook::react::State::Shared const &oldState) noexcept
|
|
@@ -38,9 +37,7 @@ struct SwitchComponentView : SwitchComponentViewT<SwitchComponentView, ViewCompo
|
|
|
38
37
|
facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept override;
|
|
39
38
|
void FinalizeUpdates(winrt::Microsoft::ReactNative::ComponentViewUpdateMask updateMask) noexcept override;
|
|
40
39
|
void onThemeChanged() noexcept override;
|
|
41
|
-
void OnKeyUp(
|
|
42
|
-
const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
|
|
43
|
-
const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept override;
|
|
40
|
+
void OnKeyUp(const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept override;
|
|
44
41
|
void OnPointerPressed(
|
|
45
42
|
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept override;
|
|
46
43
|
void OnPointerReleased(
|
|
@@ -59,6 +56,8 @@ struct SwitchComponentView : SwitchComponentViewT<SwitchComponentView, ViewCompo
|
|
|
59
56
|
|
|
60
57
|
static facebook::react::SharedViewProps defaultProps() noexcept;
|
|
61
58
|
const facebook::react::SwitchProps &switchProps() const noexcept;
|
|
59
|
+
ToggleState getToggleState() noexcept override;
|
|
60
|
+
void Toggle() noexcept override;
|
|
62
61
|
winrt::Microsoft::ReactNative::Composition::Experimental::IVisual createVisual() noexcept override;
|
|
63
62
|
|
|
64
63
|
private:
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
namespace winrt::Microsoft::ReactNative::Composition {
|
|
17
17
|
|
|
18
18
|
void RenderText(
|
|
19
|
-
|
|
19
|
+
ID2D1RenderTarget &deviceContext,
|
|
20
20
|
::IDWriteTextLayout &textLayout,
|
|
21
21
|
const facebook::react::AttributedString &attributedString,
|
|
22
22
|
const facebook::react::TextAttributes &textAttributes,
|
|
@@ -26,7 +26,6 @@ void RenderText(
|
|
|
26
26
|
float offsetX = offset.x / pointScaleFactor;
|
|
27
27
|
float offsetY = offset.y / pointScaleFactor;
|
|
28
28
|
|
|
29
|
-
assert(deviceContext.GetUnitMode() == D2D1_UNIT_MODE_DIPS);
|
|
30
29
|
const auto dpi = pointScaleFactor * 96.0f;
|
|
31
30
|
float oldDpiX, oldDpiY;
|
|
32
31
|
deviceContext.GetDpi(&oldDpiX, &oldDpiY);
|