Files
Upsilon/apps/code/variable_box_controller.h
Léa Saviot 2661032993 [apps/code] Fix Python loading when going in the VarBoxController
The Var box controller deinited python on exit, and the console
controller did not reload python + it made the console controller lose
all its context, such as imported scripts
2018-09-21 11:55:12 +02:00

64 lines
2.2 KiB
C++

#ifndef CODE_VARIABLE_BOX_CONTROLLER_H
#define CODE_VARIABLE_BOX_CONTROLLER_H
#include <escher.h>
#include "menu_controller.h"
#include "script_node.h"
#include "script_node_cell.h"
#include "script_store.h"
namespace Code {
class VariableBoxController : public StackViewController {
public:
VariableBoxController(App * pythonDelegate, ScriptStore * scriptStore);
void didBecomeFirstResponder() override;
void setTextInputCaller(TextInput * textInput);
void viewWillAppear() override;
void viewDidDisappear() override;
private:
class ContentViewController : public ViewController, public SimpleListViewDataSource, public SelectableTableViewDataSource {
public:
ContentViewController(Responder * parentResponder, App * pythonDelegate, ScriptStore * scriptStore);
void setTextInputCaller(TextInput * textInput);
void reloadData();
void addFunctionAtIndex(const char * functionName, int scriptIndex);
void addVariableAtIndex(const char * variableName, int scriptIndex);
/* ViewController */
const char * title() override;
View * view() override { return &m_selectableTableView; }
void viewWillAppear() override;
void viewDidDisappear() override;
/* Responder */
void didEnterResponderChain(Responder * previousFirstResponder) override;
void didBecomeFirstResponder() override;
bool handleEvent(Ion::Events::Event event) override;
/* SimpleListViewDataSource */
KDCoordinate cellHeight() override { return Metric::ToolboxRowHeight; }
int numberOfRows() override;
HighlightCell * reusableCell(int index) override;
int reusableCellCount() override;
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
private:
constexpr static int k_maxScriptObjectNameSize = 100;
constexpr static int k_maxNumberOfDisplayedRows = 6; //240/40
constexpr static int k_maxScriptNodesCount = 32;
void insertTextInCaller(const char * text);
int m_scriptNodesCount;
ScriptNode m_scriptNodes[k_maxScriptNodesCount];
App * m_pythonDelegate;
ScriptStore * m_scriptStore;
TextInput * m_textInputCaller;
ScriptNodeCell m_leafCells[k_maxNumberOfDisplayedRows];
SelectableTableView m_selectableTableView;
};
ContentViewController m_contentViewController;
};
}
#endif