有了代理C++的世界真美好!
下列是application 应用中的帧切换事件:
//frame enter event initialize
void Widget::frameEntered(float _frame)
{
//ToolTip is set false default!
if ( ! mEnableToolTip ) return;
IntPoint point = InputManager::getInstance().getMousePositionByLayer();
//Check the ToolTip is not at the same point
if (mToolTipOldPoint != point)
{
//Initialize the tool tip hating time to start counting
mToolTipCurrentTime = 0;
//check the bounding box!
//if the cursor pointer is in the widget range
bool inside = getAbsoluteRect().inside(point);
if (inside)
{
inside = false;
//??how the InputManager get the mouse focus widget?
//by what means
Widget* widget = InputManager::getInstance().getMouseFocusWidget();
while (widget != 0)
{
if (widget/*->getName()*/ == this/*mName*/)
{
inside = true;
break;
}
// check the mNeedToolTip is true or false
if (widget->getNeedToolTip())
widget = 0;//widget->getParent();
else
widget = widget->getParent();
}
if (inside)
{
// just return the point
size_t index = _getContainerIndex(point);
if (mToolTipOldIndex != index)
{
if (mToolTipVisible)
{
mToolTipCurrentTime = 0;
mToolTipVisible = false;
eventToolTip(this, ToolTipInfo(ToolTipInfo::Hide));
}
mToolTipOldIndex = index;
}
}
else
{
if (mToolTipVisible)
{
mToolTipCurrentTime = 0;
mToolTipVisible = false;
eventToolTip(this, ToolTipInfo(ToolTipInfo::Hide));
}
}
}
else
{
if (mToolTipVisible)
{
mToolTipCurrentTime = 0;
mToolTipVisible = false;
eventToolTip(this, ToolTipInfo(ToolTipInfo::Hide));
}
}
mToolTipOldPoint = point;
}
else
{
bool inside = getAbsoluteRect().inside(point);
if (inside)
{
inside = false;
// проверяем не перекрывают ли нас
Widget* widget = InputManager::getInstance().getMouseFocusWidget();
while (widget != 0)
{
if (widget/*->getName()*/ == this/*mName*/)
{
inside = true;
break;
}
// если виджет берет тултип, значит сбрасываем
if (widget->getNeedToolTip())
widget = 0;//widget->getParent();
else
widget = widget->getParent();
}
if (inside)
{
if ( ! mToolTipVisible)
{
mToolTipCurrentTime += _frame;
if (mToolTipCurrentTime > WIDGET_TOOLTIP_TIMEOUT)
{
mToolTipVisible = true;
eventToolTip(this, ToolTipInfo(ToolTipInfo::Show, mToolTipOldIndex, point));
}
}
}
}
}
}
Widget 与LayerItem 与 Layer 之间的关系。