SFML community forums

Help => Window => Topic started by: mickes27 on May 29, 2019, 11:33:14 am

Title: Combining multiple windows
Post by: mickes27 on May 29, 2019, 11:33:14 am
Hello, I am making a program which is a physical simulation. I would like to have big lattice with atoms, next to it, on right - plots and charts and on left - sliders and buttons with options. I am wondering if I can make 3 different classes, which contains separate windows and than just combine them with single, one, big window? Or maybe there is a better solution for that?

EDIT: Just found views tutorial - is it a correct way to do that?
Title: Re: Combining multiple windows
Post by: Hapax on September 21, 2019, 05:21:33 pm
You can simply just draw the parts where you want them. You can, of course, also group together those things that go together.

Using views to separate the window into partitions would likely be better done using the views' viewports although that can be tricky to understand at first. Viewports allow you to define rectangular regions of the window of which cannot be drawn outside; things are clipped to them. Definitely useful if you need things clipping to a hard border. They can (sort of) be considered separate windows (in the way you describe) so if that's what you need, views with custom viewports are the way to go.

View tutorial:
https://www.sfml-dev.org/tutorials/2.5/graphics-view.php
Viewport part of the above tutorial:
https://www.sfml-dev.org/tutorials/2.5/graphics-view.php#defining-how-the-view-is-viewed

More in-depth tutorial about views (that help with understanding how they work and how to use them properly) on the SFML Wiki:
https://github.com/SFML/SFML/wiki/Tutorial%3A-Using-View