Skip to content

Commit

Permalink
GUI2/Window Builder: added a type alias for the builder widget function
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Aug 15, 2017
1 parent bac6f1f commit ae19f94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
9 changes: 3 additions & 6 deletions src/gui/core/window_builder.cpp
Expand Up @@ -50,11 +50,9 @@
namespace gui2
{

static std::map<std::string, std::function<builder_widget_ptr(config)> >&
builder_widget_lookup()
static std::map<std::string, widget_builder_func_t>& builder_widget_lookup()
{
static std::map<std::string, std::function<builder_widget_ptr(config)> >
result;
static std::map<std::string, widget_builder_func_t> result;
return result;
}

Expand Down Expand Up @@ -138,8 +136,7 @@ builder_widget::builder_widget(const config& cfg)
}

void
register_builder_widget(const std::string& id,
std::function<builder_widget_ptr(config)> functor)
register_builder_widget(const std::string& id, widget_builder_func_t functor)
{
builder_widget_lookup().emplace(id, functor);
}
Expand Down
5 changes: 3 additions & 2 deletions src/gui/core/window_builder.hpp
Expand Up @@ -73,6 +73,8 @@ struct builder_widget
typedef std::shared_ptr<builder_widget> builder_widget_ptr;
typedef std::shared_ptr<const builder_widget> builder_widget_const_ptr;

using widget_builder_func_t = std::function<builder_widget_ptr(config)>;

/**
* Registers a widget to be build.
*
Expand All @@ -83,8 +85,7 @@ typedef std::shared_ptr<const builder_widget> builder_widget_const_ptr;
* @param functor The functor to create the widget.
*/
void
register_builder_widget(const std::string& id,
std::function<builder_widget_ptr(config)> functor);
register_builder_widget(const std::string& id, widget_builder_func_t functor);


/**
Expand Down

0 comments on commit ae19f94

Please sign in to comment.