Hello,
in several projects now I have used these 3 libraries as a sort of lightweight gui framework, with the emphasis on graphical drawing on a canvas. The boilerplate code is contained within the following class:
#include <SFML/Window.hpp>
#include <Thor/Input/ActionMap.hpp>
#include <Thor/Input/EventSystem.hpp>
#include <SFGUI/SFGUI.hpp>
typedef thor::ActionMap<std::string> ActionMap;
typedef ActionMap::CallbackSystem CallbackSystem;
class Application
{
public:
Application();
void run();
private:
sfg::SFGUI sfgui;
sf::Window window;
sfg::Desktop desktop;
sf::Image icon;
ActionMap actions;
CallbackSystem system;
};
#include "Application.hpp"
Application::Application():
window(sf::VideoMode(800, 600), "Application")
{
if (icon.loadFromFile(""))
window.setIcon(icon.getSize().x, icon.getSize().y, icon.getPixelsPtr());
window.setFramerateLimit(60);
actions["Close"] = thor::Action(sf::Event::Closed);
system.connect("Close", std::bind(&sf::Window::close, &window));
}
void Application::run()
{
sf::Clock clock;
while (window.isOpen()){
actions.clearEvents();
sf::Event event;
while (window.pollEvent(event)){
actions.pushEvent(event);
desktop.HandleEvent(event);
}
actions.invokeCallbacks(system, &window);
desktop.Update(clock.restart().asSeconds());
sfgui.Display(window);
window.display();
}
}
Note that sfml drawing can be done on a sfg::Canvas, therefore a sf::RenderWindow is not required.
Comments welcome.