diff --git a/libs/ui/source/default_element_factory.cpp b/libs/ui/source/default_element_factory.cpp index 8d744dc8..2451074e 100644 --- a/libs/ui/source/default_element_factory.cpp +++ b/libs/ui/source/default_element_factory.cpp @@ -224,6 +224,33 @@ namespace psemek::ui return children_range{children_}; } + bool on_event(mouse_move const & e) + { + mouse_ = e.position; + + if (drag_ && *drag_ != e.position) + { + shape_.box += geom::cast(e.position - *drag_); + drag_ = e.position; + post_reshape(); + return true; + } + return false; + } + + bool on_event(mouse_click const & e) + { + if (e.button == mouse_button::left) + { + if (mouse_ && e.down) + drag_ = *mouse_; + else + drag_ = std::nullopt; + return true; + } + return false; + } + struct shape const & shape() const override { return shape_; @@ -310,6 +337,9 @@ namespace psemek::ui std::shared_ptr close_button_; std::shared_ptr child_; + std::optional> mouse_; + std::optional> drag_; + box_shape shape_; element * children_[3];