diff --git a/Userland/Libraries/LibCore/Object.h b/Userland/Libraries/LibCore/Object.h index 33a1fbf443..69c3203e34 100644 --- a/Userland/Libraries/LibCore/Object.h +++ b/Userland/Libraries/LibCore/Object.h @@ -98,6 +98,11 @@ public: virtual StringView class_name() const = 0; + template + bool fast_is() const = delete; + + virtual bool is_widget() const { return false; } + String const& name() const { return m_name; } void set_name(String name) { m_name = move(name); } diff --git a/Userland/Libraries/LibGUI/Widget.h b/Userland/Libraries/LibGUI/Widget.h index c90672ebd4..04567e6f05 100644 --- a/Userland/Libraries/LibGUI/Widget.h +++ b/Userland/Libraries/LibGUI/Widget.h @@ -404,6 +404,8 @@ protected: void show_or_hide_tooltip(); private: + virtual bool is_widget() const final { return true; } + void handle_paint_event(PaintEvent&); void handle_resize_event(ResizeEvent&); void handle_mousedown_event(MouseEvent&); @@ -466,6 +468,9 @@ inline Widget const* Widget::parent_widget() const } } +template<> +inline bool Core::Object::fast_is() const { return is_widget(); } + template<> struct AK::Formatter : AK::Formatter { };