conjugate_layout.cpp
1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "conjugate_layout.h"
extern "C" {
#include <assert.h>
#include <stdlib.h>
}
namespace Poincare {
ConjugateLayout::ConjugateLayout(ExpressionLayout * operandLayout) :
ExpressionLayout(),
m_operandLayout(operandLayout)
{
m_operandLayout->setParent(this);
m_baseline = m_operandLayout->baseline()+k_overlineWidth+k_overlineMargin;
}
ConjugateLayout::~ConjugateLayout() {
delete m_operandLayout;
}
void ConjugateLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) {
ctx->fillRect(KDRect(p.x(), p.y(), m_operandLayout->size().width(), k_overlineWidth), expressionColor);
}
KDSize ConjugateLayout::computeSize() {
KDSize operandSize = m_operandLayout->size();
return KDSize(operandSize.width(), operandSize.height()+k_overlineWidth+k_overlineMargin);
}
ExpressionLayout * ConjugateLayout::child(uint16_t index) {
if (index == 0) {
return m_operandLayout;
}
return nullptr;
}
KDPoint ConjugateLayout::positionOfChild(ExpressionLayout * child) {
return KDPoint(0, k_overlineWidth+k_overlineMargin);
}
}