refactor(simu): use SDL & ImGui
This is a refactor of the good old simu that now uses only SDL & ImGui (fetched via CMake). On macOS, this does not require XQuartz anymore. The simulated screen scales automatically with the window size.
The function switches I recently added to the simu are missing from this variant
Yeah, sorry, that’s really for now just a simple rebase of what I had since a long time. I can add them later.
Looks very nice, I miss the CFS too, but other than that works fine on MacOSX Sequoia
Issues:
- build fails for radios without function switches (tx16s)
- function switch buttons are invisible for radios without LEDs (t15)
build fails for radios without function switches (tx16s) function switch buttons are invisible for radios without LEDs (t15)
Both fixed. I improved the visuals a bit more, and switching to dark/light mode should work properly as well (d/l keys).
C'est comme les Kinder : Bueno !
Hm ... hoping this will go away when we finally jump to Ubuntu 22.04 for the build container, else will now need to manually build/install libSDL2 in order to use simu ... either that, or add it to the build container ...
/workspaces/edgetx/build-tx16s/native/radio/src/targets/simu/imgui/backends/imgui_impl_sdlrenderer2.cpp:50:2: error: #error This backend requires SDL 2.0.17+ because of SDL_RenderGeometry() function 50 | #error This backend requires SDL 2.0.17+ because of SDL_RenderGeometry() function | ^~~~~
libsdl2-2.0-0 is already the newest version (2.0.10+dfsg1-3).
On Linux Mint, running VSCode devcontainer, moving the simu window makes the window go nuts - I think it is trying to auto-resize and gets it wrong in a big way? I've not tried yet on Windows via WSL2 so will be interesting to see if that behaves the same, or actually works now... :open_mouth: Plus not every screen is a Retina screen, so the screen sizing is a bit big ;)
https://youtu.be/KEcgpNYAU0Y
either that, or add it to the build container
Here it is: https://github.com/EdgeTX/build-edgetx/pull/30
On Linux Mint, running VSCode devcontainer, moving the simu window makes the window go nuts - I think it is trying to auto-resize and gets it wrong in a big way?
~~Ok, I'll try to find out what's going wrong.~~ Window resize is a big pain with SDL2...
It seems I cannot run simu via remote X... which makes sense since it uses the OpenGL renderer on Linux... I might have to tweak something. Running this on Windows via WSL2 might be tricky as well. I might need some software rendering fallback.
@pfeerick could you try commenting out this block?
Edit: seems it might really have been because of the minimum size. I pushed something that might fix it.
Moving the window no longer results in simu having a mild seizure :) UI is still double resolution on non-ultrahigh DPI resolutions, but I can at least resize the window to fix that now also. And new build container just worked.
Running on Windows via WSL2/WSLg "worked" (which it hasn't done for quite a while) but seems to have some issues with timing... it sort of does and doesn't register mouse input as input. Given this hasn't worked properly for me for a while now, I'm not overly fussed about that working right now. i.e. if it works fine for you on macOS also, so just let me know when you're finished with this for now... ;)
UI is still double resolution on non-ultrahigh DPI resolutions, but I can at least resize the window to fix that now also. And new build container just worked.
Like how big on you screen? It is meant to be big enough :-D (800 x 600 is the default size)
According to the SDL docs, SDL_WINDOW_ALLOW_HIGHDPI will only lead to a higher resolution on platforms that support it.
if it works fine for you on macOS also, so just let me know when you're finished with this for now... ;)
I even managed to make it work over X11-forwarding with simu running on an Intel NUC running Linux, and XQuartz on my Mac. Apart from being slow, it just works.