Print messages using SkParagraph and new TextParagraph element
This commit is contained in:
parent
9ceb4e1b8a
commit
921e111255
9 changed files with 147 additions and 16 deletions
28
src/GUIStuff/Elements/TextParagraph.cpp
Normal file
28
src/GUIStuff/Elements/TextParagraph.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include "TextParagraph.hpp"
|
||||
#include <include/core/SkPath.h>
|
||||
#include <iostream>
|
||||
|
||||
namespace GUIStuff {
|
||||
|
||||
void TextParagraph::update(UpdateInputData& io, std::unique_ptr<skia::textlayout::Paragraph> paragraph, float width, const std::function<void()>& elemUpdate) {
|
||||
data = std::move(paragraph);
|
||||
data->layout(width);
|
||||
CLAY({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_FIXED(width), .height = CLAY_SIZING_FIXED(data->getHeight())}
|
||||
},
|
||||
.custom = { .customData = this }
|
||||
}) {
|
||||
if(elemUpdate)
|
||||
elemUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void TextParagraph::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command) {
|
||||
bb = get_bb(command);
|
||||
|
||||
if(data)
|
||||
data->paint(canvas, bb.min.x(), bb.min.y());
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue