6#include <unordered_map>
7#include <unordered_set>
36using std::unordered_map;
37using std::unordered_set;
59GUIScreenNode::GUIScreenNode(
60 const string& fileName,
61 const string& applicationRootPathName,
62 const string& applicationSubPathName,
70 const string& backgroundImage,
72 const GUIColor& backgroundImageEffectColorMul,
73 const GUIColor& backgroundImageEffectColorAdd,
82 GUIParentNode(this, nullptr, id, flow, overflowX, overflowY, alignments, requestedConstraints, backgroundColor, backgroundImage, backgroundImageScale9Grid, backgroundImageEffectColorMul, backgroundImageEffectColorAdd, border, padding, showOn, hideOn)
101 for (
auto i = 0; i <
subNodes.size(); i++) {
122 if (this->visible ==
visible)
return;
124 if (
gui !=
nullptr &&
161 for (
auto i = 0; i <
subNodes.size(); i++) {
168 if (
controller !=
nullptr && node->layouted ==
true) {
178 while (_node !=
nullptr) {
179 if (_node->conditionsMet ==
false) {
190 while (_node !=
nullptr) {
191 if (_node->layouted ==
false) __node = _node;
197 for (__node = node; __node != _node; __node = __node->
parentNode) {
203 _node->parentNode !=
nullptr &&
210 (_node->layouted ==
false &&
216 (_node->layouted ==
false &&
221 _node->layouted =
false;
222 _node = _node->parentNode;
226 _node->layouted =
false;
239 map<string, GUINode*> nodesToForceLayout;
242 if (node ==
nullptr)
continue;
244 if (layoutNode ==
nullptr)
continue;
245 nodesToForceLayout[layoutNode->getHierarchicalId()] = layoutNode;
250 for (
auto& nodesToForceLayoutIt: nodesToForceLayout) {
252 auto parentNodeLayouted =
false;
253 auto node = nodesToForceLayoutIt.second;
254 auto _node = node->parentNode;
256 while (_node !=
nullptr) {
257 if (nodesToForceLayout.find(_node->getHierarchicalId()) != nodesToForceLayout.end()) {
258 parentNodeLayouted =
true;
261 _node = _node->parentNode;
264 if (parentNodeLayouted ==
true)
continue;
274 auto parentNode = required_dynamic_cast<GUIParentNode*>(node);
281 auto childController = childNode->getController();
282 if (childController !=
nullptr) childController->postLayout();
289 if (nodeController !=
nullptr) nodeController->
postLayout();
346 if (node ==
nullptr) {
347 Console::println(
"GUIScreenNode::removeNodeById(): node not found: " + nodeId);
350 if (node->parentNode !=
nullptr) node->parentNode->removeSubNode(node, resetScrollOffsets);
364 elementNodeToNodeMappingIt.second.erase(node->
getId());
368 auto parentNode = required_dynamic_cast<GUIParentNode*>(node);
397 auto skipFloatingNode =
false;
398 auto _floatingNode = floatingNode;
400 if (_floatingNode->conditionsMet ==
false) {
401 skipFloatingNode =
true;
404 _floatingNode = _floatingNode->parentNode;
405 }
while (_floatingNode !=
nullptr);
406 if (skipFloatingNode ==
true)
continue;
422 auto parentElementNode = required_dynamic_cast<GUIElementNode*>(
parentNode);
423 if (parentElementNode->focusable ==
true && (parentElementNode->getController() ==
nullptr || parentElementNode->getController()->isDisabled() ==
false)) {
424 focusableNodes.push_back(required_dynamic_cast<GUIElementNode*>(
parentNode));
547 auto now = Time::getCurrentMillis();
548 vector<int64_t> timedExpressionsToRemove;
550 if (now >= timedExpressionIt.first) {
551 timedExpressionsToRemove.push_back(timedExpressionIt.first);
555 for (
auto& timedExpressionToRemove: timedExpressionsToRemove) {
559 for (
auto tickNodesByIdIt: _tickNodesById) {
560 auto node = tickNodesByIdIt.second;
561 if (node->controller !=
nullptr) node->controller->tick();
571 if (
dynamic_cast<GUIElementNode*
>(childControllerNode) !=
nullptr ==
false)
574 auto guiElementNode = required_dynamic_cast<GUIElementNode*>(childControllerNode);
575 auto guiElementNodeController = guiElementNode->getController();
576 if (guiElementNodeController->hasValue()) {
577 auto& name = guiElementNode->getName();
578 auto& value = guiElementNodeController->getValue();
579 auto currentValueIt = values.find(name);
580 if (currentValueIt == values.end() || currentValueIt->second.size() == 0) {
581 values[name] = value;
592 if (
dynamic_cast<GUIElementNode*
>(childControllerNode) !=
nullptr ==
false)
595 auto guiElementNode = required_dynamic_cast<GUIElementNode*>(childControllerNode);
596 auto guiElementNodeController = guiElementNode->getController();
597 if (guiElementNodeController->hasValue()) {
598 auto name = guiElementNode->getName();
599 auto newValueIt = values.find(name);
600 if (newValueIt == values.end())
602 guiElementNodeController->setValue(newValueIt->second);
610 constraints.
minWidth = minWidth.empty() ==
true?-1:Integer::parse(minWidth);
611 constraints.
minHeight = minHeight.empty() ==
true?-1:Integer::parse(minHeight);
612 constraints.
maxWidth = maxWidth.empty() ==
true?-1:Integer::parse(maxWidth);
613 constraints.
maxHeight = maxHeight.empty() ==
true?-1:Integer::parse(maxHeight);
GUIElementNode * getFocussedNode()
void applyRenderScreensChange()
Render screens change.
void invalidateFocussedNode()
Invalidate focussed node.
void executeOnChangeExpression()
Execute on change expression.
static void executeExpression(GUIScreenNode *screenNode, const string &expression)
Execute expression.
GUI element node conditions.
GUI node controller base class.
virtual void postLayout()=0
Post layout event.
static STATIC_DLL_IMPEXT GUINode_Flow * FLOATING
GUI node requested constraints requested constraints type enum.
static STATIC_DLL_IMPEXT GUINode_RequestedConstraints_RequestedConstraintsType * PERCENT
static STATIC_DLL_IMPEXT GUINode_RequestedConstraints_RequestedConstraintsType * STAR
static STATIC_DLL_IMPEXT GUINode_RequestedConstraints_RequestedConstraintsType * PIXEL
static STATIC_DLL_IMPEXT GUINode_RequestedConstraints_RequestedConstraintsType * AUTO
GUINodeController * controller
virtual void layoutOnDemand()
Layout on demand.
void _scrollToNodeX(GUIParentNode *toNode=nullptr)
Scroll to node X.
virtual void computeContentAlignment()
Do content alignment.
GUIParentNode * parentNode
void _scrollToNodeY(GUIParentNode *toNode=nullptr)
Scroll to node Y.
virtual void undoEffects(GUIRenderer *guiRenderer)
Undo effects.
GUINode_ComputedConstraints computedConstraints
GUIScreenNode * screenNode
GUINode_RequestedConstraints requestedConstraints
virtual void dispose()
Dispose node.
virtual void applyEffects(GUIRenderer *guiRenderer)
Apply effects.
GUIScreenNode * getScreenNode()
virtual void layout()
Layout.
GUINodeController * getController()
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.
void determineMouseEventNodes(GUIMouseEvent *event, bool floatingNode, unordered_set< string > &eventNodeIds, unordered_set< string > &eventFloatingNodeIds) override
Determine mouse event nodes.
void render(GUIRenderer *guiRenderer) override
Render.
virtual void layoutSubNodes()
Layout sub nodes.
vector< GUINode * > subNodes
void invalidateRenderCaches()
Invalidate render caches.
GUI screen node that represents a screen that can be rendered via GUI system.
GUIInputEventHandler * inputEventHandler
void delegateUnfocus(GUIElementNode *node)
Delegate unfocus event.
void setInputEventHandler(GUIInputEventHandler *inputEventHandler)
Set input event handler.
~GUIScreenNode()
Destructor.
const string getNodeType() override
void determineFocussedNodes(GUIParentNode *parentNode, vector< GUIElementNode * > &focusableNodes)
Determine focussed nodes.
void setVisible(bool visible)
Set visible.
int getContentWidth() override
bool removeNode(GUINode *node)
Add node.
void scrollToNodeX(const string &node, const string &toNode)
Register deferred scroll to node X.
void scrollToNodeY(const string &node, const string &toNode)
Register deferred scroll to node Y.
GUIInputEventHandler * getInputEventHandler()
int getContentHeight() override
unordered_map< string, GUINode * > tickNodesById
void addContextMenuRequestListener(GUIContextMenuRequestListener *listener)
Add context menu request listener.
vector< GUIMouseOverListener * > mouseOverListener
vector< GUINode * > childControllerNodes
void scrollToNodes()
Scroll to nodes.
void addChangeListener(GUIChangeListener *listener)
Add change listener.
void removeContextMenuRequestListener(GUIContextMenuRequestListener *listener)
Remove context menu request listener.
void setPopUp(bool popUp)
Set pop up.
GUINode * getNodeById(const string &nodeId)
Get GUI node by id.
vector< GUIChangeListener * > changeListener
void setValues(const unordered_map< string, MutableString > &values)
Set values.
GUINode * forceInvalidateLayout(GUINode *node)
Actually do the invalidate layout.
void removeChangeListener(GUIChangeListener *listener)
Remove change listener.
void removeNodeById(const string &nodeId, bool resetScrollOffsets)
Remove GUI node by id.
void layout() override
Layout.
void delegateFocus(GUIElementNode *node)
Delegate focus event.
void removeActionListener(GUIActionListener *listener)
Remove action listener.
void removeFocusListener(GUIFocusListener *listener)
Remove focus listener.
void removeMouseOverListener(GUIMouseOverListener *listener)
Remove mouse over listener.
void delegateMouseOver(GUIElementNode *node)
Delegate mouse over event.
void delegateValueChanged(GUIElementNode *node)
Delegate value changed.
vector< GUIFocusListener * > focusListener
static GUIScreenNode_SizeConstraints createSizeConstraints(const string &minWidth, const string &minHeight, const string &maxWidth, const string &maxHeight)
Create size constraints.
void tick()
Calls registered tick nodes controller tick method.
void addMouseOverListener(GUIMouseOverListener *listener)
Add mouse over listener.
void renderFloatingNodes(GUIRenderer *guiRenderer)
Render floating nodes.
void determineMouseEventNodes(GUIMouseEvent *event, bool floatingNode, unordered_set< string > &eventNodeIds, unordered_set< string > &eventFloatingNodeIds) override
Determine mouse event nodes.
GUIScreenNode_SizeConstraints sizeConstraints
vector< ScrollToNodeStruct > scrollToNodesY
void setScreenSize(int width, int height)
Set screen size.
void delegateActionPerformed(GUIActionListenerType type, GUIElementNode *node)
Delegate action performed.
void getValues(unordered_map< string, MutableString > &values)
Get values.
vector< GUIActionListener * > actionListener
void render(GUIRenderer *guiRenderer) override
Render screen.
void addActionListener(GUIActionListener *listener)
Add action listener.
string applicationSubPathName
unordered_map< string, GUINode * > nodesById
string applicationRootPathName
vector< GUINode * > floatingNodes
bool isContentNode() override
bool addNode(GUINode *node)
Add node.
void invalidateLayouts()
Actually do the nodes marked for layout invalidation.
unordered_map< int64_t, string > timedExpressions
unordered_map< string, unordered_set< string > > elementNodeToNodeMapping
void setGUI(GUI *gui)
Set GUI.
void delegateContextMenuRequest(GUIElementNode *node, int mouseX, int mouseY)
Delegate mouse over event.
vector< ScrollToNodeStruct > scrollToNodesX
void addFocusListener(GUIFocusListener *listener)
Add focus listener.
unordered_set< string > invalidateLayoutNodeIds
void forceLayout(GUINode *node)
Force layout node content (e.g.
vector< GUIContextMenuRequestListener * > contextMenuRequestListener
const vector< GUINode * > & getFloatingNodes()
void setRenderAreaLeft(float renderAreaLeft)
Set up render area left.
void initScreen(GUIScreenNode *screenNode)
Init screen.
void doneScreen()
Done screen.
void setRenderAreaRight(float renderAreaRight)
Set up render area right.
void setRenderAreaTop(float renderAreaTop)
Set up render area top.
void setRenderAreaBottom(float renderAreaBottom)
Set up render area bottom.
GUI action listener interface.
GUI change listener interface.
GUI focus listener interface.
GUI node computed constraints.
GUI node requested constraints entity.
GUINode_RequestedConstraints_RequestedConstraintsType * widthType
GUINode_RequestedConstraints_RequestedConstraintsType * heightType
GUI node scale 9 grid entity.
GUI screen node size constraints entity.