35 const std::string
XML_TYPE(
"Layout");
46 layoutParent =
nullptr;
54 if (!mIsInitialise)
return;
60 mIsInitialise =
false;
65 mVectorWidgetPtr.clear();
67 return mVectorWidgetPtr;
72 #if MYGUI_DEBUG_MODE == 1
73 MYGUI_LOG(Info,
"load layout '" << _file <<
"'");
75 parseLayout(mVectorWidgetPtr, _node);
83 layoutPrefix = _prefix;
84 layoutParent = _parent;
85 widgets =
load(_file);
87 layoutParent =
nullptr;
100 while (widget.
next(
"Widget")) parseWidget(_widgets, widget, layoutParent);
103 void LayoutManager::parseWidget(
VectorWidgetPtr& _widgets, xml::ElementEnumerator& _widget, Widget* _parent)
106 std::string widgetType, widgetSkin, widgetName, widgetLayer, tmp;
108 _widget->findAttribute(
"type", widgetType);
109 _widget->findAttribute(
"skin", widgetSkin);
110 _widget->findAttribute(
"layer", widgetLayer);
113 if (_widget->findAttribute(
"align", tmp)) align =
Align::parse(tmp);
115 _widget->findAttribute(
"name", widgetName);
116 if (!widgetName.empty()) widgetName = layoutPrefix + widgetName;
123 if (_widget->findAttribute(
"position", tmp)) coord =
IntCoord::parse(tmp);
124 else if (_widget->findAttribute(
"position_real", tmp))
133 if (
nullptr == _parent)
134 wid =
Gui::getInstance().createWidgetT(widgetType, widgetSkin, coord, align, widgetLayer, widgetName);
136 wid = _parent->createWidgetT(style, widgetType, widgetSkin, coord, align, widgetLayer, widgetName);
138 if (layoutParent == _parent) _widgets.push_back(wid);
141 xml::ElementEnumerator node = _widget->getElementEnumerator();
144 if (node->getName() ==
"Widget")
146 parseWidget(_widgets, node, wid);
148 else if (node->getName() ==
"Property")
150 wid->setProperty(node->findAttribute(
"key"), node->findAttribute(
"value"));
152 else if (node->getName() ==
"UserString")
154 wid->setUserString(node->findAttribute(
"key"), node->findAttribute(
"value"));
156 else if (node->getName() ==
"Controller")
158 const std::string& type = node->findAttribute(
"type");
162 xml::ElementEnumerator prop = node->getElementEnumerator();
163 while (prop.next(
"Property"))
165 item->
setProperty(prop->findAttribute(
"key"), prop->findAttribute(
"value"));