*

Djer

  • *
  • 13
    • View Profile
v0.7 lack of examples ?
« on: 16 January 2016, 21:13:40 »
Hi Texus,

How can we know how to create widgets? (The widgets constructors in the documentation don't help us since they are created by the tgui::Theme)
How can we know if we have to use the tgui::Theme::load() function to create a widget?

The examples show us just a few widgets...

For example, the tgui::Panel::Ptr doesn't require the tgui::Theme::load() function to be create.

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: v0.7 lack of examples ?
« Reply #1 on: 16 January 2016, 21:36:06 »
All widgets can be created like this and it should thus be the default option when you hesitate:
tgui::Button::Ptr button = std::make_shared<tgui::Button>();

The few widgets which don't work with themes (e.g. Picture and Panel) can also be created like that, but may provide shortcuts to make it easier (but which you don't need to know to use the widget).
auto pic = std::make_shared<tgui::Picture>("Image.png"); // Parameters are shortcut for extra setTexture call
auto panel = std::make_shared<tgui::Panel>(400, 300); // Parameters are shortcut for extra setSize call

Only when you don't want to use the default white skin you have to create a theme and use tgui::Theme::load(). The reason some widgets can't be loaded with a theme is just because it doesn't make sense to have different skins. Panel is just a collection of widgets so having a skin doesn't has much meaning (although I might have implemented it anyway for its background color). But a widget like Picture definately wouldn't make sense to be loaded from a theme.
« Last Edit: 16 January 2016, 22:00:06 by texus »

*

Djer

  • *
  • 13
    • View Profile
Re: v0.7 lack of examples ?
« Reply #2 on: 16 January 2016, 23:00:42 »
Okay, thanks !