frameEntered -- Widget class

有了代理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 之间的关系。













  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值