react-native-windows 0.74.3 → 0.74.5
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/TextInput/TextInput.windows.js +6 -2
- package/Libraries/Components/View/View.windows.js +3 -0
- package/Microsoft.ReactNative/CompositionComponentView.idl +17 -7
- package/Microsoft.ReactNative/CompositionRootView.idl +1 -0
- package/Microsoft.ReactNative/CompositionUIService.idl +4 -0
- package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +2 -1
- package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +106 -19
- package/Microsoft.ReactNative/Fabric/AbiViewProps.h +45 -13
- package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.cpp +28 -64
- package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.h +7 -11
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.cpp +4 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.h +2 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView_emptyimpl.cpp +4 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService.cpp +12 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService.h +4 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService_emptyimpl.cpp +6 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +27 -16
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +13 -4
- package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +49 -95
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +11 -15
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +16 -31
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +5 -8
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +24 -81
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +4 -13
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +53 -68
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +5 -7
- package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +38 -84
- package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +6 -10
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +52 -104
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +7 -13
- package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +1 -0
- package/Microsoft.ReactNative/ViewProps.idl +37 -3
- package/Microsoft.ReactNative.Cxx/JSValueComposition.h +4 -0
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/PropertySheets/JSEngine.props +1 -1
- package/Shared/HermesRuntimeHolder.cpp +8 -0
- package/package.json +1 -1
|
@@ -29,13 +29,12 @@ SwitchComponentView::SwitchComponentView(
|
|
|
29
29
|
facebook::react::Tag tag,
|
|
30
30
|
winrt::Microsoft::ReactNative::ReactContext const &reactContext)
|
|
31
31
|
: base_type(
|
|
32
|
+
SwitchComponentView::defaultProps(),
|
|
32
33
|
compContext,
|
|
33
34
|
tag,
|
|
34
35
|
reactContext,
|
|
35
36
|
ComponentViewFeatures::Default & ~ComponentViewFeatures::Background,
|
|
36
|
-
false) {
|
|
37
|
-
m_props = std::make_shared<facebook::react::SwitchProps const>();
|
|
38
|
-
}
|
|
37
|
+
false) {}
|
|
39
38
|
|
|
40
39
|
winrt::Microsoft::ReactNative::ComponentView SwitchComponentView::Create(
|
|
41
40
|
const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
|
|
@@ -72,24 +71,17 @@ void SwitchComponentView::HandleCommand(
|
|
|
72
71
|
void SwitchComponentView::updateProps(
|
|
73
72
|
facebook::react::Props::Shared const &props,
|
|
74
73
|
facebook::react::Props::Shared const &oldProps) noexcept {
|
|
75
|
-
const auto &oldViewProps =
|
|
74
|
+
const auto &oldViewProps =
|
|
75
|
+
*std::static_pointer_cast<const facebook::react::SwitchProps>(oldProps ? oldProps : viewProps());
|
|
76
76
|
const auto &newViewProps = *std::static_pointer_cast<const facebook::react::SwitchProps>(props);
|
|
77
77
|
|
|
78
|
-
ensureVisual();
|
|
79
|
-
|
|
80
78
|
if (oldViewProps.backgroundColor != newViewProps.backgroundColor ||
|
|
81
79
|
oldViewProps.thumbTintColor != newViewProps.thumbTintColor || oldViewProps.value != newViewProps.value ||
|
|
82
80
|
oldViewProps.disabled != newViewProps.disabled) {
|
|
83
81
|
m_visualUpdateRequired = true;
|
|
84
82
|
}
|
|
85
|
-
if (oldViewProps.testId != newViewProps.testId) {
|
|
86
|
-
m_visual.Comment(winrt::to_hstring(newViewProps.testId));
|
|
87
|
-
}
|
|
88
83
|
|
|
89
|
-
// update BaseComponentView props
|
|
90
|
-
updateTransformProps(oldViewProps, newViewProps, m_visual);
|
|
91
84
|
Super::updateProps(props, oldProps);
|
|
92
|
-
m_props = std::static_pointer_cast<facebook::react::ViewProps const>(props);
|
|
93
85
|
}
|
|
94
86
|
|
|
95
87
|
void SwitchComponentView::updateState(
|
|
@@ -99,17 +91,7 @@ void SwitchComponentView::updateState(
|
|
|
99
91
|
void SwitchComponentView::updateLayoutMetrics(
|
|
100
92
|
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
101
93
|
facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept {
|
|
102
|
-
// Set Position & Size Properties
|
|
103
|
-
ensureVisual();
|
|
104
|
-
|
|
105
|
-
if ((layoutMetrics.displayType != m_layoutMetrics.displayType)) {
|
|
106
|
-
OuterVisual().IsVisible(layoutMetrics.displayType != facebook::react::DisplayType::None);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
94
|
Super::updateLayoutMetrics(layoutMetrics, oldLayoutMetrics);
|
|
110
|
-
m_visual.Size(
|
|
111
|
-
{layoutMetrics.frame.size.width * layoutMetrics.pointScaleFactor,
|
|
112
|
-
layoutMetrics.frame.size.height * layoutMetrics.pointScaleFactor});
|
|
113
95
|
|
|
114
96
|
if (oldLayoutMetrics.pointScaleFactor != layoutMetrics.pointScaleFactor) {
|
|
115
97
|
handleScaleChange();
|
|
@@ -135,7 +117,7 @@ void SwitchComponentView::handleScaleChange() noexcept {
|
|
|
135
117
|
}
|
|
136
118
|
|
|
137
119
|
void SwitchComponentView::updateVisuals() noexcept {
|
|
138
|
-
const auto
|
|
120
|
+
const auto &props = switchProps();
|
|
139
121
|
auto &theme = *this->theme();
|
|
140
122
|
winrt::Microsoft::ReactNative::Composition::Experimental::IBrush defaultColor;
|
|
141
123
|
winrt::Microsoft::ReactNative::Composition::Experimental::IBrush fillColor;
|
|
@@ -144,8 +126,8 @@ void SwitchComponentView::updateVisuals() noexcept {
|
|
|
144
126
|
auto thumbWidth = SwitchConstants::thumbWidth;
|
|
145
127
|
auto thumbHeight = SwitchConstants::thumbWidth;
|
|
146
128
|
|
|
147
|
-
if (
|
|
148
|
-
if (
|
|
129
|
+
if (props.value) {
|
|
130
|
+
if (props.disabled) {
|
|
149
131
|
defaultColor = theme.PlatformBrush("ToggleSwitchStrokeOnDisabled");
|
|
150
132
|
fillColor = theme.PlatformBrush("ToggleSwitchFillOnDisabled");
|
|
151
133
|
thumbFill = theme.PlatformBrush("ToggleSwitchKnobFillOnDisabled");
|
|
@@ -163,7 +145,7 @@ void SwitchComponentView::updateVisuals() noexcept {
|
|
|
163
145
|
thumbFill = theme.PlatformBrush("ToggleSwitchKnobFillOn");
|
|
164
146
|
}
|
|
165
147
|
} else {
|
|
166
|
-
if (
|
|
148
|
+
if (props.disabled) {
|
|
167
149
|
defaultColor = theme.PlatformBrush("ToggleSwitchStrokeOffDisabled");
|
|
168
150
|
fillColor = theme.PlatformBrush("ToggleSwitchFillOffDisabled");
|
|
169
151
|
thumbFill = theme.PlatformBrush("ToggleSwitchKnobFillOffDisabled");
|
|
@@ -182,7 +164,7 @@ void SwitchComponentView::updateVisuals() noexcept {
|
|
|
182
164
|
}
|
|
183
165
|
}
|
|
184
166
|
|
|
185
|
-
if (
|
|
167
|
+
if (props.disabled) {
|
|
186
168
|
thumbWidth = SwitchConstants::thumbWidth;
|
|
187
169
|
} else if (m_pressed) {
|
|
188
170
|
thumbWidth = SwitchConstants::thumbWidthPressed;
|
|
@@ -194,18 +176,18 @@ void SwitchComponentView::updateVisuals() noexcept {
|
|
|
194
176
|
thumbWidth = SwitchConstants::thumbWidth;
|
|
195
177
|
}
|
|
196
178
|
|
|
197
|
-
if (!
|
|
198
|
-
thumbFill = theme.Brush(*
|
|
179
|
+
if (!props.disabled && props.thumbTintColor) {
|
|
180
|
+
thumbFill = theme.Brush(*props.thumbTintColor);
|
|
199
181
|
}
|
|
200
182
|
|
|
201
|
-
if (!
|
|
202
|
-
fillColor = theme.Brush(*
|
|
203
|
-
} else if (!
|
|
204
|
-
fillColor = theme.Brush(*
|
|
183
|
+
if (!props.disabled && props.onTintColor && props.value) {
|
|
184
|
+
fillColor = theme.Brush(*props.onTintColor);
|
|
185
|
+
} else if (!props.disabled && props.tintColor && !props.value) {
|
|
186
|
+
fillColor = theme.Brush(*props.tintColor);
|
|
205
187
|
}
|
|
206
188
|
|
|
207
189
|
// switch track - outline
|
|
208
|
-
if ((!
|
|
190
|
+
if ((!props.onTintColor && props.value) || (!props.tintColor && !props.value)) {
|
|
209
191
|
m_trackVisual.StrokeThickness(std::round(SwitchConstants::trackStrokeThickness * m_layoutMetrics.pointScaleFactor));
|
|
210
192
|
m_trackVisual.StrokeBrush(defaultColor);
|
|
211
193
|
} else {
|
|
@@ -220,7 +202,7 @@ void SwitchComponentView::updateVisuals() noexcept {
|
|
|
220
202
|
m_thumbVisual.AnimationClass(winrt::Microsoft::ReactNative::Composition::Experimental::AnimationClass::None);
|
|
221
203
|
}
|
|
222
204
|
|
|
223
|
-
if (
|
|
205
|
+
if (props.value) {
|
|
224
206
|
m_thumbVisual.Offset(
|
|
225
207
|
{(SwitchConstants::trackWidth - (SwitchConstants::thumbMargin + thumbWidth)) * m_layoutMetrics.pointScaleFactor,
|
|
226
208
|
offsetY,
|
|
@@ -249,47 +231,18 @@ void SwitchComponentView::FinalizeUpdates(winrt::Microsoft::ReactNative::Compone
|
|
|
249
231
|
base_type::FinalizeUpdates(updateMask);
|
|
250
232
|
}
|
|
251
233
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
facebook::react::SharedViewProps SwitchComponentView::viewProps() noexcept {
|
|
255
|
-
return m_props;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
void SwitchComponentView::ensureVisual() noexcept {
|
|
259
|
-
if (!m_visual) {
|
|
260
|
-
m_visual = m_compContext.CreateSpriteVisual();
|
|
261
|
-
OuterVisual().InsertAt(m_visual, 0);
|
|
262
|
-
|
|
263
|
-
m_trackVisual = m_compContext.CreateRoundedRectangleVisual();
|
|
264
|
-
m_visual.InsertAt(m_trackVisual, 0);
|
|
265
|
-
|
|
266
|
-
m_thumbVisual = m_compContext.CreateRoundedRectangleVisual();
|
|
267
|
-
m_thumbVisual.AnimationClass(winrt::Microsoft::ReactNative::Composition::Experimental::AnimationClass::SwitchThumb);
|
|
268
|
-
m_trackVisual.InsertAt(m_thumbVisual, 0);
|
|
269
|
-
|
|
270
|
-
handleScaleChange();
|
|
271
|
-
}
|
|
272
|
-
}
|
|
234
|
+
winrt::Microsoft::ReactNative::Composition::Experimental::IVisual SwitchComponentView::createVisual() noexcept {
|
|
235
|
+
auto visual = m_compContext.CreateSpriteVisual();
|
|
273
236
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
facebook::react::Point &localPt,
|
|
277
|
-
bool ignorePointerEvents) const noexcept {
|
|
278
|
-
facebook::react::Point ptLocal{pt.x - m_layoutMetrics.frame.origin.x, pt.y - m_layoutMetrics.frame.origin.y};
|
|
279
|
-
|
|
280
|
-
if ((ignorePointerEvents || m_props->pointerEvents == facebook::react::PointerEventsMode::Auto ||
|
|
281
|
-
m_props->pointerEvents == facebook::react::PointerEventsMode::BoxOnly) &&
|
|
282
|
-
ptLocal.x >= 0 && ptLocal.x <= m_layoutMetrics.frame.size.width && ptLocal.y >= 0 &&
|
|
283
|
-
ptLocal.y <= m_layoutMetrics.frame.size.height) {
|
|
284
|
-
localPt = ptLocal;
|
|
285
|
-
return Tag();
|
|
286
|
-
}
|
|
237
|
+
m_trackVisual = m_compContext.CreateRoundedRectangleVisual();
|
|
238
|
+
visual.InsertAt(m_trackVisual, 0);
|
|
287
239
|
|
|
288
|
-
|
|
289
|
-
|
|
240
|
+
m_thumbVisual = m_compContext.CreateRoundedRectangleVisual();
|
|
241
|
+
m_thumbVisual.AnimationClass(winrt::Microsoft::ReactNative::Composition::Experimental::AnimationClass::SwitchThumb);
|
|
242
|
+
m_trackVisual.InsertAt(m_thumbVisual, 0);
|
|
290
243
|
|
|
291
|
-
|
|
292
|
-
return
|
|
244
|
+
handleScaleChange();
|
|
245
|
+
return visual;
|
|
293
246
|
}
|
|
294
247
|
|
|
295
248
|
void SwitchComponentView::onThemeChanged() noexcept {
|
|
@@ -304,9 +257,7 @@ void SwitchComponentView::OnPointerPressed(
|
|
|
304
257
|
return;
|
|
305
258
|
}
|
|
306
259
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
if (!switchProps->disabled) {
|
|
260
|
+
if (!switchProps().disabled) {
|
|
310
261
|
m_pressed = true;
|
|
311
262
|
m_supressAnimationForNextFrame = true;
|
|
312
263
|
|
|
@@ -364,27 +315,30 @@ void SwitchComponentView::OnKeyUp(
|
|
|
364
315
|
}
|
|
365
316
|
|
|
366
317
|
bool SwitchComponentView::toggle() noexcept {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
if (switchProps->disabled || !m_eventEmitter)
|
|
318
|
+
if (switchProps().disabled || !m_eventEmitter)
|
|
370
319
|
return false;
|
|
371
320
|
|
|
372
321
|
auto switchEventEmitter = std::static_pointer_cast<facebook::react::SwitchEventEmitter const>(m_eventEmitter);
|
|
373
322
|
|
|
374
323
|
facebook::react::SwitchEventEmitter::OnChange args;
|
|
375
|
-
args.value = !(switchProps
|
|
324
|
+
args.value = !(switchProps().value);
|
|
376
325
|
args.target = Tag();
|
|
377
326
|
|
|
378
327
|
switchEventEmitter->onChange(args);
|
|
379
328
|
return true;
|
|
380
329
|
}
|
|
381
330
|
|
|
382
|
-
bool SwitchComponentView::focusable() const noexcept {
|
|
383
|
-
return m_props->focusable;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
331
|
std::string SwitchComponentView::DefaultControlType() const noexcept {
|
|
387
332
|
return "switch";
|
|
388
333
|
}
|
|
389
334
|
|
|
335
|
+
facebook::react::SharedViewProps SwitchComponentView::defaultProps() noexcept {
|
|
336
|
+
static auto const defaultProps = std::make_shared<facebook::react::SwitchProps const>();
|
|
337
|
+
return defaultProps;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const facebook::react::SwitchProps &SwitchComponentView::switchProps() const noexcept {
|
|
341
|
+
return *std::static_pointer_cast<const facebook::react::SwitchProps>(viewProps());
|
|
342
|
+
}
|
|
343
|
+
|
|
390
344
|
} // namespace winrt::Microsoft::ReactNative::Composition::implementation
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
namespace winrt::Microsoft::ReactNative::Composition::implementation {
|
|
15
15
|
|
|
16
|
-
struct SwitchComponentView : SwitchComponentViewT<SwitchComponentView,
|
|
17
|
-
using Super = SwitchComponentViewT<SwitchComponentView,
|
|
16
|
+
struct SwitchComponentView : SwitchComponentViewT<SwitchComponentView, ViewComponentView> {
|
|
17
|
+
using Super = SwitchComponentViewT<SwitchComponentView, ViewComponentView>;
|
|
18
18
|
|
|
19
19
|
[[nodiscard]] static winrt::Microsoft::ReactNative::ComponentView Create(
|
|
20
20
|
const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
|
|
@@ -37,9 +37,6 @@ struct SwitchComponentView : SwitchComponentViewT<SwitchComponentView, Component
|
|
|
37
37
|
facebook::react::LayoutMetrics const &layoutMetrics,
|
|
38
38
|
facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept override;
|
|
39
39
|
void FinalizeUpdates(winrt::Microsoft::ReactNative::ComponentViewUpdateMask updateMask) noexcept override;
|
|
40
|
-
void prepareForRecycle() noexcept override;
|
|
41
|
-
facebook::react::SharedViewProps viewProps() noexcept override;
|
|
42
|
-
bool focusable() const noexcept override;
|
|
43
40
|
void onThemeChanged() noexcept override;
|
|
44
41
|
void OnKeyUp(
|
|
45
42
|
const winrt::Microsoft::ReactNative::Composition::Input::KeyboardSource &source,
|
|
@@ -53,9 +50,6 @@ struct SwitchComponentView : SwitchComponentViewT<SwitchComponentView, Component
|
|
|
53
50
|
void OnPointerExited(
|
|
54
51
|
const winrt::Microsoft::ReactNative::Composition::Input::PointerRoutedEventArgs &args) noexcept override;
|
|
55
52
|
|
|
56
|
-
facebook::react::Tag hitTest(facebook::react::Point pt, facebook::react::Point &localPt, bool ignorePointerEvents)
|
|
57
|
-
const noexcept override;
|
|
58
|
-
winrt::Microsoft::ReactNative::Composition::Experimental::IVisual Visual() const noexcept override;
|
|
59
53
|
std::string DefaultControlType() const noexcept override;
|
|
60
54
|
|
|
61
55
|
SwitchComponentView(
|
|
@@ -63,6 +57,10 @@ struct SwitchComponentView : SwitchComponentViewT<SwitchComponentView, Component
|
|
|
63
57
|
facebook::react::Tag tag,
|
|
64
58
|
winrt::Microsoft::ReactNative::ReactContext const &reactContext);
|
|
65
59
|
|
|
60
|
+
static facebook::react::SharedViewProps defaultProps() noexcept;
|
|
61
|
+
const facebook::react::SwitchProps &switchProps() const noexcept;
|
|
62
|
+
winrt::Microsoft::ReactNative::Composition::Experimental::IVisual createVisual() noexcept override;
|
|
63
|
+
|
|
66
64
|
private:
|
|
67
65
|
void ensureVisual() noexcept;
|
|
68
66
|
bool toggle() noexcept;
|
|
@@ -74,10 +72,8 @@ struct SwitchComponentView : SwitchComponentViewT<SwitchComponentView, Component
|
|
|
74
72
|
bool m_supressAnimationForNextFrame{false};
|
|
75
73
|
bool m_visualUpdateRequired{true};
|
|
76
74
|
facebook::react::Size m_contentSize;
|
|
77
|
-
winrt::Microsoft::ReactNative::Composition::Experimental::ISpriteVisual m_visual{nullptr};
|
|
78
75
|
winrt::Microsoft::ReactNative::Composition::Experimental::IRoundedRectangleVisual m_trackVisual{nullptr};
|
|
79
76
|
winrt::Microsoft::ReactNative::Composition::Experimental::IRoundedRectangleVisual m_thumbVisual{nullptr};
|
|
80
|
-
facebook::react::SharedViewProps m_props;
|
|
81
77
|
};
|
|
82
78
|
|
|
83
79
|
} // namespace winrt::Microsoft::ReactNative::Composition::implementation
|
package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp
CHANGED
|
@@ -164,7 +164,7 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
|
|
|
164
164
|
|
|
165
165
|
//@cmember Show the caret
|
|
166
166
|
BOOL TxShowCaret(BOOL fShow) override {
|
|
167
|
-
m_outer->ShowCaret(m_outer->
|
|
167
|
+
m_outer->ShowCaret(m_outer->windowsTextInputProps().caretHidden ? false : fShow);
|
|
168
168
|
return true;
|
|
169
169
|
}
|
|
170
170
|
|
|
@@ -304,14 +304,14 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
|
|
|
304
304
|
|
|
305
305
|
switch (nIndex) {
|
|
306
306
|
case COLOR_WINDOWTEXT:
|
|
307
|
-
if (m_outer->
|
|
308
|
-
return (*m_outer->
|
|
307
|
+
if (m_outer->windowsTextInputProps().textAttributes.foregroundColor)
|
|
308
|
+
return (*m_outer->windowsTextInputProps().textAttributes.foregroundColor).AsColorRefNoAlpha();
|
|
309
309
|
// cr = 0x000000FF;
|
|
310
310
|
break;
|
|
311
311
|
|
|
312
312
|
case COLOR_WINDOW:
|
|
313
|
-
if (m_outer->
|
|
314
|
-
return (*m_outer->
|
|
313
|
+
if (m_outer->viewProps()->backgroundColor)
|
|
314
|
+
return (*m_outer->viewProps()->backgroundColor).AsColorRefNoAlpha();
|
|
315
315
|
break;
|
|
316
316
|
// case COLOR_HIGHLIGHT:
|
|
317
317
|
// cr = RGB(0, 0, 255);
|
|
@@ -356,8 +356,8 @@ struct CompTextHost : public winrt::implements<CompTextHost, ITextHost> {
|
|
|
356
356
|
|
|
357
357
|
//@cmember Get the maximum length for the text
|
|
358
358
|
HRESULT TxGetMaxLength(DWORD *plength) override {
|
|
359
|
-
auto length = m_outer->
|
|
360
|
-
if (length > static_cast<decltype(m_outer->
|
|
359
|
+
auto length = m_outer->windowsTextInputProps().maxLength;
|
|
360
|
+
if (length > static_cast<decltype(m_outer->windowsTextInputProps().maxLength)>(std::numeric_limits<DWORD>::max())) {
|
|
361
361
|
length = std::numeric_limits<DWORD>::max();
|
|
362
362
|
}
|
|
363
363
|
*plength = static_cast<DWORD>(length);
|
|
@@ -454,7 +454,7 @@ facebook::react::AttributedString WindowsTextInputComponentView::getAttributedSt
|
|
|
454
454
|
|
|
455
455
|
auto childTextAttributes = facebook::react::TextAttributes::defaultTextAttributes();
|
|
456
456
|
|
|
457
|
-
childTextAttributes.apply(
|
|
457
|
+
childTextAttributes.apply(windowsTextInputProps().textAttributes);
|
|
458
458
|
|
|
459
459
|
auto attributedString = facebook::react::AttributedString{};
|
|
460
460
|
// auto attachments = facebook::react::BaseTextShadowNode::Attachments{};
|
|
@@ -465,7 +465,7 @@ facebook::react::AttributedString WindowsTextInputComponentView::getAttributedSt
|
|
|
465
465
|
// if (!m_props->text.empty()) {
|
|
466
466
|
if (!text.empty()) {
|
|
467
467
|
auto textAttributes = facebook::react::TextAttributes::defaultTextAttributes();
|
|
468
|
-
textAttributes.apply(
|
|
468
|
+
textAttributes.apply(windowsTextInputProps().textAttributes);
|
|
469
469
|
auto fragment = facebook::react::AttributedString::Fragment{};
|
|
470
470
|
fragment.string = text;
|
|
471
471
|
// fragment.string = m_props->text;
|
|
@@ -486,14 +486,12 @@ WindowsTextInputComponentView::WindowsTextInputComponentView(
|
|
|
486
486
|
facebook::react::Tag tag,
|
|
487
487
|
winrt::Microsoft::ReactNative::ReactContext const &reactContext)
|
|
488
488
|
: Super(
|
|
489
|
+
WindowsTextInputComponentView::defaultProps(),
|
|
489
490
|
compContext,
|
|
490
491
|
tag,
|
|
491
492
|
reactContext,
|
|
492
493
|
ComponentViewFeatures::Default & ~ComponentViewFeatures::Background,
|
|
493
494
|
false) {
|
|
494
|
-
static auto const defaultProps = std::make_shared<facebook::react::WindowsTextInputProps const>();
|
|
495
|
-
m_props = defaultProps;
|
|
496
|
-
|
|
497
495
|
/*
|
|
498
496
|
m_textChangedRevoker =
|
|
499
497
|
m_element.TextChanged(winrt::auto_revoke, [this](auto sender, xaml::Controls::TextChangedEventArgs args) {
|
|
@@ -950,20 +948,16 @@ void WindowsTextInputComponentView::onFocusGained() noexcept {
|
|
|
950
948
|
}
|
|
951
949
|
}
|
|
952
950
|
|
|
953
|
-
bool WindowsTextInputComponentView::focusable() const noexcept {
|
|
954
|
-
return m_props->focusable;
|
|
955
|
-
}
|
|
956
|
-
|
|
957
951
|
std::string WindowsTextInputComponentView::DefaultControlType() const noexcept {
|
|
958
952
|
return "textinput";
|
|
959
953
|
}
|
|
960
954
|
|
|
961
955
|
std::string WindowsTextInputComponentView::DefaultAccessibleName() const noexcept {
|
|
962
|
-
return
|
|
956
|
+
return windowsTextInputProps().placeholder;
|
|
963
957
|
}
|
|
964
958
|
|
|
965
959
|
std::string WindowsTextInputComponentView::DefaultHelpText() const noexcept {
|
|
966
|
-
return
|
|
960
|
+
return windowsTextInputProps().placeholder;
|
|
967
961
|
}
|
|
968
962
|
|
|
969
963
|
void WindowsTextInputComponentView::updateCursorColor(
|
|
@@ -981,19 +975,13 @@ void WindowsTextInputComponentView::updateCursorColor(
|
|
|
981
975
|
void WindowsTextInputComponentView::updateProps(
|
|
982
976
|
facebook::react::Props::Shared const &props,
|
|
983
977
|
facebook::react::Props::Shared const &oldProps) noexcept {
|
|
984
|
-
const auto &oldTextInputProps =
|
|
978
|
+
const auto &oldTextInputProps =
|
|
979
|
+
*std::static_pointer_cast<const facebook::react::WindowsTextInputProps>(oldProps ? oldProps : viewProps());
|
|
985
980
|
const auto &newTextInputProps = *std::static_pointer_cast<const facebook::react::WindowsTextInputProps>(props);
|
|
986
981
|
|
|
987
982
|
DWORD propBitsMask = 0;
|
|
988
983
|
DWORD propBits = 0;
|
|
989
984
|
|
|
990
|
-
ensureVisual();
|
|
991
|
-
|
|
992
|
-
if (oldTextInputProps.testId != newTextInputProps.testId) {
|
|
993
|
-
m_visual.Comment(winrt::to_hstring(newTextInputProps.testId));
|
|
994
|
-
}
|
|
995
|
-
// update BaseComponentView props
|
|
996
|
-
updateTransformProps(oldTextInputProps, newTextInputProps, m_visual);
|
|
997
985
|
Super::updateProps(props, oldProps);
|
|
998
986
|
|
|
999
987
|
if (!facebook::react::floatEquality(
|
|
@@ -1105,8 +1093,6 @@ void WindowsTextInputComponentView::updateProps(
|
|
|
1105
1093
|
}
|
|
1106
1094
|
*/
|
|
1107
1095
|
|
|
1108
|
-
m_props = std::static_pointer_cast<facebook::react::WindowsTextInputProps const>(props);
|
|
1109
|
-
|
|
1110
1096
|
if (propBitsMask != 0) {
|
|
1111
1097
|
DrawBlock db(*this);
|
|
1112
1098
|
winrt::check_hresult(m_textServices->OnTxPropertyBitsChange(propBitsMask, propBits));
|
|
@@ -1177,10 +1163,6 @@ void WindowsTextInputComponentView::updateLayoutMetrics(
|
|
|
1177
1163
|
facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept {
|
|
1178
1164
|
// Set Position & Size Properties
|
|
1179
1165
|
|
|
1180
|
-
if ((layoutMetrics.displayType != m_layoutMetrics.displayType)) {
|
|
1181
|
-
OuterVisual().IsVisible(layoutMetrics.displayType != facebook::react::DisplayType::None);
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
1166
|
if ((layoutMetrics.pointScaleFactor != m_layoutMetrics.pointScaleFactor)) {
|
|
1185
1167
|
LRESULT res;
|
|
1186
1168
|
winrt::check_hresult(m_textServices->TxSendMessage(
|
|
@@ -1202,10 +1184,6 @@ void WindowsTextInputComponentView::updateLayoutMetrics(
|
|
|
1202
1184
|
|
|
1203
1185
|
m_imgWidth = newWidth;
|
|
1204
1186
|
m_imgHeight = newHeight;
|
|
1205
|
-
|
|
1206
|
-
m_visual.Size(
|
|
1207
|
-
{layoutMetrics.frame.size.width * layoutMetrics.pointScaleFactor,
|
|
1208
|
-
layoutMetrics.frame.size.height * layoutMetrics.pointScaleFactor});
|
|
1209
1187
|
}
|
|
1210
1188
|
|
|
1211
1189
|
// When we are notified by RichEdit that the text changed, we need to notify JS
|
|
@@ -1282,13 +1260,16 @@ void WindowsTextInputComponentView::setAcccessiblityValue(std::string &&value) n
|
|
|
1282
1260
|
}
|
|
1283
1261
|
|
|
1284
1262
|
bool WindowsTextInputComponentView::getAcccessiblityIsReadOnly() noexcept {
|
|
1285
|
-
return !
|
|
1263
|
+
return !windowsTextInputProps().editable;
|
|
1286
1264
|
}
|
|
1287
1265
|
|
|
1288
|
-
|
|
1266
|
+
facebook::react::SharedViewProps WindowsTextInputComponentView::defaultProps() noexcept {
|
|
1267
|
+
static auto const defaultProps = std::make_shared<facebook::react::WindowsTextInputProps const>();
|
|
1268
|
+
return defaultProps;
|
|
1269
|
+
}
|
|
1289
1270
|
|
|
1290
|
-
facebook::react::
|
|
1291
|
-
return
|
|
1271
|
+
const facebook::react::WindowsTextInputProps &WindowsTextInputComponentView::windowsTextInputProps() const noexcept {
|
|
1272
|
+
return *std::static_pointer_cast<const facebook::react::WindowsTextInputProps>(viewProps());
|
|
1292
1273
|
}
|
|
1293
1274
|
|
|
1294
1275
|
void WindowsTextInputComponentView::UpdateCharFormat() noexcept {
|
|
@@ -1311,17 +1292,18 @@ void WindowsTextInputComponentView::UpdateCharFormat() noexcept {
|
|
|
1311
1292
|
// cfNew.bPitchAndFamily = FF_DONTCARE;
|
|
1312
1293
|
|
|
1313
1294
|
// set font size -- 15 to convert twips to pt
|
|
1314
|
-
|
|
1295
|
+
const auto &props = windowsTextInputProps();
|
|
1296
|
+
float fontSize = props.textAttributes.fontSize;
|
|
1315
1297
|
if (std::isnan(fontSize))
|
|
1316
1298
|
fontSize = facebook::react::TextAttributes::defaultTextAttributes().fontSize;
|
|
1317
|
-
// TODO get fontSize from
|
|
1299
|
+
// TODO get fontSize from props.textAttributes, or defaultTextAttributes, or fragment?
|
|
1318
1300
|
cfNew.dwMask |= CFM_SIZE;
|
|
1319
1301
|
cfNew.yHeight = static_cast<LONG>(fontSize * 15);
|
|
1320
1302
|
|
|
1321
1303
|
// set bold
|
|
1322
1304
|
cfNew.dwMask |= CFM_WEIGHT;
|
|
1323
|
-
cfNew.wWeight =
|
|
1324
|
-
|
|
1305
|
+
cfNew.wWeight =
|
|
1306
|
+
props.textAttributes.fontWeight ? static_cast<WORD>(*props.textAttributes.fontWeight) : DWRITE_FONT_WEIGHT_NORMAL;
|
|
1325
1307
|
|
|
1326
1308
|
// set font style
|
|
1327
1309
|
// cfNew.dwMask |= (CFM_ITALIC | CFM_STRIKEOUT | CFM_UNDERLINE);
|
|
@@ -1392,7 +1374,7 @@ void WindowsTextInputComponentView::ensureDrawingSurface() noexcept {
|
|
|
1392
1374
|
m_drawingSurface.HorizontalAlignmentRatio(0.f);
|
|
1393
1375
|
m_drawingSurface.VerticalAlignmentRatio(0.f);
|
|
1394
1376
|
m_drawingSurface.Stretch(winrt::Microsoft::ReactNative::Composition::Experimental::CompositionStretch::None);
|
|
1395
|
-
|
|
1377
|
+
Visual().as<Experimental::ISpriteVisual>().Brush(m_drawingSurface);
|
|
1396
1378
|
}
|
|
1397
1379
|
}
|
|
1398
1380
|
|
|
@@ -1406,11 +1388,12 @@ winrt::com_ptr<::IDWriteTextLayout> WindowsTextInputComponentView::CreatePlaceho
|
|
|
1406
1388
|
winrt::com_ptr<::IDWriteTextLayout> textLayout = nullptr;
|
|
1407
1389
|
facebook::react::AttributedString attributedString;
|
|
1408
1390
|
facebook::react::AttributedString::Fragment fragment1;
|
|
1409
|
-
|
|
1410
|
-
|
|
1391
|
+
const auto &props = windowsTextInputProps();
|
|
1392
|
+
facebook::react::TextAttributes textAttributes = props.textAttributes;
|
|
1393
|
+
if (std::isnan(props.textAttributes.fontSize)) {
|
|
1411
1394
|
textAttributes.fontSize = 12.0f;
|
|
1412
1395
|
}
|
|
1413
|
-
fragment1.string =
|
|
1396
|
+
fragment1.string = props.placeholder;
|
|
1414
1397
|
fragment1.textAttributes = textAttributes;
|
|
1415
1398
|
attributedString.appendFragment(fragment1);
|
|
1416
1399
|
|
|
@@ -1461,8 +1444,9 @@ void WindowsTextInputComponentView::DrawText() noexcept {
|
|
|
1461
1444
|
|
|
1462
1445
|
winrt::check_hresult(m_textServices->OnTxInPlaceActivate(&rcClient));
|
|
1463
1446
|
|
|
1464
|
-
|
|
1465
|
-
|
|
1447
|
+
const auto &props = windowsTextInputProps();
|
|
1448
|
+
if (facebook::react::isColorMeaningful(props.backgroundColor)) {
|
|
1449
|
+
auto backgroundColor = theme()->D2DColor(*props.backgroundColor);
|
|
1466
1450
|
winrt::com_ptr<ID2D1SolidColorBrush> backgroundBrush;
|
|
1467
1451
|
winrt::check_hresult(d2dDeviceContext->CreateSolidColorBrush(backgroundColor, backgroundBrush.put()));
|
|
1468
1452
|
const D2D1_RECT_F fillRect = {
|
|
@@ -1478,11 +1462,11 @@ void WindowsTextInputComponentView::DrawText() noexcept {
|
|
|
1478
1462
|
winrt::check_hresult(hrDraw);
|
|
1479
1463
|
|
|
1480
1464
|
// draw placeholder text if needed
|
|
1481
|
-
if (!
|
|
1465
|
+
if (!props.placeholder.empty() && GetTextFromRichEdit().empty()) {
|
|
1482
1466
|
// set brush color
|
|
1483
1467
|
winrt::com_ptr<ID2D1SolidColorBrush> brush;
|
|
1484
|
-
if (
|
|
1485
|
-
auto color = theme()->D2DColor(*
|
|
1468
|
+
if (props.placeholderTextColor) {
|
|
1469
|
+
auto color = theme()->D2DColor(*props.placeholderTextColor);
|
|
1486
1470
|
winrt::check_hresult(d2dDeviceContext->CreateSolidColorBrush(color, brush.put()));
|
|
1487
1471
|
} else {
|
|
1488
1472
|
winrt::check_hresult(
|
|
@@ -1507,65 +1491,29 @@ void WindowsTextInputComponentView::DrawText() noexcept {
|
|
|
1507
1491
|
m_needsRedraw = false;
|
|
1508
1492
|
}
|
|
1509
1493
|
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
ComponentView
|
|
1523
|
-
*>(child)->hitTest(ptLocal, localPt); return targetTag != -1;
|
|
1524
|
-
}))
|
|
1525
|
-
return targetTag;
|
|
1526
|
-
*/
|
|
1527
|
-
|
|
1528
|
-
if ((ignorePointerEvents || m_props->pointerEvents == facebook::react::PointerEventsMode::Auto ||
|
|
1529
|
-
m_props->pointerEvents == facebook::react::PointerEventsMode::BoxOnly) &&
|
|
1530
|
-
ptLocal.x >= 0 && ptLocal.x <= m_layoutMetrics.frame.size.width && ptLocal.y >= 0 &&
|
|
1531
|
-
ptLocal.y <= m_layoutMetrics.frame.size.height) {
|
|
1532
|
-
localPt = ptLocal;
|
|
1533
|
-
return Tag();
|
|
1534
|
-
}
|
|
1535
|
-
|
|
1536
|
-
return -1;
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
void WindowsTextInputComponentView::ensureVisual() noexcept {
|
|
1540
|
-
if (!m_visual) {
|
|
1541
|
-
HrEnsureRichEd20Loaded();
|
|
1542
|
-
m_visual = m_compContext.CreateSpriteVisual();
|
|
1543
|
-
m_textHost = winrt::make<CompTextHost>(this);
|
|
1544
|
-
winrt::com_ptr<::IUnknown> spUnk;
|
|
1545
|
-
winrt::check_hresult(g_pfnCreateTextServices(nullptr, m_textHost.get(), spUnk.put()));
|
|
1546
|
-
spUnk.as(m_textServices);
|
|
1547
|
-
OuterVisual().InsertAt(m_visual, 0);
|
|
1548
|
-
}
|
|
1494
|
+
winrt::Microsoft::ReactNative::Composition::Experimental::IVisual
|
|
1495
|
+
WindowsTextInputComponentView::createVisual() noexcept {
|
|
1496
|
+
HrEnsureRichEd20Loaded();
|
|
1497
|
+
auto visual = m_compContext.CreateSpriteVisual();
|
|
1498
|
+
m_textHost = winrt::make<CompTextHost>(this);
|
|
1499
|
+
winrt::com_ptr<::IUnknown> spUnk;
|
|
1500
|
+
winrt::check_hresult(g_pfnCreateTextServices(nullptr, m_textHost.get(), spUnk.put()));
|
|
1501
|
+
spUnk.as(m_textServices);
|
|
1502
|
+
|
|
1503
|
+
m_caretVisual = m_compContext.CreateCaretVisual();
|
|
1504
|
+
visual.InsertAt(m_caretVisual.InnerVisual(), 0);
|
|
1505
|
+
m_caretVisual.IsVisible(false);
|
|
1549
1506
|
|
|
1550
|
-
|
|
1551
|
-
m_caretVisual = m_compContext.CreateCaretVisual();
|
|
1552
|
-
m_visual.InsertAt(m_caretVisual.InnerVisual(), 0);
|
|
1553
|
-
m_caretVisual.IsVisible(false);
|
|
1554
|
-
}
|
|
1507
|
+
return visual;
|
|
1555
1508
|
}
|
|
1556
1509
|
|
|
1557
1510
|
void WindowsTextInputComponentView::onThemeChanged() noexcept {
|
|
1558
|
-
auto props =
|
|
1559
|
-
updateCursorColor(props
|
|
1511
|
+
const auto &props = windowsTextInputProps();
|
|
1512
|
+
updateCursorColor(props.cursorColor, props.textAttributes.foregroundColor);
|
|
1560
1513
|
DrawText();
|
|
1561
1514
|
base_type::onThemeChanged();
|
|
1562
1515
|
}
|
|
1563
1516
|
|
|
1564
|
-
winrt::Microsoft::ReactNative::Composition::Experimental::IVisual WindowsTextInputComponentView::Visual()
|
|
1565
|
-
const noexcept {
|
|
1566
|
-
return m_visual;
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1569
1517
|
winrt::Microsoft::ReactNative::ComponentView WindowsTextInputComponentView::Create(
|
|
1570
1518
|
const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
|
|
1571
1519
|
facebook::react::Tag tag,
|