18#define TO_STRING(...) #__VA_ARGS__
19#define ANCHOR(PREFIX, NAME) \
21 static constexpr dimension_parameter_t x{TO_STRING(PREFIX##_##NAME##_x)}; \
22 static constexpr dimension_parameter_t y{TO_STRING(PREFIX##_##NAME##_y)}; \
25#define CYDUI_INTERNAL_EV_HANDLER_DECL(NAME) void on_##NAME CYDUI_INTERNAL_EV_##NAME##_ARGS
27#define CYDUI_INTERNAL_EV_HANDLER_DECL_W_RET(NAME) \
28 CYDUI_INTERNAL_EV_##NAME##_RETURN on_##NAME CYDUI_INTERNAL_EV_##NAME##_ARGS
35#pragma clang diagnostic push
36#pragma ide diagnostic ignored "OCUnusedMacroInspection"
44 const std::list<std::shared_ptr<component_base_t>>&
$children;
48 component_base_t* comp,
const std::list<std::shared_ptr<component_base_t>>& $children_
59#define DIMENSIONAL_ARGS \
60 $x, $y, $width, $height, $padding_top, $padding_bottom, $padding_left, $padding_right
63#define CYDUI_INTERNAL_EV_button_PROPAGATE(NAME) \
64 if (component->parent.has_value()) \
65 component->parent.value()->get_event_dispatcher()->dispatch_button_##NAME( \
66 button, x + $x, y + $y \
68#define CYDUI_INTERNAL_EV_mouse_PROPAGATE(NAME) \
69 if (component->parent.has_value()) \
70 component->parent.value()->get_event_dispatcher()->dispatch_mouse_##NAME(x + $x, y + $y);
92 if (component->parent.has_value())
93 component->parent.value()->get_event_dispatcher()->dispatch_scroll(dx, dy);
99 if (component->parent.has_value())
100 component->parent.value()->get_event_dispatcher()->dispatch_key_press(ev);
104 if (component->parent.has_value())
105 component->parent.value()->get_event_dispatcher()->dispatch_key_release(ev);
117#pragma clang diagnostic pop
119 template <
typename Component>
122 Component& component_,
123 const std::list<std::shared_ptr<component_base_t>>& children_,
124 const std::shared_ptr<typename Component::state_t>& state_,
125 const std::shared_ptr<fabric::async::async_bus_t>& window_,
126 typename Component::props_t& props_,
128 typename Component::style_t& style_
133 window(*static_cast<typename Component::window_type*>(window_.get())),
151 template <
typename Event>
155 fabric::async::async_bus_t* window,
156 std::function<fabric::task<>(
const Event&)> callback,
157 std::function<fabric::task<>()> post
170 : window_(other.window_),
171 callback_(other.callback_),
177 this->window_ = other.window_;
178 this->callback_ = other.callback_;
179 this->post_ = other.post_;
185 : window_(other.window_),
186 callback_(other.callback_),
188 other.stop_listening();
193 this->window_ = other.window_;
194 this->callback_ = other.callback_;
195 this->post_ = other.post_;
196 other.stop_listening();
202 void start_listening() {
205 listener_ = window_->on_event([&](
const Event& ev) -> fabric::task<> {
206 co_await callback_(ev);
211 void stop_listening() {
212 if (listener_.has_value()) {
213 listener_.value().remove();
214 listener_ = std::nullopt;
219 fabric::async::async_bus_t* window_;
220 std::function<fabric::task<>(
const Event&)> callback_;
221 std::function<fabric::task<>()> post_;
222 std::optional<fabric::async::listener<Event>> listener_{std::nullopt};
custom_event_listener & operator=(custom_event_listener &&other)
custom_event_listener(custom_event_listener &&other) noexcept
custom_event_listener(fabric::async::async_bus_t *window, std::function< fabric::task<>(const Event &)> callback, std::function< fabric::task<>()> post)
custom_event_listener(const custom_event_listener &other)
custom_event_listener & operator=(const custom_event_listener &other)
#define CYDUI_INTERNAL_EV_mouse_PROPAGATE(NAME)
#define CYDUI_INTERNAL_EV_HANDLER_DECL(NAME)
#define CYDUI_INTERNAL_EV_HANDLER_DECL_W_RET(NAME)
#define CYDUI_INTERNAL_EV_button_PROPAGATE(NAME)
#define CYDUI_INTERNAL_EV_fragment_ARGS
anchors::previous_component $previous
Component::style_t & style
event_handler_data_t(Component &component_, const std::list< std::shared_ptr< component_base_t > > &children_, const std::shared_ptr< typename Component::state_t > &state_, const std::shared_ptr< fabric::async::async_bus_t > &window_, typename Component::props_t &props_, attrs_component< Component > &attrs_, typename Component::style_t &style_)
anchors::parent_component $parent
Component::window_type & window
Component::state_t & state
anchors::self_component $self
attrs_component< Component > & attrs
Component::props_t & props
event_handler_t(component_base_t *comp, const std::list< std::shared_ptr< component_base_t > > & $children_)
const std::list< std::shared_ptr< component_base_t > > & $children
void draw_fragment(vg::fragment_t &fragment, const cydui::dimension_t::value_type & $x, const cydui::dimension_t::value_type & $y, const cydui::dimension_t::value_type & $width, const cydui::dimension_t::value_type & $height, const cydui::dimension_t::value_type & $padding_top, const cydui::dimension_t::value_type & $padding_bottom, const cydui::dimension_t::value_type & $padding_left, const cydui::dimension_t::value_type & $padding_right)
static constexpr bool handles_text_input