I’ve made 2 functions I use to place my GUI elements on the screen.
1st function calculates the scale of my GUI based of a base resolution of my GUI. I work with a base resolution of 1920x1080.
I calculate the scale of the current window based on this resolution and set the smaller of the scales as the master scale. Every element is then scaled by that value.
So if I have the full 1920 width, but only half the height, I scale all GUI elements down to half, this is to make sure things are not cluttered due to screen size.
The other function translates my GUI placement to the window size, again based on the master scale, this is a bit more complicated, but nothing too fancy.
If you feed negative values into this, you get placement from the bottom right instead of top left.
This allows me to place a button the same distance from any side of the screen(You just have to account for the width of the button).
I hope someone finds this useful.
I’m working to expand this to into a prototyping GUI framework to help build mock up GUIs.
I have a basic button in the works with hover effect. A basic bar is also in the works. This is just meant as something easy and simple, not a full blown GUI tool.
Oh, and I use Vector2D for most things… just a choice, you can easily modify this to work with floats instead.
Watch this space.