Big realization after stream that makes a lot of this a lot easier. Widgets are already type erased when added to the layout system! This means that we are totally free to add compile time interfaces to widgets themselves. Many instantiations of the same DragFloat can have different sizes. This fixes a huge part of the complexity of handling callbacks with context pointers. E.g. retrieving a float for a DragFloat with some custom internal data can be as simple as ``` const AppGetAdjustableFloat = struct { app: *App, idx: usize, fn getVal(self: AppGetAdjustableFloat) f32 { return self.app.adjustable_float[self.idx]; } }; ``` Then our DragFloat just has a signiture DragFloat(comptime ActionType: type, comptime ValRetriever: type)
@mcmaddieАй бұрын
Never written a line of Zig and know it only by name and yet here I am coming back to these streams. I'm long time C/C++ coder myself. Maybe I'll learn something here. :)
@AlexMG54Ай бұрын
Nice, I've been working on a retained-mode UI library of my own in C and OpenGL. The most time consuming widget has been the Edit Text field (which still has a lot of work to do but I'm actually not really using it at the moment so bleh lol). Just wrapped up a scroll view that supports keyboard navigation. I probably will need to make a draggable float field as well. Thanks for the stream, it's interesting seeing how you approach it!
@11WicToR11Ай бұрын
dont you think you should break that file into more files? i mean navigation in vim across buffers is so much better than in a single one imho
@PopescuAlexandruCristianАй бұрын
Dear IMGUI cheats for all this cases by having a ton of global data that it resets in different events based on what you interact with. A context that you pass around is seiner in my perspective.