[apps/shared][apps/calculation] Change class names:

ScrollableInputExactApproximateExpressionsCell -->
ScrollableThreeExpressionsCell
AbstractScrollableExactApproximateExpressionsView -->
AbstractScrollableMultipleExpressionsView
ScrollableExactApproximateExpressionsView -->
ScrollableTwoExpressionsView
ScrollableInputExactApproximateExpressionsView -->
ScrollableTwoExpressionsCell
This commit is contained in:
Émilie Feral
2020-01-21 12:03:56 +01:00
committed by Léa Saviot
parent 87e4836196
commit 251db5b60e
16 changed files with 125 additions and 125 deletions

View File

@@ -15,7 +15,7 @@ app_calculation_src = $(addprefix apps/calculation/,\
additional_outputs/illustrated_list_controller.cpp \
additional_outputs/illustration_cell.cpp \
additional_outputs/integer_list_controller.cpp \
additional_outputs/scrollable_input_exact_approximate_expressions_cell.cpp \
additional_outputs/scrollable_three_expressions_cell.cpp \
additional_outputs/list_controller.cpp \
additional_outputs/rational_list_controller.cpp \
additional_outputs/trigonometry_graph_cell.cpp \

View File

@@ -87,7 +87,7 @@ void IllustratedListController::willDisplayCellForIndex(HighlightCell * cell, in
return;
}
Poincare::Context * context = App::app()->localContext();
ScrollableInputExactApproximateExpressionsCell * myCell = (ScrollableInputExactApproximateExpressionsCell *)cell;
ScrollableThreeExpressionsCell * myCell = (ScrollableThreeExpressionsCell *)cell;
Calculation * c = m_calculationStore.calculationAtIndex(index-1).pointer();
myCell->setCalculation(c);
myCell->setDisplayCenter(c->displayOutput(context) != Calculation::DisplayOutput::ApproximateOnly);
@@ -103,7 +103,7 @@ void IllustratedListController::tableViewDidChangeSelection(SelectableTableView
t->selectCellAtLocation(0, 1);
}
/* But scroll to the top when we select the first
* ScrollableInputExactApproximateExpressionsCell in order display the
* ScrollableThreeExpressionsCell in order display the
* illustration cell. */
if (t->selectedRow() == 1) {
t->scrollToCell(0, 0);
@@ -119,9 +119,9 @@ void IllustratedListController::setExpression(Poincare::Expression e) {
}
int IllustratedListController::textAtIndex(char * buffer, size_t bufferSize, int index) {
ScrollableInputExactApproximateExpressionsCell * myCell = static_cast<ScrollableInputExactApproximateExpressionsCell *>(m_listController.selectableTableView()->selectedCell());
ScrollableThreeExpressionsCell * myCell = static_cast<ScrollableThreeExpressionsCell *>(m_listController.selectableTableView()->selectedCell());
Shared::ExpiringPointer<Calculation> c = m_calculationStore.calculationAtIndex(index-1);
const char * text = myCell->selectedSubviewPosition() == ScrollableInputExactApproximateExpressionsView::SubviewPosition::Right ? c->approximateOutputText() : c->exactOutputText();
const char * text = myCell->selectedSubviewPosition() == ScrollableThreeExpressionsView::SubviewPosition::Right ? c->approximateOutputText() : c->exactOutputText();
return strlcpy(buffer, text, bufferSize);
}

View File

@@ -2,7 +2,7 @@
#define CALCULATION_ADDITIONAL_OUTPUTS_ILLUSTRATED_LIST_CONTROLLER_H
#include <escher.h>
#include "scrollable_input_exact_approximate_expressions_cell.h"
#include "scrollable_three_expressions_cell.h"
#include "list_controller.h"
#include "../calculation_store.h"
#include <apps/i18n.h>
@@ -41,7 +41,7 @@ private:
constexpr static int k_maxNumberOfAdditionalCalculations = 4;
// Cells
virtual HighlightCell * illustrationCell() = 0;
ScrollableInputExactApproximateExpressionsCell m_additionalCalculationCells[k_maxNumberOfAdditionalCalculations];
ScrollableThreeExpressionsCell m_additionalCalculationCells[k_maxNumberOfAdditionalCalculations];
};
}

View File

@@ -1,10 +1,10 @@
#include "scrollable_input_exact_approximate_expressions_cell.h"
#include "scrollable_three_expressions_cell.h"
#include <poincare/exception_checkpoint.h>
#include "../app.h"
namespace Calculation {
void ScrollableInputExactApproximateExpressionsView::setCalculation(Calculation * calculation) {
void ScrollableThreeExpressionsView::setCalculation(Calculation * calculation) {
Poincare::Context * context = App::app()->localContext();
// Clean the layouts to make room in the pool
@@ -61,22 +61,22 @@ void ScrollableInputExactApproximateExpressionsView::setCalculation(Calculation
layoutSubviews();
}
void ScrollableInputExactApproximateExpressionsCell::didBecomeFirstResponder() {
void ScrollableThreeExpressionsCell::didBecomeFirstResponder() {
reinitSelection();
Container::activeApp()->setFirstResponder(&m_view);
}
void ScrollableInputExactApproximateExpressionsCell::reinitSelection() {
m_view.setSelectedSubviewPosition(Shared::ScrollableExactApproximateExpressionsView::SubviewPosition::Left);
void ScrollableThreeExpressionsCell::reinitSelection() {
m_view.setSelectedSubviewPosition(ScrollableThreeExpressionsView::SubviewPosition::Left);
m_view.reloadScroll();
}
void ScrollableInputExactApproximateExpressionsCell::setCalculation(Calculation * calculation) {
void ScrollableThreeExpressionsCell::setCalculation(Calculation * calculation) {
m_view.setCalculation(calculation);
layoutSubviews();
}
void ScrollableInputExactApproximateExpressionsCell::setDisplayCenter(bool display) {
void ScrollableThreeExpressionsCell::setDisplayCenter(bool display) {
m_view.setDisplayCenter(display);
layoutSubviews();
}

View File

@@ -1,22 +1,22 @@
#ifndef CALCULATION_SCROLLABLE_INPUT_EXACT_APPROXIMATE_EXPRESSIONS_CELL_H
#define CALCULATION_SCROLLABLE_INPUT_EXACT_APPROXIMATE_EXPRESSIONS_CELL_H
#ifndef CALCULATION_SCROLLABLE_THREE_EXPRESSIONS_CELL_H
#define CALCULATION_SCROLLABLE_THREE_EXPRESSIONS_CELL_H
#include <escher.h>
#include "../../shared/scrollable_exact_approximate_expressions_view.h"
#include "../../shared/scrollable_multiple_expressions_view.h"
#include "../calculation.h"
#include "expression_with_equal_sign_view.h"
namespace Calculation {
class ScrollableInputExactApproximateExpressionsView : public Shared::AbstractScrollableExactApproximateExpressionsView {
class ScrollableThreeExpressionsView : public Shared::AbstractScrollableMultipleExpressionsView {
public:
ScrollableInputExactApproximateExpressionsView(Responder * parentResponder) : Shared::AbstractScrollableExactApproximateExpressionsView(parentResponder, &m_contentCell), m_contentCell() {
ScrollableThreeExpressionsView(Responder * parentResponder) : Shared::AbstractScrollableMultipleExpressionsView(parentResponder, &m_contentCell), m_contentCell() {
setMargins(Metric::CommonSmallMargin, Metric::CommonSmallMargin, Metric::CommonSmallMargin, Metric::CommonSmallMargin); // Left Right margins are already added by TableCell
setBackgroundColor(KDColorWhite);
}
void setCalculation(Calculation * calculation);
private:
class ContentCell : public Shared::AbstractScrollableExactApproximateExpressionsView::ContentCell {
class ContentCell : public Shared::AbstractScrollableMultipleExpressionsView::ContentCell {
public:
ContentCell() : m_leftExpressionView() {}
KDColor backgroundColor() const override { return KDColorWhite; }
@@ -31,9 +31,9 @@ private:
ContentCell m_contentCell;
};
class ScrollableInputExactApproximateExpressionsCell : public TableCell, public Responder {
class ScrollableThreeExpressionsCell : public TableCell, public Responder {
public:
ScrollableInputExactApproximateExpressionsCell() :
ScrollableThreeExpressionsCell() :
Responder(nullptr),
m_view(this) {}
@@ -52,14 +52,14 @@ public:
void setHighlighted(bool highlight) override { m_view.evenOddCell()->setHighlighted(highlight); }
void setCalculation(Calculation * calculation);
void setDisplayCenter(bool display);
ScrollableInputExactApproximateExpressionsView::SubviewPosition selectedSubviewPosition() { return m_view.selectedSubviewPosition(); }
void setSelectedSubviewPosition(ScrollableInputExactApproximateExpressionsView::SubviewPosition subviewPosition) { m_view.setSelectedSubviewPosition(subviewPosition); }
ScrollableThreeExpressionsView::SubviewPosition selectedSubviewPosition() { return m_view.selectedSubviewPosition(); }
void setSelectedSubviewPosition(ScrollableThreeExpressionsView::SubviewPosition subviewPosition) { m_view.setSelectedSubviewPosition(subviewPosition); }
void reinitSelection();
private:
// Remove label margin added by TableCell because they're already handled by ScrollableInputExactApproximateExpressionsView
// Remove label margin added by TableCell because they're already handled by ScrollableThreeExpressionsView
KDCoordinate labelMargin() const override { return 0; }
ScrollableInputExactApproximateExpressionsView m_view;
ScrollableThreeExpressionsView m_view;
};
}

View File

@@ -73,8 +73,8 @@ bool HistoryController::handleEvent(Ion::Events::Event event) {
Container::activeApp()->setFirstResponder(editController);
editController->insertTextBody(calculationAtIndex(focusRow)->inputText());
} else {
ScrollableExactApproximateExpressionsView::SubviewPosition outputSubviewPosition = selectedCell->outputView()->selectedSubviewPosition();
if (outputSubviewPosition == ScrollableExactApproximateExpressionsView::SubviewPosition::Left) {
ScrollableTwoExpressionsView::SubviewPosition outputSubviewPosition = selectedCell->outputView()->selectedSubviewPosition();
if (outputSubviewPosition == ScrollableTwoExpressionsView::SubviewPosition::Left) {
Calculation::AdditionalInformationType additionalInfoType = selectedCell->additionalInformationType();
ListController * vc = nullptr;
Expression e = calculationAtIndex(focusRow)->exactOutput();
@@ -98,7 +98,7 @@ bool HistoryController::handleEvent(Ion::Events::Event event) {
m_selectableTableView.deselectTable();
Container::activeApp()->setFirstResponder(editController);
Shared::ExpiringPointer<Calculation> calculation = calculationAtIndex(focusRow);
if (outputSubviewPosition == ScrollableExactApproximateExpressionsView::SubviewPosition::Right
if (outputSubviewPosition == ScrollableTwoExpressionsView::SubviewPosition::Right
&& !calculation->shouldOnlyDisplayExactOutput())
{
editController->insertTextBody(calculation->approximateOutputText());

View File

@@ -43,7 +43,7 @@ HistoryViewCell::HistoryViewCell(Responder * parentResponder) :
m_calculationCRC32 = 0;
}
Shared::ScrollableExactApproximateExpressionsView * HistoryViewCell::outputView() {
Shared::ScrollableTwoExpressionsView * HistoryViewCell::outputView() {
return &m_scrollableOutputView;
}
@@ -86,12 +86,12 @@ void HistoryViewCell::reloadOutputSelection() {
/* Select the right output according to the calculation display output. This
* will reload the scroll to display the selected output. */
if (m_calculationDisplayOutput == Calculation::DisplayOutput::ExactAndApproximate) {
m_scrollableOutputView.setSelectedSubviewPosition(Shared::ScrollableExactApproximateExpressionsView::SubviewPosition::Center);
m_scrollableOutputView.setSelectedSubviewPosition(Shared::ScrollableTwoExpressionsView::SubviewPosition::Center);
} else {
assert((m_calculationDisplayOutput == Calculation::DisplayOutput::ApproximateOnly)
|| (m_calculationDisplayOutput == Calculation::DisplayOutput::ExactAndApproximateToggle)
|| (m_calculationDisplayOutput == Calculation::DisplayOutput::ExactOnly));
m_scrollableOutputView.setSelectedSubviewPosition(Shared::ScrollableExactApproximateExpressionsView::SubviewPosition::Right);
m_scrollableOutputView.setSelectedSubviewPosition(Shared::ScrollableTwoExpressionsView::SubviewPosition::Right);
}
}

View File

@@ -3,7 +3,7 @@
#include <escher.h>
#include "calculation.h"
#include "../shared/scrollable_exact_approximate_expressions_view.h"
#include "../shared/scrollable_multiple_expressions_view.h"
namespace Calculation {
@@ -45,7 +45,7 @@ public:
void layoutSubviews(bool force = false) override;
void didBecomeFirstResponder() override;
bool handleEvent(Ion::Events::Event event) override;
Shared::ScrollableExactApproximateExpressionsView * outputView();
Shared::ScrollableTwoExpressionsView * outputView();
Calculation::AdditionalInformationType additionalInformationType() const { return m_calculationAdditionInformation; }
private:
constexpr static KDCoordinate k_resultWidth = 80;
@@ -56,7 +56,7 @@ private:
Calculation::AdditionalInformationType m_calculationAdditionInformation;
bool m_calculationExpanded;
ScrollableExpressionView m_inputView;
Shared::ScrollableExactApproximateExpressionsView m_scrollableOutputView;
Shared::ScrollableTwoExpressionsView m_scrollableOutputView;
HistoryViewCellDataSource * m_dataSource;
};

View File

@@ -55,8 +55,8 @@ app_shared_src = $(addprefix apps/shared/,\
range_parameter_controller.cpp \
regular_table_view_data_source.cpp \
round_cursor_view.cpp \
scrollable_exact_approximate_expressions_cell.cpp \
scrollable_exact_approximate_expressions_view.cpp \
scrollable_multiple_expressions_view.cpp \
scrollable_two_expressions_cell.cpp \
separable.cpp \
separator_even_odd_buffer_text_cell.cpp \
simple_interactive_curve_view_controller.cpp \

View File

@@ -1,54 +0,0 @@
#include "scrollable_exact_approximate_expressions_cell.h"
#include <assert.h>
using namespace Poincare;
namespace Shared {
ScrollableExactApproximateExpressionsCell::ScrollableExactApproximateExpressionsCell(Responder * parentResponder) :
Responder(parentResponder),
m_view(this)
{
}
void ScrollableExactApproximateExpressionsCell::setLayouts(Poincare::Layout exactLayout, Poincare::Layout approximateLayout) {
m_view.setLayouts(Layout(), exactLayout, approximateLayout);
}
void ScrollableExactApproximateExpressionsCell::setHighlighted(bool highlight) {
m_view.evenOddCell()->setHighlighted(highlight);
}
void ScrollableExactApproximateExpressionsCell::setEven(bool even) {
EvenOddCell::setEven(even);
m_view.setBackgroundColor(backgroundColor());
m_view.evenOddCell()->setEven(even);
}
void ScrollableExactApproximateExpressionsCell::reloadScroll() {
m_view.reloadScroll();
}
void ScrollableExactApproximateExpressionsCell::didBecomeFirstResponder() {
reinitSelection();
Container::activeApp()->setFirstResponder(&m_view);
}
void ScrollableExactApproximateExpressionsCell::reinitSelection() {
ScrollableExactApproximateExpressionsView::SubviewPosition selectedSubview = m_view.displayCenter() ? ScrollableExactApproximateExpressionsView::SubviewPosition::Center : ScrollableExactApproximateExpressionsView::SubviewPosition::Right;
m_view.setSelectedSubviewPosition(selectedSubview);
reloadScroll();
}
int ScrollableExactApproximateExpressionsCell::numberOfSubviews() const {
return 1;
}
View * ScrollableExactApproximateExpressionsCell::subviewAtIndex(int index) {
return &m_view;
}
void ScrollableExactApproximateExpressionsCell::layoutSubviews(bool force) {
m_view.setFrame(bounds(), force);
}
}

View File

@@ -1,4 +1,4 @@
#include "scrollable_exact_approximate_expressions_view.h"
#include "scrollable_multiple_expressions_view.h"
#include <apps/i18n.h>
#include <assert.h>
using namespace Poincare;
@@ -7,7 +7,7 @@ namespace Shared {
static inline KDCoordinate maxCoordinate(KDCoordinate x, KDCoordinate y) { return x > y ? x : y; }
AbstractScrollableExactApproximateExpressionsView::ContentCell::ContentCell() :
AbstractScrollableMultipleExpressionsView::ContentCell::ContentCell() :
m_rightExpressionView(),
m_approximateSign(KDFont::LargeFont, I18n::Message::AlmostEqual, 0.5f, 0.5f, Palette::GreyVeryDark),
m_centeredExpressionView(),
@@ -16,12 +16,12 @@ AbstractScrollableExactApproximateExpressionsView::ContentCell::ContentCell() :
{
}
KDColor AbstractScrollableExactApproximateExpressionsView::ContentCell::backgroundColor() const {
KDColor AbstractScrollableMultipleExpressionsView::ContentCell::backgroundColor() const {
KDColor background = m_even ? KDColorWhite : Palette::WallScreen;
return background;
}
void AbstractScrollableExactApproximateExpressionsView::ContentCell::setHighlighted(bool highlight) {
void AbstractScrollableMultipleExpressionsView::ContentCell::setHighlighted(bool highlight) {
// Do not call HighlightCell::setHighlighted to avoid marking all cell as dirty
m_highlighted = highlight;
KDColor defaultColor = backgroundColor();
@@ -36,7 +36,7 @@ void AbstractScrollableExactApproximateExpressionsView::ContentCell::setHighligh
}
}
void AbstractScrollableExactApproximateExpressionsView::ContentCell::setEven(bool even) {
void AbstractScrollableMultipleExpressionsView::ContentCell::setEven(bool even) {
EvenOddCell::setEven(even);
KDColor defaultColor = backgroundColor();
m_centeredExpressionView.setBackgroundColor(defaultColor);
@@ -47,7 +47,7 @@ void AbstractScrollableExactApproximateExpressionsView::ContentCell::setEven(boo
}
}
void AbstractScrollableExactApproximateExpressionsView::ContentCell::reloadTextColor() {
void AbstractScrollableMultipleExpressionsView::ContentCell::reloadTextColor() {
if (displayCenter()) {
m_rightExpressionView.setTextColor(Palette::GreyVeryDark);
} else {
@@ -55,7 +55,7 @@ void AbstractScrollableExactApproximateExpressionsView::ContentCell::reloadTextC
}
}
KDSize AbstractScrollableExactApproximateExpressionsView::ContentCell::minimalSizeForOptimalDisplay() const {
KDSize AbstractScrollableMultipleExpressionsView::ContentCell::minimalSizeForOptimalDisplay() const {
KDSize leftSize = KDSizeZero;
KDCoordinate leftViewBaseline = 0;
KDCoordinate width = 0;
@@ -79,18 +79,18 @@ KDSize AbstractScrollableExactApproximateExpressionsView::ContentCell::minimalSi
return KDSize(width, height);
}
void AbstractScrollableExactApproximateExpressionsView::ContentCell::setSelectedSubviewPosition(AbstractScrollableExactApproximateExpressionsView::SubviewPosition subviewPosition) {
void AbstractScrollableMultipleExpressionsView::ContentCell::setSelectedSubviewPosition(AbstractScrollableMultipleExpressionsView::SubviewPosition subviewPosition) {
m_selectedSubviewPosition = subviewPosition;
setHighlighted(isHighlighted());
}
void AbstractScrollableExactApproximateExpressionsView::ContentCell::setDisplayCenter(bool display) {
void AbstractScrollableMultipleExpressionsView::ContentCell::setDisplayCenter(bool display) {
m_displayCenter = display;
reloadTextColor();
layoutSubviews();
}
Poincare::Layout AbstractScrollableExactApproximateExpressionsView::ContentCell::layout() const {
Poincare::Layout AbstractScrollableMultipleExpressionsView::ContentCell::layout() const {
if (m_selectedSubviewPosition == SubviewPosition::Center) {
return m_centeredExpressionView.layout();
} else if (m_selectedSubviewPosition == SubviewPosition::Right) {
@@ -101,7 +101,7 @@ Poincare::Layout AbstractScrollableExactApproximateExpressionsView::ContentCell:
return leftExpressionView()->layout();
}
int AbstractScrollableExactApproximateExpressionsView::ContentCell::numberOfSubviews() const {
int AbstractScrollableMultipleExpressionsView::ContentCell::numberOfSubviews() const {
int nbOfSubviews = 1;
if (displayCenter()) {
nbOfSubviews += 2;
@@ -112,7 +112,7 @@ int AbstractScrollableExactApproximateExpressionsView::ContentCell::numberOfSubv
return nbOfSubviews;
}
View * AbstractScrollableExactApproximateExpressionsView::ContentCell::subviewAtIndex(int index) {
View * AbstractScrollableMultipleExpressionsView::ContentCell::subviewAtIndex(int index) {
bool leftIsVisible = leftExpressionView() != nullptr;
if (leftIsVisible && index == 0) {
return leftExpressionView();
@@ -121,7 +121,7 @@ View * AbstractScrollableExactApproximateExpressionsView::ContentCell::subviewAt
return views[index - leftIsVisible];
}
void AbstractScrollableExactApproximateExpressionsView::ContentCell::layoutSubviews(bool force) {
void AbstractScrollableMultipleExpressionsView::ContentCell::layoutSubviews(bool force) {
// Subviews sizes
KDSize leftSize = leftExpressionView() ? leftExpressionView()->minimalSizeForOptimalDisplay() : KDSizeZero;
KDCoordinate leftViewBaseline = leftExpressionView() && !leftExpressionView()->layout().isUninitialized() ? leftExpressionView()->layout().baseline() : 0;
@@ -153,13 +153,13 @@ void AbstractScrollableExactApproximateExpressionsView::ContentCell::layoutSubvi
m_rightExpressionView.setFrame(KDRect(currentWidth, baseline-rightBaseline, rightExpressionSize), force);
}
AbstractScrollableExactApproximateExpressionsView::AbstractScrollableExactApproximateExpressionsView(Responder * parentResponder, View * contentCell) :
AbstractScrollableMultipleExpressionsView::AbstractScrollableMultipleExpressionsView(Responder * parentResponder, View * contentCell) :
ScrollableView(parentResponder, contentCell, this)
{
setDecoratorType(ScrollView::Decorator::Type::Arrows);
}
void AbstractScrollableExactApproximateExpressionsView::setLayouts(Poincare::Layout leftLayout, Poincare::Layout centerLayout, Poincare::Layout rightLayout) {
void AbstractScrollableMultipleExpressionsView::setLayouts(Poincare::Layout leftLayout, Poincare::Layout centerLayout, Poincare::Layout rightLayout) {
bool updateRightLayout = contentCell()->rightExpressionView()->setLayout(rightLayout);
bool updateCenterLayout = contentCell()->centeredExpressionView()->setLayout(centerLayout);
bool updateLeftLayout = false;
@@ -173,11 +173,11 @@ void AbstractScrollableExactApproximateExpressionsView::setLayouts(Poincare::Lay
}
}
void AbstractScrollableExactApproximateExpressionsView::setEqualMessage(I18n::Message equalSignMessage) {
void AbstractScrollableMultipleExpressionsView::setEqualMessage(I18n::Message equalSignMessage) {
contentCell()->approximateSign()->setMessage(equalSignMessage);
}
void AbstractScrollableExactApproximateExpressionsView::reloadScroll() {
void AbstractScrollableMultipleExpressionsView::reloadScroll() {
if (selectedSubviewPosition() == SubviewPosition::Right) {
// Scroll to the right extremity
scrollToContentPoint(KDPoint(contentCell()->bounds().width(), 0), true);
@@ -186,12 +186,12 @@ void AbstractScrollableExactApproximateExpressionsView::reloadScroll() {
ScrollableView::reloadScroll();
}
}
void AbstractScrollableExactApproximateExpressionsView::setDisplayCenter(bool display) {
void AbstractScrollableMultipleExpressionsView::setDisplayCenter(bool display) {
contentCell()->setDisplayCenter(display);
layoutSubviews();
}
bool AbstractScrollableExactApproximateExpressionsView::handleEvent(Ion::Events::Event event) {
bool AbstractScrollableMultipleExpressionsView::handleEvent(Ion::Events::Event event) {
bool leftIsVisible = false;
KDCoordinate leftWidth = 0;
if (contentCell()->leftExpressionView()) {

View File

@@ -1,18 +1,18 @@
#ifndef SHARED_SCROLLABLE_EXACT_APPROXIMATE_EXPRESSIONS_VIEW_H
#define SHARED_SCROLLABLE_EXACT_APPROXIMATE_EXPRESSIONS_VIEW_H
#ifndef SHARED_SCROLLABLE_MULTIPLE_EXPRESSIONS_VIEW_H
#define SHARED_SCROLLABLE_MULTIPLE_EXPRESSIONS_VIEW_H
#include <escher.h>
namespace Shared {
class AbstractScrollableExactApproximateExpressionsView : public ScrollableView, public ScrollViewDataSource {
class AbstractScrollableMultipleExpressionsView : public ScrollableView, public ScrollViewDataSource {
public:
enum class SubviewPosition : uint8_t {
Left = 0,
Center = 1,
Right = 2
};
AbstractScrollableExactApproximateExpressionsView(Responder * parentResponder, View * contentCell);
AbstractScrollableMultipleExpressionsView(Responder * parentResponder, View * contentCell);
::EvenOddCell * evenOddCell() {
return contentCell();
}
@@ -72,9 +72,9 @@ protected:
virtual const ContentCell * constContentCell() const = 0;
};
class ScrollableExactApproximateExpressionsView : public AbstractScrollableExactApproximateExpressionsView {
class ScrollableTwoExpressionsView : public AbstractScrollableMultipleExpressionsView {
public:
ScrollableExactApproximateExpressionsView(Responder * parentResponder) : AbstractScrollableExactApproximateExpressionsView(parentResponder, &m_contentCell) {
ScrollableTwoExpressionsView(Responder * parentResponder) : AbstractScrollableMultipleExpressionsView(parentResponder, &m_contentCell) {
setMargins(
Metric::CommonSmallMargin,
Metric::CommonLargeMargin,

View File

@@ -0,0 +1,54 @@
#include "scrollable_two_expressions_cell.h"
#include <assert.h>
using namespace Poincare;
namespace Shared {
ScrollableTwoExpressionsCell::ScrollableTwoExpressionsCell(Responder * parentResponder) :
Responder(parentResponder),
m_view(this)
{
}
void ScrollableTwoExpressionsCell::setLayouts(Poincare::Layout exactLayout, Poincare::Layout approximateLayout) {
m_view.setLayouts(Layout(), exactLayout, approximateLayout);
}
void ScrollableTwoExpressionsCell::setHighlighted(bool highlight) {
m_view.evenOddCell()->setHighlighted(highlight);
}
void ScrollableTwoExpressionsCell::setEven(bool even) {
EvenOddCell::setEven(even);
m_view.setBackgroundColor(backgroundColor());
m_view.evenOddCell()->setEven(even);
}
void ScrollableTwoExpressionsCell::reloadScroll() {
m_view.reloadScroll();
}
void ScrollableTwoExpressionsCell::didBecomeFirstResponder() {
reinitSelection();
Container::activeApp()->setFirstResponder(&m_view);
}
void ScrollableTwoExpressionsCell::reinitSelection() {
ScrollableTwoExpressionsView::SubviewPosition selectedSubview = m_view.displayCenter() ? ScrollableTwoExpressionsView::SubviewPosition::Center : ScrollableTwoExpressionsView::SubviewPosition::Right;
m_view.setSelectedSubviewPosition(selectedSubview);
reloadScroll();
}
int ScrollableTwoExpressionsCell::numberOfSubviews() const {
return 1;
}
View * ScrollableTwoExpressionsCell::subviewAtIndex(int index) {
return &m_view;
}
void ScrollableTwoExpressionsCell::layoutSubviews(bool force) {
m_view.setFrame(bounds(), force);
}
}

View File

@@ -1,14 +1,14 @@
#ifndef SHARED_SCROLLABLE_EXACT_APPROXIMATE_EXPRESSIONS_CELL_H
#define SHARED_SCROLLABLE_EXACT_APPROXIMATE_EXPRESSIONS_CELL_H
#ifndef SHARED_SCROLLABLE_TWO_EXPRESSIONS_CELL_H
#define SHARED_SCROLLABLE_TWO_EXPRESSIONS_CELL_H
#include <escher.h>
#include "scrollable_exact_approximate_expressions_view.h"
#include "scrollable_multiple_expressions_view.h"
namespace Shared {
class ScrollableExactApproximateExpressionsCell : public ::EvenOddCell, public Responder {
class ScrollableTwoExpressionsCell : public ::EvenOddCell, public Responder {
public:
ScrollableExactApproximateExpressionsCell(Responder * parentResponder = nullptr);
ScrollableTwoExpressionsCell(Responder * parentResponder = nullptr);
void setLayouts(Poincare::Layout approximateLayout, Poincare::Layout exactLayout);
void setEqualMessage(I18n::Message equalSignMessage) {
return m_view.setEqualMessage(equalSignMessage);
@@ -26,7 +26,7 @@ private:
int numberOfSubviews() const override;
View * subviewAtIndex(int index) override;
void layoutSubviews(bool force = false) override;
ScrollableExactApproximateExpressionsView m_view;
ScrollableTwoExpressionsView m_view;
};
}

View File

@@ -201,7 +201,7 @@ void SolutionsController::willDisplayCellAtLocation(HighlightCell * cell, int i,
PoincareHelpers::ConvertFloatToText<double>(m_equationStore->approximateSolutionAtIndex(j), bufferValue, bufferSize, precision);
valueCell->setText(bufferValue);
} else {
Shared::ScrollableExactApproximateExpressionsCell * valueCell = static_cast<ScrollableExactApproximateExpressionsCell *>(cell);
ScrollableTwoExpressionsCell * valueCell = static_cast<ScrollableTwoExpressionsCell *>(cell);
Poincare::Layout exactLayout = m_equationStore->exactSolutionLayoutsAtIndexAreIdentical(j) ? Poincare::Layout() : m_equationStore->exactSolutionLayoutAtIndex(j, true);
valueCell->setLayouts(exactLayout, m_equationStore->exactSolutionLayoutAtIndex(j, false));
if (!exactLayout.isUninitialized()) {

View File

@@ -3,7 +3,7 @@
#include <escher.h>
#include "equation_store.h"
#include "../shared/scrollable_exact_approximate_expressions_cell.h"
#include "../shared/scrollable_two_expressions_cell.h"
#include <apps/i18n.h>
namespace Solver {
@@ -61,7 +61,7 @@ private:
EvenOddBufferTextCell m_symbolCells[EquationStore::k_maxNumberOfSolutions];
EvenOddExpressionCell m_deltaCell;
Poincare::Layout m_delta2Layout;
Shared::ScrollableExactApproximateExpressionsCell m_exactValueCells[EquationStore::k_maxNumberOfExactSolutions];
Shared::ScrollableTwoExpressionsCell m_exactValueCells[EquationStore::k_maxNumberOfExactSolutions];
EvenOddBufferTextCell m_approximateValueCells[EquationStore::k_maxNumberOfApproximateSolutions];
ContentView m_contentView;
};