LeviLamina
Loading...
Searching...
No Matches
CustomForm.h
1#pragma once
2
3#include <cstdint>
4#include <memory>
5#include <optional>
6#include <vector>
7
8#include "ll/api/Expected.h"
9#include "ll/api/base/Macro.h"
10#include "ll/api/coro/CoroTask.h"
11#include "ll/api/ui/base/Observable.h"
12#include "ll/api/ui/base/ScreenSession.h"
13
14#include "mc/platform/brstd/move_only_function.h"
15
16class Player;
17
18namespace ll::ui {
19
21 std::optional<BooleanValue> disabled;
22 std::optional<TextValue> tooltip;
23 std::optional<BooleanValue> visible;
24};
25
27 std::optional<BooleanValue> visible;
28};
29
31 TextValue label;
32 double value;
33 std::optional<TextValue> description;
34};
35
37 std::optional<TextValue> description;
38 std::optional<BooleanValue> disabled;
39 std::optional<BooleanValue> visible;
40};
41
43 std::optional<TextValue> description;
44 std::optional<BooleanValue> disabled;
45 std::optional<NumberValue> step;
46 std::optional<BooleanValue> visible;
47};
48
50 std::optional<BooleanValue> visible;
51};
52
54 std::optional<TextValue> description;
55 std::optional<BooleanValue> disabled;
56 std::optional<BooleanValue> visible;
57};
58
60 std::optional<BooleanValue> visible;
61};
62
64 std::optional<TextValue> description;
65 std::optional<BooleanValue> disabled;
66 std::optional<BooleanValue> visible;
67};
68
69class CustomForm {
70 struct Impl;
71 std::shared_ptr<Impl> impl;
72
73public:
74 using Result = ScreenSession::Result;
75 using Callback = ScreenSession::Callback;
76 using ButtonCallback = brstd::move_only_function<void()>;
77
78 LLNDAPI CustomForm(Player& player, TextValue title);
79 LLAPI ~CustomForm();
80
81 CustomForm(CustomForm const&) = delete;
82 CustomForm& operator=(CustomForm const&) = delete;
83 LLAPI CustomForm(CustomForm&&) noexcept;
84 LLAPI CustomForm& operator=(CustomForm&&) noexcept;
85
86 LLAPI CustomForm& button(TextValue label, ButtonCallback callback, ButtonOptions options = {});
87 LLAPI CustomForm& closeButton();
88 LLAPI CustomForm& divider(DividerOptions options = {});
89 LLAPI CustomForm& dropdown(
90 TextValue label,
91 ObservableNumber value,
92 std::vector<DropdownItemData> items,
93 DropdownOptions options = {}
94 );
95 LLAPI CustomForm& header(TextValue text, TextOptions options = {});
96 LLAPI CustomForm& label(TextValue text, TextOptions options = {});
97 LLAPI CustomForm&
98 slider(TextValue label, ObservableNumber value, NumberValue min, NumberValue max, SliderOptions options = {});
99 LLAPI CustomForm& spacer(SpacingOptions options = {});
100 LLAPI CustomForm& textField(TextValue label, ObservableString text, TextFieldOptions options = {});
101 LLAPI CustomForm& toggle(TextValue label, ObservableBoolean toggled, ToggleOptions options = {});
102
103 LLNDAPI Expected<> show(Callback callback = {});
104 LLNDAPI coro::CoroTask<Result> showAsync();
105
106 LLNDAPI Expected<> close();
107 LLNDAPI bool isShowing() const noexcept;
108};
109
110} // namespace ll::ui
Definition Player.h:137
Definition move_only_function.h:9
Definition CoroTask.h:45
Definition Observable.h:33
Definition Observable.h:38
Definition Observable.h:43
Definition CustomForm.h:20
Definition CustomForm.h:26
Definition CustomForm.h:30
Definition CustomForm.h:36
Definition CustomForm.h:42
Definition CustomForm.h:49
Definition CustomForm.h:53
Definition CustomForm.h:59
Definition CustomForm.h:63