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

Method _setItemChildVisibleAt

MyGUIEngine/src/MyGUI_MenuControl.cpp:326–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324 }
325
326 void MenuControl::_setItemChildVisibleAt(size_t _index, bool _visible, bool _smooth)
327 {
328 MYGUI_ASSERT_RANGE(_index, mItemsInfo.size(), "MenuControl::setItemChildVisibleAt");
329
330 if (_visible)
331 {
332 if (mItemsInfo[_index].submenu && mItemsInfo[_index].submenu->getItemCount())
333 {
334 int offset = mItemsInfo[0].item->getAbsoluteTop() - getAbsoluteTop();
335
336 const IntCoord& coord = mItemsInfo[_index].item->getAbsoluteCoord();
337 IntPoint point(getAbsoluteRect().right, coord.top - offset);
338
339 MenuControl* menu = mItemsInfo[_index].submenu;
340
341 if (mVerticalAlignment)
342 {
343 // too wide
344 if (point.left + menu->getWidth() > menu->getParentSize().width)
345 {
346 // move to the left side if possible
347 if (point.left - menu->getWidth() - getWidth() >= 0)
348 point.left -= menu->getWidth() + getWidth();
349 // or put near right parent border (window) if too wide for left side too
350 else
351 point.left = menu->getParentSize().width - menu->getWidth();
352 }
353 // too high
354 if (point.top + menu->getHeight() > menu->getParentSize().height)
355 {
356 // move to the top side if possible
357 if (getBottom() - menu->getHeight() >= 0)
358 point.top = getBottom() - menu->getHeight();
359 // or put near bottom parent border (window) if too high for top side too
360 else
361 point.top = menu->getParentSize().height - menu->getHeight();
362 }
363 }
364 else
365 {
366 point.set(coord.left, getAbsoluteRect().bottom);
367 }
368
369 menu->setPosition(point);
370 if (_smooth)
371 menu->setVisibleSmooth(true);
372 else
373 menu->setVisible(true);
374
375 MyGUI::LayerManager::getInstance().upLayerItem(menu);
376 }
377 }
378 else
379 {
380 if (mItemsInfo[_index].submenu)
381 {
382 if (_smooth)
383 mItemsInfo[_index].submenu->setVisibleSmooth(false);

Callers

nothing calls this directly

Calls 15

getAbsoluteTopFunction · 0.85
getAbsoluteRectFunction · 0.85
getWidthFunction · 0.85
getBottomFunction · 0.85
getAbsoluteCoordMethod · 0.80
getParentSizeMethod · 0.80
sizeMethod · 0.45
getItemCountMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45
setMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected