mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:37:35 +00:00
Userland: Rename Core::Object to Core::EventReceiver
This is a more precise description of what this class actually does.
This commit is contained in:
parent
bdf696e488
commit
ddbe6bd7b4
128 changed files with 399 additions and 401 deletions
|
@ -14,7 +14,7 @@
|
|||
#include <LibAudio/Queue.h>
|
||||
#include <LibAudio/UserSampleQueue.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibIPC/ConnectionToServer.h>
|
||||
#include <LibThreading/Mutex.h>
|
||||
#include <LibThreading/Thread.h>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Format.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/CharacterBitmap.h>
|
||||
|
@ -77,7 +77,7 @@ enum class Suit : u8 {
|
|||
__Count
|
||||
};
|
||||
|
||||
class Card final : public Core::Object {
|
||||
class Card final : public Core::EventReceiver {
|
||||
C_OBJECT(Card)
|
||||
public:
|
||||
static constexpr int width = 80;
|
||||
|
|
|
@ -51,7 +51,7 @@ void Endpoint::event(Core::Event& event)
|
|||
case Command::Type::UCINewGame:
|
||||
return handle_ucinewgame();
|
||||
default:
|
||||
Object::event(event);
|
||||
EventReceiver::event(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibChess/UCICommand.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
#include <LibCore/Object.h>
|
||||
|
||||
namespace Chess::UCI {
|
||||
|
||||
class Endpoint : public Core::Object {
|
||||
class Endpoint : public Core::EventReceiver {
|
||||
C_OBJECT(Endpoint)
|
||||
public:
|
||||
virtual ~Endpoint() override = default;
|
||||
|
|
|
@ -12,13 +12,13 @@ set(SOURCES
|
|||
EventLoop.cpp
|
||||
EventLoopImplementation.cpp
|
||||
EventLoopImplementationUnix.cpp
|
||||
EventReceiver.cpp
|
||||
File.cpp
|
||||
LockFile.cpp
|
||||
MappedFile.cpp
|
||||
MimeData.cpp
|
||||
NetworkJob.cpp
|
||||
Notifier.cpp
|
||||
Object.cpp
|
||||
Process.cpp
|
||||
ProcessStatisticsReader.cpp
|
||||
SecretString.cpp
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class DeferredInvocationContext final : public Core::Object {
|
||||
class DeferredInvocationContext final : public Core::EventReceiver {
|
||||
C_OBJECT(DeferredInvocationContext)
|
||||
private:
|
||||
DeferredInvocationContext() = default;
|
||||
|
|
|
@ -7,39 +7,39 @@
|
|||
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <LibCore/Event.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
ChildEvent::ChildEvent(Type type, Object& child, Object* insertion_before_child)
|
||||
ChildEvent::ChildEvent(Type type, EventReceiver& child, EventReceiver* insertion_before_child)
|
||||
: Core::Event(type)
|
||||
, m_child(child.make_weak_ptr())
|
||||
, m_insertion_before_child(AK::make_weak_ptr_if_nonnull(insertion_before_child))
|
||||
{
|
||||
}
|
||||
|
||||
Object* ChildEvent::child()
|
||||
EventReceiver* ChildEvent::child()
|
||||
{
|
||||
if (auto ref = m_child.strong_ref())
|
||||
return ref.ptr();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Object const* ChildEvent::child() const
|
||||
EventReceiver const* ChildEvent::child() const
|
||||
{
|
||||
if (auto ref = m_child.strong_ref())
|
||||
return ref.ptr();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Object* ChildEvent::insertion_before_child()
|
||||
EventReceiver* ChildEvent::insertion_before_child()
|
||||
{
|
||||
if (auto ref = m_insertion_before_child.strong_ref())
|
||||
return ref.ptr();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Object const* ChildEvent::insertion_before_child() const
|
||||
EventReceiver const* ChildEvent::insertion_before_child() const
|
||||
{
|
||||
if (auto ref = m_insertion_before_child.strong_ref())
|
||||
return ref.ptr();
|
||||
|
|
|
@ -95,18 +95,18 @@ private:
|
|||
|
||||
class ChildEvent final : public Event {
|
||||
public:
|
||||
ChildEvent(Type, Object& child, Object* insertion_before_child = nullptr);
|
||||
ChildEvent(Type, EventReceiver& child, EventReceiver* insertion_before_child = nullptr);
|
||||
~ChildEvent() = default;
|
||||
|
||||
Object* child();
|
||||
Object const* child() const;
|
||||
EventReceiver* child();
|
||||
EventReceiver const* child() const;
|
||||
|
||||
Object* insertion_before_child();
|
||||
Object const* insertion_before_child() const;
|
||||
EventReceiver* insertion_before_child();
|
||||
EventReceiver const* insertion_before_child() const;
|
||||
|
||||
private:
|
||||
WeakPtr<Object> m_child;
|
||||
WeakPtr<Object> m_insertion_before_child;
|
||||
WeakPtr<EventReceiver> m_child;
|
||||
WeakPtr<EventReceiver> m_insertion_before_child;
|
||||
};
|
||||
|
||||
class CustomEvent : public Event {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <LibCore/Event.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/EventLoopImplementationUnix.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/Promise.h>
|
||||
#include <LibCore/ThreadEventQueue.h>
|
||||
|
||||
|
@ -98,12 +98,12 @@ size_t EventLoop::pump(WaitMode mode)
|
|||
return m_impl->pump(mode == WaitMode::WaitForEvents ? EventLoopImplementation::PumpMode::WaitForEvents : EventLoopImplementation::PumpMode::DontWaitForEvents);
|
||||
}
|
||||
|
||||
void EventLoop::post_event(Object& receiver, NonnullOwnPtr<Event>&& event)
|
||||
void EventLoop::post_event(EventReceiver& receiver, NonnullOwnPtr<Event>&& event)
|
||||
{
|
||||
m_impl->post_event(receiver, move(event));
|
||||
}
|
||||
|
||||
void EventLoop::add_job(NonnullRefPtr<Promise<NonnullRefPtr<Object>>> job_promise)
|
||||
void EventLoop::add_job(NonnullRefPtr<Promise<NonnullRefPtr<EventReceiver>>> job_promise)
|
||||
{
|
||||
ThreadEventQueue::current().add_job(move(job_promise));
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ void EventLoop::notify_forked(ForkEvent)
|
|||
current().m_impl->notify_forked_and_in_child();
|
||||
}
|
||||
|
||||
int EventLoop::register_timer(Object& object, int milliseconds, bool should_reload, TimerShouldFireWhenNotVisible fire_when_not_visible)
|
||||
int EventLoop::register_timer(EventReceiver& object, int milliseconds, bool should_reload, TimerShouldFireWhenNotVisible fire_when_not_visible)
|
||||
{
|
||||
return EventLoopManager::the().register_timer(object, milliseconds, should_reload, fire_when_not_visible);
|
||||
}
|
||||
|
|
|
@ -63,9 +63,9 @@ public:
|
|||
void spin_until(Function<bool()>);
|
||||
|
||||
// Post an event to this event loop.
|
||||
void post_event(Object& receiver, NonnullOwnPtr<Event>&&);
|
||||
void post_event(EventReceiver& receiver, NonnullOwnPtr<Event>&&);
|
||||
|
||||
void add_job(NonnullRefPtr<Promise<NonnullRefPtr<Object>>> job_promise);
|
||||
void add_job(NonnullRefPtr<Promise<NonnullRefPtr<EventReceiver>>> job_promise);
|
||||
|
||||
void deferred_invoke(Function<void()>);
|
||||
|
||||
|
@ -76,7 +76,7 @@ public:
|
|||
bool was_exit_requested() const;
|
||||
|
||||
// The registration functions act upon the current loop of the current thread.
|
||||
static int register_timer(Object&, int milliseconds, bool should_reload, TimerShouldFireWhenNotVisible);
|
||||
static int register_timer(EventReceiver&, int milliseconds, bool should_reload, TimerShouldFireWhenNotVisible);
|
||||
static bool unregister_timer(int timer_id);
|
||||
|
||||
static void register_notifier(Badge<Notifier>, Notifier&);
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
virtual NonnullOwnPtr<EventLoopImplementation> make_implementation() = 0;
|
||||
|
||||
virtual int register_timer(Object&, int milliseconds, bool should_reload, TimerShouldFireWhenNotVisible) = 0;
|
||||
virtual int register_timer(EventReceiver&, int milliseconds, bool should_reload, TimerShouldFireWhenNotVisible) = 0;
|
||||
virtual bool unregister_timer(int timer_id) = 0;
|
||||
|
||||
virtual void register_notifier(Notifier&) = 0;
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
virtual void quit(int) = 0;
|
||||
virtual void wake() = 0;
|
||||
|
||||
virtual void post_event(Object& receiver, NonnullOwnPtr<Event>&&) = 0;
|
||||
virtual void post_event(EventReceiver& receiver, NonnullOwnPtr<Event>&&) = 0;
|
||||
|
||||
// FIXME: These APIs only exist for obscure use-cases inside SerenityOS. Try to get rid of them.
|
||||
virtual void unquit() = 0;
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
#include <AK/WeakPtr.h>
|
||||
#include <LibCore/Event.h>
|
||||
#include <LibCore/EventLoopImplementationUnix.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/Socket.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibCore/ThreadEventQueue.h>
|
||||
|
@ -33,7 +33,7 @@ struct EventLoopTimer {
|
|||
MonotonicTime fire_time { MonotonicTime::now_coarse() };
|
||||
bool should_reload { false };
|
||||
TimerShouldFireWhenNotVisible fire_when_not_visible { TimerShouldFireWhenNotVisible::No };
|
||||
WeakPtr<Object> owner;
|
||||
WeakPtr<EventReceiver> owner;
|
||||
|
||||
void reload(MonotonicTime const& now) { fire_time = now + interval; }
|
||||
bool has_expired(MonotonicTime const& now) const { return now > fire_time; }
|
||||
|
@ -126,7 +126,7 @@ bool EventLoopImplementationUnix::was_exit_requested() const
|
|||
return m_exit_requested;
|
||||
}
|
||||
|
||||
void EventLoopImplementationUnix::post_event(Object& receiver, NonnullOwnPtr<Event>&& event)
|
||||
void EventLoopImplementationUnix::post_event(EventReceiver& receiver, NonnullOwnPtr<Event>&& event)
|
||||
{
|
||||
m_thread_event_queue.post_event(receiver, move(event));
|
||||
if (&m_thread_event_queue != &ThreadEventQueue::current())
|
||||
|
@ -481,7 +481,7 @@ void EventLoopManagerUnix::unregister_signal(int handler_id)
|
|||
info.signal_handlers.remove(remove_signal_number);
|
||||
}
|
||||
|
||||
int EventLoopManagerUnix::register_timer(Object& object, int milliseconds, bool should_reload, TimerShouldFireWhenNotVisible fire_when_not_visible)
|
||||
int EventLoopManagerUnix::register_timer(EventReceiver& object, int milliseconds, bool should_reload, TimerShouldFireWhenNotVisible fire_when_not_visible)
|
||||
{
|
||||
VERIFY(milliseconds >= 0);
|
||||
auto& thread_data = ThreadData::the();
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
|
||||
virtual NonnullOwnPtr<EventLoopImplementation> make_implementation() override;
|
||||
|
||||
virtual int register_timer(Object&, int milliseconds, bool should_reload, TimerShouldFireWhenNotVisible) override;
|
||||
virtual int register_timer(EventReceiver&, int milliseconds, bool should_reload, TimerShouldFireWhenNotVisible) override;
|
||||
virtual bool unregister_timer(int timer_id) override;
|
||||
|
||||
virtual void register_notifier(Notifier&) override;
|
||||
|
@ -52,7 +52,7 @@ public:
|
|||
virtual void unquit() override;
|
||||
virtual bool was_exit_requested() const override;
|
||||
virtual void notify_forked_and_in_child() override;
|
||||
virtual void post_event(Object& receiver, NonnullOwnPtr<Event>&&) override;
|
||||
virtual void post_event(EventReceiver& receiver, NonnullOwnPtr<Event>&&) override;
|
||||
|
||||
private:
|
||||
bool m_exit_requested { false };
|
||||
|
|
|
@ -10,19 +10,19 @@
|
|||
#include <AK/JsonObject.h>
|
||||
#include <LibCore/Event.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
Object::Object(Object* parent)
|
||||
EventReceiver::EventReceiver(EventReceiver* parent)
|
||||
: m_parent(parent)
|
||||
{
|
||||
if (m_parent)
|
||||
m_parent->add_child(*this);
|
||||
}
|
||||
|
||||
Object::~Object()
|
||||
EventReceiver::~EventReceiver()
|
||||
{
|
||||
// NOTE: We move our children out to a stack vector to prevent other
|
||||
// code from trying to iterate over them.
|
||||
|
@ -37,7 +37,7 @@ Object::~Object()
|
|||
m_parent->remove_child(*this);
|
||||
}
|
||||
|
||||
void Object::event(Core::Event& event)
|
||||
void EventReceiver::event(Core::Event& event)
|
||||
{
|
||||
switch (event.type()) {
|
||||
case Core::Event::Timer:
|
||||
|
@ -55,7 +55,7 @@ void Object::event(Core::Event& event)
|
|||
}
|
||||
}
|
||||
|
||||
ErrorOr<void> Object::try_add_child(Object& object)
|
||||
ErrorOr<void> EventReceiver::try_add_child(EventReceiver& object)
|
||||
{
|
||||
// FIXME: Should we support reparenting objects?
|
||||
VERIFY(!object.parent() || object.parent() == this);
|
||||
|
@ -66,12 +66,12 @@ ErrorOr<void> Object::try_add_child(Object& object)
|
|||
return {};
|
||||
}
|
||||
|
||||
void Object::add_child(Object& object)
|
||||
void EventReceiver::add_child(EventReceiver& object)
|
||||
{
|
||||
MUST(try_add_child(object));
|
||||
}
|
||||
|
||||
void Object::insert_child_before(Object& new_child, Object& before_child)
|
||||
void EventReceiver::insert_child_before(EventReceiver& new_child, EventReceiver& before_child)
|
||||
{
|
||||
// FIXME: Should we support reparenting objects?
|
||||
VERIFY(!new_child.parent() || new_child.parent() == this);
|
||||
|
@ -81,12 +81,12 @@ void Object::insert_child_before(Object& new_child, Object& before_child)
|
|||
event(child_event);
|
||||
}
|
||||
|
||||
void Object::remove_child(Object& object)
|
||||
void EventReceiver::remove_child(EventReceiver& object)
|
||||
{
|
||||
for (size_t i = 0; i < m_children.size(); ++i) {
|
||||
if (m_children[i] == &object) {
|
||||
// NOTE: We protect the child so it survives the handling of ChildRemoved.
|
||||
NonnullRefPtr<Object> protector = object;
|
||||
NonnullRefPtr<EventReceiver> protector = object;
|
||||
object.m_parent = nullptr;
|
||||
m_children.remove(i);
|
||||
Core::ChildEvent child_event(Core::Event::ChildRemoved, object);
|
||||
|
@ -97,25 +97,25 @@ void Object::remove_child(Object& object)
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
void Object::remove_all_children()
|
||||
void EventReceiver::remove_all_children()
|
||||
{
|
||||
while (!m_children.is_empty())
|
||||
m_children.first()->remove_from_parent();
|
||||
}
|
||||
|
||||
void Object::timer_event(Core::TimerEvent&)
|
||||
void EventReceiver::timer_event(Core::TimerEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void Object::child_event(Core::ChildEvent&)
|
||||
void EventReceiver::child_event(Core::ChildEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void Object::custom_event(CustomEvent&)
|
||||
void EventReceiver::custom_event(CustomEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void Object::start_timer(int ms, TimerShouldFireWhenNotVisible fire_when_not_visible)
|
||||
void EventReceiver::start_timer(int ms, TimerShouldFireWhenNotVisible fire_when_not_visible)
|
||||
{
|
||||
if (m_timer_id) {
|
||||
dbgln("{} {:p} already has a timer!", class_name(), this);
|
||||
|
@ -125,7 +125,7 @@ void Object::start_timer(int ms, TimerShouldFireWhenNotVisible fire_when_not_vis
|
|||
m_timer_id = Core::EventLoop::register_timer(*this, ms, true, fire_when_not_visible);
|
||||
}
|
||||
|
||||
void Object::stop_timer()
|
||||
void EventReceiver::stop_timer()
|
||||
{
|
||||
if (!m_timer_id)
|
||||
return;
|
||||
|
@ -136,12 +136,12 @@ void Object::stop_timer()
|
|||
m_timer_id = 0;
|
||||
}
|
||||
|
||||
void Object::deferred_invoke(Function<void()> invokee)
|
||||
void EventReceiver::deferred_invoke(Function<void()> invokee)
|
||||
{
|
||||
Core::deferred_invoke([invokee = move(invokee), strong_this = NonnullRefPtr(*this)] { invokee(); });
|
||||
}
|
||||
|
||||
bool Object::is_ancestor_of(Object const& other) const
|
||||
bool EventReceiver::is_ancestor_of(EventReceiver const& other) const
|
||||
{
|
||||
if (&other == this)
|
||||
return false;
|
||||
|
@ -152,7 +152,7 @@ bool Object::is_ancestor_of(Object const& other) const
|
|||
return false;
|
||||
}
|
||||
|
||||
void Object::dispatch_event(Core::Event& e, Object* stay_within)
|
||||
void EventReceiver::dispatch_event(Core::Event& e, EventReceiver* stay_within)
|
||||
{
|
||||
VERIFY(!stay_within || stay_within == this || stay_within->is_ancestor_of(*this));
|
||||
auto* target = this;
|
||||
|
@ -169,14 +169,14 @@ void Object::dispatch_event(Core::Event& e, Object* stay_within)
|
|||
} while (target && !e.is_accepted());
|
||||
}
|
||||
|
||||
bool Object::is_visible_for_timer_purposes() const
|
||||
bool EventReceiver::is_visible_for_timer_purposes() const
|
||||
{
|
||||
if (parent())
|
||||
return parent()->is_visible_for_timer_purposes();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Object::set_event_filter(Function<bool(Core::Event&)> filter)
|
||||
void EventReceiver::set_event_filter(Function<bool(Core::Event&)> filter)
|
||||
{
|
||||
m_event_filter = move(filter);
|
||||
}
|
|
@ -49,16 +49,16 @@ public: \
|
|||
return #klass##sv; \
|
||||
}
|
||||
|
||||
class Object
|
||||
: public RefCounted<Object>
|
||||
, public Weakable<Object> {
|
||||
// NOTE: No C_OBJECT macro for Core::Object itself.
|
||||
class EventReceiver
|
||||
: public RefCounted<EventReceiver>
|
||||
, public Weakable<EventReceiver> {
|
||||
// NOTE: No C_OBJECT macro for Core::EventReceiver itself.
|
||||
|
||||
AK_MAKE_NONCOPYABLE(Object);
|
||||
AK_MAKE_NONMOVABLE(Object);
|
||||
AK_MAKE_NONCOPYABLE(EventReceiver);
|
||||
AK_MAKE_NONMOVABLE(EventReceiver);
|
||||
|
||||
public:
|
||||
virtual ~Object();
|
||||
virtual ~EventReceiver();
|
||||
|
||||
virtual StringView class_name() const = 0;
|
||||
|
||||
|
@ -70,8 +70,8 @@ public:
|
|||
DeprecatedString const& name() const { return m_name; }
|
||||
void set_name(DeprecatedString name) { m_name = move(name); }
|
||||
|
||||
Vector<NonnullRefPtr<Object>>& children() { return m_children; }
|
||||
Vector<NonnullRefPtr<Object>> const& children() const { return m_children; }
|
||||
Vector<NonnullRefPtr<EventReceiver>>& children() { return m_children; }
|
||||
Vector<NonnullRefPtr<EventReceiver>> const& children() const { return m_children; }
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_child(Callback callback)
|
||||
|
@ -84,51 +84,51 @@ public:
|
|||
|
||||
template<typename T, typename Callback>
|
||||
void for_each_child_of_type(Callback callback)
|
||||
requires IsBaseOf<Object, T>;
|
||||
requires IsBaseOf<EventReceiver, T>;
|
||||
|
||||
template<typename T>
|
||||
T* find_child_of_type_named(StringView)
|
||||
requires IsBaseOf<Object, T>;
|
||||
requires IsBaseOf<EventReceiver, T>;
|
||||
|
||||
template<typename T, size_t N>
|
||||
ALWAYS_INLINE T* find_child_of_type_named(char const (&string_literal)[N])
|
||||
requires IsBaseOf<Object, T>
|
||||
requires IsBaseOf<EventReceiver, T>
|
||||
{
|
||||
return find_child_of_type_named<T>(StringView { string_literal, N - 1 });
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T* find_descendant_of_type_named(StringView)
|
||||
requires IsBaseOf<Object, T>;
|
||||
requires IsBaseOf<EventReceiver, T>;
|
||||
|
||||
template<typename T, size_t N>
|
||||
ALWAYS_INLINE T* find_descendant_of_type_named(char const (&string_literal)[N])
|
||||
requires IsBaseOf<Object, T>
|
||||
requires IsBaseOf<EventReceiver, T>
|
||||
{
|
||||
return find_descendant_of_type_named<T>(StringView { string_literal, N - 1 });
|
||||
}
|
||||
|
||||
bool is_ancestor_of(Object const&) const;
|
||||
bool is_ancestor_of(EventReceiver const&) const;
|
||||
|
||||
Object* parent() { return m_parent; }
|
||||
Object const* parent() const { return m_parent; }
|
||||
EventReceiver* parent() { return m_parent; }
|
||||
EventReceiver const* parent() const { return m_parent; }
|
||||
|
||||
void start_timer(int ms, TimerShouldFireWhenNotVisible = TimerShouldFireWhenNotVisible::No);
|
||||
void stop_timer();
|
||||
bool has_timer() const { return m_timer_id; }
|
||||
|
||||
ErrorOr<void> try_add_child(Object&);
|
||||
ErrorOr<void> try_add_child(EventReceiver&);
|
||||
|
||||
void add_child(Object&);
|
||||
void insert_child_before(Object& new_child, Object& before_child);
|
||||
void remove_child(Object&);
|
||||
void add_child(EventReceiver&);
|
||||
void insert_child_before(EventReceiver& new_child, EventReceiver& before_child);
|
||||
void remove_child(EventReceiver&);
|
||||
void remove_all_children();
|
||||
|
||||
void set_event_filter(Function<bool(Core::Event&)>);
|
||||
|
||||
void deferred_invoke(Function<void()>);
|
||||
|
||||
void dispatch_event(Core::Event&, Object* stay_within = nullptr);
|
||||
void dispatch_event(Core::Event&, EventReceiver* stay_within = nullptr);
|
||||
|
||||
void remove_from_parent()
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ public:
|
|||
virtual bool is_visible_for_timer_purposes() const;
|
||||
|
||||
protected:
|
||||
explicit Object(Object* parent = nullptr);
|
||||
explicit EventReceiver(EventReceiver* parent = nullptr);
|
||||
|
||||
virtual void event(Core::Event&);
|
||||
|
||||
|
@ -166,18 +166,18 @@ protected:
|
|||
virtual void child_event(ChildEvent&);
|
||||
|
||||
private:
|
||||
Object* m_parent { nullptr };
|
||||
EventReceiver* m_parent { nullptr };
|
||||
DeprecatedString m_name;
|
||||
int m_timer_id { 0 };
|
||||
Vector<NonnullRefPtr<Object>> m_children;
|
||||
Vector<NonnullRefPtr<EventReceiver>> m_children;
|
||||
Function<bool(Core::Event&)> m_event_filter;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Core::Object> : AK::Formatter<FormatString> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Core::Object const& value)
|
||||
struct AK::Formatter<Core::EventReceiver> : AK::Formatter<FormatString> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Core::EventReceiver const& value)
|
||||
{
|
||||
return AK::Formatter<FormatString>::format(builder, "{}({})"sv, value.class_name(), &value);
|
||||
}
|
||||
|
@ -185,8 +185,8 @@ struct AK::Formatter<Core::Object> : AK::Formatter<FormatString> {
|
|||
|
||||
namespace Core {
|
||||
template<typename T, typename Callback>
|
||||
inline void Object::for_each_child_of_type(Callback callback)
|
||||
requires IsBaseOf<Object, T>
|
||||
inline void EventReceiver::for_each_child_of_type(Callback callback)
|
||||
requires IsBaseOf<EventReceiver, T>
|
||||
{
|
||||
for_each_child([&](auto& child) {
|
||||
if (is<T>(child))
|
||||
|
@ -196,8 +196,8 @@ requires IsBaseOf<Object, T>
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
T* Object::find_child_of_type_named(StringView name)
|
||||
requires IsBaseOf<Object, T>
|
||||
T* EventReceiver::find_child_of_type_named(StringView name)
|
||||
requires IsBaseOf<EventReceiver, T>
|
||||
{
|
||||
T* found_child = nullptr;
|
||||
for_each_child_of_type<T>([&](auto& child) {
|
||||
|
@ -212,8 +212,8 @@ requires IsBaseOf<Object, T>
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
T* Object::find_descendant_of_type_named(StringView name)
|
||||
requires IsBaseOf<Object, T>
|
||||
T* EventReceiver::find_descendant_of_type_named(StringView name)
|
||||
requires IsBaseOf<EventReceiver, T>
|
||||
{
|
||||
if (is<T>(*this) && this->name() == name) {
|
||||
return static_cast<T*>(this);
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -22,6 +22,7 @@ class DeferredInvocationContext;
|
|||
class ElapsedTimer;
|
||||
class Event;
|
||||
class EventLoop;
|
||||
class EventReceiver;
|
||||
class File;
|
||||
class LocalServer;
|
||||
class LocalSocket;
|
||||
|
@ -30,8 +31,6 @@ class MimeData;
|
|||
class NetworkJob;
|
||||
class NetworkResponse;
|
||||
class Notifier;
|
||||
class Object;
|
||||
class ObjectClassRegistration;
|
||||
class ProcessStatisticsReader;
|
||||
class Socket;
|
||||
template<typename Result, typename TError = AK::Error>
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
LocalServer::LocalServer(Object* parent)
|
||||
: Object(parent)
|
||||
LocalServer::LocalServer(EventReceiver* parent)
|
||||
: EventReceiver(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
#include <LibCore/Object.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class LocalServer : public Object {
|
||||
class LocalServer : public EventReceiver {
|
||||
C_OBJECT(LocalServer)
|
||||
public:
|
||||
virtual ~LocalServer() override;
|
||||
|
@ -26,7 +26,7 @@ public:
|
|||
Function<void(Error)> on_accept_error;
|
||||
|
||||
private:
|
||||
explicit LocalServer(Object* parent = nullptr);
|
||||
explicit LocalServer(EventReceiver* parent = nullptr);
|
||||
|
||||
void setup_notifier();
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/URL.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class MimeData : public Object {
|
||||
class MimeData : public EventReceiver {
|
||||
C_OBJECT(MimeData);
|
||||
|
||||
public:
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
|
||||
#include <AK/Function.h>
|
||||
#include <AK/Stream.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/Forward.h>
|
||||
#include <LibCore/Object.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class NetworkJob : public Object {
|
||||
class NetworkJob : public EventReceiver {
|
||||
C_OBJECT_ABSTRACT(NetworkJob)
|
||||
public:
|
||||
enum class Error {
|
||||
|
@ -70,5 +70,5 @@ char const* to_string(NetworkJob::Error);
|
|||
}
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Core::NetworkJob> : Formatter<Core::Object> {
|
||||
struct AK::Formatter<Core::NetworkJob> : Formatter<Core::EventReceiver> {
|
||||
};
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
Notifier::Notifier(int fd, Type type, Object* parent)
|
||||
: Object(parent)
|
||||
Notifier::Notifier(int fd, Type type, EventReceiver* parent)
|
||||
: EventReceiver(parent)
|
||||
, m_fd(fd)
|
||||
, m_type(type)
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ void Notifier::event(Core::Event& event)
|
|||
on_activation();
|
||||
return;
|
||||
}
|
||||
Object::event(event);
|
||||
EventReceiver::event(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class Notifier final : public Object {
|
||||
class Notifier final : public EventReceiver {
|
||||
C_OBJECT(Notifier);
|
||||
|
||||
public:
|
||||
|
@ -37,7 +37,7 @@ public:
|
|||
void event(Core::Event&) override;
|
||||
|
||||
private:
|
||||
Notifier(int fd, Type type, Object* parent = nullptr);
|
||||
Notifier(int fd, Type type, EventReceiver* parent = nullptr);
|
||||
|
||||
int m_fd { -1 };
|
||||
Type m_type { Type::None };
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
|
||||
#include <AK/Concepts.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
template<typename Result, typename TError>
|
||||
class Promise : public Object {
|
||||
class Promise : public EventReceiver {
|
||||
C_OBJECT(Promise);
|
||||
|
||||
public:
|
||||
|
@ -116,8 +116,8 @@ private:
|
|||
}
|
||||
|
||||
Promise() = default;
|
||||
Promise(Object* parent)
|
||||
: Object(parent)
|
||||
Promise(EventReceiver* parent)
|
||||
: EventReceiver(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
ErrorOr<NonnullRefPtr<TCPServer>> TCPServer::try_create(Object* parent)
|
||||
ErrorOr<NonnullRefPtr<TCPServer>> TCPServer::try_create(EventReceiver* parent)
|
||||
{
|
||||
#ifdef SOCK_NONBLOCK
|
||||
int fd = TRY(Core::System::socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0));
|
||||
|
@ -28,8 +28,8 @@ ErrorOr<NonnullRefPtr<TCPServer>> TCPServer::try_create(Object* parent)
|
|||
return adopt_nonnull_ref_or_enomem(new (nothrow) TCPServer(fd, parent));
|
||||
}
|
||||
|
||||
TCPServer::TCPServer(int fd, Object* parent)
|
||||
: Object(parent)
|
||||
TCPServer::TCPServer(int fd, EventReceiver* parent)
|
||||
: EventReceiver(parent)
|
||||
, m_fd(fd)
|
||||
{
|
||||
VERIFY(m_fd >= 0);
|
||||
|
|
|
@ -8,15 +8,15 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/IPv4Address.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
#include <LibCore/Object.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class TCPServer : public Object {
|
||||
class TCPServer : public EventReceiver {
|
||||
C_OBJECT_ABSTRACT(TCPServer)
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<TCPServer>> try_create(Object* parent = nullptr);
|
||||
static ErrorOr<NonnullRefPtr<TCPServer>> try_create(EventReceiver* parent = nullptr);
|
||||
virtual ~TCPServer() override;
|
||||
|
||||
enum class AllowAddressReuse {
|
||||
|
@ -36,7 +36,7 @@ public:
|
|||
Function<void()> on_ready_to_accept;
|
||||
|
||||
private:
|
||||
explicit TCPServer(int fd, Object* parent = nullptr);
|
||||
explicit TCPServer(int fd, EventReceiver* parent = nullptr);
|
||||
|
||||
int m_fd { -1 };
|
||||
bool m_listening { false };
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibCore/DeferredInvocationContext.h>
|
||||
#include <LibCore/EventLoopImplementation.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/Promise.h>
|
||||
#include <LibCore/ThreadEventQueue.h>
|
||||
#include <LibThreading/Mutex.h>
|
||||
|
@ -21,7 +21,7 @@ struct ThreadEventQueue::Private {
|
|||
AK_MAKE_DEFAULT_MOVABLE(QueuedEvent);
|
||||
|
||||
public:
|
||||
QueuedEvent(Object& receiver, NonnullOwnPtr<Event> event)
|
||||
QueuedEvent(EventReceiver& receiver, NonnullOwnPtr<Event> event)
|
||||
: receiver(receiver)
|
||||
, event(move(event))
|
||||
{
|
||||
|
@ -29,13 +29,13 @@ struct ThreadEventQueue::Private {
|
|||
|
||||
~QueuedEvent() = default;
|
||||
|
||||
WeakPtr<Object> receiver;
|
||||
WeakPtr<EventReceiver> receiver;
|
||||
NonnullOwnPtr<Event> event;
|
||||
};
|
||||
|
||||
Threading::Mutex mutex;
|
||||
Vector<QueuedEvent, 128> queued_events;
|
||||
Vector<NonnullRefPtr<Promise<NonnullRefPtr<Object>>>, 16> pending_promises;
|
||||
Vector<NonnullRefPtr<Promise<NonnullRefPtr<EventReceiver>>>, 16> pending_promises;
|
||||
bool warned_promise_count { false };
|
||||
};
|
||||
|
||||
|
@ -57,7 +57,7 @@ ThreadEventQueue::ThreadEventQueue()
|
|||
|
||||
ThreadEventQueue::~ThreadEventQueue() = default;
|
||||
|
||||
void ThreadEventQueue::post_event(Core::Object& receiver, NonnullOwnPtr<Core::Event> event)
|
||||
void ThreadEventQueue::post_event(Core::EventReceiver& receiver, NonnullOwnPtr<Core::Event> event)
|
||||
{
|
||||
{
|
||||
Threading::MutexLocker lock(m_private->mutex);
|
||||
|
@ -66,7 +66,7 @@ void ThreadEventQueue::post_event(Core::Object& receiver, NonnullOwnPtr<Core::Ev
|
|||
Core::EventLoopManager::the().did_post_event();
|
||||
}
|
||||
|
||||
void ThreadEventQueue::add_job(NonnullRefPtr<Promise<NonnullRefPtr<Object>>> promise)
|
||||
void ThreadEventQueue::add_job(NonnullRefPtr<Promise<NonnullRefPtr<EventReceiver>>> promise)
|
||||
{
|
||||
Threading::MutexLocker lock(m_private->mutex);
|
||||
m_private->pending_promises.append(move(promise));
|
||||
|
@ -107,7 +107,7 @@ size_t ThreadEventQueue::process()
|
|||
} else if (event.type() == Event::Type::DeferredInvoke) {
|
||||
static_cast<DeferredInvocationEvent&>(event).m_invokee();
|
||||
} else {
|
||||
NonnullRefPtr<Object> protector(*receiver);
|
||||
NonnullRefPtr<EventReceiver> protector(*receiver);
|
||||
receiver->dispatch_event(event);
|
||||
}
|
||||
++processed_events;
|
||||
|
|
|
@ -25,10 +25,10 @@ public:
|
|||
size_t process();
|
||||
|
||||
// Posts an event to the event queue.
|
||||
void post_event(Object& receiver, NonnullOwnPtr<Event>);
|
||||
void post_event(EventReceiver& receiver, NonnullOwnPtr<Event>);
|
||||
|
||||
// Used by Threading::BackgroundAction.
|
||||
void add_job(NonnullRefPtr<Promise<NonnullRefPtr<Object>>>);
|
||||
void add_job(NonnullRefPtr<Promise<NonnullRefPtr<EventReceiver>>>);
|
||||
void cancel_all_pending_jobs();
|
||||
|
||||
// Returns true if there are events waiting to be flushed.
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Concepts.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibThreading/Mutex.h>
|
||||
|
||||
namespace Core {
|
||||
|
@ -179,8 +179,8 @@ private:
|
|||
}
|
||||
|
||||
ThreadedPromise() = default;
|
||||
ThreadedPromise(Object* parent)
|
||||
: Object(parent)
|
||||
ThreadedPromise(EventReceiver* parent)
|
||||
: EventReceiver(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -9,13 +9,13 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
Timer::Timer(Object* parent)
|
||||
: Object(parent)
|
||||
Timer::Timer(EventReceiver* parent)
|
||||
: EventReceiver(parent)
|
||||
{
|
||||
}
|
||||
|
||||
Timer::Timer(int interval_ms, Function<void()>&& timeout_handler, Object* parent)
|
||||
: Object(parent)
|
||||
Timer::Timer(int interval_ms, Function<void()>&& timeout_handler, EventReceiver* parent)
|
||||
: EventReceiver(parent)
|
||||
, on_timeout(move(timeout_handler))
|
||||
, m_interval_ms(interval_ms)
|
||||
{
|
||||
|
|
|
@ -8,19 +8,19 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class Timer final : public Object {
|
||||
class Timer final : public EventReceiver {
|
||||
C_OBJECT(Timer);
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<Timer>> create_repeating(int interval_ms, Function<void()>&& timeout_handler, Object* parent = nullptr)
|
||||
static ErrorOr<NonnullRefPtr<Timer>> create_repeating(int interval_ms, Function<void()>&& timeout_handler, EventReceiver* parent = nullptr)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new Timer(interval_ms, move(timeout_handler), parent));
|
||||
}
|
||||
static ErrorOr<NonnullRefPtr<Timer>> create_single_shot(int interval_ms, Function<void()>&& timeout_handler, Object* parent = nullptr)
|
||||
static ErrorOr<NonnullRefPtr<Timer>> create_single_shot(int interval_ms, Function<void()>&& timeout_handler, EventReceiver* parent = nullptr)
|
||||
{
|
||||
auto timer = TRY(adopt_nonnull_ref_or_enomem(new Timer(interval_ms, move(timeout_handler), parent)));
|
||||
timer->set_single_shot(true);
|
||||
|
@ -53,8 +53,8 @@ public:
|
|||
Function<void()> on_timeout;
|
||||
|
||||
private:
|
||||
explicit Timer(Object* parent = nullptr);
|
||||
Timer(int interval_ms, Function<void()>&& timeout_handler, Object* parent = nullptr);
|
||||
explicit Timer(EventReceiver* parent = nullptr);
|
||||
Timer(int interval_ms, Function<void()>&& timeout_handler, EventReceiver* parent = nullptr);
|
||||
|
||||
virtual void timer_event(TimerEvent&) override;
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
UDPServer::UDPServer(Object* parent)
|
||||
: Object(parent)
|
||||
UDPServer::UDPServer(EventReceiver* parent)
|
||||
: EventReceiver(parent)
|
||||
{
|
||||
#ifdef SOCK_NONBLOCK
|
||||
m_fd = socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/Function.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/Forward.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/SocketAddress.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class UDPServer : public Object {
|
||||
class UDPServer : public EventReceiver {
|
||||
C_OBJECT(UDPServer)
|
||||
public:
|
||||
virtual ~UDPServer() override;
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
Function<void()> on_ready_to_receive;
|
||||
|
||||
protected:
|
||||
explicit UDPServer(Object* parent = nullptr);
|
||||
explicit UDPServer(EventReceiver* parent = nullptr);
|
||||
|
||||
private:
|
||||
int m_fd { -1 };
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibGUI/AbstractTableView.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/Button.h>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <AK/Debug.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/Utf8View.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibGUI/AbstractView.h>
|
||||
#include <LibGUI/DragOperation.h>
|
||||
|
|
|
@ -15,62 +15,62 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return adopt_ref(*new Action(move(text), move(callback), parent));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return adopt_ref(*new Action(move(text), move(icon), move(callback), parent));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return adopt_ref(*new Action(move(text), shortcut, move(callback), parent));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return adopt_ref(*new Action(move(text), shortcut, alternate_shortcut, move(callback), parent));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return adopt_ref(*new Action(move(text), shortcut, Shortcut {}, move(icon), move(callback), parent));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return adopt_ref(*new Action(move(text), shortcut, alternate_shortcut, move(icon), move(callback), parent));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> Action::create_checkable(DeprecatedString text, Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> Action::create_checkable(DeprecatedString text, Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return adopt_ref(*new Action(move(text), move(callback), parent, true));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> Action::create_checkable(DeprecatedString text, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> Action::create_checkable(DeprecatedString text, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return adopt_ref(*new Action(move(text), move(icon), move(callback), parent, true));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> Action::create_checkable(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> Action::create_checkable(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return adopt_ref(*new Action(move(text), shortcut, move(callback), parent, true));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> Action::create_checkable(DeprecatedString text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> Action::create_checkable(DeprecatedString text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return adopt_ref(*new Action(move(text), shortcut, Shortcut {}, move(icon), move(callback), parent, true));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Action>> Action::try_create_checkable(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::Object* parent)
|
||||
ErrorOr<NonnullRefPtr<Action>> Action::try_create_checkable(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) Action(move(text), shortcut, Shortcut {}, move(callback), parent, true));
|
||||
}
|
||||
|
||||
RefPtr<Action> Action::find_action_for_shortcut(Core::Object& object, Shortcut const& shortcut)
|
||||
RefPtr<Action> Action::find_action_for_shortcut(Core::EventReceiver& object, Shortcut const& shortcut)
|
||||
{
|
||||
RefPtr<Action> found_action = nullptr;
|
||||
object.for_each_child_of_type<Action>([&](auto& action) {
|
||||
|
@ -83,28 +83,28 @@ RefPtr<Action> Action::find_action_for_shortcut(Core::Object& object, Shortcut c
|
|||
return found_action;
|
||||
}
|
||||
|
||||
Action::Action(DeprecatedString text, Function<void(Action&)> on_activation_callback, Core::Object* parent, bool checkable)
|
||||
Action::Action(DeprecatedString text, Function<void(Action&)> on_activation_callback, Core::EventReceiver* parent, bool checkable)
|
||||
: Action(move(text), Shortcut {}, Shortcut {}, nullptr, move(on_activation_callback), parent, checkable)
|
||||
{
|
||||
}
|
||||
|
||||
Action::Action(DeprecatedString text, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> on_activation_callback, Core::Object* parent, bool checkable)
|
||||
Action::Action(DeprecatedString text, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> on_activation_callback, Core::EventReceiver* parent, bool checkable)
|
||||
: Action(move(text), Shortcut {}, Shortcut {}, move(icon), move(on_activation_callback), parent, checkable)
|
||||
{
|
||||
}
|
||||
|
||||
Action::Action(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> on_activation_callback, Core::Object* parent, bool checkable)
|
||||
Action::Action(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> on_activation_callback, Core::EventReceiver* parent, bool checkable)
|
||||
: Action(move(text), shortcut, Shortcut {}, nullptr, move(on_activation_callback), parent, checkable)
|
||||
{
|
||||
}
|
||||
|
||||
Action::Action(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function<void(Action&)> on_activation_callback, Core::Object* parent, bool checkable)
|
||||
Action::Action(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function<void(Action&)> on_activation_callback, Core::EventReceiver* parent, bool checkable)
|
||||
: Action(move(text), shortcut, alternate_shortcut, nullptr, move(on_activation_callback), parent, checkable)
|
||||
{
|
||||
}
|
||||
|
||||
Action::Action(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> on_activation_callback, Core::Object* parent, bool checkable)
|
||||
: Core::Object(parent)
|
||||
Action::Action(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> on_activation_callback, Core::EventReceiver* parent, bool checkable)
|
||||
: Core::EventReceiver(parent)
|
||||
, on_activation(move(on_activation_callback))
|
||||
, m_text(move(text))
|
||||
, m_icon(move(icon))
|
||||
|
@ -148,7 +148,7 @@ void Action::process_event(Window& window, Event& event)
|
|||
event.ignore();
|
||||
}
|
||||
|
||||
void Action::activate(Core::Object* activator)
|
||||
void Action::activate(Core::EventReceiver* activator)
|
||||
{
|
||||
if (is_activating())
|
||||
return;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibGUI/Forward.h>
|
||||
#include <LibGUI/Shortcut.h>
|
||||
|
@ -25,39 +25,39 @@ namespace GUI {
|
|||
|
||||
namespace CommonActions {
|
||||
NonnullRefPtr<Action> make_about_action(DeprecatedString const& app_name, Icon const& app_icon, Window* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_open_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_save_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_save_as_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_undo_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_redo_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_cut_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_copy_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_paste_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_delete_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_move_to_front_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_move_to_back_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_insert_emoji_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_fullscreen_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_open_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_save_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_save_as_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_undo_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_redo_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_cut_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_copy_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_paste_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_delete_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_move_to_front_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_move_to_back_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_insert_emoji_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_fullscreen_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_quit_action(Function<void(Action&)>);
|
||||
NonnullRefPtr<Action> make_help_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_go_back_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_go_forward_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_go_home_action(Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_close_tab_action(Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_reload_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_select_all_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_rename_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_properties_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_zoom_in_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_zoom_out_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_reset_zoom_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_rotate_clockwise_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_rotate_counterclockwise_action(Function<void(Action&)>, Core::Object* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_help_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_go_back_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_go_forward_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_go_home_action(Function<void(Action&)> callback, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_close_tab_action(Function<void(Action&)> callback, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_reload_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_select_all_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_rename_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_properties_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_zoom_in_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_zoom_out_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_reset_zoom_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_rotate_clockwise_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_rotate_counterclockwise_action(Function<void(Action&)>, Core::EventReceiver* parent = nullptr);
|
||||
NonnullRefPtr<Action> make_command_palette_action(Window* window = nullptr);
|
||||
|
||||
};
|
||||
|
||||
class Action final : public Core::Object {
|
||||
class Action final : public Core::EventReceiver {
|
||||
C_OBJECT(Action)
|
||||
public:
|
||||
enum class ShortcutScope {
|
||||
|
@ -66,20 +66,20 @@ public:
|
|||
WindowLocal,
|
||||
ApplicationGlobal,
|
||||
};
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create_checkable(DeprecatedString text, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create_checkable(DeprecatedString text, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create_checkable(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create_checkable(DeprecatedString text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Function<void(Action&)> callback, Core::EventReceiver* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::EventReceiver* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::EventReceiver* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function<void(Action&)> callback, Core::EventReceiver* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::EventReceiver* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::EventReceiver* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create_checkable(DeprecatedString text, Function<void(Action&)> callback, Core::EventReceiver* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create_checkable(DeprecatedString text, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::EventReceiver* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create_checkable(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::EventReceiver* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create_checkable(DeprecatedString text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::EventReceiver* parent = nullptr);
|
||||
|
||||
static ErrorOr<NonnullRefPtr<Action>> try_create_checkable(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static ErrorOr<NonnullRefPtr<Action>> try_create_checkable(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::EventReceiver* parent = nullptr);
|
||||
|
||||
static RefPtr<Action> find_action_for_shortcut(Core::Object& object, Shortcut const& shortcut);
|
||||
static RefPtr<Action> find_action_for_shortcut(Core::EventReceiver& object, Shortcut const& shortcut);
|
||||
|
||||
virtual ~Action() override;
|
||||
|
||||
|
@ -97,12 +97,12 @@ public:
|
|||
Gfx::Bitmap const* icon() const { return m_icon.ptr(); }
|
||||
void set_icon(Gfx::Bitmap const*);
|
||||
|
||||
Core::Object const* activator() const { return m_activator.ptr(); }
|
||||
Core::Object* activator() { return m_activator.ptr(); }
|
||||
Core::EventReceiver const* activator() const { return m_activator.ptr(); }
|
||||
Core::EventReceiver* activator() { return m_activator.ptr(); }
|
||||
|
||||
Function<void(Action&)> on_activation;
|
||||
|
||||
void activate(Core::Object* activator = nullptr);
|
||||
void activate(Core::EventReceiver* activator = nullptr);
|
||||
void process_event(Window& window, Event& event);
|
||||
void flash_menubar_menu(GUI::Window& window);
|
||||
|
||||
|
@ -138,11 +138,11 @@ public:
|
|||
HashTable<MenuItem*> const& menu_items() const { return m_menu_items; }
|
||||
|
||||
private:
|
||||
Action(DeprecatedString, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false);
|
||||
Action(DeprecatedString, Shortcut const&, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false);
|
||||
Action(DeprecatedString, Shortcut const&, Shortcut const&, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false);
|
||||
Action(DeprecatedString, Shortcut const&, Shortcut const&, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false);
|
||||
Action(DeprecatedString, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false);
|
||||
Action(DeprecatedString, Function<void(Action&)> = nullptr, Core::EventReceiver* = nullptr, bool checkable = false);
|
||||
Action(DeprecatedString, Shortcut const&, Function<void(Action&)> = nullptr, Core::EventReceiver* = nullptr, bool checkable = false);
|
||||
Action(DeprecatedString, Shortcut const&, Shortcut const&, Function<void(Action&)> = nullptr, Core::EventReceiver* = nullptr, bool checkable = false);
|
||||
Action(DeprecatedString, Shortcut const&, Shortcut const&, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> = nullptr, Core::EventReceiver* = nullptr, bool checkable = false);
|
||||
Action(DeprecatedString, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> = nullptr, Core::EventReceiver* = nullptr, bool checkable = false);
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_toolbar_button(Callback);
|
||||
|
@ -166,7 +166,7 @@ private:
|
|||
HashTable<Button*> m_buttons;
|
||||
HashTable<MenuItem*> m_menu_items;
|
||||
WeakPtr<ActionGroup> m_action_group;
|
||||
WeakPtr<Core::Object> m_activator;
|
||||
WeakPtr<Core::EventReceiver> m_activator;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -328,7 +328,7 @@ void Application::event(Core::Event& event)
|
|||
if (on_theme_change)
|
||||
on_theme_change();
|
||||
}
|
||||
Object::event(event);
|
||||
EventReceiver::event(event);
|
||||
}
|
||||
|
||||
void Application::set_config_domain(String config_domain)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibGUI/Forward.h>
|
||||
#include <LibGUI/Shortcut.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
|
@ -21,7 +21,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
class Application : public Core::Object {
|
||||
class Application : public Core::EventReceiver {
|
||||
C_OBJECT_ABSTRACT(Application);
|
||||
|
||||
public:
|
||||
|
|
|
@ -231,7 +231,7 @@ void CommandPalette::collect_actions(GUI::Window& parent_window)
|
|||
{
|
||||
OrderedHashTable<NonnullRefPtr<GUI::Action>> actions;
|
||||
|
||||
auto collect_action_children = [&](Core::Object& action_parent) {
|
||||
auto collect_action_children = [&](Core::EventReceiver& action_parent) {
|
||||
action_parent.for_each_child_of_type<GUI::Action>([&](GUI::Action& action) {
|
||||
if (action.is_enabled() && action.is_visible())
|
||||
actions.set(action);
|
||||
|
|
|
@ -32,85 +32,85 @@ NonnullRefPtr<Action> make_about_action(DeprecatedString const& app_name, Icon c
|
|||
return action;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_open_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_open_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
auto action = Action::create("&Open...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
action->set_status_tip("Open an existing file"_string.release_value_but_fixme_should_propagate_errors());
|
||||
return action;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_save_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_save_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
auto action = Action::create("&Save", { Mod_Ctrl, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
action->set_status_tip("Save the current file"_string.release_value_but_fixme_should_propagate_errors());
|
||||
return action;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_save_as_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_save_as_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
auto action = Action::create("Save &As...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save-as.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
action->set_status_tip("Save the current file with a new name"_string.release_value_but_fixme_should_propagate_errors());
|
||||
return action;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_move_to_front_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_move_to_front_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
auto action = Action::create("Move to &Front", { Mod_Ctrl | Mod_Shift, Key_Up }, Gfx::Bitmap::load_from_file("/res/icons/16x16/move-to-front.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
action->set_status_tip("Move to the top of the stack"_string.release_value_but_fixme_should_propagate_errors());
|
||||
return action;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_move_to_back_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_move_to_back_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
auto action = Action::create("Move to &Back", { Mod_Ctrl | Mod_Shift, Key_Down }, Gfx::Bitmap::load_from_file("/res/icons/16x16/move-to-back.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
action->set_status_tip("Move to the bottom of the stack"_string.release_value_but_fixme_should_propagate_errors());
|
||||
return action;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_undo_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_undo_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return Action::create("&Undo", { Mod_Ctrl, Key_Z }, Gfx::Bitmap::load_from_file("/res/icons/16x16/undo.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_redo_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_redo_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return Action::create("&Redo", { Mod_Ctrl | Mod_Shift, Key_Z }, { Mod_Ctrl, Key_Y }, Gfx::Bitmap::load_from_file("/res/icons/16x16/redo.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_delete_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_delete_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return Action::create("&Delete", { Mod_None, Key_Delete }, Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_cut_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_cut_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
auto action = Action::create("Cu&t", { Mod_Ctrl, Key_X }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-cut.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
action->set_status_tip("Cut to clipboard"_string.release_value_but_fixme_should_propagate_errors());
|
||||
return action;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_copy_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_copy_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
auto action = Action::create("&Copy", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
action->set_status_tip("Copy to clipboard"_string.release_value_but_fixme_should_propagate_errors());
|
||||
return action;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_paste_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_paste_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
auto action = Action::create("&Paste", { Mod_Ctrl, Key_V }, Gfx::Bitmap::load_from_file("/res/icons/16x16/paste.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
action->set_status_tip("Paste from clipboard"_string.release_value_but_fixme_should_propagate_errors());
|
||||
return action;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_insert_emoji_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_insert_emoji_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
auto action = Action::create("&Insert Emoji...", { Mod_Ctrl | Mod_Alt, Key_Space }, Gfx::Bitmap::load_from_file("/res/icons/16x16/emoji.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
action->set_status_tip("Open the Emoji Picker"_string.release_value_but_fixme_should_propagate_errors());
|
||||
return action;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_fullscreen_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_fullscreen_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
auto action = Action::create("&Fullscreen", { Mod_None, Key_F11 }, move(callback), parent);
|
||||
action->set_status_tip("Enter fullscreen mode"_string.release_value_but_fixme_should_propagate_errors());
|
||||
|
@ -125,80 +125,80 @@ NonnullRefPtr<Action> make_quit_action(Function<void(Action&)> callback)
|
|||
return action;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_help_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_help_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
auto action = Action::create("&Manual", { Mod_None, Key_F1 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/app-help.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
action->set_status_tip("Show help contents"_string.release_value_but_fixme_should_propagate_errors());
|
||||
return action;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_go_back_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_go_back_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
auto action = Action::create("Go &Back", { Mod_Alt, Key_Left }, { MouseButton::Backward }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
action->set_status_tip("Move one step backward in history"_string.release_value_but_fixme_should_propagate_errors());
|
||||
return action;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_go_forward_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_go_forward_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
auto action = Action::create("Go &Forward", { Mod_Alt, Key_Right }, { MouseButton::Forward }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
action->set_status_tip("Move one step forward in history"_string.release_value_but_fixme_should_propagate_errors());
|
||||
return action;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_go_home_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_go_home_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return Action::create("Go &Home", { Mod_Alt, Key_Home }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-home.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_close_tab_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_close_tab_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
auto action = Action::create("&Close Tab", { Mod_Ctrl, Key_W }, Gfx::Bitmap::load_from_file("/res/icons/16x16/close-tab.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
action->set_status_tip("Close current tab"_string.release_value_but_fixme_should_propagate_errors());
|
||||
return action;
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_reload_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_reload_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return Action::create("&Reload", { Mod_Ctrl, Key_R }, Key_F5, Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_select_all_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_select_all_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return Action::create("Select &All", { Mod_Ctrl, Key_A }, Gfx::Bitmap::load_from_file("/res/icons/16x16/select-all.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_rename_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_rename_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return Action::create("Re&name...", Key_F2, Gfx::Bitmap::load_from_file("/res/icons/16x16/rename.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_properties_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_properties_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return Action::create("P&roperties", { Mod_Alt, Key_Return }, Gfx::Bitmap::load_from_file("/res/icons/16x16/properties.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_zoom_in_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_zoom_in_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return GUI::Action::create("Zoom &In", { Mod_Ctrl, Key_Equal }, Gfx::Bitmap::load_from_file("/res/icons/16x16/zoom-in.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_reset_zoom_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_reset_zoom_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return GUI::Action::create("&Reset Zoom", { Mod_Ctrl, Key_0 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/zoom-reset.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_zoom_out_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_zoom_out_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return GUI::Action::create("Zoom &Out", { Mod_Ctrl, Key_Minus }, Gfx::Bitmap::load_from_file("/res/icons/16x16/zoom-out.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_rotate_clockwise_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_rotate_clockwise_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return GUI::Action::create("Rotate Clock&wise", { Mod_Ctrl | Mod_Shift, Key_GreaterThan }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-rotate-cw.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> make_rotate_counterclockwise_action(Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> make_rotate_counterclockwise_action(Function<void(Action&)> callback, Core::EventReceiver* parent)
|
||||
{
|
||||
return GUI::Action::create("Rotate &Counterclockwise", { Mod_Ctrl | Mod_Shift, Key_LessThan }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-rotate-ccw.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
|
||||
}
|
||||
|
|
|
@ -57,5 +57,5 @@ private:
|
|||
}
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<GUI::Dialog> : Formatter<Core::Object> {
|
||||
struct AK::Formatter<GUI::Dialog> : Formatter<Core::EventReceiver> {
|
||||
};
|
||||
|
|
|
@ -16,8 +16,8 @@ namespace GUI {
|
|||
|
||||
static DragOperation* s_current_drag_operation;
|
||||
|
||||
DragOperation::DragOperation(Core::Object* parent)
|
||||
: Core::Object(parent)
|
||||
DragOperation::DragOperation(Core::EventReceiver* parent)
|
||||
: Core::EventReceiver(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/MimeData.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibGUI/Forward.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
|
||||
namespace GUI {
|
||||
|
||||
class DragOperation : public Core::Object {
|
||||
class DragOperation : public Core::EventReceiver {
|
||||
C_OBJECT(DragOperation)
|
||||
public:
|
||||
enum class Outcome {
|
||||
|
@ -38,7 +38,7 @@ public:
|
|||
static void notify_cancelled(Badge<ConnectionToWindowServer>);
|
||||
|
||||
protected:
|
||||
explicit DragOperation(Core::Object* parent = nullptr);
|
||||
explicit DragOperation(Core::EventReceiver* parent = nullptr);
|
||||
|
||||
private:
|
||||
void done(Outcome);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <AK/String.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/ColorFilterer.h>
|
||||
#include <LibGUI/Event.h>
|
||||
|
@ -23,7 +23,7 @@ ErrorOr<NonnullRefPtr<Menu>> make_accessibility_menu(GUI::ColorFilterer&);
|
|||
|
||||
};
|
||||
|
||||
class Menu final : public Core::Object {
|
||||
class Menu final : public Core::EventReceiver {
|
||||
C_OBJECT(Menu)
|
||||
public:
|
||||
virtual ~Menu() override;
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/IterationDecision.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibGUI/Forward.h>
|
||||
#include <LibGUI/Menu.h>
|
||||
|
||||
namespace GUI {
|
||||
|
||||
class Menubar : public Core::Object {
|
||||
class Menubar : public Core::EventReceiver {
|
||||
C_OBJECT(Menubar);
|
||||
|
||||
public:
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
|
||||
namespace GUI {
|
||||
|
||||
class ConnectionToNotificationServer;
|
||||
|
||||
class Notification : public Core::Object {
|
||||
class Notification : public Core::EventReceiver {
|
||||
C_OBJECT(Notification);
|
||||
|
||||
friend class ConnectionToNotificationServer;
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
Object::Object(Core::Object* parent)
|
||||
: Core::Object(parent)
|
||||
Object::Object(Core::EventReceiver* parent)
|
||||
: Core::EventReceiver(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibGUI/Forward.h>
|
||||
#include <LibGUI/Property.h>
|
||||
|
||||
|
@ -44,7 +44,7 @@ private:
|
|||
ObjectClassRegistration* m_parent_class { nullptr };
|
||||
};
|
||||
|
||||
class Object : public Core::Object {
|
||||
class Object : public Core::EventReceiver {
|
||||
C_OBJECT_ABSTRACT(Object);
|
||||
|
||||
public:
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
HashMap<DeprecatedString, NonnullOwnPtr<Property>> const& properties() const { return m_properties; }
|
||||
|
||||
protected:
|
||||
explicit Object(Core::Object* parent = nullptr);
|
||||
explicit Object(Core::EventReceiver* parent = nullptr);
|
||||
|
||||
void register_property(DeprecatedString const& name, Function<JsonValue()> getter, Function<bool(JsonValue const&)> setter = nullptr);
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ ErrorOr<void> ScrollableContainerWidget::load_from_gml_ast(NonnullRefPtr<GUI::GM
|
|||
auto const& content_widget = static_cast<GUI::GML::Object const&>(*content_widget_value);
|
||||
auto class_name = content_widget.name();
|
||||
|
||||
RefPtr<Core::Object> child;
|
||||
RefPtr<Core::EventReceiver> child;
|
||||
if (auto* registration = GUI::ObjectClassRegistration::find(class_name)) {
|
||||
child = TRY(registration->construct());
|
||||
} else {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibGUI/HeaderView.h>
|
||||
#include <LibGUI/Model.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Optional.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibGUI/EditingEngine.h>
|
||||
#include <LibGUI/TextRange.h>
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ void Widget::child_event(Core::ChildEvent& event)
|
|||
}
|
||||
update();
|
||||
}
|
||||
return Core::Object::child_event(event);
|
||||
return Core::EventReceiver::child_event(event);
|
||||
}
|
||||
|
||||
void Widget::set_relative_rect(Gfx::IntRect const& a_rect)
|
||||
|
@ -347,7 +347,7 @@ void Widget::event(Core::Event& event)
|
|||
case Event::AppletAreaRectChange:
|
||||
return applet_area_rect_change_event(static_cast<AppletAreaRectChangeEvent&>(event));
|
||||
default:
|
||||
return Core::Object::event(event);
|
||||
return Core::EventReceiver::event(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1134,7 +1134,7 @@ void Widget::set_override_cursor(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<
|
|||
|
||||
ErrorOr<void> Widget::load_from_gml(StringView gml_string)
|
||||
{
|
||||
return load_from_gml(gml_string, [](DeprecatedString const& class_name) -> ErrorOr<NonnullRefPtr<Core::Object>> {
|
||||
return load_from_gml(gml_string, [](DeprecatedString const& class_name) -> ErrorOr<NonnullRefPtr<Core::EventReceiver>> {
|
||||
dbgln("Class '{}' not registered", class_name);
|
||||
return Error::from_string_literal("Class not registered");
|
||||
});
|
||||
|
@ -1195,7 +1195,7 @@ ErrorOr<void> Widget::load_from_gml_ast(NonnullRefPtr<GUI::GML::Node const> ast,
|
|||
}
|
||||
this->layout()->add_spacer();
|
||||
} else {
|
||||
RefPtr<Core::Object> child;
|
||||
RefPtr<Core::EventReceiver> child;
|
||||
if (auto* registration = GUI::ObjectClassRegistration::find(class_name)) {
|
||||
child = TRY(registration->construct());
|
||||
if (!registration->is_derived_from(widget_class)) {
|
||||
|
|
|
@ -350,7 +350,7 @@ public:
|
|||
AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> const& override_cursor() const { return m_override_cursor; }
|
||||
void set_override_cursor(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>>);
|
||||
|
||||
using UnregisteredChildHandler = ErrorOr<NonnullRefPtr<Core::Object>>(DeprecatedString const&);
|
||||
using UnregisteredChildHandler = ErrorOr<NonnullRefPtr<Core::EventReceiver>>(DeprecatedString const&);
|
||||
ErrorOr<void> load_from_gml(StringView);
|
||||
ErrorOr<void> load_from_gml(StringView, UnregisteredChildHandler);
|
||||
|
||||
|
@ -477,8 +477,8 @@ inline Widget const* Widget::parent_widget() const
|
|||
}
|
||||
|
||||
template<>
|
||||
inline bool Core::Object::fast_is<GUI::Widget>() const { return is_widget(); }
|
||||
inline bool Core::EventReceiver::fast_is<GUI::Widget>() const { return is_widget(); }
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<GUI::Widget> : AK::Formatter<Core::Object> {
|
||||
struct AK::Formatter<GUI::Widget> : AK::Formatter<Core::EventReceiver> {
|
||||
};
|
||||
|
|
|
@ -71,7 +71,7 @@ Window* Window::from_window_id(int window_id)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Window::Window(Core::Object* parent)
|
||||
Window::Window(Core::EventReceiver* parent)
|
||||
: GUI::Object(parent)
|
||||
, m_menubar(Menubar::construct())
|
||||
{
|
||||
|
@ -760,7 +760,7 @@ void Window::event(Core::Event& event)
|
|||
if (event.type() == Event::AppletAreaRectChange)
|
||||
return handle_applet_area_rect_change_event(static_cast<AppletAreaRectChangeEvent&>(event));
|
||||
|
||||
Core::Object::event(event);
|
||||
Core::EventReceiver::event(event);
|
||||
}
|
||||
|
||||
bool Window::is_visible() const
|
||||
|
|
|
@ -242,7 +242,7 @@ public:
|
|||
void propagate_shortcuts(KeyEvent& event, Widget* widget, ShortcutPropagationBoundary = ShortcutPropagationBoundary::Application);
|
||||
|
||||
protected:
|
||||
Window(Core::Object* parent = nullptr);
|
||||
Window(Core::EventReceiver* parent = nullptr);
|
||||
virtual void wm_event(WMEvent&);
|
||||
virtual void screen_rects_change_event(ScreenRectsChangeEvent&);
|
||||
virtual void applet_area_rect_change_event(AppletAreaRectChangeEvent&);
|
||||
|
@ -329,5 +329,5 @@ private:
|
|||
}
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<GUI::Window> : Formatter<Core::Object> {
|
||||
struct AK::Formatter<GUI::Window> : Formatter<Core::EventReceiver> {
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <AK/Tuple.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <LibCore/DateTime.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
|
||||
namespace IMAP {
|
||||
enum class CommandType {
|
||||
|
|
|
@ -32,7 +32,7 @@ struct DeferredInvoker {
|
|||
virtual void schedule(Function<void()>) = 0;
|
||||
};
|
||||
|
||||
class ConnectionBase : public Core::Object {
|
||||
class ConnectionBase : public Core::EventReceiver {
|
||||
C_OBJECT_ABSTRACT(ConnectionBase);
|
||||
|
||||
public:
|
||||
|
@ -161,5 +161,5 @@ protected:
|
|||
}
|
||||
|
||||
template<typename LocalEndpoint, typename PeerEndpoint>
|
||||
struct AK::Formatter<IPC::Connection<LocalEndpoint, PeerEndpoint>> : Formatter<Core::Object> {
|
||||
struct AK::Formatter<IPC::Connection<LocalEndpoint, PeerEndpoint>> : Formatter<Core::EventReceiver> {
|
||||
};
|
||||
|
|
|
@ -69,5 +69,5 @@ private:
|
|||
}
|
||||
|
||||
template<typename ClientEndpoint, typename ServerEndpoint>
|
||||
struct AK::Formatter<IPC::ConnectionFromClient<ClientEndpoint, ServerEndpoint>> : Formatter<Core::Object> {
|
||||
struct AK::Formatter<IPC::ConnectionFromClient<ClientEndpoint, ServerEndpoint>> : Formatter<Core::EventReceiver> {
|
||||
};
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibLine/KeyCallbackMachine.h>
|
||||
#include <LibLine/Span.h>
|
||||
#include <LibLine/StringMetrics.h>
|
||||
|
@ -132,7 +132,7 @@ struct Configuration {
|
|||
#define EDITOR_INTERNAL_FUNCTION(name) \
|
||||
[](auto& editor) { editor.name(); return false; }
|
||||
|
||||
class Editor : public Core::Object {
|
||||
class Editor : public Core::EventReceiver {
|
||||
C_OBJECT(Editor);
|
||||
|
||||
public:
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <AK/Optional.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibSQL/Forward.h>
|
||||
#include <LibSQL/Heap.h>
|
||||
#include <LibSQL/Index.h>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibSQL/Forward.h>
|
||||
#include <LibSQL/Heap.h>
|
||||
#include <LibSQL/Meta.h>
|
||||
|
@ -24,7 +24,7 @@ namespace SQL {
|
|||
* to store in it. It has BTree pointers for B-Trees holding the definitions
|
||||
* of tables, columns, indexes, and other SQL objects.
|
||||
*/
|
||||
class Database : public Core::Object {
|
||||
class Database : public Core::EventReceiver {
|
||||
C_OBJECT(Database);
|
||||
|
||||
public:
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibSQL/Forward.h>
|
||||
#include <LibSQL/Heap.h>
|
||||
#include <LibSQL/Index.h>
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Object.h>
|
||||
|
||||
namespace SQL {
|
||||
|
||||
|
@ -64,7 +64,7 @@ private:
|
|||
* A Heap can be thought of the backing storage of a single database. It's
|
||||
* assumed that a single SQL database is backed by a single Heap.
|
||||
*/
|
||||
class Heap : public Core::Object {
|
||||
class Heap : public Core::EventReceiver {
|
||||
C_OBJECT(Heap);
|
||||
|
||||
public:
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibSQL/Forward.h>
|
||||
#include <LibSQL/Meta.h>
|
||||
#include <LibSQL/Serializer.h>
|
||||
|
@ -31,7 +31,7 @@ private:
|
|||
Block::Index m_block_index;
|
||||
};
|
||||
|
||||
class Index : public Core::Object {
|
||||
class Index : public Core::EventReceiver {
|
||||
C_OBJECT_ABSTRACT(Index);
|
||||
|
||||
public:
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/Result.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibSQL/Forward.h>
|
||||
#include <LibSQL/Heap.h>
|
||||
#include <LibSQL/Type.h>
|
||||
|
@ -23,7 +23,7 @@ namespace SQL {
|
|||
* It remains to be seen if this will survive in it's current form.
|
||||
*/
|
||||
|
||||
class Relation : public Core::Object {
|
||||
class Relation : public Core::EventReceiver {
|
||||
C_OBJECT_ABSTRACT(Relation);
|
||||
|
||||
public:
|
||||
|
@ -36,14 +36,14 @@ public:
|
|||
|
||||
protected:
|
||||
Relation(DeprecatedString name, Block::Index block_index, Relation* parent = nullptr)
|
||||
: Core::Object(parent)
|
||||
: Core::EventReceiver(parent)
|
||||
, m_block_index(block_index)
|
||||
{
|
||||
set_name(move(name));
|
||||
}
|
||||
|
||||
explicit Relation(DeprecatedString name, Relation* parent = nullptr)
|
||||
: Core::Object(parent)
|
||||
: Core::EventReceiver(parent)
|
||||
, m_block_index(0)
|
||||
{
|
||||
set_name(move(name));
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <AK/Queue.h>
|
||||
#include <LibCore/Event.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/Promise.h>
|
||||
#include <LibThreading/Thread.h>
|
||||
|
||||
|
@ -35,14 +35,14 @@ private:
|
|||
};
|
||||
|
||||
template<typename Result>
|
||||
class BackgroundAction final : public Core::Object
|
||||
class BackgroundAction final : public Core::EventReceiver
|
||||
, private BackgroundActionBase {
|
||||
C_OBJECT(BackgroundAction);
|
||||
|
||||
public:
|
||||
// Promise is an implementation detail of BackgroundAction in order to communicate with EventLoop.
|
||||
// All of the promise's callbacks and state are either managed by us or by EventLoop.
|
||||
using Promise = Core::Promise<NonnullRefPtr<Core::Object>>;
|
||||
using Promise = Core::Promise<NonnullRefPtr<Core::EventReceiver>>;
|
||||
|
||||
virtual ~BackgroundAction() = default;
|
||||
|
||||
|
@ -55,13 +55,13 @@ public:
|
|||
|
||||
private:
|
||||
BackgroundAction(Function<ErrorOr<Result>(BackgroundAction&)> action, Function<ErrorOr<void>(Result)> on_complete, Optional<Function<void(Error)>> on_error = {})
|
||||
: Core::Object(&background_thread())
|
||||
: Core::EventReceiver(&background_thread())
|
||||
, m_promise(Promise::try_create().release_value_but_fixme_should_propagate_errors())
|
||||
, m_action(move(action))
|
||||
, m_on_complete(move(on_complete))
|
||||
{
|
||||
if (m_on_complete) {
|
||||
m_promise->on_resolution = [](NonnullRefPtr<Core::Object>& object) -> ErrorOr<void> {
|
||||
m_promise->on_resolution = [](NonnullRefPtr<Core::EventReceiver>& object) -> ErrorOr<void> {
|
||||
auto self = static_ptr_cast<BackgroundAction<Result>>(object);
|
||||
VERIFY(self->m_result.has_value());
|
||||
if (auto maybe_error = self->m_on_complete(self->m_result.value()); maybe_error.is_error())
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
namespace Threading {
|
||||
|
||||
Thread::Thread(Function<intptr_t()> action, StringView thread_name)
|
||||
: Core::Object(nullptr)
|
||||
: Core::EventReceiver(nullptr)
|
||||
, m_action(move(action))
|
||||
, m_thread_name(thread_name.is_null() ? ""sv : thread_name)
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <AK/DistinctNumeric.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/Result.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <pthread.h>
|
||||
|
||||
namespace Threading {
|
||||
|
@ -41,7 +41,7 @@ enum class ThreadState : u8 {
|
|||
Joined,
|
||||
};
|
||||
|
||||
class Thread final : public Core::Object {
|
||||
class Thread final : public Core::EventReceiver {
|
||||
C_OBJECT(Thread);
|
||||
|
||||
public:
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibVideo/DecoderError.h>
|
||||
#include <LibVideo/Sample.h>
|
||||
#include <LibVideo/Track.h>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/URL.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/Proxy.h>
|
||||
#include <LibWeb/Loader/Resource.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
|
@ -87,7 +87,7 @@ protected:
|
|||
explicit ResourceLoaderConnector();
|
||||
};
|
||||
|
||||
class ResourceLoader : public Core::Object {
|
||||
class ResourceLoader : public Core::EventReceiver {
|
||||
C_OBJECT_ABSTRACT(ResourceLoader)
|
||||
public:
|
||||
static void initialize(RefPtr<ResourceLoaderConnector>);
|
||||
|
|
|
@ -170,8 +170,8 @@ static JsonValue make_success_response(JsonValue value)
|
|||
return result;
|
||||
}
|
||||
|
||||
Client::Client(NonnullOwnPtr<Core::BufferedTCPSocket> socket, Core::Object* parent)
|
||||
: Core::Object(parent)
|
||||
Client::Client(NonnullOwnPtr<Core::BufferedTCPSocket> socket, Core::EventReceiver* parent)
|
||||
: Core::EventReceiver(parent)
|
||||
, m_socket(move(socket))
|
||||
{
|
||||
m_socket->on_ready_to_read = [this] {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibCore/Socket.h>
|
||||
#include <LibHTTP/Forward.h>
|
||||
#include <LibHTTP/HttpRequest.h>
|
||||
|
@ -24,7 +24,7 @@ namespace Web::WebDriver {
|
|||
|
||||
using Parameters = Vector<String>;
|
||||
|
||||
class Client : public Core::Object {
|
||||
class Client : public Core::EventReceiver {
|
||||
C_OBJECT_ABSTRACT(Client);
|
||||
|
||||
public:
|
||||
|
@ -106,7 +106,7 @@ public:
|
|||
virtual Response print_page(Parameters parameters, JsonValue payload) = 0;
|
||||
|
||||
protected:
|
||||
Client(NonnullOwnPtr<Core::BufferedTCPSocket>, Core::Object* parent);
|
||||
Client(NonnullOwnPtr<Core::BufferedTCPSocket>, Core::EventReceiver* parent);
|
||||
|
||||
private:
|
||||
using WrappedError = Variant<AK::Error, HTTP::HttpRequest::ParseError, WebDriver::Error>;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/URL.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
@ -116,7 +116,7 @@ protected:
|
|||
explicit WebSocketClientSocket();
|
||||
};
|
||||
|
||||
class WebSocketClientManager : public Core::Object {
|
||||
class WebSocketClientManager : public Core::EventReceiver {
|
||||
C_OBJECT_ABSTRACT(WebSocketClientManager)
|
||||
public:
|
||||
static void initialize(RefPtr<WebSocketClientManager>);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <AK/URL.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibTLS/TLSv12.h>
|
||||
#include <LibWebSocket/Message.h>
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Span.h>
|
||||
#include <LibCore/Object.h>
|
||||
#include <LibCore/EventReceiver.h>
|
||||
#include <LibWebSocket/ConnectionInfo.h>
|
||||
#include <LibWebSocket/Impl/WebSocketImpl.h>
|
||||
#include <LibWebSocket/Message.h>
|
||||
|
@ -22,7 +22,7 @@ enum class ReadyState {
|
|||
Closed = 3,
|
||||
};
|
||||
|
||||
class WebSocket final : public Core::Object {
|
||||
class WebSocket final : public Core::EventReceiver {
|
||||
C_OBJECT(WebSocket)
|
||||
public:
|
||||
static NonnullRefPtr<WebSocket> create(ConnectionInfo, RefPtr<WebSocketImpl> = nullptr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue