diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -1600,27 +1600,22 @@ NewGRFWindow::GUIGRFConfigList::FilterFu * - two column mode, put the #acs and the #avs underneath each other and the #inf next to it, or * - three column mode, put the #avs, #acs, and #inf each in its own column. */ -class NWidgetNewGRFDisplay : public NWidgetContainer { +class NWidgetNewGRFDisplay : public NWidgetBase { public: static const uint MAX_EXTRA_INFO_WIDTH; ///< Maximal additional width given to the panel. static const uint MIN_EXTRA_FOR_3_COLUMNS; ///< Minimal additional width needed before switching to 3 columns. - NWidgetBase *avs; ///< Widget with the available grfs list and buttons. - NWidgetBase *acs; ///< Widget with the active grfs list and buttons. - NWidgetBase *inf; ///< Info panel. + std::unique_ptr avs; ///< Widget with the available grfs list and buttons. + std::unique_ptr acs; ///< Widget with the active grfs list and buttons. + std::unique_ptr inf; ///< Info panel. bool editable; ///< Editable status of the parent NewGRF window (if \c false, drop all widgets that make the window editable). - NWidgetNewGRFDisplay(NWidgetBase *avs, NWidgetBase *acs, NWidgetBase *inf) : NWidgetContainer(NWID_HORIZONTAL) + NWidgetNewGRFDisplay(std::unique_ptr &&avs, std::unique_ptr &&acs, std::unique_ptr &&inf) : NWidgetBase(NWID_CUSTOM) + , avs(std::move(avs)) + , acs(std::move(acs)) + , inf(std::move(inf)) + , editable(true) // Temporary setting, 'real' value is set in SetupSmallestSize(). { - this->avs = avs; - this->acs = acs; - this->inf = inf; - - this->Add(this->avs); - this->Add(this->acs); - this->Add(this->inf); - - this->editable = true; // Temporary setting, 'real' value is set in SetupSmallestSize(). } void SetupSmallestSize(Window *w) override @@ -1785,6 +1780,13 @@ public: } } + void FillWidgetLookup(WidgetLookup &widget_lookup) override + { + this->avs->FillWidgetLookup(widget_lookup); + this->acs->FillWidgetLookup(widget_lookup); + this->inf->FillWidgetLookup(widget_lookup); + } + NWidgetCore *GetWidgetFromPos(int x, int y) override { if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return nullptr; @@ -1937,13 +1939,13 @@ static const NWidgetPart _nested_newgrf_ }; /** Construct nested container widget for managing the lists and the info panel of the NewGRF GUI. */ -NWidgetBase* NewGRFDisplay() +std::unique_ptr NewGRFDisplay() { - NWidgetBase *avs = MakeNWidgets(std::begin(_nested_newgrf_availables_widgets), std::end(_nested_newgrf_availables_widgets), nullptr); - NWidgetBase *acs = MakeNWidgets(std::begin(_nested_newgrf_actives_widgets), std::end(_nested_newgrf_actives_widgets), nullptr); - NWidgetBase *inf = MakeNWidgets(std::begin(_nested_newgrf_infopanel_widgets), std::end(_nested_newgrf_infopanel_widgets), nullptr); + std::unique_ptr avs = MakeNWidgets(std::begin(_nested_newgrf_availables_widgets), std::end(_nested_newgrf_availables_widgets), nullptr); + std::unique_ptr acs = MakeNWidgets(std::begin(_nested_newgrf_actives_widgets), std::end(_nested_newgrf_actives_widgets), nullptr); + std::unique_ptr inf = MakeNWidgets(std::begin(_nested_newgrf_infopanel_widgets), std::end(_nested_newgrf_infopanel_widgets), nullptr); - return new NWidgetNewGRFDisplay(avs, acs, inf); + return std::make_unique(std::move(avs), std::move(acs), std::move(inf)); } /* Widget definition of the manage newgrfs window */