mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/sequence/list] Display specific toolbox
Change-Id: I4af4ba588677ca6688b64b10c29c69e16f98fffb
This commit is contained in:
@@ -2,12 +2,12 @@ app_objs += $(addprefix apps/sequence/,\
|
||||
app.o\
|
||||
list/list_controller.o\
|
||||
list/list_parameter_controller.o\
|
||||
list/sequence_toolbox.o\
|
||||
list/type_parameter_controller.o\
|
||||
values/values_controller.o\
|
||||
sequence.o\
|
||||
sequence_store.o\
|
||||
sequence_title_cell.o\
|
||||
sequence_toolbox.o\
|
||||
)
|
||||
|
||||
app_images += apps/sequence/sequence_icon.png
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace Sequence {
|
||||
|
||||
App::App(Container * container, Context * context) :
|
||||
TextFieldDelegateApp(container, &m_inputViewController, "Suites", "SUITES", ImageStore::SequenceIcon),
|
||||
m_sequenceToolbox(SequenceToolbox()),
|
||||
m_sequenceStore(SequenceStore()),
|
||||
m_nContext(VariableContext('n', context)),
|
||||
m_listController(&m_listHeader, &m_sequenceStore, &m_listHeader),
|
||||
@@ -38,12 +37,4 @@ const char * App::XNT() {
|
||||
return "n";
|
||||
}
|
||||
|
||||
SequenceToolbox * App::sequenceToolbox() {
|
||||
return &m_sequenceToolbox;
|
||||
}
|
||||
|
||||
SequenceStore * App::sequenceStore() {
|
||||
return &m_sequenceStore;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <escher.h>
|
||||
#include <poincare.h>
|
||||
#include "sequence_store.h"
|
||||
#include "sequence_toolbox.h"
|
||||
#include "list/list_controller.h"
|
||||
#include "values/values_controller.h"
|
||||
#include "../shared/text_field_delegate_app.h"
|
||||
@@ -17,10 +16,7 @@ public:
|
||||
InputViewController * inputViewController();
|
||||
Poincare::Context * localContext() override;
|
||||
const char * XNT() override;
|
||||
SequenceToolbox * sequenceToolbox();
|
||||
SequenceStore * sequenceStore();
|
||||
private:
|
||||
SequenceToolbox m_sequenceToolbox;
|
||||
SequenceStore m_sequenceStore;
|
||||
Poincare::VariableContext m_nContext;
|
||||
ListController m_listController;
|
||||
|
||||
@@ -15,7 +15,8 @@ ListController::ListController(Responder * parentResponder, SequenceStore * sequ
|
||||
SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator), SequenceTitleCell(FunctionTitleCell::Orientation::VerticalIndicator)},
|
||||
m_parameterController(ListParameterController(this, sequenceStore)),
|
||||
m_typeParameterController(this, sequenceStore),
|
||||
m_typeStackController(StackViewController(nullptr, &m_typeParameterController, true, KDColorWhite, Palette::PurpleDark, Palette::PurpleDark))
|
||||
m_typeStackController(StackViewController(nullptr, &m_typeParameterController, true, KDColorWhite, Palette::PurpleDark, Palette::PurpleDark)),
|
||||
m_sequenceToolbox(SequenceToolbox(m_sequenceStore))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -23,6 +24,21 @@ const char * ListController::title() const {
|
||||
return "Suites";
|
||||
}
|
||||
|
||||
Toolbox * ListController::toolboxForTextField(TextField * textField) {
|
||||
int recurrenceDepth = 0;
|
||||
int sequenceDefinition = sequenceDefinitionForRow(m_selectableTableView.selectedRow());
|
||||
Sequence * sequence = m_sequenceStore->functionAtIndex(sequenceIndexForRow(m_selectableTableView.selectedRow()));
|
||||
if (sequenceDefinition == 0) {
|
||||
recurrenceDepth = sequence->numberOfElements()-1;
|
||||
}
|
||||
m_sequenceToolbox.addCells(recurrenceDepth);
|
||||
return &m_sequenceToolbox;
|
||||
}
|
||||
|
||||
TextFieldDelegateApp * ListController::textFieldDelegateApp() {
|
||||
return (App *)app();
|
||||
}
|
||||
|
||||
int ListController::numberOfRows() {
|
||||
int numberOfRows = 0;
|
||||
for (int i = 0; i < m_sequenceStore->numberOfFunctions(); i++) {
|
||||
@@ -116,6 +132,7 @@ void ListController::editExpression(Sequence * sequence, int sequenceDefinition,
|
||||
}
|
||||
App * myApp = (App *)app();
|
||||
InputViewController * inputController = myApp->inputViewController();
|
||||
inputController->setTextFieldDelegate(this);
|
||||
if (sequenceDefinition == 0) {
|
||||
inputController->edit(this, event, sequence, initialText,
|
||||
[](void * context, void * sender){
|
||||
|
||||
@@ -8,11 +8,13 @@
|
||||
#include "type_parameter_controller.h"
|
||||
#include "../../shared/new_function_cell.h"
|
||||
#include "../../shared/list_controller.h"
|
||||
#include "../../shared/text_field_delegate.h"
|
||||
#include "list_parameter_controller.h"
|
||||
#include "sequence_toolbox.h"
|
||||
|
||||
namespace Sequence {
|
||||
|
||||
class ListController : public Shared::ListController {
|
||||
class ListController : public Shared::ListController, public Shared::TextFieldDelegate {
|
||||
public:
|
||||
ListController(Responder * parentResponder, SequenceStore * sequenceStore, HeaderViewController * header);
|
||||
const char * title() const override;
|
||||
@@ -20,7 +22,9 @@ public:
|
||||
virtual KDCoordinate rowHeight(int j) override;
|
||||
void willDisplayCellAtLocation(TableViewCell * cell, int i, int j) override;
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
Toolbox * toolboxForTextField(TextField * textField) override;
|
||||
private:
|
||||
Shared::TextFieldDelegateApp * textFieldDelegateApp() override;
|
||||
bool handleEnter();
|
||||
void editExpression(Sequence * sequence, int sequenceDefinitionIndex, Ion::Events::Event event);
|
||||
ListParameterController * parameterController() override;
|
||||
@@ -39,6 +43,7 @@ private:
|
||||
ListParameterController m_parameterController;
|
||||
TypeParameterController m_typeParameterController;
|
||||
StackViewController m_typeStackController;
|
||||
SequenceToolbox m_sequenceToolbox;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
#include "sequence_toolbox.h"
|
||||
#include "../../poincare/src/layout/baseline_relative_layout.h"
|
||||
#include "../../poincare/src/layout/string_layout.h"
|
||||
#include "../../../poincare/src/layout/baseline_relative_layout.h"
|
||||
#include "../../../poincare/src/layout/string_layout.h"
|
||||
#include <assert.h>
|
||||
|
||||
using namespace Poincare;
|
||||
|
||||
namespace Sequence {
|
||||
|
||||
SequenceToolbox::SequenceToolbox() :
|
||||
SequenceToolbox::SequenceToolbox(SequenceStore * sequenceStore) :
|
||||
MathToolbox(),
|
||||
m_numberOfAddedCells(0)
|
||||
m_numberOfAddedCells(0),
|
||||
m_sequenceStore(sequenceStore)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -64,10 +65,14 @@ int SequenceToolbox::typeAtLocation(int i, int j) {
|
||||
return MathToolbox::typeAtLocation(i,j);
|
||||
}
|
||||
|
||||
void SequenceToolbox::addCells(int numberOfAddedCells, char ** cellNames, char ** cellSubscript) {
|
||||
m_numberOfAddedCells = numberOfAddedCells;
|
||||
for (int i = 0; i < numberOfAddedCells; i++) {
|
||||
m_addedCellLayout[i] = new BaselineRelativeLayout(new StringLayout(cellNames[i], 1, KDText::FontSize::Large), new StringLayout(cellSubscript[i], strlen(cellSubscript[i]), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
|
||||
void SequenceToolbox::addCells(int recurrenceDepth) {
|
||||
m_numberOfAddedCells = 0;
|
||||
for (int k = 0; k < m_sequenceStore->numberOfFunctions(); k++) {
|
||||
Sequence * s = m_sequenceStore->functionAtIndex(k);
|
||||
for (int j = 0; j < recurrenceDepth; j++) {
|
||||
m_addedCellLayout[m_numberOfAddedCells] = new BaselineRelativeLayout(new StringLayout((char *)s->name(), 1, KDText::FontSize::Large), new StringLayout((char *)(j == 0? "n" : "n+1"), strlen((char *)(j == 0? "n" : "n+1")), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
|
||||
m_numberOfAddedCells++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
#ifndef SEQUENCE_SEQUENCE_TOOLBOX_H
|
||||
#define SEQUENCE_SEQUENCE_TOOLBOX_H
|
||||
|
||||
#include "../math_toolbox.h"
|
||||
#include "../../math_toolbox.h"
|
||||
#include "../sequence_store.h"
|
||||
|
||||
namespace Sequence {
|
||||
|
||||
class SequenceToolbox : public MathToolbox {
|
||||
public:
|
||||
SequenceToolbox();
|
||||
SequenceToolbox(SequenceStore * sequenceStore);
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
int numberOfRows() override;
|
||||
TableViewCell * reusableCell(int index, int type) override;
|
||||
void willDisplayCellForIndex(TableViewCell * cell, int index) override;
|
||||
KDCoordinate rowHeight(int j) override;
|
||||
int typeAtLocation(int i, int j) override;
|
||||
void addCells(int numberOfAddedCells, char ** cellNames, char ** cellSubscripts);
|
||||
void addCells(int recurrenceDepth);
|
||||
private:
|
||||
bool selectAddedCell(int selectedRow);
|
||||
constexpr static KDCoordinate k_addedRowHeight = 20;
|
||||
ExpressionMenuListCell m_addedCells[k_maxNumberOfDisplayedRows];
|
||||
Poincare::ExpressionLayout * m_addedCellLayout[k_maxNumberOfDisplayedRows];
|
||||
int m_numberOfAddedCells;
|
||||
SequenceStore * m_sequenceStore;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user