As mentioned in a previous post I am creating a password manager with gideros and imgui. I am trying to figure out how to create a GUI that is adaptable for both desktop and mobile. For now I have selected a very high resolution 16/9 portrait. Do you have any advice for how to manage a non-game related GUI that is scalable and resizable?
Thanks!
Comments
https://longtitle-productions.itch.io/fragmenter
imgui:setScale(value)
Likes: MoKaLux, giovifav
Fragmenter - animated loop machine and IKONOMIKON - the memory game
1) let gideros handle that for you with "stretch" scale mode or any other scale mode that suits your app. In project properties (right click on the project name in the project tree)
2) Let it handle to imgui: I copypasted pieces from a project therefore there might be some issues here (it's not ready to run)
I am not sure that this is the best way to do it but it works for me:
there is a onWindowsResize function that sets IO displaysize, get every screen measure and saves them into a screenmeasures var.
whenever the app is resized it is called and update the measures.
Setting elements sizes in relative values based on "screenmeasures" makes the trick work. ie.
ui:setNextWindowSize(screenmeasures.w, screenmeasures.h) for a fullscreen window
ui:setNextWindowSize(screenmeasures.w*.5, screenmeasures.h) for a window that covers half of the screen.
Then I have a function to build the desired font size depending on the screen resolution. FontAtlas must be set at the beginning and I've never had a reason to update the font size on the run, but I guess it might be possible to update the fontAtlas too: my need was only to have bigger fonts on mobile devices and smaller on desktop.
hope this helps
Likes: MoKaLux, giovifav
I used the second method you suggested, with a little adjustment it is exactly what I was looking for. I added font management in applicationResize and now it behaves almost like it was a responsive website!
Gideros has a small but kind and passionate community.
Likes: keszegh, MoKaLux, pie
I wonder if it is better to define the FontAtlas outside the function scope and overwrite it instead of building a new one everytime it's needed:
I don't know how imgui handles that internally, but if there is something still referenced there, the local values can't be garbage collected. Overwriting the same one should avoid the potential issue.
Likes: MoKaLux