mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
Display floor and ceiling symbols.
This commit is contained in:
committed by
EmilieNumworks
parent
2a2112396e
commit
d5320280aa
@@ -19,6 +19,7 @@ private:
|
||||
return templatedComputeComplex(c);
|
||||
}
|
||||
template<typename T> Complex<T> templatedComputeComplex(const Complex<T> c) const;
|
||||
ExpressionLayout * privateCreateLayout(FloatDisplayMode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ private:
|
||||
return templatedComputeComplex(c);
|
||||
}
|
||||
template<typename T> Complex<T> templatedComputeComplex(const Complex<T> c) const;
|
||||
ExpressionLayout * privateCreateLayout(FloatDisplayMode floatDisplayMode, ComplexFormat complexFormat) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <poincare/ceiling.h>
|
||||
#include "layout/ceiling_layout.h"
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
@@ -32,6 +33,10 @@ Complex<T> Ceiling::templatedComputeComplex(const Complex<T> c) const {
|
||||
return Complex<T>::Float(std::ceil(c.a()));
|
||||
}
|
||||
|
||||
ExpressionLayout * Ceiling::privateCreateLayout(FloatDisplayMode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
assert(floatDisplayMode != FloatDisplayMode::Default);
|
||||
assert(complexFormat != ComplexFormat::Default);
|
||||
return new CeilingLayout(m_args[0]->createLayout(floatDisplayMode, complexFormat));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <poincare/floor.h>
|
||||
#include "layout/floor_layout.h"
|
||||
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
@@ -32,6 +33,10 @@ Complex<T> Floor::templatedComputeComplex(const Complex<T> c) const {
|
||||
return Complex<T>::Float(std::floor(c.a()));
|
||||
}
|
||||
|
||||
ExpressionLayout * Floor::privateCreateLayout(FloatDisplayMode floatDisplayMode, ComplexFormat complexFormat) const {
|
||||
assert(floatDisplayMode != FloatDisplayMode::Default);
|
||||
assert(complexFormat != ComplexFormat::Default);
|
||||
return new FloorLayout(m_args[0]->createLayout(floatDisplayMode, complexFormat));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -19,17 +19,22 @@ BracketLayout::~BracketLayout() {
|
||||
}
|
||||
|
||||
void BracketLayout::render(KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) {
|
||||
const KDCoordinate k_widthMargin = widthMargin();
|
||||
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*k_widthMargin+k_lineThickness, p.y(), k_lineThickness, m_operandLayout->size().height()), expressionColor);
|
||||
ctx->fillRect(KDRect(p.x(), p.y(), k_bracketWidth, k_lineThickness), expressionColor);
|
||||
ctx->fillRect(KDRect(p.x()+k_lineThickness+operandSize.width()+2*k_widthMargin-k_bracketWidth, p.y(), k_bracketWidth, k_lineThickness), expressionColor);
|
||||
ctx->fillRect(KDRect(p.x(), p.y()+operandSize.height()-k_lineThickness, k_bracketWidth, k_lineThickness), expressionColor);
|
||||
ctx->fillRect(KDRect(p.x()+k_lineThickness+operandSize.width()+2*k_widthMargin-k_bracketWidth, p.y()+operandSize.height()-k_lineThickness, k_bracketWidth, k_lineThickness), expressionColor);
|
||||
|
||||
if (renderTopBar()) {
|
||||
ctx->fillRect(KDRect(p.x(), p.y(), k_bracketWidth, k_lineThickness), expressionColor);
|
||||
ctx->fillRect(KDRect(p.x()+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()+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();
|
||||
KDSize operandSize = m_operandLayout->size();
|
||||
return KDSize(operandSize.width() + 2*k_widthMargin + 2*k_lineThickness, operandSize.height());
|
||||
}
|
||||
@@ -42,8 +47,8 @@ ExpressionLayout * BracketLayout::child(uint16_t index) {
|
||||
}
|
||||
|
||||
KDPoint BracketLayout::positionOfChild(ExpressionLayout * child) {
|
||||
const KDCoordinate k_widthMargin = widthMargin();
|
||||
return KDPoint(k_widthMargin+k_lineThickness, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -15,13 +15,15 @@ public:
|
||||
BracketLayout& operator=(const BracketLayout& other) = delete;
|
||||
BracketLayout& operator=(BracketLayout&& other) = delete;
|
||||
protected:
|
||||
virtual KDCoordinate widthMargin() const { return 5; }
|
||||
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;
|
||||
ExpressionLayout * child(uint16_t index) override;
|
||||
KDPoint positionOfChild(ExpressionLayout * child) override;
|
||||
private:
|
||||
constexpr static KDCoordinate k_bracketWidth = 5;
|
||||
constexpr static KDCoordinate k_widthMargin = 5;
|
||||
constexpr static KDCoordinate k_lineThickness = 1;
|
||||
ExpressionLayout * m_operandLayout;
|
||||
};
|
||||
|
||||
22
poincare/src/layout/ceiling_layout.h
Normal file
22
poincare/src/layout/ceiling_layout.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef POINCARE_CEILING_LAYOUT_H
|
||||
#define POINCARE_CEILING_LAYOUT_H
|
||||
|
||||
#include "bracket_layout.h"
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
class CeilingLayout : public BracketLayout {
|
||||
public:
|
||||
CeilingLayout(ExpressionLayout * operandLayout) : BracketLayout(operandLayout) {}
|
||||
~CeilingLayout() {}
|
||||
CeilingLayout(const CeilingLayout& other) = delete;
|
||||
CeilingLayout(CeilingLayout&& other) = delete;
|
||||
CeilingLayout& operator=(const CeilingLayout& other) = delete;
|
||||
CeilingLayout& operator=(CeilingLayout&& other) = delete;
|
||||
protected:
|
||||
bool renderBottomBar() const override { return false; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
22
poincare/src/layout/floor_layout.h
Normal file
22
poincare/src/layout/floor_layout.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef POINCARE_FLOOR_LAYOUT_H
|
||||
#define POINCARE_FLOOR_LAYOUT_H
|
||||
|
||||
#include "bracket_layout.h"
|
||||
|
||||
namespace Poincare {
|
||||
|
||||
class FloorLayout : public BracketLayout {
|
||||
public:
|
||||
FloorLayout(ExpressionLayout * operandLayout) : BracketLayout(operandLayout) {}
|
||||
~FloorLayout() {}
|
||||
FloorLayout(const FloorLayout& other) = delete;
|
||||
FloorLayout(FloorLayout&& other) = delete;
|
||||
FloorLayout& operator=(const FloorLayout& other) = delete;
|
||||
FloorLayout& operator=(FloorLayout&& other) = delete;
|
||||
protected:
|
||||
bool renderTopBar() const override { return false; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user