MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / layout

Method layout

src/GUIStuff/Elements/TextParagraph.cpp:30–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28 Element(gui) {}
29
30void TextParagraph::layout(const Clay_ElementId& id, const Data& newData) {
31 bool redraw = false;
32
33 if(!textbox) {
34 d = newData;
35 textbox = std::make_unique<RichText::TextBox>();
36 textbox->set_rich_text_data(d.text);
37 textbox->set_ellipsis(newData.ellipsis);
38 textbox->set_font_data(gui.io.fonts);
39 textbox->set_allow_newlines(newData.allowNewlines);
40 textbox->set_max_width(newData.maxGrowX);
41 textbox->set_max_height(newData.maxGrowY);
42 skia::textlayout::TextStyle tStyle;
43 tStyle.setFontFamilies(gui.io.fonts->get_default_font_families());
44 tStyle.setFontSize(gui.io.fontSize);
45 textbox->set_initial_text_style(tStyle);
46 fontSize = gui.io.fontSize;
47 redraw = true;
48 }
49
50 if(d.allowNewlines != newData.allowNewlines) {
51 d.allowNewlines = newData.allowNewlines;
52 textbox->set_allow_newlines(d.allowNewlines);
53 redraw = true;
54 }
55
56 if(gui.io.fontSize != fontSize) {
57 fontSize = gui.io.fontSize;
58 skia::textlayout::TextStyle tStyle;
59 tStyle.setFontFamilies(gui.io.fonts->get_default_font_families());
60 tStyle.setFontSize(gui.io.fontSize);
61 textbox->set_initial_text_style(tStyle);
62 redraw = true;
63 }
64
65 if(d.text != newData.text) {
66 d.text = newData.text;
67 textbox->set_rich_text_data(d.text);
68 redraw = true;
69 }
70
71 if(d.maxGrowX != newData.maxGrowX) {
72 d.maxGrowX = newData.maxGrowX;
73 textbox->set_max_width(d.maxGrowX);
74 redraw = true;
75 }
76 if(d.maxGrowY != newData.maxGrowY) {
77 d.maxGrowY = newData.maxGrowY;
78 textbox->set_max_height(d.maxGrowY);
79 redraw = true;
80 }
81
82 if(d.ellipsis != newData.ellipsis) {
83 d.ellipsis = newData.ellipsis;
84 textbox->set_ellipsis(d.ellipsis);
85 redraw = true;
86 }
87

Callers

nothing calls this directly

Calls 10

set_rich_text_dataMethod · 0.80
set_ellipsisMethod · 0.80
set_font_dataMethod · 0.80
set_allow_newlinesMethod · 0.80
set_max_widthMethod · 0.80
set_max_heightMethod · 0.80
get_widthMethod · 0.80
get_heightMethod · 0.80

Tested by

no test coverage detected