react-native-windows 0.82.0-preview.7 → 0.82.0
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/Libraries/Components/Switch/Switch.windows.js +1 -1
- package/Microsoft.ReactNative/ComponentView.idl +2 -0
- package/Microsoft.ReactNative/Composition.Input.idl +7 -0
- package/Microsoft.ReactNative/CompositionComponentView.idl +3 -0
- package/Microsoft.ReactNative/CompositionSwitcher.idl +8 -1
- package/Microsoft.ReactNative/Fabric/ComponentView.cpp +18 -0
- package/Microsoft.ReactNative/Fabric/ComponentView.h +9 -0
- package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +12 -0
- package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +15 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +15 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +75 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +161 -17
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +4 -0
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +56 -82
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +7 -4
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +46 -8
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +6 -4
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +33 -0
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +17 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +45 -22
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +3 -0
- package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +42 -15
- package/PropertySheets/Generated/PackageVersion.g.props +2 -2
- package/PropertySheets/WinUI.props +1 -1
- package/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +5 -11
- package/Scripts/rnw-dependencies.ps1 +15 -1
- package/package.json +6 -6
|
@@ -272,7 +272,7 @@ const Switch: component(
|
|
|
272
272
|
disabled,
|
|
273
273
|
onTintColor: trackColorForTrue,
|
|
274
274
|
style: StyleSheet.compose(
|
|
275
|
-
{
|
|
275
|
+
{height: 31, width: 51}, // #windows
|
|
276
276
|
StyleSheet.compose(
|
|
277
277
|
style,
|
|
278
278
|
ios_backgroundColor == null
|
|
@@ -106,6 +106,8 @@ namespace Microsoft.ReactNative
|
|
|
106
106
|
DOC_STRING("Used to handle key up events when this component is focused, or if a child component did not handle the key up")
|
|
107
107
|
event Windows.Foundation.EventHandler<Microsoft.ReactNative.Composition.Input.KeyRoutedEventArgs> KeyUp;
|
|
108
108
|
event Windows.Foundation.EventHandler<Microsoft.ReactNative.Composition.Input.CharacterReceivedRoutedEventArgs> CharacterReceived;
|
|
109
|
+
DOC_STRING("Used to handle context menu key events (SHIFT+F10 or Context Menu key) when this component is focused")
|
|
110
|
+
event Windows.Foundation.EventHandler<Microsoft.ReactNative.Composition.Input.ContextMenuKeyEventArgs> ContextMenuKey;
|
|
109
111
|
event Windows.Foundation.EventHandler<Microsoft.ReactNative.Composition.Input.PointerRoutedEventArgs> PointerPressed;
|
|
110
112
|
event Windows.Foundation.EventHandler<Microsoft.ReactNative.Composition.Input.PointerRoutedEventArgs> PointerReleased;
|
|
111
113
|
event Windows.Foundation.EventHandler<Microsoft.ReactNative.Composition.Input.PointerRoutedEventArgs> PointerMoved;
|
|
@@ -34,6 +34,13 @@ namespace Microsoft.ReactNative.Composition.Input
|
|
|
34
34
|
KeyboardSource KeyboardSource { get; };
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
DOC_STRING("Event arguments for context menu key events (SHIFT+F10 or Context Menu key)")
|
|
38
|
+
interface ContextMenuKeyEventArgs requires RoutedEventArgs
|
|
39
|
+
{
|
|
40
|
+
DOC_STRING("Gets or sets whether the event was handled. Set to true to prevent default behavior.")
|
|
41
|
+
Boolean Handled { get; set; };
|
|
42
|
+
};
|
|
43
|
+
|
|
37
44
|
interface IPointerPointTransform
|
|
38
45
|
{
|
|
39
46
|
IPointerPointTransform Inverse { get; };
|
|
@@ -154,6 +154,9 @@ namespace Microsoft.ReactNative.Composition
|
|
|
154
154
|
[webhosthidden]
|
|
155
155
|
[default_interface]
|
|
156
156
|
runtimeclass ScrollViewComponentView : ViewComponentView {
|
|
157
|
+
// Issue #15557: Event fired when scroll position changes.
|
|
158
|
+
// ContentIslandComponentView uses this to update LocalToParentTransformMatrix.
|
|
159
|
+
event Windows.Foundation.EventHandler<IInspectable> ViewChanged;
|
|
157
160
|
};
|
|
158
161
|
|
|
159
162
|
[experimental]
|
|
@@ -45,9 +45,16 @@ enum SnapPointsAlignment {
|
|
|
45
45
|
void Opacity(Single value);
|
|
46
46
|
void BlurRadius(Single value);
|
|
47
47
|
void Color(Windows.UI.Color value);
|
|
48
|
+
void Mask(IBrush mask);
|
|
49
|
+
void SourcePolicy(CompositionDropShadowSourcePolicy policy);
|
|
48
50
|
}
|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
[webhosthidden][experimental] enum CompositionDropShadowSourcePolicy {
|
|
53
|
+
Default = 0,
|
|
54
|
+
InheritedOnly = 1
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
[webhosthidden][experimental] interface IVisual {
|
|
51
58
|
void InsertAt(IVisual visual, Int32 index);
|
|
52
59
|
void Remove(IVisual visual);
|
|
53
60
|
IVisual GetAt(UInt32 index);
|
|
@@ -469,6 +469,16 @@ void ComponentView::CharacterReceived(winrt::event_token const &token) noexcept
|
|
|
469
469
|
m_characterReceivedEvent.remove(token);
|
|
470
470
|
}
|
|
471
471
|
|
|
472
|
+
winrt::event_token ComponentView::ContextMenuKey(
|
|
473
|
+
winrt::Windows::Foundation::EventHandler<
|
|
474
|
+
winrt::Microsoft::ReactNative::Composition::Input::ContextMenuKeyEventArgs> const &handler) noexcept {
|
|
475
|
+
return m_contextMenuKeyEvent.add(handler);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
void ComponentView::ContextMenuKey(winrt::event_token const &token) noexcept {
|
|
479
|
+
m_contextMenuKeyEvent.remove(token);
|
|
480
|
+
}
|
|
481
|
+
|
|
472
482
|
winrt::event_token ComponentView::PointerPressed(
|
|
473
483
|
winrt::Windows::Foundation::EventHandler<
|
|
474
484
|
winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs> const &handler) noexcept {
|
|
@@ -609,6 +619,14 @@ void ComponentView::OnCharacterReceived(
|
|
|
609
619
|
}
|
|
610
620
|
}
|
|
611
621
|
|
|
622
|
+
void ComponentView::OnContextMenuKey(
|
|
623
|
+
const winrt::Microsoft::ReactNative::Composition::Input::ContextMenuKeyEventArgs &args) noexcept {
|
|
624
|
+
m_contextMenuKeyEvent(*this, args);
|
|
625
|
+
if (m_parent && !args.Handled()) {
|
|
626
|
+
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(m_parent)->OnContextMenuKey(args);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
612
630
|
bool ComponentView::focusable() const noexcept {
|
|
613
631
|
return false;
|
|
614
632
|
}
|
|
@@ -167,6 +167,10 @@ struct ComponentView
|
|
|
167
167
|
winrt::Windows::Foundation::EventHandler<
|
|
168
168
|
winrt::Microsoft::ReactNative::Composition::Input::CharacterReceivedRoutedEventArgs> const &handler) noexcept;
|
|
169
169
|
void CharacterReceived(winrt::event_token const &token) noexcept;
|
|
170
|
+
winrt::event_token ContextMenuKey(
|
|
171
|
+
winrt::Windows::Foundation::EventHandler<
|
|
172
|
+
winrt::Microsoft::ReactNative::Composition::Input::ContextMenuKeyEventArgs> const &handler) noexcept;
|
|
173
|
+
void ContextMenuKey(winrt::event_token const &token) noexcept;
|
|
170
174
|
winrt::event_token PointerPressed(
|
|
171
175
|
winrt::Windows::Foundation::EventHandler<
|
|
172
176
|
winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs> const &handler) noexcept;
|
|
@@ -253,6 +257,8 @@ struct ComponentView
|
|
|
253
257
|
virtual void OnKeyUp(const winrt::Microsoft::ReactNative::Composition::Input::KeyRoutedEventArgs &args) noexcept;
|
|
254
258
|
virtual void OnCharacterReceived(
|
|
255
259
|
const winrt::Microsoft::ReactNative::Composition::Input::CharacterReceivedRoutedEventArgs &args) noexcept;
|
|
260
|
+
virtual void OnContextMenuKey(
|
|
261
|
+
const winrt::Microsoft::ReactNative::Composition::Input::ContextMenuKeyEventArgs &args) noexcept;
|
|
256
262
|
|
|
257
263
|
protected:
|
|
258
264
|
winrt::com_ptr<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder> m_builder;
|
|
@@ -277,6 +283,9 @@ struct ComponentView
|
|
|
277
283
|
winrt::event<winrt::Windows::Foundation::EventHandler<
|
|
278
284
|
winrt::Microsoft::ReactNative::Composition::Input::CharacterReceivedRoutedEventArgs>>
|
|
279
285
|
m_characterReceivedEvent;
|
|
286
|
+
winrt::event<winrt::Windows::Foundation::EventHandler<
|
|
287
|
+
winrt::Microsoft::ReactNative::Composition::Input::ContextMenuKeyEventArgs>>
|
|
288
|
+
m_contextMenuKeyEvent;
|
|
280
289
|
winrt::event<winrt::Windows::Foundation::EventHandler<
|
|
281
290
|
winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs>>
|
|
282
291
|
m_pointerPressedEvent;
|
|
@@ -136,6 +136,18 @@ winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource CharacterRecei
|
|
|
136
136
|
return m_source;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
ContextMenuKeyEventArgs::ContextMenuKeyEventArgs(facebook::react::Tag tag) : m_tag(tag) {}
|
|
140
|
+
|
|
141
|
+
int32_t ContextMenuKeyEventArgs::OriginalSource() noexcept {
|
|
142
|
+
return m_tag;
|
|
143
|
+
}
|
|
144
|
+
bool ContextMenuKeyEventArgs::Handled() noexcept {
|
|
145
|
+
return m_handled;
|
|
146
|
+
}
|
|
147
|
+
void ContextMenuKeyEventArgs::Handled(bool value) noexcept {
|
|
148
|
+
m_handled = value;
|
|
149
|
+
}
|
|
150
|
+
|
|
139
151
|
Pointer::Pointer(winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType type, uint32_t id)
|
|
140
152
|
: m_type(type), m_id(id) {}
|
|
141
153
|
|
|
@@ -78,6 +78,21 @@ struct CharacterReceivedRoutedEventArgs
|
|
|
78
78
|
const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource m_source;
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
+
struct ContextMenuKeyEventArgs : winrt::implements<
|
|
82
|
+
ContextMenuKeyEventArgs,
|
|
83
|
+
winrt::Microsoft::ReactNative::Composition::Input::ContextMenuKeyEventArgs,
|
|
84
|
+
winrt::Microsoft::ReactNative::Composition::Input::RoutedEventArgs> {
|
|
85
|
+
ContextMenuKeyEventArgs(facebook::react::Tag tag);
|
|
86
|
+
|
|
87
|
+
int32_t OriginalSource() noexcept;
|
|
88
|
+
bool Handled() noexcept;
|
|
89
|
+
void Handled(bool value) noexcept;
|
|
90
|
+
|
|
91
|
+
private:
|
|
92
|
+
facebook::react::Tag m_tag{-1};
|
|
93
|
+
bool m_handled{false};
|
|
94
|
+
};
|
|
95
|
+
|
|
81
96
|
struct Pointer : PointerT<Pointer> {
|
|
82
97
|
Pointer(winrt::Microsoft::ReactNative::Composition::Input::PointerDeviceType type, uint32_t id);
|
|
83
98
|
|
|
@@ -50,6 +50,7 @@ struct CompositionTypeTraits<WindowsTypeTag> {
|
|
|
50
50
|
using CompositionStretch = winrt::Windows::UI::Composition::CompositionStretch;
|
|
51
51
|
using CompositionStrokeCap = winrt::Windows::UI::Composition::CompositionStrokeCap;
|
|
52
52
|
using CompositionSurfaceBrush = winrt::Windows::UI::Composition::CompositionSurfaceBrush;
|
|
53
|
+
using CompositionDropShadowSourcePolicy = winrt::Windows::UI::Composition::CompositionDropShadowSourcePolicy;
|
|
53
54
|
using Compositor = winrt::Windows::UI::Composition::Compositor;
|
|
54
55
|
using ContainerVisual = winrt::Windows::UI::Composition::ContainerVisual;
|
|
55
56
|
using CubicBezierEasingFunction = winrt::Windows::UI::Composition::CubicBezierEasingFunction;
|
|
@@ -122,6 +123,7 @@ struct CompositionTypeTraits<MicrosoftTypeTag> {
|
|
|
122
123
|
using CompositionStretch = winrt::Microsoft::UI::Composition::CompositionStretch;
|
|
123
124
|
using CompositionStrokeCap = winrt::Microsoft::UI::Composition::CompositionStrokeCap;
|
|
124
125
|
using CompositionSurfaceBrush = winrt::Microsoft::UI::Composition::CompositionSurfaceBrush;
|
|
126
|
+
using CompositionDropShadowSourcePolicy = winrt::Microsoft::UI::Composition::CompositionDropShadowSourcePolicy;
|
|
125
127
|
using Compositor = winrt::Microsoft::UI::Composition::Compositor;
|
|
126
128
|
using ContainerVisual = winrt::Microsoft::UI::Composition::ContainerVisual;
|
|
127
129
|
using CubicBezierEasingFunction = winrt::Microsoft::UI::Composition::CubicBezierEasingFunction;
|
|
@@ -218,6 +220,19 @@ struct CompDropShadow : public winrt::implements<
|
|
|
218
220
|
m_shadow.Color(color);
|
|
219
221
|
}
|
|
220
222
|
|
|
223
|
+
void Mask(winrt::Microsoft::ReactNative::Composition::Experimental::IBrush const &mask) noexcept {
|
|
224
|
+
if (mask) {
|
|
225
|
+
m_shadow.Mask(mask.as<typename TTypeRedirects::IInnerCompositionBrush>()->InnerBrush());
|
|
226
|
+
} else {
|
|
227
|
+
m_shadow.Mask(nullptr);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
void SourcePolicy(
|
|
232
|
+
winrt::Microsoft::ReactNative::Composition::Experimental::CompositionDropShadowSourcePolicy policy) noexcept {
|
|
233
|
+
m_shadow.SourcePolicy(static_cast<typename TTypeRedirects::CompositionDropShadowSourcePolicy>(policy));
|
|
234
|
+
}
|
|
235
|
+
|
|
221
236
|
private:
|
|
222
237
|
typename TTypeRedirects::DropShadow m_shadow;
|
|
223
238
|
};
|
|
@@ -320,6 +320,32 @@ void CompositionEventHandler::Initialize() noexcept {
|
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
322
|
});
|
|
323
|
+
|
|
324
|
+
m_contextMenuKeyToken =
|
|
325
|
+
keyboardSource.ContextMenuKey([wkThis = weak_from_this()](
|
|
326
|
+
winrt::Microsoft::UI::Input::InputKeyboardSource const & /*source*/,
|
|
327
|
+
winrt::Microsoft::UI::Input::ContextMenuKeyEventArgs const &args) {
|
|
328
|
+
if (auto strongThis = wkThis.lock()) {
|
|
329
|
+
if (auto strongRootView = strongThis->m_wkRootView.get()) {
|
|
330
|
+
if (strongThis->SurfaceId() == -1)
|
|
331
|
+
return;
|
|
332
|
+
|
|
333
|
+
auto focusedComponent = strongThis->RootComponentView().GetFocusedComponent();
|
|
334
|
+
if (focusedComponent) {
|
|
335
|
+
auto tag =
|
|
336
|
+
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(focusedComponent)
|
|
337
|
+
->Tag();
|
|
338
|
+
auto contextMenuArgs = winrt::make<
|
|
339
|
+
winrt::Microsoft::ReactNative::Composition::Input::implementation::ContextMenuKeyEventArgs>(tag);
|
|
340
|
+
winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(focusedComponent)
|
|
341
|
+
->OnContextMenuKey(contextMenuArgs);
|
|
342
|
+
if (contextMenuArgs.Handled()) {
|
|
343
|
+
args.Handled(true);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
});
|
|
323
349
|
}
|
|
324
350
|
}
|
|
325
351
|
|
|
@@ -336,6 +362,7 @@ CompositionEventHandler::~CompositionEventHandler() {
|
|
|
336
362
|
keyboardSource.KeyDown(m_keyDownToken);
|
|
337
363
|
keyboardSource.KeyUp(m_keyUpToken);
|
|
338
364
|
keyboardSource.CharacterReceived(m_characterReceivedToken);
|
|
365
|
+
keyboardSource.ContextMenuKey(m_contextMenuKeyToken);
|
|
339
366
|
}
|
|
340
367
|
}
|
|
341
368
|
|
|
@@ -443,6 +470,54 @@ int64_t CompositionEventHandler::SendMessage(HWND hwnd, uint32_t msg, uint64_t w
|
|
|
443
470
|
}
|
|
444
471
|
return 0;
|
|
445
472
|
}
|
|
473
|
+
case WM_RBUTTONDOWN: {
|
|
474
|
+
if (auto strongRootView = m_wkRootView.get()) {
|
|
475
|
+
auto pp = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerPoint>(
|
|
476
|
+
hwnd, msg, wParam, lParam, strongRootView.ScaleFactor());
|
|
477
|
+
onPointerPressed(pp, GetKeyModifiers(wParam));
|
|
478
|
+
}
|
|
479
|
+
return 0;
|
|
480
|
+
}
|
|
481
|
+
case WM_RBUTTONUP: {
|
|
482
|
+
if (auto strongRootView = m_wkRootView.get()) {
|
|
483
|
+
auto pp = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerPoint>(
|
|
484
|
+
hwnd, msg, wParam, lParam, strongRootView.ScaleFactor());
|
|
485
|
+
onPointerReleased(pp, GetKeyModifiers(wParam));
|
|
486
|
+
}
|
|
487
|
+
return 0;
|
|
488
|
+
}
|
|
489
|
+
case WM_MBUTTONDOWN: {
|
|
490
|
+
if (auto strongRootView = m_wkRootView.get()) {
|
|
491
|
+
auto pp = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerPoint>(
|
|
492
|
+
hwnd, msg, wParam, lParam, strongRootView.ScaleFactor());
|
|
493
|
+
onPointerPressed(pp, GetKeyModifiers(wParam));
|
|
494
|
+
}
|
|
495
|
+
return 0;
|
|
496
|
+
}
|
|
497
|
+
case WM_MBUTTONUP: {
|
|
498
|
+
if (auto strongRootView = m_wkRootView.get()) {
|
|
499
|
+
auto pp = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerPoint>(
|
|
500
|
+
hwnd, msg, wParam, lParam, strongRootView.ScaleFactor());
|
|
501
|
+
onPointerReleased(pp, GetKeyModifiers(wParam));
|
|
502
|
+
}
|
|
503
|
+
return 0;
|
|
504
|
+
}
|
|
505
|
+
case WM_XBUTTONDOWN: {
|
|
506
|
+
if (auto strongRootView = m_wkRootView.get()) {
|
|
507
|
+
auto pp = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerPoint>(
|
|
508
|
+
hwnd, msg, wParam, lParam, strongRootView.ScaleFactor());
|
|
509
|
+
onPointerPressed(pp, GetKeyModifiers(wParam));
|
|
510
|
+
}
|
|
511
|
+
return 0;
|
|
512
|
+
}
|
|
513
|
+
case WM_XBUTTONUP: {
|
|
514
|
+
if (auto strongRootView = m_wkRootView.get()) {
|
|
515
|
+
auto pp = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerPoint>(
|
|
516
|
+
hwnd, msg, wParam, lParam, strongRootView.ScaleFactor());
|
|
517
|
+
onPointerReleased(pp, GetKeyModifiers(wParam));
|
|
518
|
+
}
|
|
519
|
+
return 0;
|
|
520
|
+
}
|
|
446
521
|
case WM_POINTERUP: {
|
|
447
522
|
if (auto strongRootView = m_wkRootView.get()) {
|
|
448
523
|
auto pp = winrt::make<winrt::Microsoft::ReactNative::Composition::Input::implementation::PointerPoint>(
|
|
@@ -175,6 +175,7 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
|
|
|
175
175
|
winrt::event_token m_keyDownToken;
|
|
176
176
|
winrt::event_token m_keyUpToken;
|
|
177
177
|
winrt::event_token m_characterReceivedToken;
|
|
178
|
+
winrt::event_token m_contextMenuKeyToken;
|
|
178
179
|
};
|
|
179
180
|
|
|
180
181
|
} // namespace Microsoft::ReactNative
|
|
@@ -36,10 +36,11 @@ constexpr float FOCUS_VISUAL_RADIUS = 3.0f;
|
|
|
36
36
|
|
|
37
37
|
// m_outerVisual
|
|
38
38
|
// |
|
|
39
|
-
// |
|
|
40
39
|
// ----- m_visual <-- Background / clip - Can be a custom visual depending on Component type
|
|
41
40
|
// |
|
|
42
41
|
// ----- Border Visuals x N (BorderPrimitive attached to m_visual)
|
|
42
|
+
// ----- <children> (default: directly in m_visual after border visuals)
|
|
43
|
+
// ----- m_childrenContainer (created on demand when overflow:hidden, children moved here)
|
|
43
44
|
// ------Focus Visual Container (created when hosting focus visuals)
|
|
44
45
|
// |
|
|
45
46
|
// |------Inner Focus Visual
|
|
@@ -708,7 +709,86 @@ void ComponentView::applyShadowProps(const facebook::react::ViewProps &viewProps
|
|
|
708
709
|
shadow.Color(theme()->Color(*viewProps.shadowColor));
|
|
709
710
|
}
|
|
710
711
|
|
|
711
|
-
|
|
712
|
+
// Check if any border radius is set
|
|
713
|
+
auto borderMetrics = BorderPrimitive::resolveAndAlignBorderMetrics(m_layoutMetrics, viewProps);
|
|
714
|
+
bool hasBorderRadius = borderMetrics.borderRadii.topLeft.horizontal != 0 ||
|
|
715
|
+
borderMetrics.borderRadii.topRight.horizontal != 0 || borderMetrics.borderRadii.bottomLeft.horizontal != 0 ||
|
|
716
|
+
borderMetrics.borderRadii.bottomRight.horizontal != 0 || borderMetrics.borderRadii.topLeft.vertical != 0 ||
|
|
717
|
+
borderMetrics.borderRadii.topRight.vertical != 0 || borderMetrics.borderRadii.bottomLeft.vertical != 0 ||
|
|
718
|
+
borderMetrics.borderRadii.bottomRight.vertical != 0;
|
|
719
|
+
|
|
720
|
+
if (hasBorderRadius) {
|
|
721
|
+
// When borderRadius is set, we need to create a shadow mask that follows the rounded rectangle shape.
|
|
722
|
+
// Use CompositionVisualSurface to capture the clipped visual's appearance as the shadow mask.
|
|
723
|
+
bool maskSet = false;
|
|
724
|
+
|
|
725
|
+
// Try Microsoft (WinUI3) Composition first
|
|
726
|
+
auto msCompositor =
|
|
727
|
+
winrt::Microsoft::ReactNative::Composition::Experimental::MicrosoftCompositionContextHelper::InnerCompositor(
|
|
728
|
+
m_compContext);
|
|
729
|
+
if (msCompositor) {
|
|
730
|
+
auto innerVisual =
|
|
731
|
+
winrt::Microsoft::ReactNative::Composition::Experimental::MicrosoftCompositionContextHelper::InnerVisual(
|
|
732
|
+
Visual());
|
|
733
|
+
if (innerVisual) {
|
|
734
|
+
// Create a VisualSurface that captures the visual (with its clip applied)
|
|
735
|
+
auto visualSurface = msCompositor.CreateVisualSurface();
|
|
736
|
+
visualSurface.SourceVisual(innerVisual);
|
|
737
|
+
visualSurface.SourceSize(
|
|
738
|
+
{m_layoutMetrics.frame.size.width * m_layoutMetrics.pointScaleFactor,
|
|
739
|
+
m_layoutMetrics.frame.size.height * m_layoutMetrics.pointScaleFactor});
|
|
740
|
+
|
|
741
|
+
// Create a brush from the visual surface to use as shadow mask
|
|
742
|
+
auto maskBrush = msCompositor.CreateSurfaceBrush(visualSurface);
|
|
743
|
+
maskBrush.Stretch(winrt::Microsoft::UI::Composition::CompositionStretch::Fill);
|
|
744
|
+
|
|
745
|
+
// Get the inner shadow and set the mask
|
|
746
|
+
auto innerShadow = winrt::Microsoft::ReactNative::Composition::Experimental::MicrosoftCompositionContextHelper::
|
|
747
|
+
InnerDropShadow(shadow);
|
|
748
|
+
if (innerShadow) {
|
|
749
|
+
innerShadow.Mask(maskBrush);
|
|
750
|
+
maskSet = true;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
// Fallback to System (Windows.UI) Composition if Microsoft Composition is not available
|
|
756
|
+
if (!maskSet) {
|
|
757
|
+
auto sysCompositor =
|
|
758
|
+
winrt::Microsoft::ReactNative::Composition::Experimental::SystemCompositionContextHelper::InnerCompositor(
|
|
759
|
+
m_compContext);
|
|
760
|
+
if (sysCompositor) {
|
|
761
|
+
auto innerVisual =
|
|
762
|
+
winrt::Microsoft::ReactNative::Composition::Experimental::SystemCompositionContextHelper::InnerVisual(
|
|
763
|
+
Visual());
|
|
764
|
+
if (innerVisual) {
|
|
765
|
+
auto visualSurface = sysCompositor.CreateVisualSurface();
|
|
766
|
+
visualSurface.SourceVisual(innerVisual);
|
|
767
|
+
visualSurface.SourceSize(
|
|
768
|
+
{m_layoutMetrics.frame.size.width * m_layoutMetrics.pointScaleFactor,
|
|
769
|
+
m_layoutMetrics.frame.size.height * m_layoutMetrics.pointScaleFactor});
|
|
770
|
+
|
|
771
|
+
auto maskBrush = sysCompositor.CreateSurfaceBrush(visualSurface);
|
|
772
|
+
maskBrush.Stretch(winrt::Windows::UI::Composition::CompositionStretch::Fill);
|
|
773
|
+
|
|
774
|
+
auto innerShadow =
|
|
775
|
+
winrt::Microsoft::ReactNative::Composition::Experimental::SystemCompositionContextHelper::InnerDropShadow(
|
|
776
|
+
shadow);
|
|
777
|
+
if (innerShadow) {
|
|
778
|
+
innerShadow.Mask(maskBrush);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
// Apply shadow to OuterVisual (which is not clipped) so the shadow can extend beyond the clip
|
|
785
|
+
OuterVisual().as<winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual>().Shadow(shadow);
|
|
786
|
+
Visual().as<winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual>().Shadow(nullptr);
|
|
787
|
+
} else {
|
|
788
|
+
// No border radius - apply shadow directly to Visual (original behavior)
|
|
789
|
+
Visual().as<winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual>().Shadow(shadow);
|
|
790
|
+
OuterVisual().as<winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual>().Shadow(nullptr);
|
|
791
|
+
}
|
|
712
792
|
}
|
|
713
793
|
|
|
714
794
|
void ComponentView::updateTransformProps(
|
|
@@ -892,23 +972,26 @@ void ComponentView::updateClippingPath(
|
|
|
892
972
|
const facebook::react::ViewProps &viewProps) noexcept {
|
|
893
973
|
auto borderMetrics = BorderPrimitive::resolveAndAlignBorderMetrics(layoutMetrics, viewProps);
|
|
894
974
|
|
|
895
|
-
|
|
896
|
-
borderMetrics.borderRadii.
|
|
897
|
-
borderMetrics.borderRadii.
|
|
898
|
-
borderMetrics.borderRadii.
|
|
899
|
-
|
|
900
|
-
|
|
975
|
+
bool hasRoundedCorners = borderMetrics.borderRadii.topLeft.horizontal != 0 ||
|
|
976
|
+
borderMetrics.borderRadii.topRight.horizontal != 0 || borderMetrics.borderRadii.bottomLeft.horizontal != 0 ||
|
|
977
|
+
borderMetrics.borderRadii.bottomRight.horizontal != 0 || borderMetrics.borderRadii.topLeft.vertical != 0 ||
|
|
978
|
+
borderMetrics.borderRadii.topRight.vertical != 0 || borderMetrics.borderRadii.bottomLeft.vertical != 0 ||
|
|
979
|
+
borderMetrics.borderRadii.bottomRight.vertical != 0;
|
|
980
|
+
|
|
981
|
+
const float scale = layoutMetrics.pointScaleFactor;
|
|
982
|
+
const float viewWidth = layoutMetrics.frame.size.width * scale;
|
|
983
|
+
const float viewHeight = layoutMetrics.frame.size.height * scale;
|
|
984
|
+
|
|
985
|
+
// Apply clipping to m_visual only for rounded corners
|
|
986
|
+
// overflow:hidden clipping is handled separately via m_childrenContainer in ViewComponentView
|
|
987
|
+
if (hasRoundedCorners) {
|
|
901
988
|
winrt::com_ptr<ID2D1PathGeometry> pathGeometry = BorderPrimitive::GenerateRoundedRectPathGeometry(
|
|
902
|
-
m_compContext,
|
|
903
|
-
borderMetrics.borderRadii,
|
|
904
|
-
{0, 0, 0, 0},
|
|
905
|
-
{0,
|
|
906
|
-
0,
|
|
907
|
-
layoutMetrics.frame.size.width * layoutMetrics.pointScaleFactor,
|
|
908
|
-
layoutMetrics.frame.size.height * layoutMetrics.pointScaleFactor});
|
|
989
|
+
m_compContext, borderMetrics.borderRadii, {0, 0, 0, 0}, {0, 0, viewWidth, viewHeight});
|
|
909
990
|
|
|
910
991
|
Visual().as<::Microsoft::ReactNative::Composition::Experimental::IVisualInterop>()->SetClippingPath(
|
|
911
992
|
pathGeometry.get());
|
|
993
|
+
} else {
|
|
994
|
+
Visual().as<::Microsoft::ReactNative::Composition::Experimental::IVisualInterop>()->SetClippingPath(nullptr);
|
|
912
995
|
}
|
|
913
996
|
}
|
|
914
997
|
|
|
@@ -1083,6 +1166,11 @@ winrt::Microsoft::ReactNative::Composition::Experimental::IVisual
|
|
|
1083
1166
|
ViewComponentView::VisualToMountChildrenInto() noexcept {
|
|
1084
1167
|
if (m_builder && m_builder->VisualToMountChildrenIntoHandler())
|
|
1085
1168
|
return m_builder->VisualToMountChildrenIntoHandler()(*this);
|
|
1169
|
+
// When overflow:hidden, children are hosted in m_childrenContainer (child of m_visual)
|
|
1170
|
+
// so we can apply clipping without affecting borders/background.
|
|
1171
|
+
// Otherwise children go directly into Visual() (the original behavior).
|
|
1172
|
+
if (m_childrenContainer)
|
|
1173
|
+
return m_childrenContainer;
|
|
1086
1174
|
return Visual();
|
|
1087
1175
|
}
|
|
1088
1176
|
|
|
@@ -1091,9 +1179,14 @@ void ViewComponentView::MountChildComponentView(
|
|
|
1091
1179
|
uint32_t index) noexcept {
|
|
1092
1180
|
base_type::MountChildComponentView(childComponentView, index);
|
|
1093
1181
|
|
|
1094
|
-
indexOffsetForBorder(index);
|
|
1095
1182
|
ensureVisual();
|
|
1096
1183
|
|
|
1184
|
+
// When children are in Visual() directly, offset past border visuals.
|
|
1185
|
+
// When children are in m_childrenContainer, no offset needed.
|
|
1186
|
+
if (!m_childrenContainer) {
|
|
1187
|
+
indexOffsetForBorder(index);
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1097
1190
|
if (auto compositionChild = childComponentView.try_as<ComponentView>()) {
|
|
1098
1191
|
auto visualIndex = index;
|
|
1099
1192
|
// Most of the time child index will align with visual index.
|
|
@@ -1105,6 +1198,7 @@ void ViewComponentView::MountChildComponentView(
|
|
|
1105
1198
|
}
|
|
1106
1199
|
}
|
|
1107
1200
|
}
|
|
1201
|
+
|
|
1108
1202
|
VisualToMountChildrenInto().InsertAt(compositionChild->OuterVisual(), visualIndex);
|
|
1109
1203
|
} else {
|
|
1110
1204
|
m_hasNonVisualChildren = true;
|
|
@@ -1116,7 +1210,6 @@ void ViewComponentView::UnmountChildComponentView(
|
|
|
1116
1210
|
uint32_t index) noexcept {
|
|
1117
1211
|
base_type::UnmountChildComponentView(childComponentView, index);
|
|
1118
1212
|
|
|
1119
|
-
indexOffsetForBorder(index);
|
|
1120
1213
|
if (auto compositionChild = childComponentView.try_as<ComponentView>()) {
|
|
1121
1214
|
VisualToMountChildrenInto().Remove(compositionChild->OuterVisual());
|
|
1122
1215
|
}
|
|
@@ -1316,6 +1409,57 @@ void ViewComponentView::updateLayoutMetrics(
|
|
|
1316
1409
|
Visual().Size(
|
|
1317
1410
|
{layoutMetrics.frame.size.width * layoutMetrics.pointScaleFactor,
|
|
1318
1411
|
layoutMetrics.frame.size.height * layoutMetrics.pointScaleFactor});
|
|
1412
|
+
|
|
1413
|
+
// Update children container clipping for overflow:hidden
|
|
1414
|
+
updateChildrenClippingPath(layoutMetrics, *viewProps());
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
void ViewComponentView::updateChildrenClippingPath(
|
|
1418
|
+
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
1419
|
+
const facebook::react::ViewProps &viewProps) noexcept {
|
|
1420
|
+
const float scale = layoutMetrics.pointScaleFactor;
|
|
1421
|
+
const float viewWidth = layoutMetrics.frame.size.width * scale;
|
|
1422
|
+
const float viewHeight = layoutMetrics.frame.size.height * scale;
|
|
1423
|
+
|
|
1424
|
+
if (viewProps.getClipsContentToBounds()) {
|
|
1425
|
+
// Create m_childrenContainer on demand (like iOS _containerView pattern)
|
|
1426
|
+
// m_childrenContainer is a child of m_visual, placed after border visuals.
|
|
1427
|
+
if (!m_childrenContainer) {
|
|
1428
|
+
m_childrenContainer = m_compContext.CreateSpriteVisual();
|
|
1429
|
+
|
|
1430
|
+
// Insert at the end of m_visual's children (after border visuals + existing children)
|
|
1431
|
+
// Then move existing children from m_visual into m_childrenContainer
|
|
1432
|
+
uint32_t borderCount = 0;
|
|
1433
|
+
indexOffsetForBorder(borderCount);
|
|
1434
|
+
|
|
1435
|
+
// Move existing child visuals from m_visual to m_childrenContainer
|
|
1436
|
+
uint32_t childVisualIndex = 0;
|
|
1437
|
+
for (auto it = m_children.begin(); it != m_children.end(); ++it) {
|
|
1438
|
+
if (auto compositionChild = (*it).try_as<ComponentView>()) {
|
|
1439
|
+
Visual().Remove(compositionChild->OuterVisual());
|
|
1440
|
+
m_childrenContainer.InsertAt(compositionChild->OuterVisual(), childVisualIndex++);
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
// Insert m_childrenContainer after border visuals in m_visual
|
|
1445
|
+
Visual().InsertAt(m_childrenContainer, borderCount);
|
|
1446
|
+
|
|
1447
|
+
// Use relative sizing so container automatically tracks parent's size
|
|
1448
|
+
m_childrenContainer.RelativeSizeWithOffset({0, 0}, {1, 1});
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
// Clip children to view bounds using outer border radii (matches iOS default behavior)
|
|
1452
|
+
auto borderMetrics = BorderPrimitive::resolveAndAlignBorderMetrics(layoutMetrics, viewProps);
|
|
1453
|
+
winrt::com_ptr<ID2D1PathGeometry> pathGeometry = BorderPrimitive::GenerateRoundedRectPathGeometry(
|
|
1454
|
+
m_compContext, borderMetrics.borderRadii, {0, 0, 0, 0}, {0, 0, viewWidth, viewHeight});
|
|
1455
|
+
|
|
1456
|
+
m_childrenContainer.as<::Microsoft::ReactNative::Composition::Experimental::IVisualInterop>()->SetClippingPath(
|
|
1457
|
+
pathGeometry.get());
|
|
1458
|
+
} else if (m_childrenContainer) {
|
|
1459
|
+
// overflow changed from hidden to visible. Keep container, just remove clip.
|
|
1460
|
+
m_childrenContainer.as<::Microsoft::ReactNative::Composition::Experimental::IVisualInterop>()->SetClippingPath(
|
|
1461
|
+
nullptr);
|
|
1462
|
+
}
|
|
1319
1463
|
}
|
|
1320
1464
|
|
|
1321
1465
|
void ViewComponentView::prepareForRecycle() noexcept {}
|
|
@@ -233,11 +233,15 @@ struct ViewComponentView : public ViewComponentViewT<
|
|
|
233
233
|
|
|
234
234
|
protected:
|
|
235
235
|
virtual winrt::Microsoft::ReactNative::ViewProps ViewPropsInner() noexcept;
|
|
236
|
+
virtual void updateChildrenClippingPath(
|
|
237
|
+
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
238
|
+
const facebook::react::ViewProps &viewProps) noexcept;
|
|
236
239
|
|
|
237
240
|
private:
|
|
238
241
|
bool m_hasNonVisualChildren{false};
|
|
239
242
|
facebook::react::SharedViewProps m_props;
|
|
240
243
|
winrt::Microsoft::ReactNative::Composition::Experimental::IVisual m_visual{nullptr};
|
|
244
|
+
winrt::Microsoft::ReactNative::Composition::Experimental::IVisual m_childrenContainer{nullptr};
|
|
241
245
|
winrt::Microsoft::ReactNative::Composition::Experimental::CreateInternalVisualDelegate m_createInternalVisualHandler{
|
|
242
246
|
nullptr};
|
|
243
247
|
};
|