diff --git a/examples/full_example/FullExample.cpp b/examples/full_example/FullExample.cpp index f832781c..016677fe 100644 --- a/examples/full_example/FullExample.cpp +++ b/examples/full_example/FullExample.cpp @@ -7,12 +7,13 @@ int main() { sf::RenderWindow window(sf::VideoMode(800, 600), "TGUI window"); tgui::Gui gui(window); - gui.setGlobalFont("../../fonts/DejaVuSans.ttf"); - gui.add(tgui::Picture::create("../RedBackground.jpg")); + tgui::Theme::Ptr theme = std::make_shared("../../widgets/Black.txt"); - auto tab = tgui::Tab::create(THEME_CONFIG_FILE); + gui.add(std::make_shared("../RedBackground.jpg")); +/* + tgui::Tab::Ptr tab = theme->load("tab"); tab->setTabHeight(30); tab->setPosition(70, 40); tab->add("Tab - 1"); @@ -20,7 +21,7 @@ int main() tab->add("Tab - 3"); gui.add(tab); - auto menu = tgui::MenuBar::create(THEME_CONFIG_FILE); + tgui::MenuBar::Ptr menu = theme->load("MenuBar"); menu->setSize(window.getSize().x, 22); menu->addMenu("MenuOption-1"); menu->addMenuItem("MenuOption-1", "Load"); @@ -32,51 +33,51 @@ int main() menu->addMenu("MenuOption-3"); menu->addMenuItem("MenuOption-3", "About"); gui.add(menu); - - auto label = tgui::Label::create(THEME_CONFIG_FILE); + */ + tgui::Label::Ptr label = theme->load("label"); label->setText("This is a label.\nAnd these are radio buttons:"); label->setPosition(10, 90); label->setTextSize(18); gui.add(label); - auto radioButton = tgui::RadioButton::create(THEME_CONFIG_FILE); + tgui::RadioButton::Ptr radioButton = theme->load("RadioButton"); radioButton->setPosition(20, 140); radioButton->setText("Yep!"); radioButton->setSize(25, 25); gui.add(radioButton); - radioButton = tgui::RadioButton::create(THEME_CONFIG_FILE); + radioButton = theme->load("RadioButton"); radioButton->setPosition(20, 170); radioButton->setText("Nope!"); radioButton->setSize(25, 25); gui.add(radioButton); - radioButton = tgui::RadioButton::create(THEME_CONFIG_FILE); + radioButton = theme->load("RadioButton"); radioButton->setPosition(20, 200); radioButton->setText("Don't know!"); radioButton->setSize(25, 25); gui.add(radioButton); - label = tgui::Label::create(THEME_CONFIG_FILE); + label = theme->load("label"); label->setText("We've got some edit boxes:"); label->setPosition(10, 240); label->setTextSize(18); gui.add(label); - auto editBox = tgui::EditBox::create(THEME_CONFIG_FILE); + tgui::EditBox::Ptr editBox = theme->load("EditBox"); editBox->setSize(200, 25); editBox->setTextSize(18); editBox->setPosition(10, 270); editBox->setDefaultText("Click to edit text..."); gui.add(editBox); - label = tgui::Label::create(THEME_CONFIG_FILE); + label = theme->load("label"); label->setText("And some list boxes too..."); label->setPosition(10, 310); label->setTextSize(18); gui.add(label); - - auto listBox = tgui::ListBox::create(THEME_CONFIG_FILE); + /* + tgui::ListBox::Ptr listBox = theme->load("ListBox"); listBox->setSize(250, 120); listBox->setItemHeight(20); listBox->setPosition(10, 340); @@ -84,45 +85,45 @@ int main() listBox->addItem("Item 2"); listBox->addItem("Item 3"); gui.add(listBox); - - label = tgui::Label::create(THEME_CONFIG_FILE); + */ + label = theme->load("label"); label->setText("It's the progress bar below"); label->setPosition(10, 470); label->setTextSize(18); gui.add(label); - auto progressBar = tgui::ProgressBar::create(THEME_CONFIG_FILE); + tgui::ProgressBar::Ptr progressBar = theme->load("ProgressBar"); progressBar->setPosition(10, 500); progressBar->setSize(200, 20); progressBar->setValue(50); gui.add(progressBar); - label = tgui::Label::create(THEME_CONFIG_FILE); + label = theme->load("label"); label->setText(std::to_string(progressBar->getValue()) + "%"); label->setPosition(220, 500); label->setTextSize(18); gui.add(label); - label = tgui::Label::create(THEME_CONFIG_FILE); + label = theme->load("label"); label->setText("That's the slider"); label->setPosition(10, 530); label->setTextSize(18); gui.add(label); - auto slider = tgui::Slider::create(THEME_CONFIG_FILE); + tgui::Slider::Ptr slider = theme->load("slider"); slider->setPosition(10, 560); slider->setSize(200, 18); slider->setValue(4); gui.add(slider); - auto scrollbar = tgui::Scrollbar::create(THEME_CONFIG_FILE); + tgui::Scrollbar::Ptr scrollbar = theme->load("scrollbar"); scrollbar->setPosition(380, 40); scrollbar->setSize(18, 540); scrollbar->setMaximum(100); scrollbar->setLowValue(70); gui.add(scrollbar); - - auto comboBox = tgui::ComboBox::create(THEME_CONFIG_FILE); + /* + tgui::ComboBox::Ptr comboBox = theme->load("ComboBox"); comboBox->setSize(120, 21); comboBox->setPosition(420, 40); comboBox->addItem("Item 1"); @@ -131,44 +132,44 @@ int main() comboBox->setSelectedItem("Item 2"); gui.add(comboBox); - auto child = tgui::ChildWindow::create(THEME_CONFIG_FILE); + tgui::ChildWindow::Ptr child = theme->load("ChildWindow"); child->setSize(250, 120); child->setPosition(420, 80); child->setTitle("Child window"); gui.add(child); - label = tgui::Label::create(THEME_CONFIG_FILE); + label = theme->load("label"); label->setText("Hi! I'm a child window."); label->setPosition(30, 30); label->setTextSize(15); child->add(label); - - auto button = tgui::Button::create(THEME_CONFIG_FILE); + */ + tgui::Button::Ptr button = theme->load("button");/* button->setPosition(75, 70); button->setText("OK"); button->setSize(100, 30); button->connect("pressed", [=](){ child->hide(); }); child->add(button); - - auto checkbox = tgui::Checkbox::create(THEME_CONFIG_FILE); + */ + tgui::Checkbox::Ptr checkbox = theme->load("checkbox"); checkbox->setPosition(420, 240); checkbox->setText("Ok, I got it"); checkbox->setSize(25, 25); gui.add(checkbox); - checkbox = tgui::Checkbox::create(THEME_CONFIG_FILE); + checkbox = theme->load("checkbox"); checkbox->setPosition(570, 240); checkbox->setText("No, I didn't"); checkbox->setSize(25, 25); gui.add(checkbox); - label = tgui::Label::create(THEME_CONFIG_FILE); + label = theme->load("label"); label->setText("Chatbox"); label->setPosition(420, 280); label->setTextSize(18); gui.add(label); - - auto chatbox = tgui::ChatBox::create(THEME_CONFIG_FILE); + /* + tgui::ChatBox::Ptr chatbox = theme->load("ChatBox"); chatbox->setSize(300, 100); chatbox->setTextSize(18); chatbox->setPosition(420, 310); @@ -177,7 +178,7 @@ int main() chatbox->addLine("Me : Looks awesome! ;)", sf::Color::Yellow); chatbox->addLine("texus : Thanks! :)", sf::Color::Green); chatbox->addLine("Me : The widgets rock ^^", sf::Color::Yellow); - + */ sf::Texture texture; sf::Sprite sprite; texture.loadFromFile("../ThinkLinux.jpg"); @@ -188,7 +189,7 @@ int main() text.setPosition(25, 100); text.setColor({200, 200, 200}); - auto canvas = tgui::Canvas::create({200, 140}); + tgui::Canvas::Ptr canvas = std::make_shared(200, 140); canvas->setPosition(420, 430); canvas->clear(); canvas->draw(sprite); @@ -196,7 +197,7 @@ int main() canvas->display(); gui.add(canvas); - button = tgui::Button::create(THEME_CONFIG_FILE); + button = theme->load("button"); button->setPosition(window.getSize().x - 115, window.getSize().y - 50); button->setText("Exit"); button->setSize(100, 40); diff --git a/examples/login_screen/LoginScreen.cpp b/examples/login_screen/LoginScreen.cpp index 7d6b9667..d30e2a94 100644 --- a/examples/login_screen/LoginScreen.cpp +++ b/examples/login_screen/LoginScreen.cpp @@ -8,32 +8,35 @@ void login(tgui::EditBox::Ptr username, tgui::EditBox::Ptr password) void loadWidgets( tgui::Gui& gui ) { + // Load the theme for the edit boxes and button + tgui::Theme::Ptr theme = std::make_shared("../../widgets/Black.txt"); + // Get a bound version of the window size // Passing this to setPosition or setSize will make the widget automatically update when the view of the gui changes auto windowWidth = tgui::bindWidth(gui); auto windowHeight = tgui::bindHeight(gui); // Create the background image (picture is of type tgui::Picture::Ptr or std::shared_widget) - auto picture = tgui::Picture::create("../xubuntu_bg_aluminium.jpg"); + tgui::Picture::Ptr picture = std::make_shared("../xubuntu_bg_aluminium.jpg"); picture->setSize(tgui::bindMax(800, windowWidth), tgui::bindMax(600, windowHeight)); gui.add(picture); // Create the username edit box - auto editBoxUsername = tgui::EditBox::create("../../widgets/Black.conf"); + tgui::EditBox::Ptr editBoxUsername = theme->load("EditBox"); editBoxUsername->setSize(windowWidth * 2/3, windowHeight / 8); editBoxUsername->setPosition(windowWidth / 6, windowHeight / 6); editBoxUsername->setDefaultText("Username"); gui.add(editBoxUsername, "Username"); // Create the password edit box (we will copy the previously created edit box) - auto editBoxPassword = tgui::EditBox::copy(editBoxUsername); + tgui::EditBox::Ptr editBoxPassword = tgui::EditBox::copy(editBoxUsername); editBoxPassword->setPosition(windowWidth / 6, windowHeight * 5/12); editBoxPassword->setPasswordCharacter('*'); editBoxPassword->setDefaultText("Password"); gui.add(editBoxPassword, "Password"); // Create the login button - auto button = tgui::Button::create("../../widgets/Black.conf"); + tgui::Button::Ptr button = theme->load("Button"); button->setSize(windowWidth / 2, windowHeight / 6); button->setPosition(windowWidth / 4, windowHeight * 7/10); button->setText("Login"); diff --git a/examples/scalable/Scalable.cpp b/examples/scalable/Scalable.cpp index 6bc9d963..a033e3e6 100644 --- a/examples/scalable/Scalable.cpp +++ b/examples/scalable/Scalable.cpp @@ -7,7 +7,7 @@ int main() gui.setGlobalFont("../../fonts/DejaVuSans.ttf"); // Create the background image - gui.add(tgui::Picture::create("../Linux.jpg")); + gui.add(std::make_shared("../Linux.jpg")); // Get a bound version of the window size // Passing this to setPosition or setSize will make the widget automatically update when the view of the gui changes @@ -19,7 +19,7 @@ int main() // Top: 20% of window height // Width: 80% of window width // Height: 25% of window height - auto play = tgui::Button::create("../../widgets/Black.conf"); + tgui::Button::Ptr play = std::make_shared(); play->setPosition(windowWidth*0.1, windowHeight*0.2); play->setSize(windowWidth*0.8, windowHeight*0.25); play->setText("Play"); @@ -28,7 +28,7 @@ int main() // Create the second button, which has the same size as the first one // Left: 10% of window width // Top: 60% of window height - auto exit = tgui::Button::copy(play); + tgui::Button::Ptr exit = tgui::Button::copy(play); exit->setPosition(windowWidth*0.1, windowHeight*0.6); exit->setText("Exit"); gui.add(exit);