MCPcopy Create free account
hub / github.com/AshampooSystems/boden / init

Method init

examples/BodenDemo/src/TextTruncationPage.cpp:11–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9namespace bdn
10{
11 void TextTruncationPage::init()
12 {
13 stylesheet = FlexJsonStringify({"flexGrow" : 1.0});
14
15 constexpr std::array<std::pair<const char *, TextOverflow>, 5> modes{
16 std::make_pair("Head", TextOverflow::EllipsisHead), std::make_pair("Tail", TextOverflow::EllipsisTail),
17 std::make_pair("Middle", TextOverflow::EllipsisMiddle), std::make_pair("Clip", TextOverflow::Clip),
18 std::make_pair("ClipWord", TextOverflow::ClipWord),
19 };
20
21 auto slider = std::make_shared<Slider>();
22 slider->stylesheet = FlexJsonStringify({"minimumSize" : {"width" : 100}});
23 slider->value = 1.0;
24 addChildView(makeRow("Width", slider));
25
26 for (auto &mode : modes) {
27 auto label = std::make_shared<Label>();
28 label->text = "The quick brown fox jumps over the lazy dog";
29 label->textOverflow = mode.second;
30 label->stylesheet = FlexJsonStringify({"flexGrow" : 1});
31
32 slider->value.onChange() += [=](const auto &property) {
33 auto json = label->stylesheet.get();
34 std::ostringstream str;
35 str << property.get() * 100.0f << "%";
36 json["flex"]["maximumSize"]["width"] = str.str();
37 label->stylesheet = json;
38 };
39
40 addChildView(makeRow(mode.first, label));
41 }
42 }
43}

Callers

nothing calls this directly

Calls 2

makeRowFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected