[poincare] Un)iline some layotu constructors

This commit is contained in:
Léa Saviot
2018-09-07 17:08:03 +02:00
parent 780ab48d5b
commit 8926ed6f36
10 changed files with 62 additions and 54 deletions

View File

@@ -66,32 +66,12 @@ class HorizontalLayoutRef : public LayoutReference {
friend class HorizontalLayoutNode;
public:
HorizontalLayoutRef(HorizontalLayoutNode * n) : LayoutReference(n) {}
HorizontalLayoutRef() : LayoutReference(TreePool::sharedPool()->createTreeNode<HorizontalLayoutNode>()) {}
HorizontalLayoutRef(LayoutRef l) : HorizontalLayoutRef() {
addChildAtIndexInPlace(l, 0, 0);
}
HorizontalLayoutRef(LayoutRef l1, LayoutRef l2) : HorizontalLayoutRef() {
addChildAtIndexInPlace(l1, 0, 0);
addChildAtIndexInPlace(l2, 1, 1);
}
HorizontalLayoutRef(LayoutRef l1, LayoutRef l2, LayoutRef l3) : HorizontalLayoutRef() {
addChildAtIndexInPlace(l1, 0, 0);
addChildAtIndexInPlace(l2, 1, 1);
addChildAtIndexInPlace(l3, 2, 2);
}
HorizontalLayoutRef(LayoutRef l1, LayoutRef l2, LayoutRef l3, LayoutRef l4) : HorizontalLayoutRef() {
addChildAtIndexInPlace(l1, 0, 0);
addChildAtIndexInPlace(l2, 1, 1);
addChildAtIndexInPlace(l3, 2, 2);
addChildAtIndexInPlace(l4, 3, 3);
}
HorizontalLayoutRef(const LayoutRef * children, size_t numberOfChildren) : HorizontalLayoutRef() {
for (size_t i = 0; i < numberOfChildren; i++) {
addChildAtIndexInPlace(children[i], i, i);
}
}
HorizontalLayoutRef();
HorizontalLayoutRef(LayoutRef l);
HorizontalLayoutRef(LayoutRef l1, LayoutRef l2);
HorizontalLayoutRef(LayoutRef l1, LayoutRef l2, LayoutRef l3);
HorizontalLayoutRef(LayoutRef l1, LayoutRef l2, LayoutRef l3, LayoutRef l4);
HorizontalLayoutRef(const LayoutRef * children, size_t numberOfChildren);
void addChildAtIndex(LayoutReference l, int index, int currentNumberOfChildren, LayoutCursor * cursor) override {
LayoutReference::addChildAtIndex(l, index, currentNumberOfChildren, cursor);
}

View File

@@ -68,18 +68,10 @@ private:
class NthRootLayoutRef : public LayoutReference {
public:
NthRootLayoutRef(LayoutRef radicand) : NthRootLayoutRef() {
replaceChildAtIndexInPlace(0, radicand);
}
NthRootLayoutRef(LayoutRef radicand, LayoutRef index) : NthRootLayoutRef() {
replaceChildAtIndexInPlace(0, radicand);
addChildAtIndexInPlace(index, 1, 1);
static_cast<NthRootLayoutNode *>(node())->setNumberOfChildren(2);
}
NthRootLayoutRef(LayoutRef radicand);
NthRootLayoutRef(LayoutRef radicand, LayoutRef index);
private:
NthRootLayoutRef() : LayoutReference(TreePool::sharedPool()->createTreeNode<NthRootLayoutNode>()) {}
NthRootLayoutRef();
};
}

View File

@@ -36,7 +36,7 @@ protected:
class RightParenthesisLayoutRef : public LayoutReference {
public:
RightParenthesisLayoutRef() : LayoutReference(TreePool::sharedPool()->createTreeNode<RightParenthesisLayoutNode>()) {}
RightParenthesisLayoutRef();
};
}

View File

@@ -29,9 +29,7 @@ protected:
class RightSquareBracketLayoutRef : public LayoutReference {
public:
RightSquareBracketLayoutRef() : LayoutReference(TreePool::sharedPool()->createTreeNode<RightSquareBracketLayoutNode>()) {}
RightSquareBracketLayoutRef();
};
}

View File

@@ -59,12 +59,7 @@ private:
class VerticalOffsetLayoutRef : public LayoutReference {
public:
VerticalOffsetLayoutRef(LayoutRef l, VerticalOffsetLayoutNode::Type type) :
LayoutReference(TreePool::sharedPool()->createTreeNode<VerticalOffsetLayoutNode>())
{
static_cast<VerticalOffsetLayoutNode *>(node())->setType(type);
replaceChildAtIndexInPlace(0,l);
}
VerticalOffsetLayoutRef(LayoutRef l, VerticalOffsetLayoutNode::Type type);
};
}

View File

@@ -350,6 +350,33 @@ bool HorizontalLayoutNode::willReplaceChild(LayoutNode * oldChild, LayoutNode *
// HorizontalLayoutRef
HorizontalLayoutRef::HorizontalLayoutRef() : LayoutReference(TreePool::sharedPool()->createTreeNode<HorizontalLayoutNode>()) {}
HorizontalLayoutRef::HorizontalLayoutRef(LayoutRef l) : HorizontalLayoutRef() {
addChildAtIndexInPlace(l, 0, 0);
}
HorizontalLayoutRef::HorizontalLayoutRef(LayoutRef l1, LayoutRef l2) : HorizontalLayoutRef() {
addChildAtIndexInPlace(l1, 0, 0);
addChildAtIndexInPlace(l2, 1, 1);
}
HorizontalLayoutRef::HorizontalLayoutRef(LayoutRef l1, LayoutRef l2, LayoutRef l3) : HorizontalLayoutRef() {
addChildAtIndexInPlace(l1, 0, 0);
addChildAtIndexInPlace(l2, 1, 1);
addChildAtIndexInPlace(l3, 2, 2);
}
HorizontalLayoutRef::HorizontalLayoutRef(LayoutRef l1, LayoutRef l2, LayoutRef l3, LayoutRef l4) : HorizontalLayoutRef() {
addChildAtIndexInPlace(l1, 0, 0);
addChildAtIndexInPlace(l2, 1, 1);
addChildAtIndexInPlace(l3, 2, 2);
addChildAtIndexInPlace(l4, 3, 3);
}
HorizontalLayoutRef::HorizontalLayoutRef(const LayoutRef * children, size_t numberOfChildren) : HorizontalLayoutRef() {
for (size_t i = 0; i < numberOfChildren; i++) {
addChildAtIndexInPlace(children[i], i, i);
}
}
void HorizontalLayoutRef::addOrMergeChildAtIndex(LayoutRef l, int index, bool removeEmptyChildren, LayoutCursor * cursor) {
if (l.isHorizontal()) {
mergeChildrenAtIndex(HorizontalLayoutRef(static_cast<HorizontalLayoutNode *>(l.node())), index, removeEmptyChildren, cursor);

View File

@@ -269,4 +269,16 @@ void NthRootLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expressionCol
}
}
NthRootLayoutRef::NthRootLayoutRef(LayoutRef radicand) : NthRootLayoutRef() {
replaceChildAtIndexInPlace(0, radicand);
}
NthRootLayoutRef::NthRootLayoutRef(LayoutRef radicand, LayoutRef index) : NthRootLayoutRef() {
replaceChildAtIndexInPlace(0, radicand);
addChildAtIndexInPlace(index, 1, 1);
static_cast<NthRootLayoutNode *>(node())->setNumberOfChildren(2);
}
NthRootLayoutRef::NthRootLayoutRef() : LayoutReference(TreePool::sharedPool()->createTreeNode<NthRootLayoutNode>()) {}
}

View File

@@ -59,11 +59,6 @@ void RightParenthesisLayoutNode::render(KDContext * ctx, KDPoint p, KDColor expr
RenderWithChildHeight(ParenthesisLayoutNode::ChildHeightGivenLayoutHeight(layoutSize().height()), ctx, p, expressionColor, backgroundColor);
}
RightParenthesisLayoutRef::RightParenthesisLayoutRef() : LayoutReference(TreePool::sharedPool()->createTreeNode<RightParenthesisLayoutNode>()) {}
}

View File

@@ -8,4 +8,6 @@ void RightSquareBracketLayoutNode::render(KDContext * ctx, KDPoint p, KDColor ex
ctx->fillRect(KDRect(p.x()+k_widthMargin-k_bracketWidth+1, p.y() + childHeight(), k_bracketWidth, k_lineThickness), expressionColor);
}
RightSquareBracketLayoutRef::RightSquareBracketLayoutRef() : LayoutReference(TreePool::sharedPool()->createTreeNode<RightSquareBracketLayoutNode>()) {}
}

View File

@@ -271,4 +271,11 @@ LayoutNode * VerticalOffsetLayoutNode::baseLayout() {
return parentNode->childAtIndex(idxInParent - 1);
}
VerticalOffsetLayoutRef::VerticalOffsetLayoutRef(LayoutRef l, VerticalOffsetLayoutNode::Type type) :
LayoutReference(TreePool::sharedPool()->createTreeNode<VerticalOffsetLayoutNode>())
{
static_cast<VerticalOffsetLayoutNode *>(node())->setType(type);
replaceChildAtIndexInPlace(0,l);
}
}