| Flutter Impeller |

line_metrics.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_IMPELLER_TOOLKIT_INTEROP_LINE_METRICS_H_
6 #define FLUTTER_IMPELLER_TOOLKIT_INTEROP_LINE_METRICS_H_
7
8 #include <map>
9
10 #include "flutter/txt/src/txt/line_metrics.h"
11 #include "impeller/toolkit/interop/impeller.h"
12 #include "impeller/toolkit/interop/object.h"
13
14 namespace impeller::interop {
15
16 //------------------------------------------------------------------------------
17 /// @brief Internal C++ peer of ImpellerLineMetrics. For detailed
18 /// documentation, refer to the headerdocs in the public API in
19 /// impeller.h.
20 ///
21 /// Accessing metrics of missing lines returns default initialized
22 /// values.
23 ///
24 class LineMetrics final
25 : public Object<LineMetrics,
26 IMPELLER_INTERNAL_HANDLE_NAME(ImpellerLineMetrics)> {
27 public:
28 explicit LineMetrics(const std::vector<txt::LineMetrics>& metrics);
29
30 ~LineMetrics();
31
32 LineMetrics(const LineMetrics&) = delete;
33
34 LineMetrics& operator=(const LineMetrics&) = delete;
35
36 //----------------------------------------------------------------------------
37 /// @see ImpellerLineMetricsGetAscent.
38 ///
39 double GetAscent(size_t line) const;
40
41 //----------------------------------------------------------------------------
42 /// @see ImpellerLineMetricsGetUnscaledAscent.
43 ///
44 double GetUnscaledAscent(size_t line) const;
45
46 //----------------------------------------------------------------------------
47 /// @see ImpellerLineMetricsGetDescent.
48 ///
49 double GetDescent(size_t line) const;
50
51 //----------------------------------------------------------------------------
52 /// @see ImpellerLineMetricsGetBaseline.
53 ///
54 double GetBaseline(size_t line) const;
55
56 //----------------------------------------------------------------------------
57 /// @see ImpellerLineMetricsIsHardbreak.
58 ///
59 bool IsHardbreak(size_t line) const;
60
61 //----------------------------------------------------------------------------
62 /// @see ImpellerLineMetricsGetWidth.
63 ///
64 double GetWidth(size_t line) const;
65
66 //----------------------------------------------------------------------------
67 /// @see ImpellerLineMetricsGetHeight.
68 ///
69 double GetHeight(size_t line) const;
70
71 //----------------------------------------------------------------------------
72 /// @see ImpellerLineMetricsGetLeft.
73 ///
74 double GetLeft(size_t line) const;
75
76 //----------------------------------------------------------------------------
77 /// @see ImpellerLineMetricsGetCodeUnitStartIndex.
78 ///
79 size_t GetCodeUnitStartIndex(size_t line) const;
80
81 //----------------------------------------------------------------------------
82 /// @see ImpellerLineMetricsGetCodeUnitEndIndex.
83 ///
84 size_t GetCodeUnitEndIndex(size_t line) const;
85
86 //----------------------------------------------------------------------------
87 /// @see ImpellerLineMetricsGetCodeUnitEndIndexExcludingWhitespace.
88 ///
89 size_t GetCodeUnitEndIndexExcludingWhitespace(size_t line) const;
90
91 //----------------------------------------------------------------------------
92 /// @see ImpellerLineMetricsGetCodeUnitEndIndexIncludingNewline.
93 ///
94 size_t GetCodeUnitEndIndexIncludingNewline(size_t line) const;
95
96 private:
97 std::map<size_t /* line number */, txt::LineMetrics> metrics_;
98
99 const txt::LineMetrics& GetLine(size_t line) const;
100 };
101
102 } // namespace impeller::interop
103
104 #endif // FLUTTER_IMPELLER_TOOLKIT_INTEROP_LINE_METRICS_H_
impeller::interop::LineMetrics
Internal C++ peer of ImpellerLineMetrics. For detailed documentation, refer to the headerdocs in the ...
Definition: line_metrics.h:26
impeller::interop::LineMetrics::GetLeft
double GetLeft(size_t line) const
Definition: line_metrics.cc:47
impeller::interop::LineMetrics::GetCodeUnitStartIndex
size_t GetCodeUnitStartIndex(size_t line) const
Definition: line_metrics.cc:51
impeller::interop::LineMetrics::GetBaseline
double GetBaseline(size_t line) const
Definition: line_metrics.cc:31
impeller::interop::LineMetrics::LineMetrics
LineMetrics(const std::vector< txt::LineMetrics > &metrics)
Definition: line_metrics.cc:9
impeller::interop::LineMetrics::GetUnscaledAscent
double GetUnscaledAscent(size_t line) const
Definition: line_metrics.cc:23
impeller::interop::LineMetrics::GetCodeUnitEndIndexIncludingNewline
size_t GetCodeUnitEndIndexIncludingNewline(size_t line) const
Definition: line_metrics.cc:63
impeller::interop::LineMetrics::GetWidth
double GetWidth(size_t line) const
Definition: line_metrics.cc:39
impeller::interop::LineMetrics::GetAscent
double GetAscent(size_t line) const
Definition: line_metrics.cc:19
impeller::interop::LineMetrics::~LineMetrics
~LineMetrics()
impeller::interop::LineMetrics::IsHardbreak
bool IsHardbreak(size_t line) const
Definition: line_metrics.cc:35
impeller::interop::LineMetrics::operator=
LineMetrics & operator=(const LineMetrics &)=delete
impeller::interop::LineMetrics::GetHeight
double GetHeight(size_t line) const
Definition: line_metrics.cc:43
impeller::interop::LineMetrics::GetCodeUnitEndIndex
size_t GetCodeUnitEndIndex(size_t line) const
Definition: line_metrics.cc:55
impeller::interop::LineMetrics::GetCodeUnitEndIndexExcludingWhitespace
size_t GetCodeUnitEndIndexExcludingWhitespace(size_t line) const
Definition: line_metrics.cc:59
impeller::interop::LineMetrics::LineMetrics
LineMetrics(const LineMetrics &)=delete
impeller::interop::LineMetrics::GetDescent
double GetDescent(size_t line) const
Definition: line_metrics.cc:27
impeller::interop::Object
Definition: object.h:56
impeller.h
impeller::interop
Definition: context_gles.cc:12
object.h