Numworks Epsilon  1.4.1
Graphing Calculator Operating System
bracket_layout.cpp
Go to the documentation of this file.
1 #include "bracket_layout.h"
2 extern "C" {
3 #include <assert.h>
4 #include <stdlib.h>
5 }
6 
7 namespace Poincare {
8 
11  m_operandLayout(operandLayout)
12 {
13  m_operandLayout->setParent(this);
14  m_baseline = m_operandLayout->baseline();
15 }
16 
18  delete m_operandLayout;
19 }
20 
21 void BracketLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) {
22  KDSize operandSize = m_operandLayout->size();
23  ctx->fillRect(KDRect(p.x(), p.y(), k_lineThickness, m_operandLayout->size().height()), expressionColor);
24  ctx->fillRect(KDRect(p.x()+operandSize.width()+2*widthMargin()+k_lineThickness, p.y(), k_lineThickness, m_operandLayout->size().height()), expressionColor);
25  if (renderTopBar()) {
26  ctx->fillRect(KDRect(p.x(), p.y(), k_bracketWidth, k_lineThickness), expressionColor);
27  ctx->fillRect(KDRect(p.x()+2*k_lineThickness+operandSize.width()+2*widthMargin()-k_bracketWidth, p.y(), k_bracketWidth, k_lineThickness), expressionColor);
28  }
29  if (renderBottomBar()) {
30  ctx->fillRect(KDRect(p.x(), p.y()+operandSize.height()-k_lineThickness, k_bracketWidth, k_lineThickness), expressionColor);
31  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);
32  }
33 }
34 
36  KDSize operandSize = m_operandLayout->size();
37  return KDSize(operandSize.width() + 2*widthMargin() + 2*k_lineThickness, operandSize.height());
38 }
39 
41  if (index == 0) {
42  return m_operandLayout;
43  }
44  return nullptr;
45 }
46 
48  return KDPoint(widthMargin()+k_lineThickness, 0);
49 }
50 
51 }
KDCoordinate y() const
Definition: point.h:11
constexpr KDCoordinate width() const
Definition: size.h:10
unsigned short uint16_t
Definition: stdint.h:5
virtual KDCoordinate widthMargin() const
Definition: point.h:6
Definition: size.h:6
KDPoint positionOfChild(ExpressionLayout *child) override
virtual bool renderBottomBar() const
void render(KDContext *ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) override
Definition: rect.h:26
void fillRect(KDRect rect, KDColor color)
Definition: context_rect.cpp:8
Definition: color.h:6
KDSize computeSize() override
virtual bool renderTopBar() const
KDCoordinate x() const
Definition: point.h:10
ExpressionLayout * child(uint16_t index) override
void setParent(ExpressionLayout *parent)
BracketLayout(ExpressionLayout *operandLayout)
constexpr KDCoordinate height() const
Definition: size.h:11