Main Menu

Recent posts

#71
General Discussion / Re: multiple windows
Last post by texus - 06 November 2024, 18:37:21
Apparently SDL3 added a SDL_GetWindowFromEvent(event) function that you can use to determine which window the event came from (and thus you can use that to forward the event to the right gui, or forward it to both guis when the function returns NULL).
#72
General Discussion / Re: Custom Widgets - Clock and...
Last post by texus - 06 November 2024, 18:32:10
No. If you want something like that then I'm afraid you will have to create it yourself.
#73
General Discussion / Re: Custom Widgets - Clock and...
Last post by KSergeyP - 06 November 2024, 16:23:41
Is it tgui?
#74
General Discussion / Re: multiple windows
Last post by texus - 06 November 2024, 14:37:58
Quote from: KSergeyP on 06 November 2024, 14:00:53But it would be better to implement this in TGUI
Since TGUI already has to handle each type of event separately, it should indeed be possible to do the filtering inside "gui.handleEvent".

The only issue with it, is that it would become harder to add fake events (e.g. create your own mouse move event and passing that to the gui). So I'll add the filtering to TGUI, but I might put it behind some option that you need to enable first to keep the filtering on windowID disabled by default.
#75
General Discussion / Re: multiple windows
Last post by KSergeyP - 06 November 2024, 14:00:53
Thanks, it's clearer now.
It looks like you need to write a wrapper to determine which window the event is from, analyzing all events that have a WindowID.
But it would be better to implement this in TGUI
#76
General Discussion / Re: multiple windows
Last post by texus - 06 November 2024, 13:23:20
The closest thing that I have is an older example that I once wrote: https://tgui.eu/tutorials/0.9/sdl-backend/#multiple-windows (it's for TGUI 0.9 which is why it e.g. uses GuiSDL instead of just Gui)

You basically need the correct OpenGL context selected whenever interacting with the gui (with SDL_GL_MakeCurrent in SDL2), and you need to use the windowID in the events to figure out which gui they belong to.

I just noticed that the example code actually contains a mistake. It accesses event.window.windowID but that is only allowed for window events (e.g. windows resize). Other events (e.g. SDL_KeyboardEvent) also contain a windowID property though.

I don't recommend using different threads for this though. TGUI code can only be accessed from one thread at a time (so you can't be handling events or drawing on both threads at the same time). You would need locks everywhere. Also OpenGL isn't really thread-safe. You need to activate the correct OpenGL context (with SDL_GL_MakeCurrent) before rendering, so you can't render with both threads at the same time even if TGUI was thread-safe.
#77
General Discussion / multiple windows
Last post by KSergeyP - 06 November 2024, 12:18:28
How?)
Backend: SDL3_OPENGL(Using the new SDL3 Callback App Structure)
Tried to launch SDL_EnterAppMainCallbacks (2 windows) from different threads. Windows are created, but the first created window slows down, the second created window works well.
I also tried to create 2 windows at once from one thread - both work well, but it is unclear how to distinguish from which window I receive events?
Are there any examples of correctly launching multiple windows. Preferably in different threads.
#78
General Discussion / Re: Custom Widgets - Clock and...
Last post by KSergeyP - 06 November 2024, 04:35:06
yes this is what I need
#79
General Discussion / Re: Custom Widgets - Clock and...
Last post by texus - 05 November 2024, 19:53:25
TGUI has nothing for time or date picking.

Can you explain a bit more what exactly you would want though? I'm imagining you mean something like a date picker that looks like the attached image?
#80
General Discussion / Custom Widgets - Clock and Cal...
Last post by KSergeyP - 05 November 2024, 19:33:17
Are there any libraries (SDL or SFML) for creating clock and calendar that can be used with TGUI?
Are there any plans to add these widgets to TGUI?