Nothing is drawn

Started by Yuri12358, 30 July 2017, 21:20:59

Yuri12358

No widgets are drawn when call gui.draw(), but usual SFML stuff draws correctly. Debug tells nothing. Im trying to draw button and a sfml circle, and get only circle.
Code (cpp) Select

#include<TGUI/TGUI.hpp>

int main() {
sf::RenderWindow window(sf::VideoMode(800, 600), "TGUI");
sf::CircleShape shape(100);
tgui::Gui gui{window};

auto theme = tgui::Theme::create("TGUI/widgets/Black.txt");

//tgui::Button::Ptr bClickMe = tgui::Button::create("Click me!");
tgui::Button::Ptr bClickMe = theme->load("Button");
bClickMe->setText("lol");
bClickMe->setPosition("50%", 100);
gui.add(bClickMe);

while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed || event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) {
window.close();
}
gui.handleEvent(event);
}

window.clear(sf::Color(128, 128, 128));
window.draw(shape);
gui.draw();
window.display();
}
}

texus

Quote
Code (cpp) Select
bClickMe->setPosition("50%", 100);
This code only works in tgui 0.8-dev. In tgui 0.7 the "50%" gets evaluated as "50 mod 0", which is NaN.

The equivalent line for tgui 0.7 is:
Code (cpp) Select
bClickMe->setPosition("parent.width/2", 100);

or shorter:
Code (cpp) Select
bClickMe->setPosition("&.w/2", 100);

Yuri12358

Thanks very much.
Btw, your library is awesome