MCPcopy Create free account
hub / github.com/MyGUI/mygui / parseWidget

Method parseWidget

Tools/LayoutEditor/EditorWidgets.cpp:412–577  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410 }
411
412 void EditorWidgets::parseWidget(MyGUI::xml::ElementEnumerator& _widget, MyGUI::Widget* _parent, bool _testMode)
413 {
414 WidgetContainer* container = new WidgetContainer();
415 // парсим атрибуты виджета
416 MyGUI::IntCoord coord;
417 MyGUI::Align align = MyGUI::Align::Default;
418 MyGUI::WidgetStyle widgetStyle = MyGUI::WidgetStyle::Child;
419 std::string position;
420
421 container->setName(_widget->findAttribute("name"));
422 container->setType(_widget->findAttribute("type"));
423 container->setSkin(_widget->findAttribute("skin"));
424 container->setLayerName(_widget->findAttribute("layer"));
425 std::string tmp;
426 if (_widget->findAttribute("style", tmp))
427 {
428 container->setStyle(tmp);
429 widgetStyle = MyGUI::WidgetStyle::parse(tmp);
430 }
431 if (_widget->findAttribute("align", tmp))
432 {
433 container->setAlign(tmp);
434 align = MyGUI::Align::parse(tmp);
435 }
436 if (_widget->findAttribute("position", position))
437 coord = MyGUI::IntCoord::parse(position);
438 if (_widget->findAttribute("position_real", position))
439 {
440 container->setRelativeMode(true);
441 MyGUI::IntSize textureSize =
442 SettingsManager::getInstance().getValue<MyGUI::IntSize>("Settings/WorkspaceTextureSize");
443 MyGUI::IntSize size = _testMode ? MyGUI::RenderManager::getInstance().getViewSize() : textureSize;
444 coord = MyGUI::CoordConverter::convertFromRelative(
445 MyGUI::DoubleCoord::parse(position),
446 _parent == nullptr ? size : _parent->getClientCoord().size());
447 }
448
449 // проверяем скин на присутствие
450 std::string_view skin = container->getSkin();
451 bool exist = isSkinExist(container->getSkin());
452 if (!exist && !container->getSkin().empty())
453 {
454 skin = WidgetTypes::getInstance().findWidgetStyle(container->getType())->default_skin;
455
456 std::string skin_string;
457 if (skin.empty())
458 skin_string = "empty skin";
459 else
460 skin_string = "'" + std::string{skin} + "'";
461
462 // FIXME : not translated string
463 std::string mess = MyGUI::utility::toString(
464 "'",
465 container->getSkin(),
466 "' skin not found , temporary changed to ",
467 skin_string);
468 GroupMessage::getInstance().addMessage(mess, MyGUI::LogLevel::Error);
469 }

Callers

nothing calls this directly

Calls 15

convertFromRelativeFunction · 0.85
toStringFunction · 0.85
getClassTypeNameFunction · 0.85
findAttributeMethod · 0.80
setSkinMethod · 0.80
setStyleMethod · 0.80
setRelativeModeMethod · 0.80
getClientCoordMethod · 0.80
getSkinMethod · 0.80
findWidgetStyleMethod · 0.80
addMessageMethod · 0.80
getElementEnumeratorMethod · 0.80

Tested by

no test coverage detected