mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-24 00:00:44 +01:00
[poincare] Add LayoutCursor::cursorHeight()
This commit is contained in:
@@ -61,7 +61,7 @@ public:
|
||||
}
|
||||
Position position() const { return m_position; }
|
||||
void setPosition(Position position) { m_position = position; }
|
||||
int cursorHeight() { return 1; } //TODO
|
||||
KDCoordinate cursorHeight();
|
||||
int baseline() { return 1; } //TODO
|
||||
LayoutCursor clone() const {
|
||||
return LayoutCursor(m_layoutRef, m_position);
|
||||
@@ -112,11 +112,12 @@ public:
|
||||
void addLayoutAndMoveCursor(LayoutRef l) {} //TODO
|
||||
|
||||
private:
|
||||
constexpr static KDCoordinate k_cursorHeight = 18;
|
||||
LayoutCursor(LayoutNode * node, Position position = Position::Right) :
|
||||
m_layoutRef(node),
|
||||
m_position(position)
|
||||
{
|
||||
}
|
||||
{}
|
||||
KDCoordinate layoutHeight();
|
||||
LayoutRef m_layoutRef;
|
||||
Position m_position;
|
||||
};
|
||||
|
||||
@@ -75,6 +75,7 @@ public:
|
||||
|
||||
// Hierarchy
|
||||
bool hasChild(TreeReference<TreeNode> t) const { return node()->hasChild(t.node()); };
|
||||
bool hasSibling(TreeReference<TreeNode> t) const { return node()->hasSibling(t.node()); };
|
||||
int numberOfChildren() const { return node()->numberOfChildren(); }
|
||||
TreeReference<T> parent() const { return TreeReference(node()->parentTree()); }
|
||||
TreeReference<T> treeChildAtIndex(int i) const { return TreeReference(node()->childTreeAtIndex(i)); }
|
||||
|
||||
@@ -4,6 +4,13 @@
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
/* Getters and setters */
|
||||
|
||||
KDCoordinate LayoutCursor::cursorHeight() {
|
||||
KDCoordinate height = layoutHeight();
|
||||
return height == 0 ? k_cursorHeight : height;
|
||||
}
|
||||
|
||||
/* Comparison */
|
||||
|
||||
bool LayoutCursor::isEquivalentTo(LayoutCursor cursor) {
|
||||
@@ -37,4 +44,23 @@ void LayoutCursor::moveUnder(bool * shouldRecomputeLayout) {
|
||||
layoutReference().typedNode()->moveCursorDown(this, shouldRecomputeLayout);
|
||||
}
|
||||
|
||||
/* Private */
|
||||
|
||||
KDCoordinate LayoutCursor::layoutHeight() {
|
||||
LayoutRef equivalentLayoutRef = m_layoutRef.equivalentCursor(this).layoutReference();
|
||||
if (m_layoutRef.hasChild(equivalentLayoutRef)) {
|
||||
return equivalentLayoutRef.layoutSize().height();
|
||||
}
|
||||
KDCoordinate pointedLayoutHeight = m_layoutRef.layoutSize().height();
|
||||
if (m_layoutRef.hasSibling(equivalentLayoutRef)) {
|
||||
KDCoordinate equivalentLayoutHeight = equivalentLayoutRef.layoutSize().height();
|
||||
KDCoordinate pointedLayoutBaseline = m_layoutRef.baseline();
|
||||
KDCoordinate equivalentLayoutBaseline = equivalentLayoutRef.baseline();
|
||||
return max(pointedLayoutBaseline, equivalentLayoutBaseline)
|
||||
+ max(pointedLayoutHeight - pointedLayoutBaseline, equivalentLayoutHeight - equivalentLayoutBaseline);
|
||||
}
|
||||
return pointedLayoutHeight;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user