infinipaint/src/GUIStuff/Elements/TextParagraph.cpp
2026-04-05 11:02:48 +03:00

28 lines
789 B
C++

#include "TextParagraph.hpp"
#include <include/core/SkPath.h>
#include <iostream>
namespace GUIStuff {
TextParagraph::TextParagraph(GUIManager& gui):
Element(gui) {}
void TextParagraph::layout(const Clay_ElementId& id, const std::shared_ptr<skia::textlayout::Paragraph>& paragraph, float width) {
data = paragraph;
data->layout(width);
CLAY(id, {
.layout = {
.sizing = {.width = CLAY_SIZING_FIXED(width), .height = CLAY_SIZING_FIXED(data->getHeight())}
},
.custom = { .customData = this }
}) {}
}
void TextParagraph::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) {
if(data) {
auto& bb = boundingBox.value();
data->paint(canvas, bb.min.x(), bb.min.y());
}
}
}