mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 20:37:34 +00:00
LibCore: Remove Core::Object::is_widget() in favor of RTTI
This commit is contained in:
parent
42179715c3
commit
7841528cd4
4 changed files with 7 additions and 11 deletions
|
@ -40,9 +40,8 @@ IntrusiveList<Object, &Object::m_all_objects_list_node>& Object::all_objects()
|
|||
return objects;
|
||||
}
|
||||
|
||||
Object::Object(Object* parent, bool is_widget)
|
||||
Object::Object(Object* parent)
|
||||
: m_parent(parent)
|
||||
, m_widget(is_widget)
|
||||
{
|
||||
all_objects().append(*this);
|
||||
if (m_parent)
|
||||
|
|
|
@ -117,8 +117,6 @@ public:
|
|||
|
||||
void deferred_invoke(Function<void(Object&)>);
|
||||
|
||||
bool is_widget() const { return m_widget; }
|
||||
|
||||
void save_to(AK::JsonObject&);
|
||||
|
||||
bool set_property(const StringView& name, const JsonValue& value);
|
||||
|
@ -151,7 +149,7 @@ public:
|
|||
void decrement_inspector_count(Badge<RPCClient>);
|
||||
|
||||
protected:
|
||||
explicit Object(Object* parent = nullptr, bool is_widget = false);
|
||||
explicit Object(Object* parent = nullptr);
|
||||
|
||||
void register_property(const String& name, Function<JsonValue()> getter, Function<bool(const JsonValue&)> setter = nullptr);
|
||||
|
||||
|
@ -169,7 +167,6 @@ private:
|
|||
String m_name;
|
||||
int m_timer_id { 0 };
|
||||
unsigned m_inspector_count { 0 };
|
||||
bool m_widget { false };
|
||||
HashMap<String, NonnullOwnPtr<Property>> m_properties;
|
||||
NonnullRefPtrVector<Object> m_children;
|
||||
};
|
||||
|
|
|
@ -37,10 +37,10 @@ void ToolBarContainer::child_event(Core::ChildEvent& event)
|
|||
Frame::child_event(event);
|
||||
|
||||
if (event.type() == Core::Event::ChildAdded) {
|
||||
if (event.child() && event.child()->is_widget())
|
||||
if (event.child() && is<Widget>(event.child()))
|
||||
did_add_toolbar((Widget&)*event.child());
|
||||
} else if (event.type() == Core::Event::ChildRemoved) {
|
||||
if (event.child() && event.child()->is_widget()) {
|
||||
if (event.child() && is<Widget>(event.child())) {
|
||||
did_remove_toolbar((Widget&)*event.child());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ const WidgetClassRegistration* WidgetClassRegistration::find(const String& class
|
|||
}
|
||||
|
||||
Widget::Widget()
|
||||
: Core::Object(nullptr, true)
|
||||
: Core::Object(nullptr)
|
||||
, m_background_role(Gfx::ColorRole::Window)
|
||||
, m_foreground_role(Gfx::ColorRole::WindowText)
|
||||
, m_font(Gfx::FontDatabase::default_font())
|
||||
|
@ -197,7 +197,7 @@ void Widget::child_event(Core::ChildEvent& event)
|
|||
{
|
||||
if (event.type() == Event::ChildAdded) {
|
||||
if (event.child() && is<Widget>(*event.child()) && layout()) {
|
||||
if (event.insertion_before_child() && event.insertion_before_child()->is_widget())
|
||||
if (event.insertion_before_child() && is<Widget>(event.insertion_before_child()))
|
||||
layout()->insert_widget_before(downcast<Widget>(*event.child()), downcast<Widget>(*event.insertion_before_child()));
|
||||
else
|
||||
layout()->add_widget(downcast<Widget>(*event.child()));
|
||||
|
@ -853,7 +853,7 @@ Vector<Widget*> Widget::child_widgets() const
|
|||
Vector<Widget*> widgets;
|
||||
widgets.ensure_capacity(children().size());
|
||||
for (auto& child : const_cast<Widget*>(this)->children()) {
|
||||
if (child.is_widget())
|
||||
if (is<Widget>(child))
|
||||
widgets.append(static_cast<Widget*>(&child));
|
||||
}
|
||||
return widgets;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue