2025-07-06 20:43:53 +03:00
|
|
|
#include "Element.hpp"
|
2026-04-08 17:34:50 +03:00
|
|
|
#include "GUIStuffHelpers.hpp"
|
2025-07-06 20:43:53 +03:00
|
|
|
|
|
|
|
|
namespace GUIStuff {
|
2026-03-27 09:51:53 +03:00
|
|
|
Element::Element(GUIManager& initGUI):
|
|
|
|
|
gui(initGUI) {}
|
|
|
|
|
|
2026-04-08 17:34:50 +03:00
|
|
|
void Element::update() {}
|
2026-03-27 09:51:53 +03:00
|
|
|
|
2026-04-04 17:52:43 +03:00
|
|
|
void Element::input_paste_callback(const CustomEvents::PasteEventData& paste) { }
|
2026-04-03 23:02:33 +03:00
|
|
|
void Element::input_text_key_callback(const InputManager::KeyCallbackArgs& key) { }
|
2026-04-04 17:52:43 +03:00
|
|
|
void Element::input_text_callback(const InputManager::TextCallbackArgs& text) { }
|
2026-04-02 21:57:26 +03:00
|
|
|
void Element::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button) { }
|
|
|
|
|
void Element::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion) { }
|
|
|
|
|
void Element::input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel) { }
|
2026-03-27 09:51:53 +03:00
|
|
|
void Element::input_key_callback(const InputManager::KeyCallbackArgs& key) {}
|
|
|
|
|
|
|
|
|
|
void Element::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) {}
|
|
|
|
|
|
2026-03-31 17:33:09 +03:00
|
|
|
void Element::set_bounding_box_from_elem_data(const Clay_ElementData& elemData) {
|
|
|
|
|
if(elemData.found)
|
|
|
|
|
boundingBox = {{elemData.boundingBox.x, elemData.boundingBox.y}, {elemData.boundingBox.x + elemData.boundingBox.width, elemData.boundingBox.y + elemData.boundingBox.height}};
|
|
|
|
|
else
|
|
|
|
|
boundingBox = std::nullopt;
|
2025-07-06 20:43:53 +03:00
|
|
|
}
|
|
|
|
|
|
2026-04-01 21:49:44 +03:00
|
|
|
void Element::set_parent_clipping_region(const std::optional<SCollision::AABB<float>>& bb) {
|
|
|
|
|
parentClippingRegion = bb;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-27 09:51:53 +03:00
|
|
|
const std::optional<SCollision::AABB<float>>& Element::get_bb() const {
|
|
|
|
|
return boundingBox;
|
2025-07-06 20:43:53 +03:00
|
|
|
}
|
|
|
|
|
|
2026-03-27 09:51:53 +03:00
|
|
|
bool Element::collides_with_point(const Vector2f& p) const {
|
|
|
|
|
if(!boundingBox.has_value())
|
|
|
|
|
return false;
|
2026-04-01 21:49:44 +03:00
|
|
|
bool inClippingRegion = !parentClippingRegion.has_value() || SCollision::collide(p, parentClippingRegion.value());
|
|
|
|
|
return inClippingRegion && SCollision::collide(p, boundingBox.value());
|
2025-07-06 20:43:53 +03:00
|
|
|
}
|
|
|
|
|
|
2026-03-27 09:51:53 +03:00
|
|
|
SCollision::AABB<float> Element::get_bb_from_command(Clay_RenderCommand* command) {
|
2026-04-08 17:34:50 +03:00
|
|
|
return clay_bounding_box_to_aabb(command->boundingBox);
|
2025-07-06 20:43:53 +03:00
|
|
|
}
|
|
|
|
|
}
|