mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 18:32:28 -05:00
Demos/CatDog: Let the speech bubble know about the CatDog widget
This will allow us to have better interaction between CatDog's state and what it's saying.
This commit is contained in:
parent
835e99c86c
commit
83d9a89275
2 changed files with 9 additions and 2 deletions
|
@ -1,11 +1,14 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Gunnar Beutner <gunnar@beutner.name>
|
||||
* Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CatDog.h"
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
|
||||
class SpeechBubble final : public GUI::Widget {
|
||||
|
@ -16,7 +19,11 @@ public:
|
|||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||
|
||||
Function<void()> on_dismiss;
|
||||
NonnullRefPtr<CatDog> m_cat_dog;
|
||||
|
||||
private:
|
||||
SpeechBubble() = default;
|
||||
SpeechBubble(NonnullRefPtr<CatDog> cat_dog)
|
||||
: m_cat_dog(move(cat_dog))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -58,7 +58,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
advice_window->set_has_alpha_channel(true);
|
||||
advice_window->set_alpha_hit_threshold(1.0f);
|
||||
|
||||
auto advice_widget = TRY(advice_window->try_set_main_widget<SpeechBubble>());
|
||||
auto advice_widget = TRY(advice_window->try_set_main_widget<SpeechBubble>(catdog_widget));
|
||||
(void)TRY(advice_widget->try_set_layout<GUI::VerticalBoxLayout>());
|
||||
advice_widget->layout()->set_spacing(0);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue