Skip to content

Commit

Permalink
GUI2/Window Builder: removed build_widget function and used std::make…
Browse files Browse the repository at this point in the history
…_shared directly

This function's name was rather misleading. It didn't actually build a widget, just created a an
object (usually a builder, as it was utilized in REGISTER_WIDGET) with the config argument as its
ctor parameters.

Lamdas render the need of a separate function to pass as an std::function argument obsolete.
  • Loading branch information
Vultraz committed Aug 20, 2017
1 parent eddea4b commit 39dff1b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
6 changes: 4 additions & 2 deletions src/gui/core/register_widget.hpp
Expand Up @@ -38,9 +38,11 @@
{ \
register_helper() \
{ \
register_widget(#id, [](const config& cfg) { return std::make_shared<type>(cfg); }, key); \
register_widget(#id, \
[](const config& cfg) { return std::make_shared<type>(cfg); }, key); \
\
register_builder_widget(#id, &build_widget<implementation::builder_##id>); \
register_builder_widget(#id, \
[](const config& cfg) { return std::make_shared<implementation::builder_##id>(cfg); }); \
} \
}; \
\
Expand Down
16 changes: 0 additions & 16 deletions src/gui/core/window_builder.hpp
Expand Up @@ -99,22 +99,6 @@ register_builder_widget(const std::string& id, widget_builder_func_t functor);
*/
builder_widget_ptr create_builder_widget(const config& cfg);

/**
* Helper to generate a widget from a WML widget instance.
*
* Mainly used as functor for @ref register_builder_widget.
*
* @param cfg The config with the information to
* Instantiate the widget.
*
* @returns A generic widget builder pointer.
*/
template <class T>
builder_widget_ptr build_widget(const config& cfg)
{
return std::make_shared<T>(cfg);
}

/**
* Helper function to implement @ref build_single_widget_instance. This keeps the main
* logic in the implementation despite said function being a template and therefor
Expand Down

0 comments on commit 39dff1b

Please sign in to comment.