bracket_pair_layout.h
1.63 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
#ifndef POINCARE_BRACKET_PAIR_LAYOUT_H
#define POINCARE_BRACKET_PAIR_LAYOUT_H
#include <poincare/static_layout_hierarchy.h>
#include <poincare/print_float.h>
namespace Poincare {
class BracketPairLayout : public StaticLayoutHierarchy<1> {
friend class MatrixLayout;
public:
using StaticLayoutHierarchy::StaticLayoutHierarchy;
ExpressionLayout * clone() const override;
// Collapse
void collapseSiblingsAndMoveCursor(ExpressionLayoutCursor * cursor) override;
// User input
void deleteBeforeCursor(ExpressionLayoutCursor * cursor) override;
// Tree navigation
ExpressionLayoutCursor cursorLeftOf(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout) override;
ExpressionLayoutCursor cursorRightOf(ExpressionLayoutCursor cursor, bool * shouldRecomputeLayout) override;
// Serialization
int writeTextInBuffer(char * buffer, int bufferSize) const override;
protected:
ExpressionLayout * operandLayout() { return editableChild(0); }
KDCoordinate externWidthMargin() const { return 2; }
virtual KDCoordinate widthMargin() const { return 5; }
virtual KDCoordinate verticalExternMargin() const { return 0; }
virtual bool renderTopBar() const { return true; }
virtual bool renderBottomBar() const { return true; }
void render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override;
KDSize computeSize() override;
void computeBaseline() override;
KDPoint positionOfChild(ExpressionLayout * child) override;
private:
constexpr static KDCoordinate k_bracketWidth = 5;
constexpr static KDCoordinate k_lineThickness = 1;
constexpr static KDCoordinate k_verticalMargin = 1;
};
}
#endif