[poincare] Added extern margins on BracketLayout to see the cursor.

Change-Id: I32f6d54c2121b4de1d7ae2552239a1e8ac557913
This commit is contained in:
Léa Saviot
2017-12-07 16:01:41 +01:00
parent 78c02e6871
commit 3af2f88da7
2 changed files with 15 additions and 8 deletions

View File

@@ -47,22 +47,26 @@ bool BracketLayout::moveLeft(ExpressionLayoutCursor * cursor) {
}
void BracketLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) {
const KDCoordinate k_widthMargin = widthMargin();
const KDCoordinate k_externWidthMargin = externWidthMargin();
KDSize operandSize = m_operandLayout->size();
ctx->fillRect(KDRect(p.x(), p.y(), k_lineThickness, m_operandLayout->size().height()), expressionColor);
ctx->fillRect(KDRect(p.x()+operandSize.width()+2*widthMargin()+k_lineThickness, p.y(), k_lineThickness, m_operandLayout->size().height()), expressionColor);
ctx->fillRect(KDRect(p.x()+k_externWidthMargin, p.y(), k_lineThickness, m_operandLayout->size().height()), expressionColor);
ctx->fillRect(KDRect(p.x()+k_externWidthMargin+operandSize.width()+2*k_widthMargin+k_lineThickness, p.y(), k_lineThickness, m_operandLayout->size().height()), expressionColor);
if (renderTopBar()) {
ctx->fillRect(KDRect(p.x(), p.y(), k_bracketWidth, k_lineThickness), expressionColor);
ctx->fillRect(KDRect(p.x()+2*k_lineThickness+operandSize.width()+2*widthMargin()-k_bracketWidth, p.y(), k_bracketWidth, k_lineThickness), expressionColor);
ctx->fillRect(KDRect(p.x()+k_externWidthMargin, p.y(), k_bracketWidth, k_lineThickness), expressionColor);
ctx->fillRect(KDRect(p.x()+k_externWidthMargin+2*k_lineThickness+operandSize.width()+2*k_widthMargin-k_bracketWidth, p.y(), k_bracketWidth, k_lineThickness), expressionColor);
}
if (renderBottomBar()) {
ctx->fillRect(KDRect(p.x(), p.y()+operandSize.height()-k_lineThickness, k_bracketWidth, k_lineThickness), expressionColor);
ctx->fillRect(KDRect(p.x()+2*k_lineThickness+operandSize.width()+2*widthMargin()-k_bracketWidth, p.y()+operandSize.height()-k_lineThickness, k_bracketWidth, k_lineThickness), expressionColor);
ctx->fillRect(KDRect(p.x()+k_externWidthMargin, p.y()+operandSize.height()-k_lineThickness, k_bracketWidth, k_lineThickness), expressionColor);
ctx->fillRect(KDRect(p.x()+k_externWidthMargin+2*k_lineThickness+operandSize.width()+2*k_widthMargin-k_bracketWidth, p.y()+operandSize.height()-k_lineThickness, k_bracketWidth, k_lineThickness), expressionColor);
}
}
KDSize BracketLayout::computeSize() {
const KDCoordinate k_widthMargin = widthMargin();
const KDCoordinate k_externWidthMargin = externWidthMargin();
KDSize operandSize = m_operandLayout->size();
return KDSize(operandSize.width() + 2*widthMargin() + 2*k_lineThickness, operandSize.height());
return KDSize(operandSize.width() + 2*k_externWidthMargin + 2*k_widthMargin + 2*k_lineThickness, operandSize.height());
}
ExpressionLayout * BracketLayout::child(uint16_t index) {
@@ -73,7 +77,9 @@ ExpressionLayout * BracketLayout::child(uint16_t index) {
}
KDPoint BracketLayout::positionOfChild(ExpressionLayout * child) {
return KDPoint(widthMargin()+k_lineThickness, 0);
const KDCoordinate k_widthMargin = widthMargin();
const KDCoordinate k_externWidthMargin = externWidthMargin();
return KDPoint(k_widthMargin+k_externWidthMargin+k_lineThickness, 0);
}
}

View File

@@ -16,6 +16,7 @@ public:
BracketLayout& operator=(BracketLayout&& other) = delete;
bool moveLeft(ExpressionLayoutCursor * cursor) override;
protected:
KDCoordinate externWidthMargin() const { return 2; }
virtual KDCoordinate widthMargin() const { return 5; }
virtual bool renderTopBar() const { return true; }
virtual bool renderBottomBar() const { return true; }