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

Method detachFromWidget

MyGUIEngine/src/MyGUI_Widget.cpp:780–840  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

778 }
779
780 void Widget::detachFromWidget(std::string_view _layer)
781 {
782 std::string_view oldlayer;
783 if (getLayer())
784 oldlayer = getLayer()->getName();
785
786 Widget* parent = getParent();
787 if (parent)
788 {
789 // отдетачиваемся от лееров
790 if (!isRootWidget())
791 {
792 detachFromLayerItemNode(true);
793
794 if (mWidgetStyle == WidgetStyle::Child)
795 {
796 mParent->removeChildItem(this);
797 }
798 else if (mWidgetStyle == WidgetStyle::Overlapped)
799 {
800 mParent->removeChildNode(this);
801 }
802
803 mWidgetStyle = WidgetStyle::Overlapped;
804
805 mCroppedParent = nullptr;
806
807 // обновляем координаты
808 mAbsolutePosition = mCoord.point();
809
810 for (auto& widget : mWidgetChild)
811 widget->_updateAbsolutePoint();
812 for (auto& widget : mWidgetChildSkin)
813 widget->_updateAbsolutePoint();
814
815 // сбрасываем обрезку
816 mMargin.clear();
817
818 _updateView();
819 }
820
821 // нам нужен самый рутовый парент
822 while (parent->getParent())
823 parent = parent->getParent();
824
825 Gui::getInstance()._linkChildWidget(this);
826 mParent->_unlinkChildWidget(this);
827 mParent = nullptr;
828 }
829
830 if (!_layer.empty())
831 {
832 LayerManager::getInstance().attachToLayerNode(_layer, this);
833 }
834 else if (!oldlayer.empty())
835 {
836 LayerManager::getInstance().attachToLayerNode(oldlayer, this);
837 }

Callers 3

DetachFromWidgetFunction · 0.80
step_detach_widgetFunction · 0.80

Calls 11

_updateViewFunction · 0.85
removeChildItemMethod · 0.80
removeChildNodeMethod · 0.80
_updateAbsolutePointMethod · 0.80
attachToLayerNodeMethod · 0.80
pointMethod · 0.45
clearMethod · 0.45
getParentMethod · 0.45
_linkChildWidgetMethod · 0.45
_unlinkChildWidgetMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected