/* * Copyright (c) 2018-2021, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include #include #include #include #include #include #include #include #include namespace GUI { class Application::TooltipWindow final : public Window { C_OBJECT(TooltipWindow); public: void set_tooltip(const String& tooltip) { m_label->set_text(Gfx::parse_ampersand_string(tooltip)); int tooltip_width = m_label->min_width() + 10; Gfx::IntRect desktop_rect = Desktop::the().rect(); if (tooltip_width > desktop_rect.width()) tooltip_width = desktop_rect.width(); set_rect(rect().x(), rect().y(), tooltip_width, m_label->font().glyph_height() + 8); } private: TooltipWindow() { set_window_type(WindowType::Tooltip); m_label = set_main_widget