Blame view

build4/epsilon-master/apps/code/variable_box_controller.h 2.15 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  #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(MenuController * menuController, 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, MenuController * menuController, 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 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_maxNumberOfDisplayedRows = 6; //240/40
      constexpr static int k_maxScriptNodesCount = 32;
      void insertTextInCaller(const char * text);
      int m_scriptNodesCount;
      ScriptNode m_scriptNodes[k_maxScriptNodesCount];
      MenuController * m_menuController;
      ScriptStore * m_scriptStore;
      TextInput * m_textInputCaller;
      ScriptNodeCell m_leafCells[k_maxNumberOfDisplayedRows];
      SelectableTableView m_selectableTableView;
    };
    ContentViewController m_contentViewController;
  };
  
  }
  #endif