summaryrefslogtreecommitdiff
path: root/Libraries/LibCore/CObject.h
AgeCommit message (Collapse)Author
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2019-12-29LibCore+LibGUI: Don't fire timers in non-visible windows by defaultAndreas Kling
LibCore timers now have a TimerShouldFireWhenNotVisible flag which is set to "No" by default. If "No", the timer will not be fired by the event loop if it's within a CObject tree whose nearest GWindow ancestor is currently not visible for timer purposes. (Specificially, this means that the window is either minimized or fully occluded, and so does not want to fire timers just to update the UI.) This is another nice step towards a calm and serene operating system.
2019-12-27LibCore: Fix errors when compiling LibCore using clang instead of gccStefano Cristiano
2019-11-05LibCore+LibGUI: Allow inserting a CObject/GWidget before anotherAndreas Kling
When adding a widget to a parent, you don't always want to append it to the set of existing children, but instead insert it before one of them. This patch makes that possible by adding CObject::insert_child_before() which also produces a ChildAdded event with an additional before_child pointer. This pointer is then used by GWidget to make sure that any layout present maintains the correct order. (Without doing that, newly added children would still be appended into the layout order, despite having a different widget sibling order.)
2019-09-22LibCore: Add CObject::remove_from_parent()Andreas Kling
This is a convenient shorthand for: if (object.parent()) object.parent()->remove_child(object);
2019-09-22LibCore: Remove ObjectPtr in favor of RefPtrAndreas Kling
Now that CObject is fully ref-counted, just use RefPtr everywhere! :^)
2019-09-22LibCore: Make CObject reference-countedAndreas Kling
Okay, I've spent a whole day on this now, and it finally kinda works! With this patch, CObject and all of its derived classes are reference counted instead of tree-owned. The previous, Qt-like model was nice and familiar, but ultimately also outdated and difficult to reason about. CObject-derived types should now be stored in RefPtr/NonnullRefPtr and each class can be constructed using the forwarding construct() helper: auto widget = GWidget::construct(parent_widget); Note that construct() simply forwards all arguments to an existing constructor. It is inserted into each class by the C_OBJECT macro, see CObject.h to understand how that works. CObject::delete_later() disappears in this patch, as there is no longer a single logical owner of a CObject.
2019-09-21LibCore: Convert CTCPSocket to ObjectPtr, add construct() helperAndreas Kling
The C_OBJECT macro now also inserts a static construct(...) helper into the class. Now we can make the constructor(s) private and instead call: auto socket = CTCPSocket::construct(arguments); construct() returns an ObjectPtr<T>, which we'll later switch to being a NonnullRefPtr<T>, once everything else in in place for ref-counting.
2019-09-20LibCore+LibGUI+WindowServer: Make events bubble up through ancestorsAndreas Kling
With this patch, CEvents no longer stop at the target object, but will bubble up the ancestor chain as long as CEvent::is_accepted() is false. To the set accepted flag, call CEvent::accept(). To clear the accepted flag, call CEvent::ignore(). Events start out in the accepted state, so if you want them to bubble up, you have to call ignore() on them. Using this mechanism, we now ignore non-tabbing keydown events in GWidget, causing them to bubble up through the widget's ancestors. :^)
2019-09-06AK: Rename <AK/AKString.h> to <AK/String.h>Andreas Kling
This was a workaround to be able to build on case-insensitive file systems where it might get confused about <string.h> vs <String.h>. Let's just not support building that way, so String.h can have an objectively nicer name. :^)
2019-08-19LibCore: Move CObject serialization into CObject::save_to(JsonObject&)Andreas Kling
The idea is for subclasses to override this and add whatever properties are relevant for them, then call up to their base class, etc.
2019-08-17CObject: Put all CObjects on a global IntrusiveList for introspectionAndreas Kling
This will allow us to easily traverse the entire CObject graph.
2019-07-27LibCore: Add comment about child events for partially-constructed children.Andreas Kling
Since ChildAdded events originate from the CObject constructor, they are not fully constructed when their parent learns that they were added. Added a little comment about this to the child_event() declaration.
2019-07-25LibCore: Introduce a C_OBJECT macro.Andreas Kling
This macro goes at the top of every CObject-derived class like so: class SomeClass : public CObject { C_OBJECT(SomeClass) public: ... At the moment, all it does is create an override for the class_name() getter but in the future this will be used to automatically insert member functions into these classes.
2019-07-14CObject: Add LogStream operator<< for CObject.Andreas Kling
2019-07-14CObject: Add custom_event() virtual.Andreas Kling
This way you can just override custom_event() to catch CCustomEvent instead of having to filter the entire event stream with event(). :^)
2019-07-10CObject: Add a "name" property.Andreas Kling
This will be useful for things like the VisualBuilder code generator.
2019-07-04Libraries: Create top level directory for libraries.Andreas Kling
Things were getting a little crowded in the project root, so this patch moves the Lib*/ directories into Libraries/.