Fixed more issues in file picker

This commit is contained in:
Yousef Khadadeh 2026-04-01 22:28:48 +03:00
parent 10217e97f4
commit f90cf5b026
8 changed files with 19 additions and 6 deletions

View file

@ -3,8 +3,8 @@
namespace GUIStuff { namespace ElementHelpers {
void scroll_area_many_entries(GUIManager& gui, const char* id, const ScrollBarManyEntriesOptions& options) {
gui.clipping_element<ScrollArea>(id, ScrollArea::Options{
ScrollArea* scroll_area_many_entries(GUIManager& gui, const char* id, const ScrollBarManyEntriesOptions& options) {
return gui.clipping_element<ScrollArea>(id, ScrollArea::Options{
.scrollVertical = true,
.clipHorizontal = options.clipHorizontal,
.clipVertical = true,

View file

@ -11,6 +11,6 @@ struct ScrollBarManyEntriesOptions {
std::function<void(const ScrollArea::InnerContentParameters&)> innerContentExtraCallback;
};
void scroll_area_many_entries(GUIManager& gui, const char* id, const ScrollBarManyEntriesOptions& options);
ScrollArea* scroll_area_many_entries(GUIManager& gui, const char* id, const ScrollBarManyEntriesOptions& options);
}}

View file

@ -4,6 +4,7 @@
#include <include/core/SkColorSpace.h>
#include <iostream>
#include "../GUIManager.hpp"
#include "Helpers/MathExtras.hpp"
namespace GUIStuff {

View file

@ -138,6 +138,10 @@ void ScrollArea::layout(const Clay_ElementId& id, const Options& options) {
}
}
void ScrollArea::reset_scroll() {
scrollOffset = {0.0f, 0.0f};
}
bool ScrollArea::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
return Element::input_mouse_button_callback(button, mouseHovering);
}

View file

@ -26,6 +26,7 @@ class ScrollArea : public Element {
};
void layout(const Clay_ElementId& id, const Options& options);
void reset_scroll();
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;

View file

@ -40,8 +40,8 @@ class GUIManager {
ElementType* elem = insert_element<ElementType>();
Clay_ElementId clayId = strArena.elem_id_from_id_stack(idStack);
elem->set_parent_clipping_region(clippingRegion);
elem->set_bounding_box_from_elem_data(Clay_GetElementData(clayId));
elem->layout(clayId, a...);
elem->set_bounding_box_from_elem_data(Clay_GetElementData(clayId)); // Setting bounding box after layout ensures that the element will have its bounding box set if it's set to be drawn.
pop_id();
return elem;
}
@ -50,7 +50,6 @@ class GUIManager {
push_id(id);
ElementType* elem = insert_element<ElementType>();
Clay_ElementId clayId = strArena.elem_id_from_id_stack(idStack);
elem->set_bounding_box_from_elem_data(Clay_GetElementData(clayId));
elem->set_parent_clipping_region(clippingRegion);
auto oldClippingRegion = clippingRegion;
if(elem->get_bb().has_value()) {
@ -60,6 +59,7 @@ class GUIManager {
clippingRegion = elem->get_bb();
}
elem->layout(clayId, a...);
elem->set_bounding_box_from_elem_data(Clay_GetElementData(clayId));
clippingRegion = oldClippingRegion;
pop_id();
return elem;