mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/escher] EvenOddExpressionCell has left and right margins
This commit is contained in:
@@ -68,7 +68,7 @@ View * ListController::loadView() {
|
||||
for (int i = 0; i < k_maxNumberOfRows; i++) {
|
||||
m_functionTitleCells[i] = new Shared::BufferFunctionTitleCell(FunctionTitleCell::Orientation::VerticalIndicator);
|
||||
m_expressionCells[i] = new FunctionExpressionCell();
|
||||
m_expressionCells[i]->setMargin(k_expressionMargin);
|
||||
m_expressionCells[i]->setLeftMargin(k_expressionMargin);
|
||||
}
|
||||
return Shared::FunctionListController::loadView();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ app_objs += $(addprefix apps/regression/,\
|
||||
column_title_cell.o\
|
||||
even_odd_buffer_text_cell_with_margin.o\
|
||||
even_odd_double_buffer_text_cell_with_separator.o\
|
||||
even_odd_expression_cell_with_margin.o\
|
||||
go_to_parameter_controller.o\
|
||||
graph_controller.o\
|
||||
graph_view.o\
|
||||
|
||||
@@ -24,6 +24,7 @@ CalculationController::CalculationController(Responder * parentResponder, Button
|
||||
m_store(store)
|
||||
{
|
||||
m_r2Layout = new HorizontalLayout(new CharLayout('r', KDText::FontSize::Small), new VerticalOffsetLayout(new CharLayout('2', KDText::FontSize::Small), VerticalOffsetLayout::Type::Superscript, false), false);
|
||||
m_r2TitleCell->setRightMargin(k_r2CellMargin);
|
||||
}
|
||||
|
||||
CalculationController::~CalculationController() {
|
||||
@@ -115,7 +116,7 @@ void CalculationController::willDisplayCellAtLocation(HighlightCell * cell, int
|
||||
// Calculation title
|
||||
if (i == 0) {
|
||||
if (j == numberOfRows()-1) {
|
||||
EvenOddExpressionCellWithMargin * myCell = (EvenOddExpressionCellWithMargin *)cell;
|
||||
EvenOddExpressionCell * myCell = static_cast<EvenOddExpressionCell *>(cell);
|
||||
myCell->setExpressionLayout(m_r2Layout);
|
||||
return;
|
||||
}
|
||||
@@ -253,7 +254,7 @@ View * CalculationController::loadView() {
|
||||
tableView->setVerticalCellOverlap(0);
|
||||
tableView->setBackgroundColor(Palette::WallScreenDark);
|
||||
tableView->setMargins(k_margin, k_scrollBarMargin, k_scrollBarMargin, k_margin);
|
||||
m_r2TitleCell = new EvenOddExpressionCellWithMargin(1.0f, 0.5f);
|
||||
m_r2TitleCell = new EvenOddExpressionCell(1.0f, 0.5f);
|
||||
for (int i = 0; i < Store::k_numberOfSeries; i++) {
|
||||
m_columnTitleCells[i] = new ColumnTitleCell(tableView);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "store.h"
|
||||
#include "column_title_cell.h"
|
||||
#include "even_odd_double_buffer_text_cell_with_separator.h"
|
||||
#include "even_odd_expression_cell_with_margin.h"
|
||||
#include "../shared/hideable_even_odd_cell.h"
|
||||
#include "../shared/margin_even_odd_message_text_cell.h"
|
||||
#include "../shared/tab_table_controller.h"
|
||||
@@ -58,13 +57,14 @@ private:
|
||||
static constexpr KDCoordinate k_cellHeight = 25;
|
||||
static constexpr KDCoordinate k_cellWidth = Ion::Display::Width/2 - Metric::CommonRightMargin/2 - Metric::CommonLeftMargin/2;
|
||||
static constexpr KDCoordinate k_margin = 8;
|
||||
static constexpr KDCoordinate k_r2CellMargin = 2;
|
||||
static constexpr KDCoordinate k_scrollBarMargin = Metric::CommonRightMargin;
|
||||
|
||||
Responder * tabController() const override;
|
||||
View * loadView() override;
|
||||
void unloadView(View * view) override;
|
||||
Shared::MarginEvenOddMessageTextCell * m_titleCells[k_maxNumberOfDisplayableRows];
|
||||
EvenOddExpressionCellWithMargin * m_r2TitleCell;
|
||||
EvenOddExpressionCell * m_r2TitleCell;
|
||||
Poincare::ExpressionLayout * m_r2Layout;
|
||||
ColumnTitleCell * m_columnTitleCells[Store::k_numberOfSeries];
|
||||
EvenOddDoubleBufferTextCellWithSeparator * m_doubleCalculationCells[k_numberOfDoubleCalculationCells];
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#include "even_odd_expression_cell_with_margin.h"
|
||||
|
||||
namespace Regression {
|
||||
|
||||
void EvenOddExpressionCellWithMargin::layoutSubviews() {
|
||||
KDRect boundsThis = bounds();
|
||||
m_expressionView.setFrame(KDRect(boundsThis.topLeft(), boundsThis.width() - k_rightMargin, boundsThis.height()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef REGRESSION_EVEN_ODD_EXPRESSION_CELL_WITH_MARGIN_H
|
||||
#define REGRESSION_EVEN_ODD_EXPRESSION_CELL_WITH_MARGIN_H
|
||||
|
||||
#include <escher/even_odd_expression_cell.h>
|
||||
|
||||
namespace Regression {
|
||||
|
||||
class EvenOddExpressionCellWithMargin : public EvenOddExpressionCell {
|
||||
public:
|
||||
using EvenOddExpressionCell::EvenOddExpressionCell;
|
||||
void layoutSubviews() override;
|
||||
private:
|
||||
static constexpr KDCoordinate k_rightMargin = 2;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -292,7 +292,7 @@ View * ListController::loadView() {
|
||||
for (int i = 0; i < k_maxNumberOfRows; i++) {
|
||||
m_sequenceTitleCells[i] = new SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator);
|
||||
m_expressionCells[i] = new FunctionExpressionCell();
|
||||
m_expressionCells[i]->setMargin(k_expressionMargin);
|
||||
m_expressionCells[i]->setLeftMargin(k_expressionMargin);
|
||||
}
|
||||
return Shared::FunctionListController::loadView();
|
||||
}
|
||||
|
||||
@@ -9,19 +9,22 @@ FunctionExpressionCell::FunctionExpressionCell() :
|
||||
|
||||
KDSize FunctionExpressionCell::minimalSizeForOptimalDisplay() const {
|
||||
KDSize expressionSize = m_expressionView.minimalSizeForOptimalDisplay();
|
||||
return KDSize(m_margin+expressionSize.width(), expressionSize.height()+k_separatorThickness);
|
||||
return KDSize(m_leftMargin + expressionSize.width() + m_rightMargin, expressionSize.height()+k_separatorThickness);
|
||||
}
|
||||
|
||||
void FunctionExpressionCell::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
KDColor separatorColor = m_even ? Palette::WallScreen : KDColorWhite;
|
||||
// Color the horizontal separator
|
||||
ctx->fillRect(KDRect(0, bounds().height()-k_separatorThickness, bounds().width(), k_separatorThickness), separatorColor);
|
||||
// Color the margin
|
||||
ctx->fillRect(KDRect(0, 0, m_margin, bounds().height()-k_separatorThickness), backgroundColor());
|
||||
// Color the left margin
|
||||
ctx->fillRect(KDRect(0, 0, m_leftMargin, bounds().height()-k_separatorThickness), backgroundColor());
|
||||
// Color the right margin
|
||||
ctx->fillRect(KDRect(0, bounds().width() - m_rightMargin, m_rightMargin, bounds().height()-k_separatorThickness), backgroundColor());
|
||||
|
||||
}
|
||||
|
||||
void FunctionExpressionCell::layoutSubviews() {
|
||||
KDRect expressionFrame(m_margin, 0, bounds().width() - m_margin, bounds().height()-k_separatorThickness);
|
||||
KDRect expressionFrame(m_leftMargin, 0, bounds().width() - m_leftMargin - m_rightMargin, bounds().height()-k_separatorThickness);
|
||||
m_expressionView.setFrame(expressionFrame);
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ View * ListController::loadView() {
|
||||
m_addNewModel->setAlignment(0.3f, 0.5f); // (EquationListView::k_braceTotalWidth+k_expressionMargin) / (Ion::Display::Width-m_addNewModel.text().size()) = (30+5)/(320-200)
|
||||
for (int i = 0; i < k_maxNumberOfRows; i++) {
|
||||
m_expressionCells[i] = new EvenOddExpressionCell();
|
||||
m_expressionCells[i]->setMargin(EquationListView::k_braceTotalWidth+k_expressionMargin);
|
||||
m_expressionCells[i]->setLeftMargin(EquationListView::k_braceTotalWidth+k_expressionMargin);
|
||||
m_expressionCells[i]->setEven(true);
|
||||
}
|
||||
EquationListView * listView = new EquationListView(this, this, this);
|
||||
|
||||
@@ -15,7 +15,8 @@ public:
|
||||
void setTextColor(KDColor textColor);
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
void setAlignment(float horizontalAlignment, float verticalAlignment);
|
||||
void setMargin(KDCoordinate margin);
|
||||
void setLeftMargin(KDCoordinate margin);
|
||||
void setRightMargin(KDCoordinate margin);
|
||||
Poincare::ExpressionLayout * expressionLayout() const override { return m_expressionView.expressionLayout(); }
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
protected:
|
||||
@@ -23,7 +24,8 @@ protected:
|
||||
View * subviewAtIndex(int index) override;
|
||||
void layoutSubviews() override;
|
||||
ExpressionView m_expressionView;
|
||||
KDCoordinate m_margin;
|
||||
KDCoordinate m_leftMargin;
|
||||
KDCoordinate m_rightMargin;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,8 @@ EvenOddExpressionCell::EvenOddExpressionCell(float horizontalAlignment, float ve
|
||||
KDColor textColor, KDColor backgroundColor) :
|
||||
EvenOddCell(),
|
||||
m_expressionView(horizontalAlignment, verticalAlignment, textColor, backgroundColor),
|
||||
m_margin(0)
|
||||
m_leftMargin(0),
|
||||
m_rightMargin(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -36,17 +37,23 @@ void EvenOddExpressionCell::setTextColor(KDColor textColor) {
|
||||
|
||||
KDSize EvenOddExpressionCell::minimalSizeForOptimalDisplay() const {
|
||||
KDSize expressionSize = m_expressionView.minimalSizeForOptimalDisplay();
|
||||
return KDSize(m_margin+expressionSize.width(), expressionSize.height());
|
||||
return KDSize(m_leftMargin + expressionSize.width() + m_rightMargin, expressionSize.height());
|
||||
}
|
||||
|
||||
void EvenOddExpressionCell::setMargin(KDCoordinate margin) {
|
||||
m_margin = margin;
|
||||
void EvenOddExpressionCell::setLeftMargin(KDCoordinate margin) {
|
||||
m_leftMargin = margin;
|
||||
layoutSubviews();
|
||||
}
|
||||
|
||||
void EvenOddExpressionCell::setRightMargin(KDCoordinate margin) {
|
||||
m_rightMargin = margin;
|
||||
layoutSubviews();
|
||||
}
|
||||
|
||||
void EvenOddExpressionCell::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
// Color the margin
|
||||
ctx->fillRect(KDRect(0, 0, m_margin, bounds().height()), backgroundColor());
|
||||
// Color the margins
|
||||
ctx->fillRect(KDRect(0, 0, m_leftMargin, bounds().height()), backgroundColor());
|
||||
ctx->fillRect(KDRect(bounds().width() - m_rightMargin, 0, m_rightMargin, bounds().height()), backgroundColor());
|
||||
}
|
||||
|
||||
int EvenOddExpressionCell::numberOfSubviews() const {
|
||||
@@ -59,5 +66,5 @@ View * EvenOddExpressionCell::subviewAtIndex(int index) {
|
||||
}
|
||||
|
||||
void EvenOddExpressionCell::layoutSubviews() {
|
||||
m_expressionView.setFrame(KDRect(m_margin, 0, bounds().width()-m_margin, bounds().height()));
|
||||
m_expressionView.setFrame(KDRect(m_leftMargin, 0, bounds().width() - m_leftMargin - m_rightMargin, bounds().height()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user