|
@@ -10,6 +10,7 @@ import 'package:zefyr/util.dart';
|
10
|
10
|
|
11
|
11
|
import 'controller.dart';
|
12
|
12
|
import 'editable_box.dart';
|
|
13
|
+import 'render_context.dart';
|
13
|
14
|
import 'scope.dart';
|
14
|
15
|
|
15
|
16
|
RenderEditableBox _getEditableBox(HitTestResult result) {
|
|
@@ -232,8 +233,7 @@ class _ZefyrSelectionOverlayState extends State<ZefyrSelectionOverlay>
|
232
|
233
|
|
233
|
234
|
RenderEditableProxyBox box = _getEditableBox(result);
|
234
|
235
|
if (box == null) {
|
235
|
|
- final scope = ZefyrScope.of(context);
|
236
|
|
- box = scope.renderContext.closestBoxForGlobalPoint(globalPoint);
|
|
236
|
+ box = _editor.renderContext.closestBoxForGlobalPoint(globalPoint);
|
237
|
237
|
}
|
238
|
238
|
if (box == null) return null;
|
239
|
239
|
|
|
@@ -349,14 +349,13 @@ class _SelectionHandleDriverState extends State<SelectionHandleDriver> {
|
349
|
349
|
|
350
|
350
|
@override
|
351
|
351
|
Widget build(BuildContext context) {
|
352
|
|
- final scope = ZefyrScope.of(context);
|
353
|
352
|
if (selection == null ||
|
354
|
353
|
selection.isCollapsed ||
|
355
|
354
|
widget.controls == null ||
|
356
|
|
- scope.focusOwner != FocusOwner.editor) {
|
|
355
|
+ _scope.focusOwner != FocusOwner.editor) {
|
357
|
356
|
return new Container();
|
358
|
357
|
}
|
359
|
|
- final block = scope.renderContext.boxForTextOffset(documentOffset);
|
|
358
|
+ final block = _scope.renderContext.boxForTextOffset(documentOffset);
|
360
|
359
|
final position = getPosition(block);
|
361
|
360
|
Widget handle;
|
362
|
361
|
if (position == null) {
|
|
@@ -400,9 +399,11 @@ class _SelectionHandleDriverState extends State<SelectionHandleDriver> {
|
400
|
399
|
Offset _dragPosition;
|
401
|
400
|
|
402
|
401
|
void _handleScopeChange() {
|
403
|
|
- setState(() {
|
404
|
|
- _selection = _scope.selection;
|
405
|
|
- });
|
|
402
|
+ if (_selection != _scope.selection) {
|
|
403
|
+ setState(() {
|
|
404
|
+ _selection = _scope.selection;
|
|
405
|
+ });
|
|
406
|
+ }
|
406
|
407
|
}
|
407
|
408
|
|
408
|
409
|
void _handleDragStart(DragStartDetails details) {
|
|
@@ -412,8 +413,7 @@ class _SelectionHandleDriverState extends State<SelectionHandleDriver> {
|
412
|
413
|
void _handleDragUpdate(DragUpdateDetails details) {
|
413
|
414
|
_dragPosition += details.delta;
|
414
|
415
|
final globalPoint = _dragPosition;
|
415
|
|
- final scope = ZefyrScope.of(context);
|
416
|
|
- final paragraph = scope.renderContext.boxForGlobalPoint(globalPoint);
|
|
416
|
+ final paragraph = _scope.renderContext.boxForGlobalPoint(globalPoint);
|
417
|
417
|
if (paragraph == null) {
|
418
|
418
|
return;
|
419
|
419
|
}
|
|
@@ -430,7 +430,7 @@ class _SelectionHandleDriverState extends State<SelectionHandleDriver> {
|
430
|
430
|
}
|
431
|
431
|
|
432
|
432
|
if (newSelection != _selection) {
|
433
|
|
- scope.updateSelection(newSelection, source: ChangeSource.local);
|
|
433
|
+ _scope.updateSelection(newSelection, source: ChangeSource.local);
|
434
|
434
|
}
|
435
|
435
|
}
|
436
|
436
|
}
|
|
@@ -468,7 +468,6 @@ class _SelectionToolbarState extends State<_SelectionToolbar> {
|
468
|
468
|
return Container();
|
469
|
469
|
}
|
470
|
470
|
final boxes = block.getEndpointsForSelection(selection);
|
471
|
|
-
|
472
|
471
|
// Find the horizontal midpoint, just above the selected text.
|
473
|
472
|
final Offset midpoint = new Offset(
|
474
|
473
|
(boxes.length == 1)
|
|
@@ -481,7 +480,6 @@ class _SelectionToolbarState extends State<_SelectionToolbar> {
|
481
|
480
|
block.localToGlobal(Offset.zero),
|
482
|
481
|
block.localToGlobal(block.size.bottomRight(Offset.zero)),
|
483
|
482
|
);
|
484
|
|
-
|
485
|
483
|
final toolbar = widget.controls
|
486
|
484
|
.buildToolbar(context, editingRegion, midpoint, widget.delegate);
|
487
|
485
|
return new CompositedTransformFollower(
|