vertical_offset_layout.h
1.88 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
43
44
45
46
47
48
49
50
51
#ifndef POINCARE_VERTICAL_OFFSET_LAYOUT_H
#define POINCARE_VERTICAL_OFFSET_LAYOUT_H
#include <poincare/static_layout_hierarchy.h>
namespace Poincare {
class VerticalOffsetLayout : public StaticLayoutHierarchy<1> {
public:
enum class Type {
Subscript,
Superscript
};
VerticalOffsetLayout(ExpressionLayout * indice, Type type, bool cloneOperands);
ExpressionLayout * clone() const override;
// VerticalOffsetLayout
Type type() const { return m_type; }
// User input
void deleteBeforeCursor(ExpressionLayoutCursor * cursor) override;
// Tree navigation
ExpressionLayoutCursor cursorLeftOf(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout) override;
ExpressionLayoutCursor cursorRightOf(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout) override;
ExpressionLayoutCursor cursorAbove(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
ExpressionLayoutCursor cursorUnder(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout, bool equivalentPositionVisited = false) override;
// Serialization
int writeTextInBuffer(char * buffer, int bufferSize) const override;
// Other
bool mustHaveLeftSibling() const override { return true; }
bool isVerticalOffset() const override { return true; }
protected:
ExpressionLayout * indiceLayout() { return editableChild(0);}
ExpressionLayout * baseLayout();
void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override {}
KDSize computeSize() override;
void computeBaseline() override;
KDPoint positionOfChild(ExpressionLayout * child) override;
void privateAddSibling(ExpressionLayoutCursor * cursor, ExpressionLayout * sibling, bool moveCursor) override;
Type m_type;
private:
constexpr static KDCoordinate k_indiceHeight = 5;
constexpr static KDCoordinate k_separationMargin = 5;
};
}
#endif