diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/String.cpp | 3 | ||||
-rw-r--r-- | src/osx/Resource.cpp | 1 | ||||
-rw-r--r-- | src/osx/graphics/quartz/Brush.cpp | 5 | ||||
-rw-r--r-- | src/osx/graphics/quartz/TextLayout.cpp | 6 | ||||
-rw-r--r-- | src/ui/render/TextRenderObject.cpp | 21 |
5 files changed, 27 insertions, 9 deletions
diff --git a/src/common/String.cpp b/src/common/String.cpp index 65d303fb..699d807f 100644 --- a/src/common/String.cpp +++ b/src/common/String.cpp @@ -38,6 +38,9 @@ String::String(const_pointer str, Index size) { this->capacity_ = size; } +String::String(std::initializer_list<char16_t> l) + : String(l.begin(), l.size()) {} + #ifdef CRU_PLATFORM_WINDOWS String::String(const wchar_t* str) : String(str, GetStrSize(str)) {} String::String(const wchar_t* str, Index size) diff --git a/src/osx/Resource.cpp b/src/osx/Resource.cpp index 76381d14..e8140856 100644 --- a/src/osx/Resource.cpp +++ b/src/osx/Resource.cpp @@ -1,2 +1 @@ #include "cru/osx/Resource.hpp" - diff --git a/src/osx/graphics/quartz/Brush.cpp b/src/osx/graphics/quartz/Brush.cpp index b55ff4e8..83ac20a2 100644 --- a/src/osx/graphics/quartz/Brush.cpp +++ b/src/osx/graphics/quartz/Brush.cpp @@ -1,4 +1,5 @@ #include "cru/osx/graphics/quartz/Brush.hpp" +#include "cru/common/String.hpp" namespace cru::platform::graphics::osx::quartz { QuartzSolidColorBrush::QuartzSolidColorBrush(IGraphicsFactory* graphics_factory, @@ -27,4 +28,8 @@ void QuartzSolidColorBrush::Select(CGContextRef context) { CGContextSetStrokeColorWithColor(context, cg_color_); CGContextSetFillColorWithColor(context, cg_color_); } + +String QuartzSolidColorBrush::GetDebugString() { + return Format(u"QuartzSolidColorBrush(Color: {})", color_); +} } // namespace cru::platform::graphics::osx::quartz diff --git a/src/osx/graphics/quartz/TextLayout.cpp b/src/osx/graphics/quartz/TextLayout.cpp index 29735606..41d04958 100644 --- a/src/osx/graphics/quartz/TextLayout.cpp +++ b/src/osx/graphics/quartz/TextLayout.cpp @@ -235,4 +235,10 @@ CTFrameRef OsxCTTextLayout::CreateFrameWithColor(const Color& color) { return frame; } + +String OsxCTTextLayout::GetDebugString() { + return Format(u"OsxCTTextLayout(text: {}, size: ({}, {}))", text_, max_width_, + max_height_); +} + } // namespace cru::platform::graphics::osx::quartz diff --git a/src/ui/render/TextRenderObject.cpp b/src/ui/render/TextRenderObject.cpp index ff9ebc58..189c5532 100644 --- a/src/ui/render/TextRenderObject.cpp +++ b/src/ui/render/TextRenderObject.cpp @@ -5,6 +5,7 @@ #include "cru/platform/graphics/Factory.hpp" #include "cru/platform/graphics/TextLayout.hpp" #include "cru/platform/graphics/util/Painter.hpp" +#include "cru/ui/DebugFlags.hpp" #include <algorithm> #include <limits> @@ -161,6 +162,15 @@ RenderObject* TextRenderObject::HitTest(const Point& point) { } void TextRenderObject::OnDrawContent(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->text_layout_->GetDebugString(), + this->brush_->GetDebugString()); + } + if (this->selection_range_.has_value()) { const auto&& rects = text_layout_->TextRangeRect(this->selection_range_.value()); @@ -186,9 +196,9 @@ Size TextRenderObject::OnMeasureContent(const MeasureRequirement& requirement, text_layout_->SetMaxWidth(measure_width); text_layout_->SetMaxHeight(std::numeric_limits<float>::max()); - const auto text_size = + const Size text_size( text_layout_->GetTextBounds(is_measure_including_trailing_space_) - .GetSize(); + .GetRightBottom()); auto result = text_size; result.width = std::max(result.width, preferred_size.width.GetLengthOr0()); @@ -205,10 +215,5 @@ void TextRenderObject::OnLayoutContent(const Rect& content_rect) { CRU_UNUSED(content_rect) } -void TextRenderObject::OnAfterLayout() { - const auto&& size = GetContentRect().GetSize(); - text_layout_->SetMaxWidth(size.width); - text_layout_->SetMaxHeight(size.height); -} - +void TextRenderObject::OnAfterLayout() {} } // namespace cru::ui::render |