make LayoutOptions CCObject aswell (ABI break!!)

This commit is contained in:
HJfod 2024-02-10 13:09:11 +02:00
parent cbd7e1e972
commit 3b7621c8a0
4 changed files with 12 additions and 12 deletions
loader
include/Geode/cocos/base_nodes
src

View file

@ -48,7 +48,7 @@ public:
virtual ~Layout() = default;
};
class GEODE_DLL LayoutOptions {
class GEODE_DLL LayoutOptions : public CCObject {
public:
virtual ~LayoutOptions() = default;
};
@ -344,9 +344,7 @@ protected:
public:
/**
* Create a new RowLayout. Note that this class is not automatically
* managed by default, so you must assign it to a CCNode or manually
* manage the memory yourself. See the chainable setters on RowLayout for
* Create a new RowLayout. See the chainable setters on RowLayout for
* what options you can customize for the layout
* @returns Created RowLayout
*/
@ -362,9 +360,7 @@ protected:
public:
/**
* Create a new ColumnLayout. Note that this class is not automatically
* managed by default, so you must assign it to a CCNode or manually
* manage the memory yourself. See the chainable setters on RowLayout for
* Create a new ColumnLayout. See the chainable setters on RowLayout for
* what options you can customize for the layout
* @returns Created ColumnLayout
*/

View file

@ -8,7 +8,9 @@
using namespace geode::prelude;
AnchorLayoutOptions* AnchorLayoutOptions::create() {
return new AnchorLayoutOptions();
auto ret = new AnchorLayoutOptions();
ret->autorelease();
return ret;
}
Anchor AnchorLayoutOptions::getAnchor() const {

View file

@ -908,7 +908,9 @@ ColumnLayout* ColumnLayout::create() {
// AxisLayoutOptions
AxisLayoutOptions* AxisLayoutOptions::create() {
return new AxisLayoutOptions();
auto ret = new AxisLayoutOptions();
ret->autorelease();
return ret;
}
std::optional<bool> AxisLayoutOptions::getAutoScale() const {

View file

@ -20,7 +20,7 @@ private:
Ref<cocos2d::CCObject> m_userObject;
std::string m_id = "";
Ref<Layout> m_layout = nullptr;
std::unique_ptr<LayoutOptions> m_layoutOptions = nullptr;
Ref<LayoutOptions> m_layoutOptions = nullptr;
std::unordered_map<std::string, matjson::Value> m_attributes;
std::unordered_set<std::unique_ptr<EventListenerProtocol>> m_eventListeners;
std::unordered_map<std::string, std::unique_ptr<EventListenerProtocol>> m_idEventListeners;
@ -147,14 +147,14 @@ Layout* CCNode::getLayout() {
}
void CCNode::setLayoutOptions(LayoutOptions* options, bool apply) {
GeodeNodeMetadata::set(this)->m_layoutOptions.reset(options);
GeodeNodeMetadata::set(this)->m_layoutOptions = options;
if (apply && m_pParent) {
m_pParent->updateLayout();
}
}
LayoutOptions* CCNode::getLayoutOptions() {
return GeodeNodeMetadata::set(this)->m_layoutOptions.get();
return GeodeNodeMetadata::set(this)->m_layoutOptions.data();
}
void CCNode::updateLayout(bool updateChildOrder) {