71 lines
1.8 KiB
C++
71 lines
1.8 KiB
C++
#include <TGUI/TGUI.hpp>
|
|
#include <TGUI/Backend/SFML-Graphics.hpp>
|
|
#include <TGUI/Widgets/Group.hpp>
|
|
#include <TGUI/Widgets/Panel.hpp>
|
|
#include <TGUI/Widgets/MenuBar.hpp>
|
|
|
|
int main() {
|
|
sf::RenderWindow window{{800, 600}, "TGUI example w/ SFML_GRAPHICS backend"};
|
|
sf::Event event;
|
|
|
|
tgui::Gui gui{window};
|
|
tgui::Font m_tguiFont("fonts/Cuprum/Cuprum-Regular.ttf");
|
|
tgui::Font::setGlobalFont(m_tguiFont);
|
|
|
|
tgui::Theme::setDefault("themes/Black.txt");
|
|
|
|
auto top_panel = tgui::Panel::create();
|
|
auto main_panel = tgui::Panel::create();
|
|
auto footer_panel = tgui::Panel::create();
|
|
|
|
auto menu_bar = tgui::MenuBar::create();
|
|
menu_bar->addMenu("File");
|
|
menu_bar->addMenuItem("Load");
|
|
menu_bar->addMenuItem("Save");
|
|
|
|
top_panel->setHeight("50px");
|
|
footer_panel->setHeight("30px");
|
|
|
|
top_panel->setAutoLayout(tgui::AutoLayout::Top);
|
|
main_panel->setAutoLayout(tgui::AutoLayout::Fill);
|
|
footer_panel->setAutoLayout(tgui::AutoLayout::Bottom);
|
|
|
|
tgui::Button::Ptr button = tgui::Button::create("Привет");
|
|
button->onPress([&] { printf("ololo\n"); });
|
|
button->setHeight("30px");
|
|
tgui::Button::Ptr button2 = tgui::Button::create("Закрыть");
|
|
button2->setAutoLayout(tgui::AutoLayout::Fill);
|
|
button2->onPress([&] { window.close(); });
|
|
|
|
auto picture = tgui::Picture::create("CLI_Logo_small.png");
|
|
|
|
auto editBox = tgui::EditBox::create();
|
|
|
|
top_panel->add(button);
|
|
main_panel->add(picture);
|
|
footer_panel->add(button2);
|
|
|
|
gui.add(menu_bar);
|
|
gui.add(top_panel);
|
|
gui.add(main_panel);
|
|
gui.add(footer_panel);
|
|
|
|
|
|
// gui.mainLoop();
|
|
while (window.isOpen()) {
|
|
while (window.pollEvent(event)) {
|
|
// while (window.waitEvent(event)) {
|
|
gui.handleEvent(event);
|
|
|
|
if (event.type == sf::Event::Closed)
|
|
window.close();
|
|
}
|
|
|
|
window.clear({240, 240, 240});
|
|
gui.draw();
|
|
window.display();
|
|
}
|
|
|
|
printf("Пока\n");
|
|
}
|