| 1793 | } |
| 1794 | |
| 1795 | void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override |
| 1796 | { |
| 1797 | switch (widget) { |
| 1798 | case WID_BV_LIST: |
| 1799 | fill.height = resize.height = GetEngineListHeight(this->vehicle_type); |
| 1800 | size.height = 3 * resize.height; |
| 1801 | size.width = std::max(size.width, this->badge_classes.GetTotalColumnsWidth() + GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_left + GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_right + 165) + padding.width; |
| 1802 | break; |
| 1803 | |
| 1804 | case WID_BV_PANEL: |
| 1805 | size.height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height; |
| 1806 | break; |
| 1807 | |
| 1808 | case WID_BV_SORT_ASCENDING_DESCENDING: { |
| 1809 | Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->GetString()); |
| 1810 | d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. |
| 1811 | d.height += padding.height; |
| 1812 | size = maxdim(size, d); |
| 1813 | break; |
| 1814 | } |
| 1815 | |
| 1816 | case WID_BV_CARGO_FILTER_DROPDOWN: |
| 1817 | size.width = std::max(size.width, GetDropDownListDimension(this->BuildCargoDropDownList()).width + padding.width); |
| 1818 | break; |
| 1819 | |
| 1820 | case WID_BV_CONFIGURE_BADGES: |
| 1821 | /* Hide the configuration button if no configurable badges are present. */ |
| 1822 | if (this->badge_classes.GetClasses().empty()) size = {0, 0}; |
| 1823 | break; |
| 1824 | |
| 1825 | case WID_BV_BUILD: |
| 1826 | size = GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_BUTTON + this->vehicle_type); |
| 1827 | size = maxdim(size, GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON + this->vehicle_type)); |
| 1828 | size.width += padding.width; |
| 1829 | size.height += padding.height; |
| 1830 | break; |
| 1831 | |
| 1832 | case WID_BV_SHOW_HIDE: |
| 1833 | size = GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_HIDE_TOGGLE_BUTTON + this->vehicle_type); |
| 1834 | size = maxdim(size, GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_SHOW_TOGGLE_BUTTON + this->vehicle_type)); |
| 1835 | size.width += padding.width; |
| 1836 | size.height += padding.height; |
| 1837 | break; |
| 1838 | } |
| 1839 | } |
| 1840 | |
| 1841 | void DrawWidget(const Rect &r, WidgetID widget) const override |
| 1842 | { |
nothing calls this directly
no test coverage detected