[escher] Create class ExpressionTableCellWithExpression

This commit is contained in:
Émilie Feral
2018-10-05 12:57:44 +02:00
parent 08439b5c54
commit d8ffb73e69
4 changed files with 42 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ objs += $(addprefix escher/src/,\
even_odd_message_text_cell.o\
expression_table_cell.o\
expression_table_cell_with_pointer.o\
expression_table_cell_with_expression.o\
expression_view.o\
highlight_cell.o\
gauge_view.o\

View File

@@ -22,6 +22,7 @@
#include <escher/even_odd_message_text_cell.h>
#include <escher/expression_table_cell.h>
#include <escher/expression_table_cell_with_pointer.h>
#include <escher/expression_table_cell_with_expression.h>
#include <escher/expression_view.h>
#include <escher/field.h>
#include <escher/gauge_view.h>

View File

@@ -0,0 +1,17 @@
#ifndef ESCHER_EXPRESSION_TABLE_CELL_WITH_EXPRESSION_H
#define ESCHER_EXPRESSION_TABLE_CELL_WITH_EXPRESSION_H
#include <escher/expression_table_cell.h>
#include <escher/i18n.h>
class ExpressionTableCellWithExpression : public ExpressionTableCell {
public:
ExpressionTableCellWithExpression();
View * accessoryView() const override;
void setHighlighted(bool highlight) override;
void setAccessoryLayout(Poincare::Layout layoutR);
private:
ExpressionView m_accessoryExpressionView;
};
#endif

View File

@@ -0,0 +1,23 @@
#include <escher/expression_table_cell_with_expression.h>
#include <escher/palette.h>
#include <assert.h>
ExpressionTableCellWithExpression::ExpressionTableCellWithExpression() :
ExpressionTableCell(Layout::Horizontal),
m_accessoryExpressionView(1.0f, 0.5f, KDColorBlack, KDColorWhite)
{}
View * ExpressionTableCellWithExpression::accessoryView() const {
return (View *)&m_accessoryExpressionView;
}
void ExpressionTableCellWithExpression::setHighlighted(bool highlight) {
ExpressionTableCell::setHighlighted(highlight);
KDColor backgroundColor = highlight? Palette::Select : KDColorWhite;
m_accessoryExpressionView.setBackgroundColor(backgroundColor);
}
void ExpressionTableCellWithExpression::setAccessoryLayout(Poincare::Layout layoutR) {
m_accessoryExpressionView.setLayout(layoutR);
layoutSubviews();
}