mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibGUI: Don't leak every tooltip window ever :^)
This commit is contained in:
parent
dcb0766d3f
commit
10ccc9e11c
Notes:
sideshowbarker
2024-07-19 09:19:35 +09:00
Author: https://github.com/awesomekling
Commit: 10ccc9e11c
2 changed files with 13 additions and 10 deletions
|
@ -106,7 +106,18 @@ Action* Application::action_for_key_event(const KeyEvent& event)
|
|||
}
|
||||
|
||||
class Application::TooltipWindow final : public Window {
|
||||
C_OBJECT(TooltipWindow);
|
||||
|
||||
public:
|
||||
void set_tooltip(const StringView& tooltip)
|
||||
{
|
||||
// FIXME: Add some kind of GLabel auto-sizing feature.
|
||||
int text_width = m_label->font().width(tooltip);
|
||||
set_rect(100, 100, text_width + 10, m_label->font().glyph_height() + 8);
|
||||
m_label->set_text(tooltip);
|
||||
}
|
||||
|
||||
private:
|
||||
TooltipWindow()
|
||||
{
|
||||
set_window_type(WindowType::Tooltip);
|
||||
|
@ -119,21 +130,13 @@ public:
|
|||
set_main_widget(m_label);
|
||||
}
|
||||
|
||||
void set_tooltip(const StringView& tooltip)
|
||||
{
|
||||
// FIXME: Add some kind of GLabel auto-sizing feature.
|
||||
int text_width = m_label->font().width(tooltip);
|
||||
set_rect(100, 100, text_width + 10, m_label->font().glyph_height() + 8);
|
||||
m_label->set_text(tooltip);
|
||||
}
|
||||
|
||||
RefPtr<Label> m_label;
|
||||
};
|
||||
|
||||
void Application::show_tooltip(const StringView& tooltip, const Gfx::Point& screen_location)
|
||||
{
|
||||
if (!m_tooltip_window) {
|
||||
m_tooltip_window = new TooltipWindow;
|
||||
m_tooltip_window = TooltipWindow::construct();
|
||||
m_tooltip_window->set_double_buffering_enabled(false);
|
||||
}
|
||||
m_tooltip_window->set_tooltip(tooltip);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue