mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/code] Empty controller in the var box
This commit is contained in:
@@ -24,6 +24,7 @@ app_code_src = $(addprefix apps/code/,\
|
||||
script_parameter_controller.cpp \
|
||||
script_store.cpp \
|
||||
variable_box_controller.cpp \
|
||||
variable_box_empty_controller.cpp \
|
||||
)
|
||||
|
||||
app_code_src += $(app_code_test_src)
|
||||
|
||||
@@ -47,7 +47,7 @@ static bool shouldAddObject(const char * name, int maxLength) {
|
||||
}
|
||||
|
||||
VariableBoxController::VariableBoxController(ScriptStore * scriptStore) :
|
||||
NestedMenuController(nullptr, I18n::Message::FunctionsAndVariables),
|
||||
AlternateEmptyNestedMenuController(I18n::Message::FunctionsAndVariables),
|
||||
m_scriptStore(scriptStore),
|
||||
m_currentScriptNodesCount(0),
|
||||
m_builtinNodesCount(0),
|
||||
@@ -141,7 +141,7 @@ void VariableBoxController::tableViewDidChangeSelection(SelectableTableView * t,
|
||||
return;
|
||||
}
|
||||
const int currentSelectedRow = selectedRow();
|
||||
if (typeAtLocation(0, currentSelectedRow) == k_subtitleCellType) {
|
||||
if (currentSelectedRow >= 0 && typeAtLocation(0, currentSelectedRow) == k_subtitleCellType) {
|
||||
if (currentSelectedRow == 0) {
|
||||
t->selectCellAtLocation(0, 1);
|
||||
} else {
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
#ifndef CODE_VARIABLE_BOX_CONTROLLER_H
|
||||
#define CODE_VARIABLE_BOX_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include <apps/alternate_empty_nested_menu_controller.h>
|
||||
#include <escher/message_table_cell.h>
|
||||
#include "script_node.h"
|
||||
#include "script_node_cell.h"
|
||||
#include "script_store.h"
|
||||
#include "variable_box_empty_controller.h"
|
||||
|
||||
namespace Code {
|
||||
|
||||
class VariableBoxController : public NestedMenuController {
|
||||
class VariableBoxController : public AlternateEmptyNestedMenuController {
|
||||
public:
|
||||
VariableBoxController(ScriptStore * scriptStore);
|
||||
|
||||
@@ -27,6 +29,10 @@ public:
|
||||
/* SelectableTableViewDelegate */
|
||||
void tableViewDidChangeSelection(SelectableTableView * t, int previousSelectedCellX, int previousSelectedCellY, bool withinTemporarySelection = false) override;
|
||||
|
||||
//AlternateEmptyNestedMenuController
|
||||
ViewController * emptyViewController() override { return &m_variableBoxEmptyController; }
|
||||
bool isDisplayingEmptyController() override { return StackViewController::depth() == 2; }
|
||||
|
||||
/* VariableBoxController */
|
||||
void loadFunctionsAndVariables(int scriptIndex, const char * textToAutocomplete, int textToAutocompleteLength);
|
||||
const char * autocompletionForText(int scriptIndex, const char * textToAutocomplete, int * textToInsertLength);
|
||||
@@ -96,6 +102,7 @@ private:
|
||||
bool shouldAddNode(const char * textToAutocomplete, int textToAutocompleteLength, const char * name, int nameLength);
|
||||
bool contains(const char * name, int nameLength);
|
||||
void addNode(ScriptNode::Type type, NodeOrigin origin, const char * name, int nameLength, const char * nodeSourceName = nullptr, const char * description = nullptr);
|
||||
VariableBoxEmptyController m_variableBoxEmptyController;
|
||||
ScriptNode m_currentScriptNodes[k_maxScriptNodesCount];
|
||||
ScriptNode m_builtinNodes[k_totalBuiltinNodesCount];
|
||||
ScriptNode m_importedNodes[k_maxScriptNodesCount];
|
||||
|
||||
14
apps/code/variable_box_empty_controller.cpp
Normal file
14
apps/code/variable_box_empty_controller.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "variable_box_empty_controller.h"
|
||||
#include <apps/i18n.h>
|
||||
|
||||
namespace Code {
|
||||
|
||||
VariableBoxEmptyController::VariableBoxEmptyView::VariableBoxEmptyView() :
|
||||
::VariableBoxEmptyController::VariableBoxEmptyView()
|
||||
{
|
||||
initMessageViews();
|
||||
m_messages[0].setMessage(I18n::Message::Degrees); //TODO LEA
|
||||
m_messages[1].setMessage(I18n::Message::Degrees);
|
||||
}
|
||||
|
||||
}
|
||||
34
apps/code/variable_box_empty_controller.h
Normal file
34
apps/code/variable_box_empty_controller.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef APPS_CODE_VARIABLE_BOX_EMPTY_CONTROLLER_H
|
||||
#define APPS_CODE_VARIABLE_BOX_EMPTY_CONTROLLER_H
|
||||
|
||||
#include <apps/variable_box_empty_controller.h>
|
||||
|
||||
namespace Code {
|
||||
|
||||
class VariableBoxEmptyController : public ::VariableBoxEmptyController {
|
||||
public:
|
||||
VariableBoxEmptyController() :
|
||||
::VariableBoxEmptyController(),
|
||||
m_view()
|
||||
{}
|
||||
// View Controller
|
||||
View * view() override { return &m_view; }
|
||||
private:
|
||||
class VariableBoxEmptyView : public ::VariableBoxEmptyController::VariableBoxEmptyView {
|
||||
public:
|
||||
constexpr static int k_numberOfMessages = 2;
|
||||
VariableBoxEmptyView();
|
||||
private:
|
||||
int numberOfMessageTextViews() const override { return k_numberOfMessages; }
|
||||
MessageTextView * messageTextViewAtIndex(int index) override {
|
||||
assert(index >= 0 && index < k_numberOfMessages);
|
||||
return &m_messages[index];
|
||||
}
|
||||
MessageTextView m_messages[k_numberOfMessages];
|
||||
};
|
||||
VariableBoxEmptyView m_view;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user