Screen sizing

Started by ingar, 11 September 2020, 17:39:10

ingar

Hi all,
I want to make an extension to my Raspberry Pi app that allows my program to run on different screen sizes.
I could make a table containing some information for every widget on the screen in terms of position and size, in order
to control the position and size of the controls.

I have seen, though, that if I make a SIZEABLE TGUI screen, TGUI somehow stretches/shrinks my controls according to the
main window size. This is something I do not want, since I want to be in the driver's seat myself.

Q: Is there a way to disable this option?
     I tried to test for the sf::Event::EventType::Resized in the message loop, and do not call gui.handleEvent for than event.
     But that didn't seem to have ant effect.

Ingar

texus

#1
This is the default SFML behavior (which I am no longer using in 0.9-dev exactly because most people probably don't want it).
You have to call gui.setView when you receive the Resized event, using the a view with rect (0, 0, newWindowWidth, newWindowHeight).
Code (cpp) Select
gui.setView(sf::View(sf::FloatRect(0.f, 0.f, static_cast<float>(event.size.width), static_cast<float>(event.size.height))));

ingar

Quote from: texus on 11 September 2020, 17:50:04
This is the default SFML behavior (which I am no longer using in 0.9-dev exactly because most people probably don't want it).
You have to call gui.setView when you receive the Resized event, using the a view with rect (0, 0, newWindowWidth, newWindowHeight).
Code (cpp) Select
gui.setView(sf::View(sf::FloatRect(0.f, 0.f, static_cast<float>(event.size.width), static_cast<float>(event.size.height))));

Worked!
Thanks :)