Screen sizing

  • 2 Replies
  • 101 Views
*

ingar

  • *
  • 30
    • View Profile
    • Label Printing Software & Solutions
Screen sizing
« on: 11 September 2020, 17:39:10 »
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

  • *****
  • 1586
    • View Profile
    • Texus's Blog
Re: Screen sizing
« Reply #1 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).
gui.setView(sf::View(sf::FloatRect(0.f, 0.f, static_cast<float>(event.size.width), static_cast<float>(event.size.height))));
« Last Edit: 11 September 2020, 18:30:20 by texus »

*

ingar

  • *
  • 30
    • View Profile
    • Label Printing Software & Solutions
Re: Screen sizing
« Reply #2 on: 12 September 2020, 07:51:13 »
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).
gui.setView(sf::View(sf::FloatRect(0.f, 0.f, static_cast<float>(event.size.width), static_cast<float>(event.size.height))));

Worked!
Thanks :)