Flutter Engine
The Flutter Engine
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
22namespace txt {
23
24/// Where to vertically align the placeholder relative to the surrounding text.
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.
60 public:
61 double width = 0;
62 double height = 0;
63
65
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
79
80 PlaceholderRun(double width,
81 double height,
84 double baseline_offset);
85};
86
87} // namespace txt
88
89#endif // LIB_TXT_SRC_PLACEHOLDER_RUN_H_
TextBaseline baseline
PlaceholderAlignment alignment
PlaceholderAlignment
Where to vertically align the placeholder relative to the surrounding text.
TextBaseline
Definition: text_baseline.h:22