* Draw a button with a dropdown (#WWT_DROPDOWN and #NWID_BUTTON_DROPDOWN). * @param r Rectangle containing the widget. * @param colour Background colour of the widget. * @param clicked_button The button-part is clicked. * @param clicked_dropdown The drop-down part is clicked. * @param str Text of the button. * @param align Alignment of the t
| 764 | * @note Magic constants are also used in #NWidgetLeaf::ButtonHit. |
| 765 | */ |
| 766 | static inline void DrawButtonDropdown(const Rect &r, Colours colour, bool clicked_button, bool clicked_dropdown, std::string_view str, StringAlignment align) |
| 767 | { |
| 768 | bool rtl = _current_text_dir == TD_RTL; |
| 769 | |
| 770 | Rect text = r.Indent(NWidgetLeaf::dropdown_dimension.width, !rtl); |
| 771 | DrawFrameRect(text, colour, clicked_button ? FrameFlag::Lowered : FrameFlags{}); |
| 772 | if (!str.empty()) { |
| 773 | text = text.CentreToHeight(GetCharacterHeight(FS_NORMAL)).Shrink(WidgetDimensions::scaled.dropdowntext, RectPadding::zero); |
| 774 | DrawString(text, str, TC_BLACK, align); |
| 775 | } |
| 776 | |
| 777 | Rect button = r.WithWidth(NWidgetLeaf::dropdown_dimension.width, !rtl); |
| 778 | DrawImageButtons(button, WWT_DROPDOWN, colour, clicked_dropdown, SPR_ARROW_DOWN, SA_CENTER); |
| 779 | } |
| 780 | |
| 781 | /** |
| 782 | * Paint all widgets of a window. |
no test coverage detected