mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare/nth_root_layout] isSquareRoot
This commit is contained in:
@@ -19,6 +19,8 @@ public:
|
||||
m_hasIndex(hasIndex)
|
||||
{}
|
||||
|
||||
bool isSquareRoot() const;
|
||||
|
||||
// Layout
|
||||
Type type() const override { return Type::NthRootLayout; }
|
||||
|
||||
|
||||
@@ -21,6 +21,17 @@ const uint8_t radixPixel[NthRootLayoutNode::k_leftRadixHeight][NthRootLayoutNode
|
||||
{0xFF, 0xFF, 0xFF, 0xFF, 0xCB}
|
||||
};
|
||||
|
||||
bool NthRootLayoutNode::isSquareRoot() const {
|
||||
if (!m_hasIndex) {
|
||||
return true;
|
||||
}
|
||||
assert((const_cast<NthRootLayoutNode *>(this))->indexLayout() != nullptr);
|
||||
if ((const_cast<NthRootLayoutNode *>(this))->indexLayout()->isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void NthRootLayoutNode::moveCursorLeft(LayoutCursor * cursor, bool * shouldRecomputeLayout) {
|
||||
if (cursor->layoutNode() == radicandLayout()
|
||||
&& cursor->position() == LayoutCursor::Position::Left)
|
||||
@@ -149,17 +160,13 @@ void NthRootLayoutNode::deleteBeforeCursor(LayoutCursor * cursor) {
|
||||
}
|
||||
|
||||
int NthRootLayoutNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
if (m_hasIndex) {
|
||||
assert((const_cast<NthRootLayoutNode *>(this))->indexLayout());
|
||||
if ((const_cast<NthRootLayoutNode *>(this))->indexLayout()->isEmpty()) {
|
||||
// Case: root(x,empty): Write "'SquareRootSymbol'('radicandLayout')"
|
||||
return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, SquareRoot::s_functionHelper.name(), true, 0);
|
||||
}
|
||||
// Case: root(x,n)
|
||||
return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, NthRoot::s_functionHelper.name(), true);
|
||||
if (isSquareRoot()) {
|
||||
/* Case: squareRoot(x) or root(x,empty):
|
||||
* Write "SquareRootSymbol(radicandLayout) */
|
||||
return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, SquareRoot::s_functionHelper.name(), true, 0);
|
||||
}
|
||||
// Case: squareRoot(x)
|
||||
return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, SquareRoot::s_functionHelper.name(), true);
|
||||
// Case: root(x,n)
|
||||
return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, NthRoot::s_functionHelper.name(), true);
|
||||
}
|
||||
|
||||
KDSize NthRootLayoutNode::computeSize() {
|
||||
|
||||
Reference in New Issue
Block a user