GUI2: removed now-redundant type parameter from build_single_widget_and_cast_to
This commit is contained in:
parent
52f7fcf5cc
commit
34195ae654
4 changed files with 8 additions and 9 deletions
|
@ -105,16 +105,15 @@ widget_ptr build_single_widget(const std::string& type, const config& cfg);
|
|||
* @tparam T The final widget type. The widget pointer will be
|
||||
* cast to this.
|
||||
*
|
||||
* @param type String ID of the widget type.
|
||||
* @param cfg Data config to pass to the widget's builder.
|
||||
*
|
||||
* @returns A shared_ptr of the given type containing the
|
||||
* newly build widget.
|
||||
*/
|
||||
template<typename T>
|
||||
std::shared_ptr<T> build_single_widget_and_cast_to(const std::string& type, const config& cfg = {})
|
||||
std::shared_ptr<T> build_single_widget_and_cast_to(const config& cfg = {})
|
||||
{
|
||||
return std::dynamic_pointer_cast<T>(build_single_widget(type, cfg));
|
||||
return std::dynamic_pointer_cast<T>(build_single_widget(T::type(), cfg));
|
||||
}
|
||||
|
||||
struct builder_grid : public builder_widget
|
||||
|
|
|
@ -137,7 +137,7 @@ void drop_down_menu::pre_show(window& window)
|
|||
find_widget<toggle_panel>(&new_row, "panel", false).set_tooltip(entry["tooltip"]);
|
||||
|
||||
if(entry.has_attribute("image")) {
|
||||
auto img = build_single_widget_and_cast_to<image>("image");
|
||||
auto img = build_single_widget_and_cast_to<image>();
|
||||
img->set_label(entry["image"]);
|
||||
|
||||
grid* mi_grid = dynamic_cast<grid*>(new_row.find("menu_item", false));
|
||||
|
@ -147,7 +147,7 @@ void drop_down_menu::pre_show(window& window)
|
|||
}
|
||||
|
||||
if(entry.has_attribute("checkbox")) {
|
||||
auto checkbox = build_single_widget_and_cast_to<toggle_button>("toggle_button");
|
||||
auto checkbox = build_single_widget_and_cast_to<toggle_button>();
|
||||
checkbox->set_id("checkbox");
|
||||
checkbox->set_value_bool(entry["checkbox"].to_bool(false));
|
||||
|
||||
|
|
|
@ -646,7 +646,7 @@ void preferences_dialog::post_build(window& window)
|
|||
}
|
||||
|
||||
case ADVANCED_PREF_TYPE::SLIDER: {
|
||||
auto setter_widget = build_single_widget_and_cast_to<slider>("slider", config {"definition", "minimal"});
|
||||
auto setter_widget = build_single_widget_and_cast_to<slider>(config {"definition", "minimal"});
|
||||
setter_widget->set_id("setter");
|
||||
// Maximum must be set first or this will assert
|
||||
setter_widget->set_value_range(option["min"].to_int(), option["max"].to_int());
|
||||
|
@ -693,7 +693,7 @@ void preferences_dialog::post_build(window& window)
|
|||
selected = 0;
|
||||
}
|
||||
|
||||
auto setter_widget = build_single_widget_and_cast_to<menu_button>("menu_button");
|
||||
auto setter_widget = build_single_widget_and_cast_to<menu_button>();
|
||||
setter_widget->set_id("setter");
|
||||
|
||||
details_grid.swap_child("setter", setter_widget, true);
|
||||
|
@ -718,7 +718,7 @@ void preferences_dialog::post_build(window& window)
|
|||
case ADVANCED_PREF_TYPE::SPECIAL: {
|
||||
//main_grid->remove_child("setter");
|
||||
|
||||
auto value_widget = build_single_widget_and_cast_to<image>("image");
|
||||
auto value_widget = build_single_widget_and_cast_to<image>();
|
||||
value_widget->set_label("icons/arrows/arrows_blank_right_25.png~CROP(3,3,18,18)");
|
||||
|
||||
main_grid->swap_child("value", value_widget, true);
|
||||
|
|
|
@ -759,7 +759,7 @@ void scrollbar_container::finalize_setup()
|
|||
}
|
||||
|
||||
/***** Setup the content *****/
|
||||
content_ = build_single_widget_and_cast_to<spacer>("spacer");
|
||||
content_ = build_single_widget_and_cast_to<spacer>();
|
||||
|
||||
content_grid_ = std::dynamic_pointer_cast<grid>(get_grid().swap_child("_content_grid", content_, true));
|
||||
assert(content_grid_);
|
||||
|
|
Loading…
Add table
Reference in a new issue