andlabs / libui

Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.
Other
10.72k stars 614 forks source link

How to capture resize events? #443

Open bartgrantham opened 5 years ago

bartgrantham commented 5 years ago

Is it possible to capture resize events on areas, controls, windows, ...anything? I'm using the Go ui library and expected to see this as a method in the AreaHandler interface. I don't see any event-handling mechanisms in libui, is this an explicit design decision to avoid having an event queue, event pump, etc.?

mischnic commented 5 years ago

Were you looking for this? https://github.com/andlabs/libui/blob/7138276ccfbde94873cb6e2db65642adcbd2ee19/ui.h#L126

expected to see this as a method in the AreaHandler interface

The draw callback in the AreaHandler get's called on resize as well, because a redraw is needed.

bartgrantham commented 5 years ago

Of course. That's what I was looking for, thank you.

Although I'm still curious: there's no big, heavy "event" system in libui, is that a specific design goal?

andlabs commented 5 years ago

That depends on what you mean by "big, heavy "event" system".

And yes, Area size handling needs to be improved, as an extension of Area scroll handling needing to be improved.

bartgrantham commented 5 years ago

Event system: like SDL2 where I would wrap some kind of event polling and then switch on the type.

For what I was working on I was expecting to hook into window resize, but I guess with layout being governed by window size it makes sense that ultimately it's an event on Area that I wanted to use. The draw callback in the WindowHandler interface is fine for this.

BTW, what is the best place to ask questions about ui or libui? So far I'm digging it and want to make sure I get the most out of it as it develops.

andlabs commented 5 years ago

I'll address your response later; for now, the only real place to ask questions is here.