basalt-win32 0.0.0-stage → 0.2.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.
Files changed (90) hide show
  1. package/LICENSE +21 -0
  2. package/cli/runWindows.js +35 -0
  3. package/cli/shared.js +75 -0
  4. package/native/CMakeLists.txt +429 -0
  5. package/native/tests/test_win32_accessibility.cpp +585 -0
  6. package/native/tests/test_win32_animated_image.cpp +351 -0
  7. package/native/tests/test_win32_clipboard.cpp +121 -0
  8. package/native/tests/test_win32_focus.cpp +195 -0
  9. package/native/tests/test_win32_hittest.cpp +750 -0
  10. package/native/tests/test_win32_image.cpp +370 -0
  11. package/native/tests/test_win32_imageloader.cpp +208 -0
  12. package/native/tests/test_win32_input.cpp +511 -0
  13. package/native/tests/test_win32_key_events.cpp +84 -0
  14. package/native/tests/test_win32_mounting.cpp +757 -0
  15. package/native/tests/test_win32_paint.cpp +1799 -0
  16. package/native/tests/test_win32_scrollview.cpp +647 -0
  17. package/native/tests/test_win32_selection.cpp +215 -0
  18. package/native/tests/test_win32_text.cpp +1456 -0
  19. package/native/tests/test_win32_textinput.cpp +1594 -0
  20. package/native/tests/test_win32_titlebar.cpp +111 -0
  21. package/native/tests/test_win32_titlebar_actions.cpp +62 -0
  22. package/native/tests/test_win32_view.cpp +222 -0
  23. package/native/win32/ColorSchemeWin32.cpp +56 -0
  24. package/native/win32/ComponentRegistryWin32.cpp +156 -0
  25. package/native/win32/DirectWriteLayout.cpp +485 -0
  26. package/native/win32/DirectWriteLayout.h +77 -0
  27. package/native/win32/DirectWriteLayoutManager.cpp +154 -0
  28. package/native/win32/FontRegistryDirectWrite.cpp +117 -0
  29. package/native/win32/PlatformServicesWin32.cpp +744 -0
  30. package/native/win32/RnWin32Accessible.cpp +343 -0
  31. package/native/win32/RnWin32Accessible.h +130 -0
  32. package/native/win32/RnWin32Image.cpp +588 -0
  33. package/native/win32/RnWin32Image.h +139 -0
  34. package/native/win32/RnWin32TextLayout.cpp +1379 -0
  35. package/native/win32/RnWin32TextLayout.h +390 -0
  36. package/native/win32/RnWin32View.cpp +2956 -0
  37. package/native/win32/RnWin32View.h +926 -0
  38. package/native/win32/Win32AnimationChoreographer.cpp +76 -0
  39. package/native/win32/Win32AnimationChoreographer.h +61 -0
  40. package/native/win32/Win32Clip.h +209 -0
  41. package/native/win32/Win32Cursors.cpp +309 -0
  42. package/native/win32/Win32Cursors.h +121 -0
  43. package/native/win32/Win32DropTarget.cpp +567 -0
  44. package/native/win32/Win32DropTarget.h +42 -0
  45. package/native/win32/Win32Focus.cpp +262 -0
  46. package/native/win32/Win32Focus.h +109 -0
  47. package/native/win32/Win32ImageLoader.cpp +199 -0
  48. package/native/win32/Win32ImageLoader.h +133 -0
  49. package/native/win32/Win32InputScopes.h +92 -0
  50. package/native/win32/Win32KeyEvents.cpp +126 -0
  51. package/native/win32/Win32KeyEvents.h +20 -0
  52. package/native/win32/Win32MenuBar.cpp +382 -0
  53. package/native/win32/Win32MenuBar.h +16 -0
  54. package/native/win32/Win32MountingManager.cpp +1282 -0
  55. package/native/win32/Win32MountingManager.h +243 -0
  56. package/native/win32/Win32Offscreen.h +53 -0
  57. package/native/win32/Win32Packaging.cpp +161 -0
  58. package/native/win32/Win32Packaging.h +56 -0
  59. package/native/win32/Win32RunLoopObserver.cpp +48 -0
  60. package/native/win32/Win32RunLoopObserver.h +42 -0
  61. package/native/win32/Win32ScrollView.cpp +718 -0
  62. package/native/win32/Win32ScrollView.h +256 -0
  63. package/native/win32/Win32SkiaContext.cpp +221 -0
  64. package/native/win32/Win32SkiaContext.h +53 -0
  65. package/native/win32/Win32SkiaModule.cpp +80 -0
  66. package/native/win32/Win32SkiaModule.h +50 -0
  67. package/native/win32/Win32SkiaPeer.cpp +358 -0
  68. package/native/win32/Win32SkiaPeer.h +66 -0
  69. package/native/win32/Win32SkiaUnicode.cpp +42 -0
  70. package/native/win32/Win32Snapshot.cpp +201 -0
  71. package/native/win32/Win32Snapshot.h +66 -0
  72. package/native/win32/Win32Strings.h +54 -0
  73. package/native/win32/Win32TextInput.cpp +1296 -0
  74. package/native/win32/Win32TextInput.h +341 -0
  75. package/native/win32/Win32TitleBar.cpp +562 -0
  76. package/native/win32/Win32TitleBar.h +146 -0
  77. package/native/win32/Win32TitleBarLayout.cpp +46 -0
  78. package/native/win32/Win32TitleBarLayout.h +58 -0
  79. package/native/win32/Win32TouchDispatcher.cpp +577 -0
  80. package/native/win32/Win32TouchDispatcher.h +201 -0
  81. package/native/win32/Win32UiThread.h +27 -0
  82. package/native/win32/Win32WindowControl.cpp +329 -0
  83. package/native/win32/Win32WindowModule.cpp +209 -0
  84. package/native/win32/Win32WindowModule.h +72 -0
  85. package/native/win32/demo_layout_win32.cpp +232 -0
  86. package/native/win32/main_win32.cpp +2722 -0
  87. package/native/win32/mount_harness_win32.cpp +316 -0
  88. package/package.json +25 -4
  89. package/react-native.config.js +22 -0
  90. package/README.md +0 -3
@@ -0,0 +1,390 @@
1
+ // A laid-out paragraph, and nothing that knows what React Native is.
2
+ //
3
+ // Deliberately separate from whatever turns an `AttributedString` into one of
4
+ // these, for the same reason `appkit/RnTextLayout.h` is separate from
5
+ // `CoreTextLayout.h`: the view layer draws paragraphs and must not gain a React
6
+ // Native dependency to do it. `basalt_win32_view` builds and is tested on a
7
+ // Windows box with nothing but a compiler and the SDK, and that is worth
8
+ // keeping -- it is the whole reason there is a test suite on this platform
9
+ // before there is a host.
10
+ //
11
+ // One object serves measurement and painting. That is not tidiness: if the two
12
+ // built layouts differently -- a different default font, a different wrap mode
13
+ // -- Yoga would allot a box computed one way and the view would paint text laid
14
+ // out another, and the result is clipped or overlapping text that looks like a
15
+ // rendering bug rather than a measurement one. The GTK side makes the same
16
+ // argument in `docs/DECISIONS.md`.
17
+ //
18
+ // Unlike Pango, DirectWrite needs no mutex around any of this. Pango's font map
19
+ // is not documented as reentrant, so GTK serialises every measurement on one
20
+ // lock and hides the cost behind a cache; a DWRITE_FACTORY_TYPE_SHARED factory
21
+ // is documented thread-safe, and this builds a fresh IDWriteTextLayout per call
22
+ // rather than mutating a held one. Fabric's layout thread and the UI thread can
23
+ // therefore measure at the same time, which on GTK they cannot.
24
+
25
+ #pragma once
26
+
27
+ #include <memory>
28
+ #include <optional>
29
+ #include <string>
30
+ #include <vector>
31
+
32
+ // Forward-declared rather than included, so a translation unit that only builds
33
+ // or measures a paragraph does not pull in <d2d1.h> and <dwrite.h> and
34
+ // windows.h behind them. The tests do exactly that.
35
+ struct ID2D1RenderTarget;
36
+ struct IDWriteTextFormat;
37
+ struct IDWriteTextLayout;
38
+
39
+ namespace basalt::win32 {
40
+
41
+ enum class RnTextAlign {
42
+ // Physical edges, which is what React Native's `left` and `right` mean: they
43
+ // stay where they are in a right-to-left paragraph, as they do on the other
44
+ // two hosts.
45
+ Left,
46
+ Center,
47
+ Right,
48
+ Justified,
49
+ // The reading direction's own start edge, which is what `natural` asks for
50
+ // and the only relative alignment left here. DirectWrite expresses it
51
+ // directly, as LEADING, so it follows the direction without this file having
52
+ // to know which way that is.
53
+ //
54
+ // `start` and `end` used to be relative too, and are not: they follow the
55
+ // *layout* direction rather than this paragraph's, which is a different
56
+ // question whenever an app shows Latin text on a mirrored desktop.
57
+ // `core/TextAlignments.h` answers it, and what arrives here is the edge.
58
+ Natural,
59
+ };
60
+
61
+ // `textDecorationStyle`, as React Native's five.
62
+ //
63
+ // DirectWrite has none of them: `SetUnderline` takes a boolean, so the style is
64
+ // drawn rather than asked for -- which is what the custom text renderer in
65
+ // RnWin32TextLayout.cpp is for, and why this host ends up with all five where
66
+ // Pango has three and Core Text four.
67
+ enum class RnTextDecorationStyle {
68
+ Solid,
69
+ Double,
70
+ Dotted,
71
+ Dashed,
72
+ Wavy,
73
+ };
74
+
75
+ // The attributes this platform honours. React Native has many more; each one
76
+ // added here is a line in `DirectWriteLayout`, which is the file that will
77
+ // translate an AttributedString once there is a mounting manager to deliver
78
+ // `lineBreakMode`, which React Native's JavaScript spells `lineBreakModeIOS`:
79
+ // how a line that does not fit its box is dealt with.
80
+ //
81
+ // `Word` is the default and wraps between words; `Char` wraps between
82
+ // characters; the other four are one line and a cut, which is the half this
83
+ // host can only half honour. DirectWrite trims at the *end* of a line and
84
+ // nowhere else -- `IDWriteTextLayout::SetTrimming` takes a granularity and a
85
+ // sign, not a position -- so `Head` and `Middle` cut the end here and
86
+ // backlog/platform-windows.md records it. Cutting the wrong end keeps the
87
+ // layout a label asked for, where wrapping would break it.
88
+ enum class RnLineBreakMode {
89
+ Word,
90
+ Char,
91
+ Clip,
92
+ Head,
93
+ Middle,
94
+ Tail,
95
+ };
96
+
97
+ // one.
98
+ struct RnTextStyle {
99
+ std::string fontFamily = "Segoe UI";
100
+ float fontSize = 14.0f;
101
+ bool bold = false;
102
+ bool italic = false;
103
+ // 0 means the font's own line spacing, which is what React Native means by an
104
+ // unset lineHeight.
105
+ float lineHeight = 0.0f;
106
+ RnTextAlign align = RnTextAlign::Left;
107
+ float color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
108
+ // `textDecorationLine`. `SetUnderline` and `SetStrikethrough` take a range
109
+ // and a boolean and nothing else, so these two say *whether* there is a line
110
+ // and the renderer in RnWin32TextLayout.cpp decides what it looks like: it is
111
+ // handed the position and thickness DirectWrite computed from the font and
112
+ // draws the line itself.
113
+ bool underline = false;
114
+ bool strikethrough = false;
115
+ // `textDecorationColor` and `textDecorationStyle`. Unset colour means the
116
+ // text's own, which is React Native's default and what the other two hosts
117
+ // do; the style is drawn by the renderer because DirectWrite has no form of
118
+ // it. See core/TextDecorations.h, which resolves both for all three hosts.
119
+ bool hasDecorationColour = false;
120
+ float decorationColour[4] = {0.0f, 0.0f, 0.0f, 0.0f};
121
+ RnTextDecorationStyle decorationStyle = RnTextDecorationStyle::Solid;
122
+ // `backgroundColor` on a `<Text>` fragment: the box behind the glyphs, which
123
+ // DirectWrite also does not draw -- it draws glyphs and nothing else. Pango
124
+ // has a background attribute and Core Text fills the rectangle itself.
125
+ bool hasBackgroundColour = false;
126
+ float backgroundColour[4] = {0.0f, 0.0f, 0.0f, 0.0f};
127
+ // `writingDirection`, which decides the order of the glyphs in a line and
128
+ // which edge the line starts from. False is left-to-right, and is also what
129
+ // `natural` resolves to for Latin text.
130
+ bool rightToLeft = false;
131
+ // `letterSpacing`, in the same points everything else here is in. Zero is
132
+ // React Native's unset, which is also "no extra space", so the two need no
133
+ // distinction -- unlike `lineHeight`, where zero means "the font's own".
134
+ //
135
+ // Added *after* each character, which is what CSS's letter-spacing and iOS's
136
+ // kerning both do: DirectWrite calls that trailing spacing.
137
+ float letterSpacing = 0.0f;
138
+ // `fontVariant`, as OpenType tags: "smcp", "tnum", "ss07". Resolved by
139
+ // `core/FontVariants.h`, which the GTK host uses in the same form; DirectWrite
140
+ // takes them as a `DWRITE_FONT_FEATURE_TAG` each, on an `IDWriteTypography`.
141
+ //
142
+ // Whether a font actually has a feature is the font's business: DirectWrite
143
+ // asks for it and a face without it renders unchanged, which is why nothing
144
+ // here asserts on the pixels.
145
+ std::vector<std::string> fontFeatures;
146
+ // `lineBreakMode`. A paragraph's rather than a run's, like the alignment and
147
+ // the reading direction above it: the format is built from the first run's
148
+ // style and this is one of the properties that lives there.
149
+ RnLineBreakMode lineBreakMode = RnLineBreakMode::Word;
150
+ };
151
+
152
+ struct RnTextSize {
153
+ float width = 0.0f;
154
+ float height = 0.0f;
155
+ };
156
+
157
+ // An inline `<View>` inside a `<Text>`, as the text layout sees it: a box that
158
+ // occupies space and draws nothing.
159
+ //
160
+ // React Native has already laid the view out and the mounting manager will
161
+ // paint it, so all the paragraph has to do is reserve the room and say where it
162
+ // landed. The box's *bottom* sits on the text baseline, which is where CSS puts
163
+ // an inline box with no explicit vertical alignment and what the other two
164
+ // hosts' shape attributes and run delegates do.
165
+ struct RnInlineBox {
166
+ float width = 0.0f;
167
+ float height = 0.0f;
168
+ };
169
+
170
+ // One styled span of a paragraph.
171
+ //
172
+ // React Native's `<Text>` is not one string with one style: a
173
+ // ParagraphShadowNode folds its whole subtree into an AttributedString of
174
+ // fragments, each with its own font, size and weight. A layout built from only
175
+ // the first fragment's style renders `Hello <b>world</b>` entirely unbold,
176
+ // which measures wrong as well as looking wrong.
177
+ struct RnTextRun {
178
+ std::string text;
179
+ RnTextStyle style;
180
+ // Set when this run is an attachment rather than text. Its `text` is then
181
+ // React Native's own placeholder character, which is what the inline object
182
+ // is attached to and is never drawn.
183
+ std::optional<RnInlineBox> inlineBox;
184
+ };
185
+
186
+ // Where an inline box landed, in the paragraph's own coordinates.
187
+ struct RnAttachmentBox {
188
+ float x = 0.0f;
189
+ float y = 0.0f;
190
+ float width = 0.0f;
191
+ float height = 0.0f;
192
+ };
193
+
194
+ class RnWin32TextLayout {
195
+ public:
196
+ // `maximumNumberOfLines` of 0 means no limit, matching
197
+ // ParagraphAttributes::maximumNumberOfLines. Returns null if DirectWrite
198
+ // could not produce a text format, which in practice means the process has no
199
+ // DirectWrite at all.
200
+ static std::shared_ptr<RnWin32TextLayout>
201
+ create(std::string utf8Text, const RnTextStyle &style, int maximumNumberOfLines);
202
+
203
+ // The same thing for a paragraph of differently styled spans. The first run's
204
+ // style sets the paragraph defaults -- alignment and line height, which
205
+ // DirectWrite has no per-range form of -- and each run's font family, size,
206
+ // weight, slant and colour are applied over its own character range.
207
+ //
208
+ // Colour is the odd one, and `draw` is where it happens: DirectWrite carries
209
+ // it as a drawing effect rather than as a range attribute, and a drawing
210
+ // effect is only meaningful to whoever renders the layout.
211
+ static std::shared_ptr<RnWin32TextLayout>
212
+ createFromRuns(const std::vector<RnTextRun> &runs, int maximumNumberOfLines);
213
+
214
+ ~RnWin32TextLayout();
215
+
216
+ RnWin32TextLayout(const RnWin32TextLayout &) = delete;
217
+ RnWin32TextLayout &operator=(const RnWin32TextLayout &) = delete;
218
+
219
+ // The original UTF-8, for `describeTree`. Kept alongside the UTF-16 copy
220
+ // DirectWrite needs so that the cross-host dump does not depend on a
221
+ // conversion round-tripping.
222
+ const std::string &text() const { return utf8_; }
223
+
224
+ const RnTextStyle &style() const { return style_; }
225
+ int maximumNumberOfLines() const { return maximumNumberOfLines_; }
226
+
227
+ // `textShadowColor`, `textShadowOffset` and `textShadowRadius`: one shadow
228
+ // for the whole paragraph, resolved by `core/TextShadows.h`.
229
+ //
230
+ // One rather than one per fragment, which is the same decision both other
231
+ // hosts made for the same reason: neither engine can draw a different shadow
232
+ // per run, so the first fragment that asks for one decides it. `sd` is the
233
+ // gaussian's standard deviation, which is what Direct2D's shadow effect takes
234
+ // too, so nothing converts here.
235
+ void setShadow(float dx, float dy, float standardDeviation, const float colour[4]);
236
+ bool hasShadow() const { return shadowColour_[3] > 0.0f; }
237
+ float shadowDx() const { return shadowDx_; }
238
+ float shadowDy() const { return shadowDy_; }
239
+ float shadowStandardDeviation() const { return shadowStandardDeviation_; }
240
+ const float *shadowColour() const { return shadowColour_; }
241
+
242
+ // The size this paragraph needs at `maxWidth`. Pass a negative width for
243
+ // unconstrained. In React Native's density-independent pixels, like every
244
+ // other coordinate here: DirectWrite measures in DIPs at 96 dpi and nothing
245
+ // multiplies by a scale factor, which is what keeps a `fontSize` of 16 the
246
+ // same sixteen units it is on the other two desktops.
247
+ RnTextSize measure(float maxWidth) const;
248
+
249
+ // Draws at the target's current origin, into a box `width` by `height`.
250
+ void draw(ID2D1RenderTarget *target, float width, float height) const;
251
+
252
+ // How far down a box this tall the paragraph is drawn: zero unless
253
+ // `setVerticalFlush` said otherwise, and the number the draw and the hit test
254
+ // both work from.
255
+ //
256
+ // Public because an inline `<View>` has to move with the text it sits in:
257
+ // React Native places an attachment from the top of the content box and knows
258
+ // nothing about `textAlignVertical`.
259
+ float verticalOffsetFor(float width, float height) const;
260
+
261
+ // --- Selecting that text ----------------------------------------------------
262
+ //
263
+ // `<Text selectable>`, which `userSelect` also arrives in. The two questions
264
+ // that need DirectWrite -- where a point lands in the text, and what a range
265
+ // covers -- plus the substring a clipboard takes. What a press and a drag
266
+ // *mean* is core/TextSelection.h, shared with the other two hosts.
267
+ //
268
+ // Offsets are UTF-16 code units, which is what DirectWrite counts and what
269
+ // this object already holds alongside the UTF-8 it was given. The AppKit host
270
+ // counts the same unit and the GTK one counts bytes; core/TextSelection.h
271
+ // says why the three never have to agree.
272
+
273
+ // The range to draw as selected. A length of zero selects nothing, which is
274
+ // how a selection is cleared.
275
+ //
276
+ // `unsigned` rather than DirectWrite's `UINT32`, which is the same type and
277
+ // needs windows.h: this header forward-declares the COM interfaces so that a
278
+ // translation unit which only draws need not include it, and the runs below
279
+ // count in `unsigned` for the same reason.
280
+ void setSelection(unsigned start, unsigned length);
281
+ unsigned selectionStart() const { return selectionStart_; }
282
+ unsigned selectionLength() const { return selectionLength_; }
283
+
284
+ // The offset nearest a point in the paragraph's own coordinates, inside a box
285
+ // of (width, height) -- the same box `draw` is given, because the answer
286
+ // depends on all of it: the width breaks the lines and the height is what
287
+ // `textAlignVertical` moved the paragraph inside.
288
+ unsigned indexAtPoint(float x, float y, float width, float height) const;
289
+
290
+ // The selected text, in UTF-8, or empty when nothing is selected.
291
+ std::string selectedText() const;
292
+
293
+ // How far down its own box the paragraph sits: 0 for the top, 0.5 for the
294
+ // middle, 1 for the bottom, which is what `textAlignVertical` asks for and
295
+ // what `verticalAlign` becomes in React Native's own JavaScript. The offset
296
+ // it produces is core/TextVerticalAlign.h's, applied in `draw` -- the box is
297
+ // only known then, a view resized without its props changing having new slack
298
+ // and the same text.
299
+ //
300
+ // Not `SetParagraphAlignment`, which is DirectWrite's own answer to this
301
+ // question: `applyLineLimit` sets the layout's maximum height to the lines
302
+ // that fit, so FAR would align against the trimmed box rather than the view's
303
+ // and a `numberOfLines` paragraph would not move at all. The draw origin is
304
+ // the same arithmetic the other two hosts do, over the box this is given.
305
+ void setVerticalFlush(float flush) {
306
+ verticalFlush_ = flush;
307
+ // The cached offset was computed against the old flush.
308
+ offsetWidth_ = -1.0f;
309
+ }
310
+
311
+ // Where each inline box landed, in the order the attachment runs were given,
312
+ // laid out at `maxWidth` -- the same width `measure` would be asked, so the
313
+ // positions belong to the paragraph Yoga was told about.
314
+ //
315
+ // Empty when the paragraph has no attachments, which is almost all of them.
316
+ // The width and height are the ones React Native measured rather than
317
+ // anything DirectWrite echoes back, so a rounding difference in the reserved
318
+ // box cannot move the view a fraction of a point from its own layout.
319
+ std::vector<RnAttachmentBox> attachmentBoxes(float maxWidth) const;
320
+
321
+ private:
322
+ RnWin32TextLayout() = default;
323
+
324
+ // The one place a layout is configured. Both `measure` and `draw` go through
325
+ // it, which is what makes the size Yoga is told the size the text is painted
326
+ // at.
327
+ //
328
+ // Returns a reference the caller owns and must release; the two callers do it
329
+ // with a ComPtr. A fresh layout per call rather than one held and mutated,
330
+ // because `SetMaxWidth` on a shared layout is exactly the race that a
331
+ // thread-safe factory would otherwise have saved us from.
332
+ IDWriteTextLayout *buildLayout(float maxWidth, float maxHeight) const;
333
+
334
+ // Applies `maximumNumberOfLines` to a built layout, and reports the height it
335
+ // is now limited to, or a negative number for "no limit applied". Separate
336
+ // because DirectWrite has no line-count property: the limit has to be turned
337
+ // into a height by adding up the line metrics, which means the layout must
338
+ // already exist.
339
+ float applyLineLimit(IDWriteTextLayout *layout) const;
340
+
341
+ // A styled span, resolved to UTF-16 character positions, which is what
342
+ // DirectWrite's ranges are counted in. Empty for a single-style paragraph,
343
+ // where the format alone says everything.
344
+ struct ResolvedRun {
345
+ unsigned start = 0;
346
+ unsigned length = 0;
347
+ RnTextStyle style;
348
+ std::optional<RnInlineBox> inlineBox;
349
+ };
350
+
351
+ // Drawing a shadow needs an effect, which needs a device context: the view
352
+ // layer hands over an ID2D1RenderTarget, and this asks it for one. See
353
+ // `draw`.
354
+ float verticalFlush_ = 0.0f;
355
+ // The last answer `verticalOffsetFor` gave, and the box it was asked about.
356
+ // A hit test asks once per view it walks into and a paint once per frame, and
357
+ // answering means building a DirectWrite layout -- which is the expensive
358
+ // half of moving a pointer across a paragraph. Mutable because the question
359
+ // is const and the memory of it is not.
360
+ mutable float offsetWidth_ = -1.0f;
361
+ mutable float offsetHeight_ = -1.0f;
362
+ mutable float offsetValue_ = 0.0f;
363
+ unsigned selectionStart_ = 0;
364
+ unsigned selectionLength_ = 0;
365
+
366
+ // The highlight, under the glyphs. Its own method for the reason the shadow's
367
+ // is: it draws before the runs and needs the layout the caller just built.
368
+ void drawSelection(ID2D1RenderTarget *target,
369
+ IDWriteTextLayout *layout,
370
+ float verticalOffset) const;
371
+
372
+ void drawShadow(ID2D1RenderTarget *target,
373
+ IDWriteTextLayout *layout,
374
+ float width,
375
+ float height,
376
+ float verticalOffset) const;
377
+
378
+ std::string utf8_;
379
+ std::wstring utf16_;
380
+ RnTextStyle style_;
381
+ std::vector<ResolvedRun> runs_;
382
+ int maximumNumberOfLines_ = 0;
383
+ float shadowDx_ = 0.0f;
384
+ float shadowDy_ = 0.0f;
385
+ float shadowStandardDeviation_ = 0.0f;
386
+ float shadowColour_[4] = {0.0f, 0.0f, 0.0f, 0.0f};
387
+ IDWriteTextFormat *format_ = nullptr;
388
+ };
389
+
390
+ } // namespace basalt::win32