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

Method init

examples/BodenDemo/src/FontPage.cpp:40–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38 };
39
40 void FontPage::init()
41 {
42 _styler = std::make_shared<ui::Styler>();
43 _styler->setCondition("os", std::make_shared<Styler::equals_condition>(BDN_TARGET));
44
45 stylesheet = FlexJsonStringify({"flexGrow" : 1.0});
46
47 auto normalTextField = std::make_shared<FontTestTextField>(needsInit, "no-font");
48 addChildView(makeRow("No-Font", normalTextField, 5., 5., 0.62, true));
49
50 auto defaultFontTextField = std::make_shared<FontTestTextField>(needsInit, "default font");
51 defaultFontTextField->stylesheet |= bdn::json({{"font", Font{"Tahoma"}}});
52 defaultFontTextField->stylesheet |= bdn::json({{"font", nullptr}});
53
54 addChildView(makeRow("Default font", defaultFontTextField, 5., 5., 0.62, true));
55
56 auto boldTextField = std::make_shared<FontTestTextField>(needsInit, "Bold font");
57 boldTextField->stylesheet |= json({{"font", Font{"", {}, Font::Style::Inherit, Font::Weight::Bold}}});
58 addChildView(makeRow("Bold", boldTextField, 5., 5., 0.62, true));
59
60 auto boldSlider = std::make_shared<Slider>();
61 boldSlider->stylesheet = FlexJsonStringify({"size" : {"width" : "66%"}});
62
63 boldSlider->value.onChange() += [=](auto p) {
64 Font f = boldTextField->stylesheet.get()["font"];
65 f.weight = (Font::Weight)(boldSlider->value.get() * 1000);
66 boldTextField->stylesheet |= json({{"font", f}});
67 };
68
69 addChildView(makeRow("Boldness", boldSlider));
70
71 auto italicTextField = std::make_shared<FontTestTextField>(needsInit, "Italic font");
72 italicTextField->stylesheet |= json({{"font", Font{"", {}, Font::Style::Italic}}});
73 addChildView(makeRow("Italic", italicTextField, 5., 5., 0.62, true));
74
75 auto smallTextField = std::make_shared<FontTestTextField>(needsInit, "small font");
76 smallTextField->stylesheet |= json({{"font", Font{"", {Font::Size::Type::Small, 10.f}}}});
77 addChildView(makeRow("Small", smallTextField, 5., 5., 0.62, true));
78
79 auto handwritingTextField =
80 std::make_shared<FontTestTextField>(needsInit, "", JsonStringify([
81 {"font" : {"family" : "Bradley Hand"}}, //
82 {"if" : {"os" : "android"}, "font" : {"family" : "cursive"}}
83 ]),
84 _styler);
85
86#ifdef BDN_PLATFORM_ANDROID
87 handwritingTextField->text = "Cursive";
88#else
89 handwritingTextField->text = "Bradley Hand font";
90#endif
91
92 addChildView(makeRow("Handwriting", handwritingTextField, 5., 5., 0.62, true));
93
94 auto bigHandwritingTextField =
95 std::make_shared<FontTestTextField>(needsInit, "", JsonStringify([
96 {"font" : {"family" : "Bradley Hand", "size" : "xxlarge"}}, //
97 {"if" : {"os" : "android"}, "font" : {"family" : "cursive"}}

Callers

nothing calls this directly

Calls 3

makeRowFunction · 0.85
setConditionMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected