diff --git a/src/DrawingProgram/DrawingProgram.cpp b/src/DrawingProgram/DrawingProgram.cpp index 295266f..bb18fd8 100644 --- a/src/DrawingProgram/DrawingProgram.cpp +++ b/src/DrawingProgram/DrawingProgram.cpp @@ -332,8 +332,8 @@ void DrawingProgram::toolbar_gui() { auto& io = gui.io; gui.new_id("Drawing Program Toolbar GUI", [&] { - gui.element("Drawing Program Toolbar GUI", [&] { - CLAY_AUTO_ID({ + gui.element("Drawing Program Toolbar GUI", [&] (const Clay_ElementId& lId) { + CLAY(lId, { .layout = { .sizing = {.width = CLAY_SIZING_FIT(0), .height = CLAY_SIZING_FIT(0)}, .padding = CLAY_PADDING_ALL(static_cast(io.theme->padding1 / 2)), @@ -446,8 +446,8 @@ void DrawingProgram::tool_options_gui() { auto& io = gui.io; float minGUIWidth = drawTool->get_type() == DrawingProgramToolType::SCREENSHOT ? 300 : 200; - gui.element("Drawing program tool options gui", [&] { - CLAY_AUTO_ID({ + gui.element("Drawing program tool options gui", [&] (const Clay_ElementId& lId) { + CLAY(lId, { .layout = { .sizing = {.width = CLAY_SIZING_FIT(minGUIWidth), .height = CLAY_SIZING_FIT(0)}, .padding = CLAY_PADDING_ALL(io.theme->padding1), @@ -470,7 +470,7 @@ void DrawingProgram::modify_grid(const NetworkingObjects::NetObjWeakPtr(); - gui.io.windowPos = {0, 0}; calculate_final_gui_scale(); + gui.update_window({0, 0}, main.window.size.cast(), final_gui_scale()); gui.layout_if_necessary(); } @@ -120,15 +119,19 @@ void GUIHolder::draw(SkCanvas* canvas, bool skiaAA) { } void GUIHolder::input_key_callback(const InputManager::KeyCallbackArgs& key) { + gui.input_key_callback(key); } void GUIHolder::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button) { + gui.input_mouse_button_callback(button); } void GUIHolder::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion) { + gui.input_mouse_motion_callback(motion); } void GUIHolder::input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel) { + gui.input_mouse_wheel_callback(wheel); } void GUIHolder::input_finger_touch_callback(const InputManager::FingerTouchCallbackArgs& touch) { diff --git a/src/GUIStuff/ElementHelpers/ColorPickerItemsHelpers.hpp b/src/GUIStuff/ElementHelpers/ColorPickerItemsHelpers.hpp index 3bcc8a6..4350c76 100644 --- a/src/GUIStuff/ElementHelpers/ColorPickerItemsHelpers.hpp +++ b/src/GUIStuff/ElementHelpers/ColorPickerItemsHelpers.hpp @@ -13,7 +13,7 @@ struct ColorPickerItemsOptions { template void color_picker_items(GUIManager& gui, const char* id, T* val, const ColorPickerItemsOptions& options = {}) { gui.new_id(id, [&] { auto fullOnEdit = [&gui, oE = options.onEdit, val]() { - oE(); + if(oE) oE(); gui.set_to_layout(); }; gui.element>("c", val, options.hasAlpha, fullOnEdit); diff --git a/src/GUIStuff/ElementHelpers/LayoutHelpers.cpp b/src/GUIStuff/ElementHelpers/LayoutHelpers.cpp index 1823370..18d3cce 100644 --- a/src/GUIStuff/ElementHelpers/LayoutHelpers.cpp +++ b/src/GUIStuff/ElementHelpers/LayoutHelpers.cpp @@ -4,8 +4,8 @@ namespace GUIStuff { namespace ElementHelpers { void top_to_bottom_window_popup_layout(GUIManager& gui, const char* id, Clay_SizingAxis x, Clay_SizingAxis y, const std::function& innerContent, const LayoutElement::Callbacks& callbacks) { - gui.element(id, [&] { - CLAY_AUTO_ID({ + gui.element(id, [&] (const Clay_ElementId& lId) { + CLAY(lId, { .layout = { .sizing = {.width = x, .height = y }, .padding = CLAY_PADDING_ALL(gui.io.theme->padding1), diff --git a/src/GUIStuff/ElementHelpers/NumberSliderHelpers.hpp b/src/GUIStuff/ElementHelpers/NumberSliderHelpers.hpp index f6bc1a3..bb40e44 100644 --- a/src/GUIStuff/ElementHelpers/NumberSliderHelpers.hpp +++ b/src/GUIStuff/ElementHelpers/NumberSliderHelpers.hpp @@ -7,7 +7,7 @@ namespace GUIStuff { namespace ElementHelpers { template void slider_scalar_field(GUIManager& gui, const char* id, std::string_view name, T* val, T min, T max, TextBoxScalarOptions options = {}) { gui.new_id(id, [&] { options.onEdit = [&, oE = options.onEdit] { - oE(); + if(oE) oE(); gui.set_to_layout(); }; left_to_right_line_layout(gui, [&]() { diff --git a/src/GUIStuff/ElementHelpers/PopupHelpers.cpp b/src/GUIStuff/ElementHelpers/PopupHelpers.cpp index aa51bf8..4533c2e 100644 --- a/src/GUIStuff/ElementHelpers/PopupHelpers.cpp +++ b/src/GUIStuff/ElementHelpers/PopupHelpers.cpp @@ -5,8 +5,8 @@ namespace GUIStuff { namespace ElementHelpers { void paint_circle_popup_menu(GUIManager& gui, const char* id, const Vector2f& centerPos, const PaintCircleMenu::Data& val) { constexpr float size = 300.0f; - gui.element(id, [&] { - CLAY_AUTO_ID({.layout = { + gui.element(id, [&] (const Clay_ElementId& lId) { + CLAY(lId, {.layout = { .sizing = {.width = CLAY_SIZING_FIXED(size), .height = CLAY_SIZING_FIXED(size)} }, .floating = { diff --git a/src/GUIStuff/Elements/CheckBox.cpp b/src/GUIStuff/Elements/CheckBox.cpp index 9edff5e..5c4a16e 100644 --- a/src/GUIStuff/Elements/CheckBox.cpp +++ b/src/GUIStuff/Elements/CheckBox.cpp @@ -8,11 +8,11 @@ namespace GUIStuff { CheckBox::CheckBox(GUIManager& gui): Element(gui) {} -void CheckBox::layout(const std::function& isTicked, const std::function& onClick) { +void CheckBox::layout(const Clay_ElementId& id, const std::function& isTicked, const std::function& onClick) { this->isTicked = isTicked; this->onClick = onClick; - CLAY_AUTO_ID({ + CLAY(id, { .layout = { .sizing = {.width = CLAY_SIZING_FIXED(15), .height = CLAY_SIZING_FIXED(15)} }, diff --git a/src/GUIStuff/Elements/CheckBox.hpp b/src/GUIStuff/Elements/CheckBox.hpp index ea65df3..282598c 100644 --- a/src/GUIStuff/Elements/CheckBox.hpp +++ b/src/GUIStuff/Elements/CheckBox.hpp @@ -11,7 +11,7 @@ class CheckBox : public Element { virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override; virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override; - void layout(const std::function& isTicked, const std::function& onClick); + void layout(const Clay_ElementId& id, const std::function& isTicked, const std::function& onClick); private: static constexpr float CHECKBOX_ANIMATION_TIME = 0.3; bool isHovering = false; diff --git a/src/GUIStuff/Elements/ColorPicker.decl.hpp b/src/GUIStuff/Elements/ColorPicker.decl.hpp index 8dbcb56..fca2041 100644 --- a/src/GUIStuff/Elements/ColorPicker.decl.hpp +++ b/src/GUIStuff/Elements/ColorPicker.decl.hpp @@ -61,7 +61,7 @@ namespace ColorPickerShaders { template class ColorPicker : public Element { public: ColorPicker(GUIManager& gui); - void layout(T* data, bool selectAlpha, const std::function& onChange); + void layout(const Clay_ElementId& id, T* data, bool selectAlpha, const std::function& onChange); virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA); bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override; bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override; diff --git a/src/GUIStuff/Elements/ColorPicker.impl.hpp b/src/GUIStuff/Elements/ColorPicker.impl.hpp index f7f2804..fcf9f6d 100644 --- a/src/GUIStuff/Elements/ColorPicker.impl.hpp +++ b/src/GUIStuff/Elements/ColorPicker.impl.hpp @@ -6,13 +6,13 @@ namespace GUIStuff { template ColorPicker::ColorPicker(GUIManager& gui): Element(gui) {} -template void ColorPicker::layout(T* data, bool selectAlpha, const std::function& onChange) { +template void ColorPicker::layout(const Clay_ElementId& id, T* data, bool selectAlpha, const std::function& onChange) { this->data = data; savedHsv = rgb_to_hsv(*data); this->selectAlpha = selectAlpha; this->onChange = onChange; - CLAY_AUTO_ID({ + CLAY(id, { .layout = { .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0) } }, diff --git a/src/GUIStuff/Elements/ColorPickerButton.decl.hpp b/src/GUIStuff/Elements/ColorPickerButton.decl.hpp index f7bf85c..036f85a 100644 --- a/src/GUIStuff/Elements/ColorPickerButton.decl.hpp +++ b/src/GUIStuff/Elements/ColorPickerButton.decl.hpp @@ -11,7 +11,7 @@ struct ColorPickerButtonData { template class ColorPickerButton : public Element { public: ColorPickerButton(GUIManager& gui); - void layout(T* val, const ColorPickerButtonData& d); + void layout(const Clay_ElementId& id, T* val, const ColorPickerButtonData& d); private: ColorPickerButtonData data; bool isOpen = false; diff --git a/src/GUIStuff/Elements/ColorPickerButton.impl.hpp b/src/GUIStuff/Elements/ColorPickerButton.impl.hpp index 4407bac..b543c7a 100644 --- a/src/GUIStuff/Elements/ColorPickerButton.impl.hpp +++ b/src/GUIStuff/Elements/ColorPickerButton.impl.hpp @@ -7,7 +7,7 @@ namespace GUIStuff { template ColorPickerButton::ColorPickerButton(GUIManager& gui): Element(gui) {} -template void ColorPickerButton::layout(T* val, const ColorPickerButtonData& d) { +template void ColorPickerButton::layout(const Clay_ElementId& id, T* val, const ColorPickerButtonData& d) { this->data = d; GUIStuff::ElementHelpers::color_button(gui, "Color Picker Button", val, { diff --git a/src/GUIStuff/Elements/ColorRectangleDisplay.cpp b/src/GUIStuff/Elements/ColorRectangleDisplay.cpp index 1a5bf10..f0132b1 100644 --- a/src/GUIStuff/Elements/ColorRectangleDisplay.cpp +++ b/src/GUIStuff/Elements/ColorRectangleDisplay.cpp @@ -6,8 +6,12 @@ sk_sp ColorRectangleDisplay::alphaBackgroundEffect; ColorRectangleDisplay::ColorRectangleDisplay(GUIManager& gui): Element(gui) {} -void ColorRectangleDisplay::layout(const std::function& colorFunc) { +void ColorRectangleDisplay::layout(const Clay_ElementId& id, const std::function& colorFunc) { this->colorFunc = colorFunc; + CLAY(id, { + .layout = {.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)}}, + .custom = {this} + }) {} } void ColorRectangleDisplay::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) { diff --git a/src/GUIStuff/Elements/ColorRectangleDisplay.hpp b/src/GUIStuff/Elements/ColorRectangleDisplay.hpp index 9fb7fec..0ddb117 100644 --- a/src/GUIStuff/Elements/ColorRectangleDisplay.hpp +++ b/src/GUIStuff/Elements/ColorRectangleDisplay.hpp @@ -7,7 +7,7 @@ namespace GUIStuff { class ColorRectangleDisplay : public Element { public: ColorRectangleDisplay(GUIManager& gui); - void layout(const std::function& colorFunc); + void layout(const Clay_ElementId& id, const std::function& colorFunc); virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) override; private: static constexpr const char* alphaBackgroundSksl = diff --git a/src/GUIStuff/Elements/DropDown.hpp b/src/GUIStuff/Elements/DropDown.hpp index 9aca317..324a634 100644 --- a/src/GUIStuff/Elements/DropDown.hpp +++ b/src/GUIStuff/Elements/DropDown.hpp @@ -17,7 +17,7 @@ struct DropdownOptions { template class DropDown : public Element { public: DropDown(GUIManager& gui): Element(gui) {} - void layout(T* data, const std::vector& selections, const DropdownOptions& options = {}) { + void layout(const Clay_ElementId& id, T* data, const std::vector& selections, const DropdownOptions& options = {}) { opts = options; ElementHelpers::left_to_right_layout(gui, CLAY_SIZING_FIXED(opts.width), CLAY_SIZING_FIT(0), [&] { gui.element("dropdown", SelectableButton::Data{ @@ -84,8 +84,8 @@ template class DropDown : public Element { .clipHorizontal = true, .elementContent = [&](size_t i) { bool selectedEntry = static_cast(*data) == i; - gui.element("elem", [&] { - CLAY_AUTO_ID({ + gui.element("elem", [&] (const Clay_ElementId& lId) { + CLAY(lId, { .layout = { .sizing = {.width = CLAY_SIZING_FIXED(250), .height = CLAY_SIZING_FIXED(18)}, .padding = CLAY_PADDING_ALL(0), diff --git a/src/GUIStuff/Elements/Element.cpp b/src/GUIStuff/Elements/Element.cpp index 115da88..59df8fc 100644 --- a/src/GUIStuff/Elements/Element.cpp +++ b/src/GUIStuff/Elements/Element.cpp @@ -13,12 +13,11 @@ namespace GUIStuff { void Element::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) {} - void Element::update_bounding_box(Clay_RenderCommand* command) { - boundingBox = get_bb_from_command(command); - } - - void Element::clear_bounding_box() { - boundingBox = std::nullopt; + 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; } const std::optional>& Element::get_bb() const { diff --git a/src/GUIStuff/Elements/Element.hpp b/src/GUIStuff/Elements/Element.hpp index 02fd199..ba2a6ca 100644 --- a/src/GUIStuff/Elements/Element.hpp +++ b/src/GUIStuff/Elements/Element.hpp @@ -11,8 +11,7 @@ namespace GUIStuff { virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA); virtual bool collides_with_point(const Vector2f& p) const; - void update_bounding_box(Clay_RenderCommand* command); - void clear_bounding_box(); + void set_bounding_box_from_elem_data(const Clay_ElementData& elemData); const std::optional>& get_bb() const; virtual ~Element() = default; diff --git a/src/GUIStuff/Elements/FontPicker.cpp b/src/GUIStuff/Elements/FontPicker.cpp index a76bfcf..0b8a9ae 100644 --- a/src/GUIStuff/Elements/FontPicker.cpp +++ b/src/GUIStuff/Elements/FontPicker.cpp @@ -12,7 +12,7 @@ namespace GUIStuff { FontPicker::FontPicker(GUIManager& gui): Element(gui) {} -void FontPicker::layout(const Data& data) { +void FontPicker::layout(const Clay_ElementId& id, const Data& data) { d = data; //auto& io = *gui.io; diff --git a/src/GUIStuff/Elements/FontPicker.hpp b/src/GUIStuff/Elements/FontPicker.hpp index 15f92c7..000594b 100644 --- a/src/GUIStuff/Elements/FontPicker.hpp +++ b/src/GUIStuff/Elements/FontPicker.hpp @@ -10,7 +10,7 @@ class FontPicker : public Element { std::function onFontChange; }; FontPicker(GUIManager& gui); - void layout(const Data& data); + void layout(const Clay_ElementId& id, const Data& data); private: Data d; diff --git a/src/GUIStuff/Elements/GUIStuffHelpers.hpp b/src/GUIStuff/Elements/GUIStuffHelpers.hpp index 1c27e73..fd15f0e 100644 --- a/src/GUIStuff/Elements/GUIStuffHelpers.hpp +++ b/src/GUIStuff/Elements/GUIStuffHelpers.hpp @@ -14,6 +14,7 @@ #include #include "../../RichText/TextBox.hpp" #include "../../InputManager.hpp" +#include "../GUIManagerID.hpp" using namespace Eigen; @@ -37,6 +38,18 @@ template class StringArena { Clay_String std_str_to_clay_str(std::string_view str) { return Clay_String{.length = static_cast(str.size()), .chars = insert_string_into_arena(str)}; } + Clay_ElementId elem_id_from_id_stack(const GUIManagerIDStack& idStack) { + std::string strToAdd; + for(const GUIManagerID& id : idStack) { + if(id.idIsStr) + strToAdd += reinterpret_cast(id.idNum); + else + strToAdd += std::to_string(id.idNum); + strToAdd += '~'; + } + Clay_String strForId = std_str_to_clay_str(strToAdd); + return CLAY_SID(strForId); + } private: std::array stringArena; size_t stringArenaIndex; diff --git a/src/GUIStuff/Elements/LayoutElement.cpp b/src/GUIStuff/Elements/LayoutElement.cpp index 12de50b..c9b554c 100644 --- a/src/GUIStuff/Elements/LayoutElement.cpp +++ b/src/GUIStuff/Elements/LayoutElement.cpp @@ -1,12 +1,13 @@ #include "LayoutElement.hpp" +#include "Helpers/ConvertVec.hpp" namespace GUIStuff { LayoutElement::LayoutElement(GUIManager& gui): Element(gui) {} -void LayoutElement::layout(const std::function& layout, const Callbacks& c) { +void LayoutElement::layout(const Clay_ElementId& id, const std::function& layout, const Callbacks& c) { this->c = c; - layout(); + layout(id); } bool LayoutElement::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) { diff --git a/src/GUIStuff/Elements/LayoutElement.hpp b/src/GUIStuff/Elements/LayoutElement.hpp index 10b7041..4f6d369 100644 --- a/src/GUIStuff/Elements/LayoutElement.hpp +++ b/src/GUIStuff/Elements/LayoutElement.hpp @@ -12,7 +12,7 @@ class LayoutElement : public Element { std::function mouseWheel; std::function key; }; - void layout(const std::function& layout, const Callbacks& c = {}); + void layout(const Clay_ElementId& id, const std::function& layout, const Callbacks& c = {}); virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override; virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override; virtual bool input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering) override; diff --git a/src/GUIStuff/Elements/MovableTabList.cpp b/src/GUIStuff/Elements/MovableTabList.cpp index 864ebcc..8c12340 100644 --- a/src/GUIStuff/Elements/MovableTabList.cpp +++ b/src/GUIStuff/Elements/MovableTabList.cpp @@ -7,7 +7,7 @@ namespace GUIStuff { MovableTabList::MovableTabList(GUIManager& gui): Element(gui) {} -void MovableTabList::layout(const Data& d) { +void MovableTabList::layout(const Clay_ElementId& id, const Data& d) { //CLAY_AUTO_ID({.layout = { // .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(GUIStuff::GUIManager::BIG_BUTTON_SIZE)}, // .padding = CLAY_PADDING_ALL(0), diff --git a/src/GUIStuff/Elements/MovableTabList.hpp b/src/GUIStuff/Elements/MovableTabList.hpp index 9545311..2f2f71d 100644 --- a/src/GUIStuff/Elements/MovableTabList.hpp +++ b/src/GUIStuff/Elements/MovableTabList.hpp @@ -15,7 +15,7 @@ class MovableTabList : public Element { }; MovableTabList(GUIManager& gui); - void layout(const Data& d); + void layout(const Clay_ElementId& id, const Data& d); }; } diff --git a/src/GUIStuff/Elements/NumberSlider.hpp b/src/GUIStuff/Elements/NumberSlider.hpp index ef7cbc2..28d1c63 100644 --- a/src/GUIStuff/Elements/NumberSlider.hpp +++ b/src/GUIStuff/Elements/NumberSlider.hpp @@ -9,13 +9,13 @@ template class NumberSlider : public Element { NumberSlider(GUIManager& gui): Element(gui) {} - void layout(T* data, T minData, T maxData, const std::function& onChange) { + void layout(const Clay_ElementId& id, T* data, T minData, T maxData, const std::function& onChange) { this->data = data; this->minData = minData; this->maxData = maxData; this->onChange = onChange; - CLAY_AUTO_ID({ + CLAY(id, { .layout = { .sizing = {.width = CLAY_SIZING_GROW(100), .height = CLAY_SIZING_FIXED(10)} }, @@ -76,23 +76,21 @@ template class NumberSlider : public Element { virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override { isHovering = mouseHovering; isHeld = isHovering && button.button == InputManager::MouseButton::LEFT && button.down; - update_slider_pos(button.pos); + if(isHeld && boundingBox.has_value()) + update_slider_pos(button.pos); return Element::input_mouse_button_callback(button, mouseHovering); } virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override { - update_slider_pos(motion.pos); return Element::input_mouse_motion_callback(motion, mouseHovering); } private: void update_slider_pos(const Vector2f& p) { gui.set_post_callback_func([&, p] { - if(isHeld && boundingBox.has_value()) { - float fracPosOnSlider = (p.x() - boundingBox.value().min.x()) / boundingBox.value().width(); - *data = static_cast(std::clamp(std::lerp(minData, maxData, fracPosOnSlider), minData, maxData)); // Clamp as double then cast so that unsigned types dont wrap on clamp - onChange(); - } + float fracPosOnSlider = (p.x() - boundingBox.value().min.x()) / boundingBox.value().width(); + *data = static_cast(std::clamp(std::lerp(minData, maxData, fracPosOnSlider), minData, maxData)); // Clamp as double then cast so that unsigned types dont wrap on clamp + if(onChange) onChange(); }); } diff --git a/src/GUIStuff/Elements/PaintCircleMenu.cpp b/src/GUIStuff/Elements/PaintCircleMenu.cpp index 5bb190e..3981396 100644 --- a/src/GUIStuff/Elements/PaintCircleMenu.cpp +++ b/src/GUIStuff/Elements/PaintCircleMenu.cpp @@ -14,10 +14,10 @@ constexpr double ROTATE_BAR_SNAP_DISTRIBUTION = std::numbers::pi * 0.25; PaintCircleMenu::PaintCircleMenu(GUIManager& gui): Element(gui) {} -void PaintCircleMenu::layout(const Data& data) { +void PaintCircleMenu::layout(const Clay_ElementId& id, const Data& data) { d = data; - CLAY_AUTO_ID({ + CLAY(id, { .layout = { .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)} }, diff --git a/src/GUIStuff/Elements/PaintCircleMenu.hpp b/src/GUIStuff/Elements/PaintCircleMenu.hpp index 0e7e948..502f0c6 100644 --- a/src/GUIStuff/Elements/PaintCircleMenu.hpp +++ b/src/GUIStuff/Elements/PaintCircleMenu.hpp @@ -13,7 +13,7 @@ class PaintCircleMenu : public Element { std::function onRotate; std::function onPaletteClick; }; - void layout(const Data& data); + void layout(const Clay_ElementId& id, const Data& data); virtual bool collides_with_point(const Vector2f& p) const override; virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) override; virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override; diff --git a/src/GUIStuff/Elements/PositionAdjustingPopupMenu.cpp b/src/GUIStuff/Elements/PositionAdjustingPopupMenu.cpp index 81d59a6..74d8a0b 100644 --- a/src/GUIStuff/Elements/PositionAdjustingPopupMenu.cpp +++ b/src/GUIStuff/Elements/PositionAdjustingPopupMenu.cpp @@ -1,11 +1,12 @@ #include "PositionAdjustingPopupMenu.hpp" #include "../GUIManager.hpp" +#include "Helpers/ConvertVec.hpp" namespace GUIStuff { PositionAdjustingPopupMenu::PositionAdjustingPopupMenu(GUIManager& gui): Element(gui) {} -void PositionAdjustingPopupMenu::layout(Vector2f popupPos, const std::function& innerContent) { +void PositionAdjustingPopupMenu::layout(const Clay_ElementId& id, Vector2f popupPos, const std::function& innerContent) { if(layoutElement && layoutElement->get_bb().has_value()) { auto& bb = layoutElement->get_bb().value(); if((popupPos.y() + bb.height()) > gui.io.windowSize.y()) @@ -14,8 +15,8 @@ void PositionAdjustingPopupMenu::layout(Vector2f popupPos, const std::function("popup", [&]{ - CLAY_AUTO_ID({ + layoutElement = gui.element("popup", [&] (const Clay_ElementId& lId) { + CLAY(lId, { .layout = { .sizing = {.width = CLAY_SIZING_FIT(100), .height = CLAY_SIZING_FIT(0)}, .padding = CLAY_PADDING_ALL(gui.io.theme->padding1), diff --git a/src/GUIStuff/Elements/PositionAdjustingPopupMenu.hpp b/src/GUIStuff/Elements/PositionAdjustingPopupMenu.hpp index 9177968..4663711 100644 --- a/src/GUIStuff/Elements/PositionAdjustingPopupMenu.hpp +++ b/src/GUIStuff/Elements/PositionAdjustingPopupMenu.hpp @@ -7,7 +7,7 @@ namespace GUIStuff { class PositionAdjustingPopupMenu : public Element { public: PositionAdjustingPopupMenu(GUIManager& gui); - void layout(Vector2f popupPos, const std::function& innerContent); + void layout(const Clay_ElementId& id, Vector2f popupPos, const std::function& innerContent); private: LayoutElement* layoutElement = nullptr; }; diff --git a/src/GUIStuff/Elements/RadioButton.cpp b/src/GUIStuff/Elements/RadioButton.cpp index cd67abf..3eefacf 100644 --- a/src/GUIStuff/Elements/RadioButton.cpp +++ b/src/GUIStuff/Elements/RadioButton.cpp @@ -6,11 +6,11 @@ namespace GUIStuff { RadioButton::RadioButton(GUIManager& gui): Element(gui) {} -void RadioButton::layout(const std::function& isTicked, const std::function& onClick) { +void RadioButton::layout(const Clay_ElementId& id, const std::function& isTicked, const std::function& onClick) { this->onClick = onClick; this->isTicked = isTicked; - CLAY_AUTO_ID({ + CLAY(id, { .layout = { .sizing = {.width = CLAY_SIZING_FIXED(20), .height = CLAY_SIZING_FIXED(20)} }, diff --git a/src/GUIStuff/Elements/RadioButton.hpp b/src/GUIStuff/Elements/RadioButton.hpp index 2d78e0d..ea6ad9d 100644 --- a/src/GUIStuff/Elements/RadioButton.hpp +++ b/src/GUIStuff/Elements/RadioButton.hpp @@ -10,7 +10,7 @@ class RadioButton : public Element { virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override; virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override; - void layout(const std::function& isTicked, const std::function& onClick); + void layout(const Clay_ElementId& id, const std::function& isTicked, const std::function& onClick); private: static constexpr float RADIOBUTTON_ANIMATION_TIME = 0.3; bool isHovering = false; diff --git a/src/GUIStuff/Elements/RotateWheel.cpp b/src/GUIStuff/Elements/RotateWheel.cpp index 801356f..d8165de 100644 --- a/src/GUIStuff/Elements/RotateWheel.cpp +++ b/src/GUIStuff/Elements/RotateWheel.cpp @@ -12,11 +12,11 @@ constexpr double ROTATE_BAR_SNAP_DISTRIBUTION = std::numbers::pi * 0.25; RotateWheel::RotateWheel(GUIManager& gui): Element(gui) {} -void RotateWheel::layout(double* rotateAngle, const std::function& onChange) { +void RotateWheel::layout(const Clay_ElementId& id, double* rotateAngle, const std::function& onChange) { this->rotateAngle = rotateAngle; this->onChange = onChange; - CLAY_AUTO_ID({ + CLAY(id, { .layout = { .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)} }, diff --git a/src/GUIStuff/Elements/RotateWheel.hpp b/src/GUIStuff/Elements/RotateWheel.hpp index ee0d2f4..5ac7feb 100644 --- a/src/GUIStuff/Elements/RotateWheel.hpp +++ b/src/GUIStuff/Elements/RotateWheel.hpp @@ -6,7 +6,7 @@ namespace GUIStuff { class RotateWheel : public Element { public: RotateWheel(GUIManager& gui); - void layout(double* rotateAngle, const std::function& onChange); + void layout(const Clay_ElementId& id, double* rotateAngle, const std::function& onChange); virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) override; virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override; virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override; diff --git a/src/GUIStuff/Elements/SVGIcon.cpp b/src/GUIStuff/Elements/SVGIcon.cpp index 9f6b143..1075daa 100644 --- a/src/GUIStuff/Elements/SVGIcon.cpp +++ b/src/GUIStuff/Elements/SVGIcon.cpp @@ -10,7 +10,7 @@ namespace GUIStuff { SVGIcon::SVGIcon(GUIManager& gui): Element(gui) {} -void SVGIcon::layout(const std::string& newSvgPath, bool newIsHighlighted) { +void SVGIcon::layout(const Clay_ElementId& id, const std::string& newSvgPath, bool newIsHighlighted) { auto& io = gui.io; auto findSVGData = io.svgData.find(newSvgPath); if(findSVGData == io.svgData.end()) @@ -20,7 +20,7 @@ void SVGIcon::layout(const std::string& newSvgPath, bool newIsHighlighted) { highlighted = newIsHighlighted; - CLAY_AUTO_ID({ + CLAY(id, { .layout = { .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0) } }, diff --git a/src/GUIStuff/Elements/SVGIcon.hpp b/src/GUIStuff/Elements/SVGIcon.hpp index 5941c75..239def7 100644 --- a/src/GUIStuff/Elements/SVGIcon.hpp +++ b/src/GUIStuff/Elements/SVGIcon.hpp @@ -6,7 +6,7 @@ namespace GUIStuff { class SVGIcon : public Element { public: SVGIcon(GUIManager& gui); - void layout(const std::string& newSvgPath, bool newIsHighlighted); + void layout(const Clay_ElementId& id, const std::string& newSvgPath, bool newIsHighlighted); virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) override; private: bool highlighted; diff --git a/src/GUIStuff/Elements/ScrollArea.cpp b/src/GUIStuff/Elements/ScrollArea.cpp index 9a5cf37..1097799 100644 --- a/src/GUIStuff/Elements/ScrollArea.cpp +++ b/src/GUIStuff/Elements/ScrollArea.cpp @@ -5,9 +5,9 @@ namespace GUIStuff { ScrollArea::ScrollArea(GUIManager& gui): Element(gui) {} -void ScrollArea::layout(const Options& options) { +void ScrollArea::layout(const Clay_ElementId& id, const Options& options) { opts = options; - CLAY_AUTO_ID({ + CLAY(id, { .layout = {.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)}} }) { Clay_ElementId localID = CLAY_ID_LOCAL("SCROLL_AREA"); diff --git a/src/GUIStuff/Elements/ScrollArea.hpp b/src/GUIStuff/Elements/ScrollArea.hpp index 8916b4b..4835894 100644 --- a/src/GUIStuff/Elements/ScrollArea.hpp +++ b/src/GUIStuff/Elements/ScrollArea.hpp @@ -25,7 +25,7 @@ class ScrollArea : public Element { std::function innerContent; }; - void layout(const Options& options); + void layout(const Clay_ElementId& id, const Options& options); virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override; virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override; diff --git a/src/GUIStuff/Elements/SelectableButton.cpp b/src/GUIStuff/Elements/SelectableButton.cpp index 4435ed7..f86c160 100644 --- a/src/GUIStuff/Elements/SelectableButton.cpp +++ b/src/GUIStuff/Elements/SelectableButton.cpp @@ -7,7 +7,7 @@ namespace GUIStuff { SelectableButton::SelectableButton(GUIManager& gui): Element(gui) {} -void SelectableButton::layout(const Data& d) { +void SelectableButton::layout(const Clay_ElementId& id, const Data& d) { auto& io = gui.io; SkColor4f borderColor; @@ -37,7 +37,7 @@ void SelectableButton::layout(const Data& d) { else backgroundColor = io.theme->fillColor2; - CLAY_AUTO_ID({.layout = { + CLAY(id, {.layout = { .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)}, .childGap = 0, .childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER } diff --git a/src/GUIStuff/Elements/SelectableButton.hpp b/src/GUIStuff/Elements/SelectableButton.hpp index c244ead..6c554ff 100644 --- a/src/GUIStuff/Elements/SelectableButton.hpp +++ b/src/GUIStuff/Elements/SelectableButton.hpp @@ -26,7 +26,7 @@ class SelectableButton : public Element { }; SelectableButton(GUIManager& gui); - void layout(const Data& d); + void layout(const Clay_ElementId& id, const Data& d); virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override; virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override; diff --git a/src/GUIStuff/Elements/TextBox.decl.hpp b/src/GUIStuff/Elements/TextBox.decl.hpp index a6e53ae..d8f8c5e 100644 --- a/src/GUIStuff/Elements/TextBox.decl.hpp +++ b/src/GUIStuff/Elements/TextBox.decl.hpp @@ -24,7 +24,7 @@ template class TextBox : public Element { public: TextBox(GUIManager& gui); - void layout(const TextBoxData& userInfo); + void layout(const Clay_ElementId& id, const TextBoxData& userInfo); virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) override; virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override; virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override; diff --git a/src/GUIStuff/Elements/TextBox.impl.hpp b/src/GUIStuff/Elements/TextBox.impl.hpp index 1034d00..408a908 100644 --- a/src/GUIStuff/Elements/TextBox.impl.hpp +++ b/src/GUIStuff/Elements/TextBox.impl.hpp @@ -5,11 +5,11 @@ namespace GUIStuff { template TextBox::TextBox(GUIManager& gui): Element(gui) {} -template void TextBox::layout(const TextBoxData& userInfo) { +template void TextBox::layout(const Clay_ElementId& id, const TextBoxData& userInfo) { auto& io = gui.io; this->userInfo = userInfo; init_textbox(io); - CLAY_AUTO_ID({ + CLAY(id, { .layout = { .sizing = {.width = CLAY_SIZING_GROW(static_cast(io.fontSize * 2)), .height = CLAY_SIZING_FIXED(static_cast(io.fontSize * 1.25f))} }, diff --git a/src/GUIStuff/Elements/TextParagraph.cpp b/src/GUIStuff/Elements/TextParagraph.cpp index 211b159..f4369c5 100644 --- a/src/GUIStuff/Elements/TextParagraph.cpp +++ b/src/GUIStuff/Elements/TextParagraph.cpp @@ -7,10 +7,10 @@ namespace GUIStuff { TextParagraph::TextParagraph(GUIManager& gui): Element(gui) {} -void TextParagraph::layout(std::unique_ptr paragraph, float width) { +void TextParagraph::layout(const Clay_ElementId& id, std::unique_ptr paragraph, float width) { data = std::move(paragraph); data->layout(width); - CLAY_AUTO_ID({ + CLAY(id, { .layout = { .sizing = {.width = CLAY_SIZING_FIXED(width), .height = CLAY_SIZING_FIXED(data->getHeight())} }, diff --git a/src/GUIStuff/Elements/TextParagraph.hpp b/src/GUIStuff/Elements/TextParagraph.hpp index fa0ac6b..945ba65 100644 --- a/src/GUIStuff/Elements/TextParagraph.hpp +++ b/src/GUIStuff/Elements/TextParagraph.hpp @@ -7,7 +7,7 @@ namespace GUIStuff { class TextParagraph : public Element { public: TextParagraph(GUIManager& gui); - void layout(std::unique_ptr paragraph, float width); + void layout(const Clay_ElementId& id, std::unique_ptr paragraph, float width); virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) override; private: std::unique_ptr data; diff --git a/src/GUIStuff/Elements/TreeListing.cpp b/src/GUIStuff/Elements/TreeListing.cpp index ab34240..f0ab85f 100644 --- a/src/GUIStuff/Elements/TreeListing.cpp +++ b/src/GUIStuff/Elements/TreeListing.cpp @@ -12,7 +12,7 @@ namespace GUIStuff { TreeListing::TreeListing(GUIManager& gui): Element(gui) {} -void TreeListing::layout(NetworkingObjects::NetObjID rootObjID, const DisplayData& displayData, SelectionData& selectionData) { +void TreeListing::layout(const Clay_ElementId& id, NetworkingObjects::NetObjID rootObjID, const DisplayData& displayData, SelectionData& selectionData) { //auto& io = *gui.io; //if(!io.mouse.leftHeld) diff --git a/src/GUIStuff/Elements/TreeListing.hpp b/src/GUIStuff/Elements/TreeListing.hpp index 036ea13..eab7d14 100644 --- a/src/GUIStuff/Elements/TreeListing.hpp +++ b/src/GUIStuff/Elements/TreeListing.hpp @@ -41,7 +41,7 @@ class TreeListing : public Element { }; TreeListing(GUIManager& gui); - void layout(NetworkingObjects::NetObjID rootObjID, const DisplayData& displayData, SelectionData& selectionData); + void layout(const Clay_ElementId& id, NetworkingObjects::NetObjID rootObjID, const DisplayData& displayData, SelectionData& selectionData); virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override; virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override; virtual void input_key_callback(const InputManager::KeyCallbackArgs& key) override; diff --git a/src/GUIStuff/GUIManager.cpp b/src/GUIStuff/GUIManager.cpp index 4621053..832b130 100644 --- a/src/GUIStuff/GUIManager.cpp +++ b/src/GUIStuff/GUIManager.cpp @@ -256,6 +256,8 @@ void GUIManager::layout_begin() { strArena.reset(); + orderedElements.clear(); + Clay_BeginLayout(); } @@ -266,19 +268,9 @@ void GUIManager::layout_end() { std::erase_if(elements, [](auto& p) { return !p.second.isUsedThisFrame; }); - update_element_bounding_boxes(); -} - -void GUIManager::update_element_bounding_boxes() { - for(auto& e : elements) - e.second.elem->clear_bounding_box(); - for(size_t i = 0; i < static_cast(renderCommands.length); i++) { - Clay_RenderCommand* command = Clay_RenderCommandArray_Get(&renderCommands, i); - if(command->commandType == CLAY_RENDER_COMMAND_TYPE_CUSTOM) { - Element* customElement = static_cast(command->renderData.custom.customData); - customElement->update_bounding_box(command); - } - } + std::stable_sort(orderedElements.begin(), orderedElements.end(), [](ElementContainer* a, ElementContainer* b) { + return b->elem->zIndex < a->elem->zIndex; // Order from highest to lowest zIndex + }); } void GUIManager::single_layout_run() { @@ -319,4 +311,51 @@ void GUIManager::set_post_callback_func(const std::function& f) { postCallbackFunc = f; } +void GUIManager::run_post_callback_func() { + if(postCallbackFunc) { + postCallbackFunc(); + postCallbackFunc = nullptr; + } +} + +bool GUIManager::cursor_obstructed() const { + return cursorObstructed; +} + +void GUIManager::input_key_callback(const InputManager::KeyCallbackArgs& key) { + for(ElementContainer* e : orderedElements) + e->elem->input_key_callback(key); + run_post_callback_func(); +} + +void GUIManager::input_mouse_button_callback(InputManager::MouseButtonCallbackArgs button) { + button.pos *= io.guiScaleMultiplier; + mouse_callback(button.pos, [&button] (ElementContainer* e, bool mouseHovering) { e->elem->input_mouse_button_callback(button, mouseHovering); }); +} + +void GUIManager::input_mouse_motion_callback(InputManager::MouseMotionCallbackArgs motion) { + motion.pos *= io.guiScaleMultiplier; + mouse_callback(motion.pos, [&motion] (ElementContainer* e, bool mouseHovering) { e->elem->input_mouse_motion_callback(motion, mouseHovering); }); +} + +void GUIManager::input_mouse_wheel_callback(InputManager::MouseWheelCallbackArgs wheel) { + wheel.mousePos *= io.guiScaleMultiplier; + mouse_callback(wheel.mousePos, [&wheel] (ElementContainer* e, bool mouseHovering) { e->elem->input_mouse_wheel_callback(wheel, mouseHovering); }); +} + +void GUIManager::mouse_callback(const Vector2f& mousePos, const std::function& f) { + cursorObstructed = false; + int16_t zIndexObstructed = 0; + for(ElementContainer* e : orderedElements) { + if((!cursorObstructed || zIndexObstructed == e->elem->zIndex) && e->elem->get_bb().has_value() && SCollision::collide(e->elem->get_bb().value(), mousePos)) { + zIndexObstructed = e->elem->zIndex; + cursorObstructed = true; + f(e, true); + } + else + f(e, false); + } + run_post_callback_func(); +} + } diff --git a/src/GUIStuff/GUIManager.hpp b/src/GUIStuff/GUIManager.hpp index fe5bee6..fda5262 100644 --- a/src/GUIStuff/GUIManager.hpp +++ b/src/GUIStuff/GUIManager.hpp @@ -25,38 +25,50 @@ class GUIManager { UpdateInputData io; - GUIManagerIDStack idStack; - std::unordered_map elements; - void new_id(const char* id, const std::function& f); void new_id(int64_t id, const std::function& f); void set_post_callback_func(const std::function& f); + void run_post_callback_func(); int16_t zIndex = 0; template ElementType* element(const char* id, const Args&... a) { push_id(id); ElementType* elem = insert_element(); - elem->layout(a...); + Clay_ElementId clayId = strArena.elem_id_from_id_stack(idStack); + elem->set_bounding_box_from_elem_data(Clay_GetElementData(clayId)); + elem->layout(clayId, a...); pop_id(); return elem; } DefaultStringArena strArena; + void input_key_callback(const InputManager::KeyCallbackArgs& key); + void input_mouse_button_callback(InputManager::MouseButtonCallbackArgs button); + void input_mouse_motion_callback(InputManager::MouseMotionCallbackArgs motion); + void input_mouse_wheel_callback(InputManager::MouseWheelCallbackArgs wheel); + + bool cursor_obstructed() const; private: void layout(); - void update_element_bounding_boxes(); void layout_begin(); void layout_end(); void single_layout_run(); + void mouse_callback(const Vector2f& mousePos, const std::function& f); + + GUIManagerIDStack idStack; + std::vector orderedElements; + std::unordered_map elements; + template NewElement* insert_element() { auto [it, inserted] = elements.emplace(idStack, ElementContainer()); auto& container = it->second; if(inserted) container = {std::make_unique(*this)}; container.elem->zIndex = zIndex; + orderedElements.emplace_back(&container); container.isUsedThisFrame = true; return static_cast(it->second.elem.get()); } @@ -73,6 +85,7 @@ class GUIManager { Clay_Arena clayArena; Clay_RenderCommandArray renderCommands; bool setToLayout; + bool cursorObstructed; }; } diff --git a/src/MainProgram.cpp b/src/MainProgram.cpp index 5efd611..9f23585 100755 --- a/src/MainProgram.cpp +++ b/src/MainProgram.cpp @@ -349,21 +349,25 @@ void MainProgram::input_key_callback(const InputManager::KeyCallbackArgs& key) { drawGui = !drawGui; } } + g.input_key_callback(key); if(world) world->input_key_callback(key); } void MainProgram::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button) { + g.input_mouse_button_callback(button); if(world) world->input_mouse_button_callback(button); } void MainProgram::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion) { + g.input_mouse_motion_callback(motion); if(world) world->input_mouse_motion_callback(motion); } void MainProgram::input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel) { + g.input_mouse_wheel_callback(wheel); if(world) world->input_mouse_wheel_callback(wheel); } diff --git a/src/Toolbar.cpp b/src/Toolbar.cpp index 87a001f..9759528 100644 --- a/src/Toolbar.cpp +++ b/src/Toolbar.cpp @@ -546,8 +546,8 @@ void Toolbar::top_toolbar() { layer_menu(layerMenuPopUpJustOpen); } if(menuPopUpOpen) { - gui.element("main menu popup", [&] { - CLAY_AUTO_ID({ + gui.element("main menu popup", [&] (const Clay_ElementId& id) { + CLAY(id, { .layout = { .sizing = {.width = CLAY_SIZING_FIT(100), .height = CLAY_SIZING_FIT(0) }, .padding = CLAY_PADDING_ALL(io.theme->padding1), @@ -1518,8 +1518,8 @@ void Toolbar::center_obstructing_window_gui(const char* id, Clay_SizingAxis x, C auto& gui = main.g.gui; auto& io = gui.io; - gui.element(id, [&] { - CLAY_AUTO_ID({ + gui.element(id, [&] (const Clay_ElementId& id) { + CLAY(id, { .layout = { .sizing = {.width = x, .height = y }, .padding = CLAY_PADDING_ALL(io.theme->padding1), @@ -2109,8 +2109,8 @@ void Toolbar::file_picker_gui() { .elementContent = [&] (size_t i) { const std::filesystem::path& entry = filePicker.entries[i]; bool selectedEntry = filePicker.currentSelectedPath == entry; - gui.element("elem", [&] { - CLAY_AUTO_ID({ + gui.element("elem", [&] (const Clay_ElementId& lId) { + CLAY(lId, { .layout = { .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(entryHeight)}, .childGap = 1,