Flutter Engine
The Flutter Engine
third_party
txt
src
txt
placeholder_run.h
Go to the documentation of this file.
1
/*
2
* Copyright 2019 Google Inc.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#ifndef LIB_TXT_SRC_PLACEHOLDER_RUN_H_
18
#define LIB_TXT_SRC_PLACEHOLDER_RUN_H_
19
20
#include "
text_baseline.h
"
21
22
namespace
txt
{
23
24
/// Where to vertically align the placeholder relative to the surrounding text.
25
enum class
PlaceholderAlignment
{
26
/// Match the baseline of the placeholder with the baseline.
27
kBaseline,
28
29
/// Align the bottom edge of the placeholder with the baseline such that the
30
/// placeholder sits on top of the baseline.
31
kAboveBaseline,
32
33
/// Align the top edge of the placeholder with the baseline specified in
34
/// such that the placeholder hangs below the baseline.
35
kBelowBaseline,
36
37
/// Align the top edge of the placeholder with the top edge of the font.
38
/// When the placeholder is very tall, the extra space will hang from
39
/// the top and extend through the bottom of the line.
40
kTop
,
41
42
/// Align the bottom edge of the placeholder with the top edge of the font.
43
/// When the placeholder is very tall, the extra space will rise from
44
/// the bottom and extend through the top of the line.
45
kBottom,
46
47
/// Align the middle of the placeholder with the middle of the text. When the
48
/// placeholder is very tall, the extra space will grow equally from
49
/// the top and bottom of the line.
50
kMiddle,
51
};
52
53
// Represents the metrics required to fully define a rect that will fit a
54
// placeholder.
55
//
56
// LibTxt will leave an empty space in the layout of the text of the size
57
// defined by this class. After layout, the framework will draw placeholders
58
// into the reserved space.
59
class
PlaceholderRun
{
60
public
:
61
double
width
= 0;
62
double
height
= 0;
63
64
PlaceholderAlignment
alignment
;
65
66
TextBaseline
baseline
;
67
68
// Distance from the top edge of the rect to the baseline position. This
69
// baseline will be aligned against the alphabetic baseline of the surrounding
70
// text.
71
//
72
// Positive values drop the baseline lower (positions the rect higher) and
73
// small or negative values will cause the rect to be positioned underneath
74
// the line. When baseline == height, the bottom edge of the rect will rest on
75
// the alphabetic baseline.
76
double
baseline_offset
= 0;
77
78
PlaceholderRun
();
79
80
PlaceholderRun
(
double
width
,
81
double
height
,
82
PlaceholderAlignment
alignment
,
83
TextBaseline
baseline
,
84
double
baseline_offset
);
85
};
86
87
}
// namespace txt
88
89
#endif
// LIB_TXT_SRC_PLACEHOLDER_RUN_H_
GrQuadAAFlags::kTop
@ kTop
txt::PlaceholderRun
Definition:
placeholder_run.h:59
txt::PlaceholderRun::PlaceholderRun
PlaceholderRun()
Definition:
placeholder_run.cc:21
txt::PlaceholderRun::width
double width
Definition:
placeholder_run.h:61
txt::PlaceholderRun::baseline_offset
double baseline_offset
Definition:
placeholder_run.h:76
txt::PlaceholderRun::baseline
TextBaseline baseline
Definition:
placeholder_run.h:66
txt::PlaceholderRun::height
double height
Definition:
placeholder_run.h:62
txt::PlaceholderRun::alignment
PlaceholderAlignment alignment
Definition:
placeholder_run.h:64
txt
Definition:
paragraph_builder_skia.cc:27
txt::PlaceholderAlignment
PlaceholderAlignment
Where to vertically align the placeholder relative to the surrounding text.
Definition:
placeholder_run.h:25
txt::TextBaseline
TextBaseline
Definition:
text_baseline.h:22
text_baseline.h
Generated on Sun Jun 23 2024 21:56:53 for Flutter Engine by
1.9.4