mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[escher] ExpressionTableCell is composed of a ScrollableExpressionView
instead of an ExpressionView
This commit is contained in:
@@ -1,18 +1,25 @@
|
||||
#ifndef ESCHER_EXPRESSION_TABLE_CELL_H
|
||||
#define ESCHER_EXPRESSION_TABLE_CELL_H
|
||||
|
||||
#include <escher/expression_view.h>
|
||||
#include <escher/scrollable_expression_view.h>
|
||||
#include <escher/table_cell.h>
|
||||
|
||||
class ExpressionTableCell : public TableCell {
|
||||
class ExpressionTableCell : public Responder, public TableCell {
|
||||
public:
|
||||
ExpressionTableCell(Layout layout = Layout::Horizontal);
|
||||
ExpressionTableCell(Responder * responder = nullptr, Layout layout = Layout::Horizontal);
|
||||
View * labelView() const override;
|
||||
void setHighlighted(bool highlight) override;
|
||||
void setLayout(Poincare::Layout layout);
|
||||
Poincare::Layout layout() const override { return m_labelExpressionView.layout(); }
|
||||
|
||||
Responder * responder() override {
|
||||
return this;
|
||||
}
|
||||
void didBecomeFirstResponder() override;
|
||||
private:
|
||||
ExpressionView m_labelExpressionView;
|
||||
// Remove margins added by TableCell because they're already handled by ScrollableInputExactApproximateExpressionsView
|
||||
KDCoordinate labelMargin() const override { return 0; }
|
||||
ScrollableExpressionView m_labelExpressionView;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
class ExpressionTableCellWithExpression : public ExpressionTableCell {
|
||||
public:
|
||||
ExpressionTableCellWithExpression();
|
||||
ExpressionTableCellWithExpression(Responder * parentResponder = nullptr);
|
||||
View * accessoryView() const override;
|
||||
void setHighlighted(bool highlight) override;
|
||||
void setAccessoryLayout(Poincare::Layout l);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
class ExpressionTableCellWithPointer : public ExpressionTableCell {
|
||||
public:
|
||||
ExpressionTableCellWithPointer(I18n::Message accessoryMessage = (I18n::Message)0, Layout layout = Layout::Horizontal);
|
||||
ExpressionTableCellWithPointer(Responder * responder = nullptr, I18n::Message accessoryMessage = (I18n::Message)0, Layout layout = Layout::Horizontal);
|
||||
View * accessoryView() const override;
|
||||
void setHighlighted(bool highlight) override;
|
||||
void setAccessoryMessage(I18n::Message messageBody);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
class ScrollableExpressionView : public ScrollableView, public ScrollViewDataSource {
|
||||
public:
|
||||
ScrollableExpressionView(Responder * parentResponder);
|
||||
ScrollableExpressionView(Responder * parentResponder, KDCoordinate leftRightMargin, KDCoordinate topBottomMargin, float horizontalAlignment = 0.0f, float verticalAlignment = 0.5f, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite);
|
||||
Poincare::Layout layout() const;
|
||||
void setLayout(Poincare::Layout layout);
|
||||
void setBackgroundColor(KDColor backgroundColor) override;
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include <escher/expression_table_cell.h>
|
||||
#include <escher/container.h>
|
||||
#include <escher/palette.h>
|
||||
#include <assert.h>
|
||||
|
||||
ExpressionTableCell::ExpressionTableCell(Layout layout) :
|
||||
ExpressionTableCell::ExpressionTableCell(Responder * parentResponder, Layout layout) :
|
||||
Responder(parentResponder),
|
||||
TableCell(layout),
|
||||
m_labelExpressionView(0.0f, 0.5f, KDColorBlack, KDColorWhite)
|
||||
m_labelExpressionView(this, k_labelMargin, 0, 0.0f, 0.5f, KDColorBlack, KDColorWhite)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -24,3 +26,7 @@ void ExpressionTableCell::setLayout(Poincare::Layout layout) {
|
||||
layoutSubviews();
|
||||
}
|
||||
}
|
||||
|
||||
void ExpressionTableCell::didBecomeFirstResponder() {
|
||||
Container::activeApp()->setFirstResponder(&m_labelExpressionView);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#include <escher/palette.h>
|
||||
#include <assert.h>
|
||||
|
||||
ExpressionTableCellWithExpression::ExpressionTableCellWithExpression() :
|
||||
ExpressionTableCell(Layout::Horizontal),
|
||||
ExpressionTableCellWithExpression::ExpressionTableCellWithExpression(Responder * parentResponder) :
|
||||
ExpressionTableCell(parentResponder, Layout::Horizontal),
|
||||
m_accessoryExpressionView(1.0f, 0.5f, Palette::GreyDark, KDColorWhite)
|
||||
{}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#include <escher/palette.h>
|
||||
#include <assert.h>
|
||||
|
||||
ExpressionTableCellWithPointer::ExpressionTableCellWithPointer(I18n::Message accessoryMessage, Layout layout) :
|
||||
ExpressionTableCell(layout),
|
||||
ExpressionTableCellWithPointer::ExpressionTableCellWithPointer(Responder * parentResponder, I18n::Message accessoryMessage, Layout layout) :
|
||||
ExpressionTableCell(parentResponder, layout),
|
||||
m_accessoryView(KDFont::SmallFont, accessoryMessage, 0.0f, 0.5f, Palette::GreyDark, KDColorWhite)
|
||||
{
|
||||
if (layout == Layout::Horizontal) {
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
#include <escher/metric.h>
|
||||
#include <assert.h>
|
||||
|
||||
ScrollableExpressionView::ScrollableExpressionView(Responder * parentResponder) :
|
||||
ScrollableExpressionView::ScrollableExpressionView(Responder * parentResponder, KDCoordinate leftRightMargin, KDCoordinate topBottomMargin, float horizontalAlignment, float verticalAlignment, KDColor textColor, KDColor backgroundColor) :
|
||||
ScrollableView(parentResponder, &m_expressionView, this),
|
||||
m_expressionView()
|
||||
m_expressionView(horizontalAlignment, verticalAlignment, textColor, backgroundColor)
|
||||
{
|
||||
setDecoratorType(ScrollView::Decorator::Type::Arrows);
|
||||
setMargins(
|
||||
Metric::CommonSmallMargin,
|
||||
Metric::CommonLargeMargin,
|
||||
Metric::CommonSmallMargin,
|
||||
Metric::CommonLargeMargin
|
||||
topBottomMargin,
|
||||
leftRightMargin,
|
||||
topBottomMargin,
|
||||
leftRightMargin
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user