-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathmain.cpp
51 lines (39 loc) · 1.1 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <SFML/Graphics.hpp>
#include "Gui/Gui.hpp"
int main()
{
sf::RenderWindow app(sf::VideoMode(800, 600), "SFML Widgets", sf::Style::Close);
// Declare menu
gui::Menu menu(app);
gui::Theme::loadFont("demo/tahoma.ttf");
gui::Theme::loadTexture("demo/texture-default.png");
// Create some button widget
gui::Button* button = new gui::Button("My button");
// Insert button into menu
menu.add(button);
// Define a callback
button->setCallback([] {
std::cout << "click!" << std::endl;
});
// Start the application loop
while (app.isOpen())
{
// Process events
sf::Event event;
while (app.pollEvent(event))
{
// Send events to the menu
menu.onEvent(event);
if (event.type == sf::Event::Closed)
app.close();
}
// Optional: clear window with theme background color
app.clear(gui::Theme::windowBgColor);
// Render menu
app.draw(menu);
// Update the window
app.display();
}
return 0;
}