* Draw a caption bar. * @param r Rectangle of the bar. * @param colour Colour of the window. * @param owner 'Owner' of the window. * @param text_colour Colour of the text. * @param str Text to draw in the bar. * @param align Alignment of the text. * @param fs Font size of the text. */
| 734 | * @param fs Font size of the text. |
| 735 | */ |
| 736 | void DrawCaption(const Rect &r, Colours colour, Owner owner, TextColour text_colour, std::string_view str, StringAlignment align, FontSize fs) |
| 737 | { |
| 738 | bool company_owned = owner < MAX_COMPANIES; |
| 739 | |
| 740 | DrawFrameRect(r, colour, FrameFlag::BorderOnly); |
| 741 | Rect ir = r.Shrink(WidgetDimensions::scaled.bevel); |
| 742 | DrawFrameRect(ir, colour, company_owned ? FrameFlags{FrameFlag::Lowered, FrameFlag::Darkened, FrameFlag::BorderOnly} : FrameFlags{FrameFlag::Lowered, FrameFlag::Darkened}); |
| 743 | |
| 744 | if (company_owned) { |
| 745 | GfxFillRect(ir.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(_company_colours[owner], SHADE_NORMAL)); |
| 746 | } |
| 747 | |
| 748 | if (str.empty()) return; |
| 749 | |
| 750 | Dimension d = GetStringBoundingBox(str); |
| 751 | Point p = GetAlignedPosition(r, d, align); |
| 752 | DrawString(r.left + WidgetDimensions::scaled.captiontext.left, r.right - WidgetDimensions::scaled.captiontext.left, p.y, str, text_colour, align, false, fs); |
| 753 | } |
| 754 | |
| 755 | /** |
| 756 | * Draw a button with a dropdown (#WWT_DROPDOWN and #NWID_BUTTON_DROPDOWN). |
no test coverage detected