-
-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Proposal] clay_interactions.h #231
Comments
Thanks for opening this, for external readers this is definitely the direction that we're going to go long term. |
I really like Clay for its current simplicity and limited scope. This seems in line with the approach of choosing C in the first place. For what its worth, i'd definitely prefer having a layout-only clay core with a rich set of examples to provide further ideas on handling input (the raylib examples work well). A clay_interactions.h file may quickly run into issues of not being exhaustive enough to cover every possible concern people may ask for; theres some value in explicitly not being super opinionated there. Do see value in one thing: A query to get all elements at a specific X/Y seems a bit more general-purpose over the current in-house solutions around detecting hovered elements - sorry if i'm missing something there that already exists |
Yeah, that's basically the inspiration for this proposal in the first place. All that said, I think clay should probably have a recommended solution that covers the 80-90% of use cases to make it easier to get started. |
There's been a bunch of discussions in the discord server, and in the github issues (#230, #224, #198, #197, #154, #67) about moving mouse/scroll interactions out of clay.h and leave it for the user space. While I do personally think that clay should come out of the box with support for mouse/keyboard/scroll inputs (as well as accessibility features like tab indexes, keyboard navigation, etc), I wanted to start a thread about how an input system could be developed on top of clay.h. I'll be referring to a theoretical header called
clay_interactions.h
, which could be bundled in the clay repo. But even if not, I think this is still a useful exercise, as anyone trying to implement this will still have similar requirements.Things that I'm intentionally leaving out of scope here:
State Management
One of the first problems that needs to be solved, is how could such a library store its state? For example:
The library can of course have its own memory storage, like having its own arena. However, this means that the consumer would need to allocate multiple blocks of memory and track them separately, and take extra caution not to mix & match contexts with different interaction memory.
Proposal for clay.h
Clay_Context
to include additional third party data, preferably in a generic/extensible way. This would allow third party libraries to keep their data co-located with the clay context, and could be re-allocated at the same time as the rest of the memory, e.g. if max element count needs to be increased.Querying Layout Information
There's a lot of tasks that an interactions library might need to perform based on the final layout data from the previous frame:
Proposal for clay.h
clay.h
doesn't need to directly solve these problems for us, but it should provide some tools that could be used to implement solutions for them:Get the bounding box for an element[Core] Add API to query element bounding boxes #199Scroll Views
Scroll views are already implemented in
clay.h
, but if we want to move them to user space, we'll need a more generic way to render them.Proposal for clay.h
overflow: hidden
for containers, to allow children to exceed the parent bounding box and clip contentsThe text was updated successfully, but these errors were encountered: