TDME2  1.9.200
MarkdownTabController.cpp
Go to the documentation of this file.
2 
3 #include <string>
4 
5 #include <tdme/tdme.h>
13 #include <tdme/gui/GUI.h>
14 #include <tdme/gui/GUIParser.h>
24 #include <tdme/utilities/Action.h>
25 #include <tdme/utilities/Console.h>
29 
31 
32 using std::string;
33 
40 using tdme::gui::GUI;
56 
57 MarkdownTabController::MarkdownTabController(MarkdownTabView* view)
58 {
59  this->view = view;
60  this->popUps = view->getPopUps();
61 }
62 
64 }
65 
67 {
68  this->screenNode = screenNode;
69 }
70 
72 {
73 }
74 
76 {
77  showInfoPopUp("Warning", "This command is not supported yet");
78 }
79 
80 void MarkdownTabController::onDrop(const string& payload, int mouseX, int mouseY) {
81  showInfoPopUp("Warning", "You can not drop a file here");
82 }
83 
84 void MarkdownTabController::showInfoPopUp(const string& caption, const string& message)
85 {
86  popUps->getInfoDialogScreenController()->show(caption, message);
87 }
88 
90 {
91  if (node->getId() == "selectbox_outliner") {
92  auto selection = node->getController()->getValue().getString();
93  if (StringTools::startsWith(selection, "toc_") == true) {
94  auto node = view->getScreenNode()->getNodeById(StringTools::substring(selection, 4));
95  if (node != nullptr) {
96  node->scrollToNodeX();
97  node->scrollToNodeY();
98  }
99  }
100  }
101 }
102 
104 }
105 
107 }
108 
109 void MarkdownTabController::onContextMenuRequest(GUIElementNode* node, int mouseX, int mouseY) {
110 }
111 
112 void MarkdownTabController::onTooltipShowRequest(GUINode* node, int mouseX, int mouseY) {
113  int tooltipLeft, tooltipTop;
114  if (view->getEditorView()->getCurrentTabTooltipPosition(screenNode, mouseX, mouseY, tooltipLeft, tooltipTop) == false) return;
115  //
116  popUps->getTooltipScreenController()->show(tooltipLeft, tooltipTop, node->getToolTip());
117 }
118 
121 }
122 
124  string xml;
125  xml+= "<selectbox-parent-option text='Table of Contents' value='toc' >\n";
126  auto levelCounter = 1;
127  const auto& toc = view->getTableOfContent();
128  if (toc.empty() == false) {
129  string lastLevel = toc[0].level;
130  for (auto i = 0; i < toc.size(); i++) {
131  const auto& tocEntry = toc[i];
132  //
133  if (i > 0 && tocEntry.level.size() < lastLevel.size()) {
134  xml+= "</selectbox-parent-option>\n";
135  levelCounter--;
136  }
137  //
138  if (i == toc.size() - 1 || toc[i + 1].level.size() <= tocEntry.level.size()) {
139  xml+= "<selectbox-option text='" + GUIParser::escape(tocEntry.title) + "' value='toc_" + GUIParser::escape(tocEntry.id) + "' />\n";
140  } else {
141  xml+= "<selectbox-parent-option text='" + GUIParser::escape(tocEntry.title) + "' value='toc_" + GUIParser::escape(tocEntry.id) + "'>\n";
142  levelCounter++;
143  }
144  lastLevel = tocEntry.level;
145  }
146  }
147  for (auto i = 0; i < levelCounter; i++) {
148  xml+= "</selectbox-parent-option>\n";
149  }
151 }
152 
155 }
156 
158 {
159 }
GUI parser.
Definition: GUIParser.h:40
GUI module class.
Definition: GUI.h:64
GUI node controller base class.
virtual const MutableString & getValue()=0
GUI node base class.
Definition: GUINode.h:64
void scrollToNodeY(GUIParentNode *toNode=nullptr)
Scroll to node Y.
Definition: GUINode.cpp:1100
void scrollToNodeX(GUIParentNode *toNode=nullptr)
Scroll to node X.
Definition: GUINode.cpp:1096
const string & getToolTip()
Definition: GUINode.h:346
GUINodeController * getController()
Definition: GUINode.h:661
const string & getId()
Definition: GUINode.h:339
GUI parent node base class thats supporting child nodes.
Definition: GUIParentNode.h:42
GUI screen node that represents a screen that can be rendered via GUI system.
Definition: GUIScreenNode.h:72
GUINode * getNodeById(const string &nodeId)
Get GUI node by id.
File system singleton class.
Definition: FileSystem.h:17
void show(const string &caption, const string &message)
Shows the pop up.
void show(int mouseX, int mouseY, const string &tooltip)
Show tooltip.
Pop ups controller accessor class.
Definition: PopUps.h:29
TooltipScreenController * getTooltipScreenController()
Definition: PopUps.h:131
InfoDialogScreenController * getInfoDialogScreenController()
Definition: PopUps.h:75
void onContextMenuRequest(GUIElementNode *node, int mouseX, int mouseY) override
On context menu request.
void onDrop(const string &payload, int mouseX, int mouseY) override
On drop.
void setOutlinerAddDropDownContent()
Set outliner add drop down content.
void onChange(GUIElementNode *node) override
On change.
void onCommand(TabControllerCommand command) override
On command.
void onUnfocus(GUIElementNode *node) override
On unfocus.
void onTooltipCloseRequest() override
On tooltip close request.
void onFocus(GUIElementNode *node) override
On focus.
void initialize(GUIScreenNode *screenNode) override
Init.
void showInfoPopUp(const string &caption, const string &message)
Show the information pop up / modal.
void onAction(GUIActionListenerType type, GUIElementNode *node) override
void onTooltipShowRequest(GUINode *node, int mouseX, int mouseY) override
On tooltip show request.
const vector< Markdown::TOCEntry > & getTableOfContent()
void setOutlinerAddDropDownContent(const string &xml)
Set outliner add drop down content.
Definition: EditorView.cpp:400
void setOutlinerContent(const string &xml)
Set outliner content.
Definition: EditorView.cpp:396
bool getCurrentTabTooltipPosition(GUIScreenNode *screenNode, int mouseX, int mouseY, int &tooltipLeft, int &tooltipTop)
Determine current tab tooltip position.
Definition: EditorView.cpp:439
Console class.
Definition: Console.h:29
Exception base class.
Definition: ExceptionBase.h:19
const string & getString() const
String tools class.
Definition: StringTools.h:22
std::exception Exception
Exception base class.
Definition: Exception.h:18
Tab controller, which connects UI with logic.
Definition: TabController.h:34
Action Interface.
Definition: Action.h:11