mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-24 03:39:56 -04:00
add option to ignore invisible children to Layout
This commit is contained in:
parent
21173311c1
commit
152f90cf67
2 changed files with 20 additions and 4 deletions
loader
|
@ -23,7 +23,9 @@ class CCNode;
|
|||
*/
|
||||
class GEODE_DLL Layout : public CCObject {
|
||||
protected:
|
||||
static CCArray* getNodesToPosition(CCNode* forNode);
|
||||
CCArray* getNodesToPosition(CCNode* forNode);
|
||||
|
||||
bool m_ignoreInvisibleChildren = false;
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -35,6 +37,9 @@ public:
|
|||
*/
|
||||
virtual void apply(CCNode* on) = 0;
|
||||
|
||||
void ignoreInvisibleChildren(bool ignore);
|
||||
bool isIgnoreInvisibleChildren() const;
|
||||
|
||||
virtual ~Layout() = default;
|
||||
};
|
||||
|
||||
|
|
|
@ -51,10 +51,21 @@ bool CCNode::hasAncestor(CCNode* ancestor) {
|
|||
}
|
||||
|
||||
CCArray* Layout::getNodesToPosition(CCNode* on) {
|
||||
if (!on->getChildren()) {
|
||||
return CCArray::create();
|
||||
auto arr = CCArray::create();
|
||||
for (auto child : CCArrayExt<CCNode>(on->getChildren())) {
|
||||
if (!m_ignoreInvisibleChildren || child->isVisible()) {
|
||||
arr->addObject(child);
|
||||
}
|
||||
}
|
||||
return on->getChildren()->shallowCopy();
|
||||
return arr;
|
||||
}
|
||||
|
||||
void Layout::ignoreInvisibleChildren(bool ignore) {
|
||||
m_ignoreInvisibleChildren = ignore;
|
||||
}
|
||||
|
||||
bool Layout::isIgnoreInvisibleChildren() const {
|
||||
return m_ignoreInvisibleChildren;
|
||||
}
|
||||
|
||||
static AxisLayoutOptions const* axisOpts(CCNode* node) {
|
||||
|
|
Loading…
Add table
Reference in a new issue