Skip to content

Commit

Permalink
GUI2/Window Builder: renamed a function for clarity and used it in a …
Browse files Browse the repository at this point in the history
…few more places for consistency
  • Loading branch information
Vultraz committed Aug 20, 2017
1 parent 4460647 commit d916218
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/gui/core/register_widget.hpp
Expand Up @@ -40,7 +40,7 @@
{ \
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, &make_builder<implementation::builder_##id>); \
} \
}; \
\
Expand Down
11 changes: 6 additions & 5 deletions src/gui/core/window_builder.cpp
Expand Up @@ -132,25 +132,26 @@ builder_widget_ptr create_builder_widget(const config& cfg)
if(item.first == "window" || item.first == "tooltip") {
continue;
}

if(const config& c = cfg.child(item.first)) {
return item.second(c);
}
}

if(const config& c = cfg.child("grid")) {
return std::make_shared<builder_grid>(c);
return make_builder<builder_grid>(c);
}

if(const config& instance = cfg.child("instance")) {
return std::make_shared<implementation::builder_instance>(instance);
return make_builder<implementation::builder_instance>(instance);
}

if(const config& pane = cfg.child("pane")) {
return std::make_shared<implementation::builder_pane>(pane);
return make_builder<implementation::builder_pane>(pane);
}

if(const config& viewport = cfg.child("viewport")) {
return std::make_shared<implementation::builder_viewport>(viewport);
return make_builder<implementation::builder_viewport>(viewport);
}

/*
Expand Down Expand Up @@ -372,7 +373,7 @@ builder_window::window_resolution::window_resolution(const config& cfg)
, linked_groups()
, tooltip(cfg.child_or_empty("tooltip"), "tooltip")
, helptip(cfg.child_or_empty("helptip"), "helptip")
, grid(0)
, grid(nullptr)
{
if(!cfg["functions"].empty()) {
wfl::formula(cfg["functions"], &functions).evaluate();
Expand Down
16 changes: 12 additions & 4 deletions src/gui/core/window_builder.hpp
Expand Up @@ -100,17 +100,17 @@ 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.
* Helper to create a generic widget builder with the given WML data.
*
* Mainly used as functor for @ref register_builder_widget.
*
* @param cfg The config with the information to
* Instantiate the widget.
* instantiate the widget.
*
* @returns A generic widget builder pointer.
*/
template <class T>
builder_widget_ptr build_widget(const config& cfg)
template<typename T>
builder_widget_ptr make_builder(const config& cfg)
{
return std::make_shared<T>(cfg);
}
Expand Down Expand Up @@ -227,6 +227,14 @@ class builder_window
builder_grid_ptr grid;
};

/**
* Resolution options for this window instance.
*
* The window widget handles resolution options differently from other widgets.
* Most specify their resolution options in their definitions. However, windows
* define different resolution options for each window *instance*. That enables
* each dialog to have its own set of options.
*/
std::vector<window_resolution> resolutions;

private:
Expand Down

0 comments on commit d916218

Please sign in to comment.