Flutter Engine
Loading...
Searching...
No Matches
placeholder_run.h
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#ifndef FLUTTER_TXT_SRC_TXT_PLACEHOLDER_RUN_H_
6
#define FLUTTER_TXT_SRC_TXT_PLACEHOLDER_RUN_H_
7
8
#include "
text_baseline.h
"
9
10
namespace
txt
{
11
12
/// Where to vertically align the placeholder relative to the surrounding text.
13
enum class
PlaceholderAlignment
{
14
/// Match the baseline of the placeholder with the baseline.
15
kBaseline
,
16
17
/// Align the bottom edge of the placeholder with the baseline such that the
18
/// placeholder sits on top of the baseline.
19
kAboveBaseline
,
20
21
/// Align the top edge of the placeholder with the baseline specified in
22
/// such that the placeholder hangs below the baseline.
23
kBelowBaseline
,
24
25
/// Align the top edge of the placeholder with the top edge of the font.
26
/// When the placeholder is very tall, the extra space will hang from
27
/// the top and extend through the bottom of the line.
28
kTop
,
29
30
/// Align the bottom edge of the placeholder with the top edge of the font.
31
/// When the placeholder is very tall, the extra space will rise from
32
/// the bottom and extend through the top of the line.
33
kBottom
,
34
35
/// Align the middle of the placeholder with the middle of the text. When the
36
/// placeholder is very tall, the extra space will grow equally from
37
/// the top and bottom of the line.
38
kMiddle
,
39
};
40
41
// Represents the metrics required to fully define a rect that will fit a
42
// placeholder.
43
//
44
// LibTxt will leave an empty space in the layout of the text of the size
45
// defined by this class. After layout, the framework will draw placeholders
46
// into the reserved space.
47
class
PlaceholderRun
{
48
public
:
49
double
width
= 0;
50
double
height
= 0;
51
52
PlaceholderAlignment
alignment
;
53
54
TextBaseline
baseline
;
55
56
// Distance from the top edge of the rect to the baseline position. This
57
// baseline will be aligned against the alphabetic baseline of the surrounding
58
// text.
59
//
60
// Positive values drop the baseline lower (positions the rect higher) and
61
// small or negative values will cause the rect to be positioned underneath
62
// the line. When baseline == height, the bottom edge of the rect will rest on
63
// the alphabetic baseline.
64
double
baseline_offset
= 0;
65
66
PlaceholderRun
();
67
68
PlaceholderRun
(
double
width
,
69
double
height
,
70
PlaceholderAlignment
alignment
,
71
TextBaseline
baseline
,
72
double
baseline_offset
);
73
};
74
75
}
// namespace txt
76
77
#endif
// FLUTTER_TXT_SRC_TXT_PLACEHOLDER_RUN_H_
txt::PlaceholderRun
Definition
placeholder_run.h:47
txt::PlaceholderRun::PlaceholderRun
PlaceholderRun()
Definition
placeholder_run.cc:9
txt::PlaceholderRun::width
double width
Definition
placeholder_run.h:49
txt::PlaceholderRun::baseline_offset
double baseline_offset
Definition
placeholder_run.h:64
txt::PlaceholderRun::baseline
TextBaseline baseline
Definition
placeholder_run.h:54
txt::PlaceholderRun::height
double height
Definition
placeholder_run.h:50
txt::PlaceholderRun::alignment
PlaceholderAlignment alignment
Definition
placeholder_run.h:52
txt
Definition
paragraph_builder_skia.cc:15
txt::PlaceholderAlignment
PlaceholderAlignment
Where to vertically align the placeholder relative to the surrounding text.
Definition
placeholder_run.h:13
txt::PlaceholderAlignment::kBelowBaseline
@ kBelowBaseline
txt::PlaceholderAlignment::kBaseline
@ kBaseline
Match the baseline of the placeholder with the baseline.
txt::PlaceholderAlignment::kBottom
@ kBottom
txt::PlaceholderAlignment::kAboveBaseline
@ kAboveBaseline
txt::PlaceholderAlignment::kMiddle
@ kMiddle
txt::PlaceholderAlignment::kTop
@ kTop
txt::TextBaseline
TextBaseline
Definition
text_baseline.h:10
text_baseline.h
txt
src
txt
placeholder_run.h
Generated on Thu Nov 6 2025 16:11:30 for Flutter Engine by
1.9.8