| 262 | } |
| 263 | |
| 264 | std::vector<UIWidget*> UISceneNode::loadNode( pugi::xml_node node, Node* parent, |
| 265 | const Uint32& marker ) { |
| 266 | std::vector<UIWidget*> rootWidgets; |
| 267 | |
| 268 | if ( NULL == parent ) |
| 269 | parent = this; |
| 270 | |
| 271 | Clock clock; |
| 272 | for ( pugi::xml_node widget = node; widget; widget = widget.next_sibling() ) { |
| 273 | clock.restart(); |
| 274 | |
| 275 | if ( String::iequals( widget.name(), "style" ) ) { |
| 276 | CSS::StyleSheetParser parser; |
| 277 | std::string styleContent; |
| 278 | for ( pugi::xml_node child = widget.first_child(); child; |
| 279 | child = child.next_sibling() ) { |
| 280 | if ( child.type() == pugi::node_pcdata || child.type() == pugi::node_cdata ) { |
| 281 | styleContent += child.value(); |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | if ( parser.loadFromString( std::string_view{ styleContent } ) ) { |
| 286 | parser.getStyleSheet().setMarker( marker ); |
| 287 | combineStyleSheet( parser.getStyleSheet(), false ); |
| 288 | } |
| 289 | continue; |
| 290 | } else if ( String::iequals( widget.name(), "link" ) ) { |
| 291 | auto type = widget.attribute( "type" ); |
| 292 | auto href = widget.attribute( "href" ); |
| 293 | auto rel = widget.attribute( "rel" ); |
| 294 | if ( !href.empty() && ( String::iequals( type.value(), "text/css" ) || |
| 295 | String::iequals( rel.value(), "stylesheet" ) ) ) { |
| 296 | loadCSS( href.as_string() ); |
| 297 | } |
| 298 | continue; |
| 299 | } |
| 300 | |
| 301 | UIWidget* uiwidget = UIWidgetCreator::createFromName( widget.name() ); |
| 302 | |
| 303 | if ( NULL != uiwidget ) { |
| 304 | rootWidgets.push_back( uiwidget ); |
| 305 | |
| 306 | uiwidget->setParent( parent ); |
| 307 | uiwidget->loadFromXmlNode( widget ); |
| 308 | |
| 309 | if ( mVerbose ) { |
| 310 | std::string name( widget.name() ); |
| 311 | pugi::xml_attribute idAttr( widget.attribute( "id" ) ); |
| 312 | pugi::xml_attribute classAttr( widget.attribute( "class" ) ); |
| 313 | |
| 314 | if ( !idAttr.empty() ) { |
| 315 | name += "#" + std::string( idAttr.as_string() ); |
| 316 | } |
| 317 | |
| 318 | if ( !classAttr.empty() ) { |
| 319 | std::string classes( String::trim( std::string( classAttr.as_string() ) ) ); |
| 320 | String::replaceAll( classes, " ", "." ); |
| 321 | name += "." + classes; |
no test coverage detected