Create struct for glyph heights

pull/1128/head
Adil Hanney 2 years ago
parent 504335ed15
commit 0b0e671fca
  1. 20
      lib/src/widgets/raw_editor.dart

@ -332,8 +332,8 @@ class RawEditorState extends EditorState
final points = renderEditor.getEndpointsForSelection(selection); final points = renderEditor.getEndpointsForSelection(selection);
return TextSelectionToolbarAnchors.fromSelection( return TextSelectionToolbarAnchors.fromSelection(
renderBox: renderEditor, renderBox: renderEditor,
startGlyphHeight: glyphHeights.item1, startGlyphHeight: glyphHeights.startGlyphHeight,
endGlyphHeight: glyphHeights.item2, endGlyphHeight: glyphHeights.endGlyphHeight,
selectionEndpoints: points, selectionEndpoints: points,
); );
} }
@ -342,7 +342,7 @@ class RawEditorState extends EditorState
/// [RawEditorState]. /// [RawEditorState].
/// ///
/// Copied from [EditableTextState]. /// Copied from [EditableTextState].
Tuple2<double, double> _getGlyphHeights() { _GlyphHeights _getGlyphHeights() {
final selection = textEditingValue.selection; final selection = textEditingValue.selection;
// Only calculate handle rects if the text in the previous frame // Only calculate handle rects if the text in the previous frame
@ -355,7 +355,7 @@ class RawEditorState extends EditorState
final prevText = renderEditor.document.toPlainText(); final prevText = renderEditor.document.toPlainText();
final currText = textEditingValue.text; final currText = textEditingValue.text;
if (prevText != currText || !selection.isValid || selection.isCollapsed) { if (prevText != currText || !selection.isValid || selection.isCollapsed) {
return Tuple2( return _GlyphHeights(
renderEditor.preferredLineHeight(selection.base), renderEditor.preferredLineHeight(selection.base),
renderEditor.preferredLineHeight(selection.base), renderEditor.preferredLineHeight(selection.base),
); );
@ -365,7 +365,7 @@ class RawEditorState extends EditorState
renderEditor.getLocalRectForCaret(selection.base); renderEditor.getLocalRectForCaret(selection.base);
final endCharacterRect = final endCharacterRect =
renderEditor.getLocalRectForCaret(selection.extent); renderEditor.getLocalRectForCaret(selection.extent);
return Tuple2( return _GlyphHeights(
startCharacterRect.height, startCharacterRect.height,
endCharacterRect.height, endCharacterRect.height,
); );
@ -2428,3 +2428,13 @@ typedef QuillEditorContextMenuBuilder = Widget Function(
BuildContext context, BuildContext context,
RawEditorState rawEditorState, RawEditorState rawEditorState,
); );
class _GlyphHeights {
_GlyphHeights(
this.startGlyphHeight,
this.endGlyphHeight,
);
final double startGlyphHeight;
final double endGlyphHeight;
}

Loading…
Cancel
Save