|
@@ -20,6 +20,7 @@ class EditableBox extends SingleChildRenderObjectWidget {
|
20
|
20
|
@required this.showCursor,
|
21
|
21
|
@required this.selection,
|
22
|
22
|
@required this.selectionColor,
|
|
23
|
+ @required this.cursorColor,
|
23
|
24
|
}) : super(child: child);
|
24
|
25
|
|
25
|
26
|
final ContainerNode node;
|
|
@@ -28,6 +29,7 @@ class EditableBox extends SingleChildRenderObjectWidget {
|
28
|
29
|
final ValueNotifier<bool> showCursor;
|
29
|
30
|
final TextSelection selection;
|
30
|
31
|
final Color selectionColor;
|
|
32
|
+ final Color cursorColor;
|
31
|
33
|
|
32
|
34
|
@override
|
33
|
35
|
RenderEditableProxyBox createRenderObject(BuildContext context) {
|
|
@@ -38,6 +40,7 @@ class EditableBox extends SingleChildRenderObjectWidget {
|
38
|
40
|
showCursor: showCursor,
|
39
|
41
|
selection: selection,
|
40
|
42
|
selectionColor: selectionColor,
|
|
43
|
+ cursorColor: cursorColor,
|
41
|
44
|
);
|
42
|
45
|
}
|
43
|
46
|
|
|
@@ -50,7 +53,8 @@ class EditableBox extends SingleChildRenderObjectWidget {
|
50
|
53
|
..renderContext = renderContext
|
51
|
54
|
..showCursor = showCursor
|
52
|
55
|
..selection = selection
|
53
|
|
- ..selectionColor = selectionColor;
|
|
56
|
+ ..selectionColor = selectionColor
|
|
57
|
+ ..cursorColor = cursorColor;
|
54
|
58
|
}
|
55
|
59
|
}
|
56
|
60
|
|
|
@@ -67,6 +71,7 @@ class RenderEditableProxyBox extends RenderBox
|
67
|
71
|
@required ValueNotifier<bool> showCursor,
|
68
|
72
|
@required TextSelection selection,
|
69
|
73
|
@required Color selectionColor,
|
|
74
|
+ @required Color cursorColor,
|
70
|
75
|
}) : _node = node,
|
71
|
76
|
_layerLink = layerLink,
|
72
|
77
|
_renderContext = renderContext,
|
|
@@ -75,6 +80,16 @@ class RenderEditableProxyBox extends RenderBox
|
75
|
80
|
_selectionColor = selectionColor,
|
76
|
81
|
super() {
|
77
|
82
|
this.child = child;
|
|
83
|
+ _cursorPainter = CursorPainter(cursorColor);
|
|
84
|
+ }
|
|
85
|
+
|
|
86
|
+ CursorPainter _cursorPainter;
|
|
87
|
+
|
|
88
|
+ set cursorColor(Color value) {
|
|
89
|
+ if (_cursorPainter.color != value) {
|
|
90
|
+ _cursorPainter.color = value;
|
|
91
|
+ markNeedsPaint();
|
|
92
|
+ }
|
78
|
93
|
}
|
79
|
94
|
|
80
|
95
|
bool _isDirty = true;
|
|
@@ -171,7 +186,7 @@ class RenderEditableProxyBox extends RenderBox
|
171
|
186
|
@mustCallSuper
|
172
|
187
|
void performLayout() {
|
173
|
188
|
super.performLayout();
|
174
|
|
- _caretPainter.layout(preferredLineHeight);
|
|
189
|
+ _cursorPainter.layout(preferredLineHeight);
|
175
|
190
|
// Indicate to render context that this object can be used by other
|
176
|
191
|
// layers (selection overlay, for instance).
|
177
|
192
|
_isDirty = false;
|
|
@@ -196,16 +211,14 @@ class RenderEditableProxyBox extends RenderBox
|
196
|
211
|
paintSelection(context, offset, selection, selectionColor);
|
197
|
212
|
}
|
198
|
213
|
if (isCaretVisible) {
|
199
|
|
- _paintCaret(context, offset);
|
|
214
|
+ _paintCursor(context, offset);
|
200
|
215
|
}
|
201
|
216
|
}
|
202
|
217
|
|
203
|
|
- final CaretPainter _caretPainter = new CaretPainter();
|
204
|
|
-
|
205
|
|
- void _paintCaret(PaintingContext context, Offset offset) {
|
|
218
|
+ void _paintCursor(PaintingContext context, Offset offset) {
|
206
|
219
|
Offset caretOffset =
|
207
|
|
- getOffsetForCaret(_selection.extent, _caretPainter.prototype);
|
208
|
|
- _caretPainter.paint(context.canvas, caretOffset + offset);
|
|
220
|
+ getOffsetForCaret(_selection.extent, _cursorPainter.prototype);
|
|
221
|
+ _cursorPainter.paint(context.canvas, caretOffset + offset);
|
209
|
222
|
}
|
210
|
223
|
|
211
|
224
|
@override
|