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

Method moveNewWidget

Tools/LayoutEditor/WidgetCreatorManager.cpp:86–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84 }
85
86 void WidgetCreatorManager::moveNewWidget(const MyGUI::IntPoint& _point)
87 {
88 if (mNewWidget == nullptr)
89 {
90 // тип виджета может отсутсвовать
91 if (!MyGUI::WidgetManager::getInstance().isFactoryExist(mWidgetType))
92 return;
93
94 // выделяем верний виджет
95 if (!mPopupMode)
96 WidgetSelectorManager::getInstance().selectWidget(mStartPoint);
97
98 MyGUI::Widget* parent = WidgetSelectorManager::getInstance().getSelectedWidget();
99
100 // пока не найдем ближайшего над нами способного быть родителем
101 while (parent != nullptr && !WidgetTypes::getInstance().findWidgetStyle(parent->getTypeName())->parent)
102 parent = parent->getParent();
103
104 if (!WidgetTypes::getInstance().findWidgetStyle(mWidgetType)->child)
105 parent = nullptr;
106
107 if (parent != nullptr)
108 mNewWidget = parent->createWidgetT(
109 mPopupMode ? MyGUI::WidgetStyle::Popup : MyGUI::WidgetStyle::Child,
110 mWidgetType,
111 EditorWidgets::getInstance().getSkinReplace(mWidgetSkin),
112 MyGUI::IntCoord(),
113 MyGUI::Align::Default,
114 DEFAULT_EDITOR_LAYER);
115 else
116 mNewWidget = MyGUI::Gui::getInstance().createWidgetT(
117 mWidgetType,
118 EditorWidgets::getInstance().getSkinReplace(mWidgetSkin),
119 MyGUI::IntCoord(),
120 MyGUI::Align::Default,
121 DEFAULT_EDITOR_LAYER);
122
123 // переводим старт поинт в координаты отца
124 if (parent != nullptr && !mNewWidget->isRootWidget())
125 {
126 if (parent->getClientWidget())
127 mStartPoint -= parent->getClientWidget()->getAbsolutePosition();
128 else
129 mStartPoint -= parent->getAbsolutePosition();
130 }
131
132 if (!MyGUI::InputManager::getInstance().isShiftPressed())
133 {
134 mStartPoint.left = GridManager::getInstance().toGrid(mStartPoint.left);
135 mStartPoint.top = GridManager::getInstance().toGrid(mStartPoint.top);
136 }
137 }
138
139 MyGUI::IntCoord coord = getCoordNewWidget(_point);
140 mNewWidget->setCoord(coord);
141
142 eventChangeSelector(true, mNewWidget->getAbsoluteCoord());
143 }

Callers 1

onMouseDragMethod · 0.80

Calls 14

selectWidgetMethod · 0.80
getSelectedWidgetMethod · 0.80
findWidgetStyleMethod · 0.80
getSkinReplaceMethod · 0.80
isRootWidgetMethod · 0.80
getClientWidgetMethod · 0.80
isShiftPressedMethod · 0.80
toGridMethod · 0.80
getAbsoluteCoordMethod · 0.80
IntCoordFunction · 0.50
isFactoryExistMethod · 0.45
getParentMethod · 0.45

Tested by

no test coverage detected