* Add a string to draw in the current viewport. * @param dpi current viewport area * @param sign sign position and dimension * @param flags ViewportStringFlags to control the string's appearance. * @param colour colour of the sign background; or INVALID_COLOUR if transparent * @returns Pointer to std::string to filled with sign, or nullptr if string would be outside the viewport bounds. */
| 1328 | * @returns Pointer to std::string to filled with sign, or nullptr if string would be outside the viewport bounds. |
| 1329 | */ |
| 1330 | std::string *ViewportAddString(const DrawPixelInfo *dpi, const ViewportSign *sign, ViewportStringFlags flags, Colours colour) |
| 1331 | { |
| 1332 | int left = dpi->left; |
| 1333 | int top = dpi->top; |
| 1334 | int right = left + dpi->width; |
| 1335 | int bottom = top + dpi->height; |
| 1336 | |
| 1337 | bool small = flags.Test(ViewportStringFlag::Small); |
| 1338 | int sign_height = ScaleByZoom(WidgetDimensions::scaled.fullbevel.top + GetCharacterHeight(small ? FS_SMALL : FS_NORMAL) + WidgetDimensions::scaled.fullbevel.bottom, dpi->zoom); |
| 1339 | int sign_half_width = ScaleByZoom((small ? sign->width_small : sign->width_normal) / 2, dpi->zoom); |
| 1340 | |
| 1341 | if (bottom < sign->top || |
| 1342 | top > sign->top + sign_height || |
| 1343 | right < sign->center - sign_half_width || |
| 1344 | left > sign->center + sign_half_width) { |
| 1345 | return nullptr; |
| 1346 | } |
| 1347 | |
| 1348 | return &AddStringToDraw(sign->center - sign_half_width, sign->top, colour, flags, small ? sign->width_small : sign->width_normal); |
| 1349 | } |
| 1350 | |
| 1351 | static Rect ExpandRectWithViewportSignMargins(Rect r, ZoomLevel zoom) |
| 1352 | { |
no test coverage detected