aboutsummaryrefslogtreecommitdiff
path: root/src/ui/render/TextRenderObject.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2022-02-09 22:29:17 +0800
committercrupest <crupest@outlook.com>2022-02-09 22:29:17 +0800
commite18c4fb46d7913f337cc25b9a6e3a25359c3f10a (patch)
treeca0d2ba0477af904c2b3ccc0f1b4ea5d3c101dc0 /src/ui/render/TextRenderObject.cpp
parent1cbbad7166ca3dad08f947aeea5d7efc197bd2f3 (diff)
downloadcru-e18c4fb46d7913f337cc25b9a6e3a25359c3f10a.tar.gz
cru-e18c4fb46d7913f337cc25b9a6e3a25359c3f10a.tar.bz2
cru-e18c4fb46d7913f337cc25b9a6e3a25359c3f10a.zip
...
Diffstat (limited to 'src/ui/render/TextRenderObject.cpp')
-rw-r--r--src/ui/render/TextRenderObject.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/ui/render/TextRenderObject.cpp b/src/ui/render/TextRenderObject.cpp
index 675bac3c..ec5ce662 100644
--- a/src/ui/render/TextRenderObject.cpp
+++ b/src/ui/render/TextRenderObject.cpp
@@ -21,8 +21,6 @@ TextRenderObject::TextRenderObject(
Expects(selection_brush);
Expects(caret_brush);
- SetChildMode(ChildMode::None);
-
brush.swap(brush_);
font.swap(font_);
selection_brush.swap(selection_brush_);
@@ -176,16 +174,19 @@ RenderObject* TextRenderObject::HitTest(const Point& point) {
return padding_rect.IsPointInside(point) ? this : nullptr;
}
-void TextRenderObject::OnDrawContent(platform::graphics::IPainter* painter) {
+void TextRenderObject::Draw(platform::graphics::IPainter* painter) {
if constexpr (debug_flags::draw) {
log::TagDebug(log_tag,
u"Begin to paint, total_offset: {}, size: {}, text_layout: "
u"{}, brush: {}.",
- this->GetTotalOffset(), this->GetSize(),
+ this->GetTotalOffset(), this->GetDesiredSize(),
this->text_layout_->GetDebugString(),
this->brush_->GetDebugString());
}
+ painter->PushState();
+ painter->ConcatTransform(Matrix::Translation(GetOffset()));
+
if (this->selection_range_.has_value()) {
const auto&& rects =
text_layout_->TextRangeRect(this->selection_range_.value());
@@ -198,6 +199,8 @@ void TextRenderObject::OnDrawContent(platform::graphics::IPainter* painter) {
if (this->draw_caret_ && this->caret_width_ != 0.0f) {
painter->FillRectangle(GetCaretRectInContent(), this->caret_brush_.get());
}
+
+ painter->PopState();
}
Size TextRenderObject::OnMeasureContent(const MeasureRequirement& requirement,
@@ -229,6 +232,4 @@ Size TextRenderObject::OnMeasureContent(const MeasureRequirement& requirement,
void TextRenderObject::OnLayoutContent(const Rect& content_rect) {
CRU_UNUSED(content_rect)
}
-
-void TextRenderObject::OnAfterLayout() {}
} // namespace cru::ui::render