mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare] Cleanup
This commit is contained in:
@@ -22,11 +22,11 @@ FractionLayout::~FractionLayout() {
|
||||
delete m_numerator;
|
||||
}
|
||||
|
||||
void FractionLayout::render(KDPoint origin) {
|
||||
KDCoordinate fractionLineY = m_numerator->size().height + FRACTION_LINE_MARGIN;
|
||||
void FractionLayout::render(KDPoint point) {
|
||||
KDCoordinate fractionLineY = point.y + m_numerator->size().height + FRACTION_LINE_MARGIN;
|
||||
|
||||
KDDrawLine((KDPoint){.x = 0, .y = fractionLineY},
|
||||
(KDPoint){.x = size().width, .y = fractionLineY});
|
||||
KDDrawLine((KDPoint){.x = point.x, .y = fractionLineY},
|
||||
(KDPoint){.x = (KDCoordinate)(point.x + size().width), .y = fractionLineY});
|
||||
}
|
||||
|
||||
KDSize FractionLayout::computeSize() {
|
||||
@@ -54,7 +54,7 @@ KDPoint FractionLayout::positionOfChild(ExpressionLayout * child) {
|
||||
p.y = 0;
|
||||
} else if (child == m_denominator) {
|
||||
p.x = (KDCoordinate)((size().width - m_denominator->size().width)/2);
|
||||
p.y = (KDCoordinate)(size().height + 2*FRACTION_LINE_MARGIN + FRACTION_LINE_HEIGHT);
|
||||
p.y = (KDCoordinate)(m_numerator->size().height + 2*FRACTION_LINE_MARGIN + FRACTION_LINE_HEIGHT);
|
||||
} else {
|
||||
assert(false); // Should not happen
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class FractionLayout : public ExpressionLayout {
|
||||
FractionLayout(ExpressionLayout * parent, Expression * numerator, Expression * denominator);
|
||||
~FractionLayout();
|
||||
protected:
|
||||
void render(KDPoint origin) override;
|
||||
void render(KDPoint point) override;
|
||||
KDSize computeSize() override;
|
||||
ExpressionLayout * child(uint16_t index) override;
|
||||
KDPoint positionOfChild(ExpressionLayout * child) override;
|
||||
|
||||
@@ -31,7 +31,6 @@ void HorizontalLayout::render(KDPoint point) {
|
||||
|
||||
KDSize HorizontalLayout::computeSize() {
|
||||
KDSize size = (KDSize){.width = 0, .height = 0};
|
||||
KDCoordinate width = 0, height = 0;
|
||||
int i = 0;
|
||||
while (ExpressionLayout * c = child(i++)) {
|
||||
KDSize childSize = c->size();
|
||||
@@ -52,6 +51,7 @@ ExpressionLayout * HorizontalLayout::child(uint16_t index) {
|
||||
|
||||
KDPoint HorizontalLayout::positionOfChild(ExpressionLayout * child) {
|
||||
KDPoint position = (KDPoint){.x = 0, .y = 0};
|
||||
#if 1
|
||||
uint16_t index = 0;
|
||||
for (int i=0;i<3;i++) {
|
||||
if (m_children[i] == child) {
|
||||
@@ -64,6 +64,13 @@ KDPoint HorizontalLayout::positionOfChild(ExpressionLayout * child) {
|
||||
assert(previousChild != nullptr);
|
||||
position.x = previousChild->origin().x + previousChild->size().width;
|
||||
}
|
||||
#else
|
||||
int i = 0;
|
||||
while(i<3 && m_children[i] != child) {
|
||||
position.x += m_children[i]->size().width;
|
||||
i++;
|
||||
}
|
||||
#endif
|
||||
position.y = (size().height - child->size().height)/2;
|
||||
return position;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class HorizontalLayout : public ExpressionLayout {
|
||||
HorizontalLayout(ExpressionLayout * parent, Expression * left_expression, char symbol, Expression * right_expression);
|
||||
~HorizontalLayout();
|
||||
protected:
|
||||
void render(KDPoint origin) override;
|
||||
void render(KDPoint point) override;
|
||||
KDSize computeSize() override;
|
||||
ExpressionLayout * child(uint16_t index) override;
|
||||
KDPoint positionOfChild(ExpressionLayout * child) override;
|
||||
|
||||
Reference in New Issue
Block a user