6663b6c9
adorian
projet complet av...
|
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
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#include "right_parenthesis_layout.h"
extern "C" {
#include <assert.h>
#include <stdlib.h>
}
namespace Poincare {
const uint8_t topRightCurve[ParenthesisLayout::k_parenthesisCurveHeight][ParenthesisLayout::k_parenthesisCurveWidth] = {
{0x66, 0xF9, 0xFF, 0xFF, 0xFF},
{0x9A, 0x40, 0xEB, 0xFF, 0xFF},
{0xFF, 0xBF, 0x40, 0xF2, 0xFF},
{0xFF, 0xFF, 0xB6, 0x49, 0xFF},
{0xFF, 0xFF, 0xFF, 0x5A, 0xA9},
{0xFF, 0xFF, 0xFF, 0xBE, 0x45},
{0xFF, 0xFF, 0xFF, 0xEE, 0x11},
};
const uint8_t bottomRightCurve[ParenthesisLayout::k_parenthesisCurveHeight][ParenthesisLayout::k_parenthesisCurveWidth] = {
{0xFF, 0xFF, 0xFF, 0xEE, 0x11},
{0xFF, 0xFF, 0xFF, 0xBE, 0x45},
{0xFF, 0xFF, 0xFF, 0x5A, 0xA9},
{0xFF, 0xFF, 0xB6, 0x49, 0xFF},
{0xFF, 0xBF, 0x40, 0xF2, 0xFF},
{0x9A, 0x40, 0xEB, 0xFF, 0xFF},
{0x66, 0xF9, 0xFF, 0xFF, 0xFF},
};
ExpressionLayout * RightParenthesisLayout::clone() const {
RightParenthesisLayout * layout = new RightParenthesisLayout();
return layout;
}
bool RightParenthesisLayout::isCollapsable(int * numberOfOpenParenthesis, bool goingLeft) const {
if (*numberOfOpenParenthesis == 0 && !goingLeft) {
return false;
}
*numberOfOpenParenthesis = goingLeft ? *numberOfOpenParenthesis + 1 : *numberOfOpenParenthesis - 1;
return true;
}
void RightParenthesisLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) {
KDRect frame = KDRect(p.x() + ParenthesisLayout::k_widthMargin + ParenthesisLayout::k_lineThickness - ParenthesisLayout::k_parenthesisCurveWidth,
p.y() + ParenthesisLayout::k_externHeightMargin,
ParenthesisLayout::k_parenthesisCurveWidth,
ParenthesisLayout::k_parenthesisCurveHeight);
ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topRightCurve, (KDColor *)(ParenthesisLayout::s_parenthesisWorkingBuffer));
frame = KDRect(p.x() + ParenthesisLayout::k_widthMargin + ParenthesisLayout::k_lineThickness - ParenthesisLayout::k_parenthesisCurveWidth,
p.y() + size().height() - ParenthesisLayout::k_parenthesisCurveHeight - ParenthesisLayout::k_externHeightMargin,
ParenthesisLayout::k_parenthesisCurveWidth,
ParenthesisLayout::k_parenthesisCurveHeight);
ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomRightCurve, (KDColor *)(ParenthesisLayout::s_parenthesisWorkingBuffer));
ctx->fillRect(KDRect(p.x()+ParenthesisLayout::k_widthMargin,
p.y()+ParenthesisLayout::k_parenthesisCurveHeight+2,
ParenthesisLayout::k_lineThickness,
size().height() - 2*(ParenthesisLayout::k_parenthesisCurveHeight+ParenthesisLayout::k_externHeightMargin)),
expressionColor);
}
}
|