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

Method findCurrentActiveItem

MyGUIEngine/src/MyGUI_ItemBox.cpp:247–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245 }
246
247 void ItemBox::findCurrentActiveItem()
248 {
249 MYGUI_DEBUG_ASSERT(mIndexActive == ITEM_NONE, "use : resetCurrentActiveItem() before findCurrentActiveItem()");
250
251 const IntPoint& point = InputManager::getInstance().getMousePositionByLayer();
252
253 // сначала проверяем клиентскую зону
254 const IntRect& rect = _getClientWidget()->getAbsoluteRect();
255 if ((point.left < rect.left) || (point.left > rect.right) || (point.top < rect.top) ||
256 (point.top > rect.bottom))
257 {
258 return;
259 }
260
261 for (const auto& item : mVectorItems)
262 {
263 const IntRect& abs_rect = item->getAbsoluteRect();
264 if ((point.left >= abs_rect.left) && (point.left <= abs_rect.right) && (point.top >= abs_rect.top) &&
265 (point.top <= abs_rect.bottom))
266 {
267 size_t index = calcIndexByWidget(item);
268 // при переборе индекс может быть больше, так как может создасться сколько угодно
269 if (index < mItemsInfo.size())
270 {
271 mIndexActive = index;
272 IBDrawItemInfo data(index, mIndexSelect, mIndexActive, mIndexAccept, mIndexRefuse, false, false);
273
274 requestDrawItem(this, item, data);
275 }
276
277 break;
278 }
279 }
280 }
281
282 size_t ItemBox::_getItemIndex(Widget* _item) const
283 {

Callers

nothing calls this directly

Calls 3

requestDrawItemFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected