Gamedev Framework (gf)  0.3.0
A C++11 framework for 2D games
Public Member Functions | List of all members
gf::ViewContainer Class Reference

A container of views. More...

#include <gf/ViewContainer.h>

Public Member Functions

void addView (AdaptativeView &view)
 Add a view to the container. More...
 
void processEvent (const Event &event)
 Update the views thanks to the event. More...
 
void onScreenResize (Vector2u screenSize)
 Update the views with the new screen size. More...
 
void setInitialScreenSize (Vector2u screenSize)
 Set the initial screen size. More...
 

Detailed Description

A container of views.

A view manager handles several adaptive views. It can update all the views at the same time. All it needs is the events that come from the window.

Here is a full example with two adaptive views:

// ...
gf::ExtendView extendView;
extendView.setSize({ 1000.0f, 1000.0f });
views.addView(extendView);
gf::ScreenView screenView;
views.addView(screenView);
// initialize the views with the initial screen size
views.onScreenResize(screenSize);
// ...
while (window.isOpen()) {
gf::Event event;
while (window.pollEvent(event)) {
// ...
views.update(event);
}
// ...
renderer.clear();
renderer.setView(extendView);
renderer.draw(...);
renderer.setView(screenView);
renderer.draw(...);
renderer.display();
}
See also
gf::AdaptativeView

Member Function Documentation

void gf::ViewContainer::addView ( AdaptativeView view)

Add a view to the container.

Parameters
viewAn adaptive view
void gf::ViewContainer::onScreenResize ( Vector2u  screenSize)

Update the views with the new screen size.

Parameters
screenSizeThe new size of the screen
See also
gf::AdaptativeView::onScreenResize()
void gf::ViewContainer::processEvent ( const Event event)

Update the views thanks to the event.

Internally it calls onScreenResize() if a resize event occurs.

Parameters
eventAn event
void gf::ViewContainer::setInitialScreenSize ( Vector2u  screenSize)

Set the initial screen size.

Parameters
screenSizeThe initial size of the screen