68 string GUIElementNode::CONDITION_ALWAYS =
"always";
69 string GUIElementNode::CONDITION_ONMOUSEOVER =
"mouseover";
70 string GUIElementNode::CONDITION_CLICK =
"click";
71 string GUIElementNode::CONDITION_FOCUS =
"focus";
73 GUIElementNode::GUIElementNode(
83 const string& backgroundImage,
85 const GUIColor& backgroundImageEffectColorMul,
86 const GUIColor& backgroundImageEffectColorAdd,
91 const string& tooltip,
98 const string& onInitializeExpression,
99 const string& onMouseClickExpression,
100 const string& onMouseDoubleClickExpression,
101 const string& onMouseOverExpression,
102 const string& onMouseOutExpression,
103 const string& onChangeExpression,
104 const string& parentElementId,
105 const string& options
107 GUILayerNode(screenNode, parentNode, id, flow, overflowX, overflowY, alignments, requestedConstraints, backgroundColor, backgroundImage, backgroundImageScaleGrid, backgroundImageEffectColorMul, backgroundImageEffectColorAdd, border, padding, showOn, hideOn, tooltip),
108 activeConditions(this)
131 while (t.
hasMoreTokens() ==
true) this->options.push_back(StringTools::toLowerCase(StringTools::trim(t.
nextToken())));
196 if (StringTools::startsWith(expression,
"http://") ==
true || StringTools::startsWith(expression,
"https://") ==
true) {
197 Application::openBrowser(expression);
210 command = StringTools::trim(t2.
nextToken());
215 nodeId = StringTools::trim(t2.
nextToken());
216 subCommand = StringTools::trim(t2.
nextToken());
219 if (subCommand ==
"value") {
221 auto nodeController = nodeElementNode !=
nullptr?nodeElementNode->
getController():
nullptr;
222 if (StringTools::startsWith(
value,
"'") ==
true && StringTools::endsWith(
value,
"'") ==
true) {
225 if (StringTools::endsWith(
value,
".value") ==
true) {
227 auto nodeValueController = nodeValueElementNode !=
nullptr?nodeValueElementNode->
getController():
nullptr;
228 if (nodeController !=
nullptr && nodeValueController !=
nullptr) nodeController->
setValue(nodeValueController->getValue());
230 Console::println(
"GUIElementController::executeExpression(): Unknown value in expression: " +
value);
234 if (subCommand ==
"condition") {
236 if (nodeElementNode !=
nullptr) {
237 if (
value.find(
'?') != string::npos &&
238 value.find(
':') != string::npos &&
244 if (testCondition.empty() ==
true ||
245 setOnTrueCondition.empty() ==
true ||
246 setOnFalseCondition.empty() ==
true) {
247 Console::println(
"GUIElementController::executeExpression(): = ternary operator requires the following format 'node.condition=a?b:c'");
250 if (nodeElementNode !=
nullptr) {
251 if (nodeElementNode->getActiveConditions().has(testCondition) ==
true) {
253 nodeElementNode->getActiveConditions().add(setOnTrueCondition);
255 nodeElementNode->getActiveConditions().removeAll();
256 nodeElementNode->getActiveConditions().add(setOnFalseCondition);
261 nodeElementNode->getActiveConditions().removeAll();
262 nodeElementNode->getActiveConditions().add(
value);
266 if (subCommand ==
"condition-") {
270 if (subCommand ==
"condition+") {
274 if (subCommand ==
"condition!") {
276 if (nodeElementNode !=
nullptr) {
277 if (nodeElementNode->getActiveConditions().has(
value) ==
true) {
280 nodeElementNode->getActiveConditions().add(
value);
284 if (subCommand ==
"condition?") {
289 if (
value.find(
'?') == string::npos ||
290 value.find(
':') == string::npos ||
292 testCondition.empty() ==
true ||
293 setOnTrueCondition.empty() ==
true ||
294 setOnFalseCondition.empty() ==
true) {
295 Console::println(
"GUIElementController::executeExpression(): ?= ternary operator requires the following format 'node.condition?=a?b:c'");
298 if (nodeElementNode !=
nullptr) {
299 if (nodeElementNode->getActiveConditions().has(testCondition) ==
true) {
301 nodeElementNode->getActiveConditions().add(setOnTrueCondition);
303 nodeElementNode->getActiveConditions().remove(setOnTrueCondition);
304 nodeElementNode->getActiveConditions().add(setOnFalseCondition);
309 if (subCommand ==
"maskmaxvalue") {
311 if (imageNode !=
nullptr) {
312 if (StringTools::endsWith(
value,
".value") ==
true) {
314 auto nodeValueController = nodeValueElementNode !=
nullptr?nodeValueElementNode->
getController():
nullptr;
315 if (nodeValueController !=
nullptr) imageNode->setMaskMaxValue(Float::parse(nodeValueController->getValue().getString()));
317 imageNode->setMaskMaxValue(Float::parse(
value));
321 if (StringTools::startsWith(command,
"delay(") ==
true &&
322 StringTools::endsWith(command,
")") ==
true) {
323 int64_t delay = Integer::parse(StringTools::substring(command, command.find(
'(') + 1, command.rfind(
')')));
327 Console::println(
"GUIElementController::executeExpression(): Unknown sub command in expression: expression = " + expression +
", sub command = " + subCommand);
349 auto optionName = StringTools::trim(t.
nextToken());
350 if (optionName != option)
continue;
370 vector<GUINode*> childControllerNodes;
376 for (
auto childControllerNode: childControllerNodes) {
377 childControllerNode->getController()->handleKeyboardEvent(event);
Application base class, please make sure to allocate application on heap to have correct application ...
const string getNodeType() override
const string & getOnMouseClickExpression()
void executeOnChangeExpression()
Execute on change expression.
const string & getOnInitializeExpression()
const string & getOnMouseDoubleClickExpression()
string onChangeExpression
const string & getOnMouseOverExpression()
GUINodeConditions activeConditions
const string & getParentElementNodeId()
string onInitializeExpression
const string getOptionValue(const string &option)
string onMouseClickExpression
string onMouseDoubleClickExpression
const string & getOnChangeExpression()
bool hasOption(const string &option)
string onMouseOverExpression
string onMouseOutExpression
const string & getValue()
const string & getOnMouseOutExpression()
bool isContentNode() override
static void executeExpression(GUIScreenNode *screenNode, const string &expression)
Execute expression.
void handleKeyboardEvent(GUIKeyboardEvent *event)
Handle keyboard event.
GUINodeConditions & getActiveConditions()
GUI element node conditions.
bool add(const string &condition)
Add a condition.
bool removeAll()
Remove all.
bool remove(const string &condition)
Remove a condition.
GUI node controller base class.
virtual void setValue(const MutableString &value)=0
Set value.
GUI node requested constraints requested constraints type enum.
unique_ptr< GUINodeController > controller
GUINodeController * getController()
GUIScreenNode * screenNode
GUIScreenNode * getScreenNode()
void setController(GUINodeController *controller)
Set up node controller.
GUI parent node overflow enum.
GUI parent node base class thats supporting child nodes.
void getChildControllerNodes(vector< GUINode * > &childControllerNodes, bool requireConditionsMet=false)
Get child controller nodes.
GUI screen node that represents a screen that can be rendered via GUI system.
void addTimedExpression(int64_t time, const string &expression)
Add a timed expression.
GUINode * getNodeById(const string &nodeId)
Get GUI node by id.
Mutable utf8 aware string class.
Run time type information utility class.
const string & nextToken()
void tokenize(const string &str, const string &delimiters, bool emptyTokens=false)
Tokenize.
GUI node computed constraints.
GUI node requested constraints entity.
GUI node scale 9 grid entity.