MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / build

Method build

samples/application/ogui2/sandbox/src/counter_state.cpp:13–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11{
12
13NotNull<Widget*> CounterState::build(NotNull<IBuildContext*> context) SKR_NOEXCEPT
14{
15 if (!_click_gesture)
16 {
17 // TODO. pass input manager by setter
18 _click_gesture = SkrNew<ClickGestureRecognizer>(context->build_owner()->input_manager());
19 _click_gesture->on_click = [this]() {
20 set_state([this]() {
21 ++count;
22 });
23 };
24 }
25
26 return SNewWidget(Flex)
27 {
28 p.flex_direction = EFlexDirection::Column;
29 p.children += SNewWidget(Text)
30 {
31 p.text = skr::format(u8"count: {}", count);
32 };
33 // for (int32_t i = 0; i < count; ++i)
34 // {
35 // p.children += SNewWidget(ColoredBox)
36 // {
37 // p.color = { 0, 0, 1, 1 };
38 // p.child = SNewWidget(Text)
39 // {
40 // p.text = skr::format(u8"count {}", i);
41 // };
42 // };
43 // };
44
45 p.children += SNewWidget(MouseRegin)
46 {
47 p.on_down = [this](PointerDownEvent* event) {
48 if (event->phase != EEventRoutePhase::BubbleUp) return false;
49 if (event->button == EPointerButton::Left)
50 {
51 _click_gesture->add_pointer(event);
52 return true;
53 }
54 return false;
55 };
56 p.on_up = [this](PointerUpEvent* event) {
57 if (event->phase != EEventRoutePhase::BubbleUp) return false;
58 if (event->button == EPointerButton::Left)
59 {
60 _click_gesture->handle_event_from_widget(event);
61 return true;
62 }
63 return false;
64 };
65
66 p.child = SNewWidget_S(ColoredBox)
67 {
68 p.color = { 1, 0, 0, 1 };
69 p.child = SNewWidget_S(Text)
70 {

Callers 15

InstallMethod · 0.45
create_test_sceneFunction · 0.45
async_attach_skin_meshFunction · 0.45
async_attach_render_meshFunction · 0.45
on_registerMethod · 0.45
create_test_sceneFunction · 0.45
on_registerMethod · 0.45
LoadSceneMethod · 0.45
UpdateMethod · 0.45
SpawnPrefabMethod · 0.45
SnapshotMethod · 0.45

Calls 4

build_ownerMethod · 0.80
add_pointerMethod · 0.80
formatFunction · 0.50

Tested by

no test coverage detected