Exemplo n.º 1
0
bool Indigo::Render::UILayer::on_cursormove(const glm::dvec2& pos)
{
	if (!visible())
		return false;

	const glm::uvec2& sz = size();
	glm::ivec2 ipos = glm::clamp(glm::ivec2(glm::floor(pos)),glm::ivec2(0),glm::ivec2(sz.x-1,sz.y-1));

	OOBase::Vector<OOBase::WeakPtr<UIDrawable>,OOBase::ThreadLocalAllocator> hits;
	hit_test(hits,ipos);

	for (OOBase::Vector<OOBase::WeakPtr<UIDrawable>,OOBase::ThreadLocalAllocator>::iterator i=m_cursor_hits.begin();i;)
	{
		if (hits.find(*i))
			++i;
		else
		{
			OOBase::SharedPtr<UIDrawable> d = i->lock();

			i = m_cursor_hits.erase(i);

			if (d && d->on_cursorenter(false))
				break;
		}
	}

	for (OOBase::Vector<OOBase::WeakPtr<UIDrawable>,OOBase::ThreadLocalAllocator>::iterator i=hits.begin();i;++i)
	{
		if (m_cursor_hits.remove(*i) == 0)
		{
			OOBase::SharedPtr<UIDrawable> d = i->lock();
			if (d && d->on_cursorenter(true))
				break;
		}
	}

	m_cursor_hits.swap(hits);

	bool handled = false;
	for (OOBase::Vector<OOBase::WeakPtr<UIDrawable>,OOBase::ThreadLocalAllocator>::iterator i=m_cursor_hits.begin();!handled && i;)
	{
		OOBase::SharedPtr<UIDrawable> d = i->lock();
		if (!d)
			m_cursor_hits.erase(i);
		else
		{
			handled = d->on_cursormove();
			++i;
		}
	}

	return m_owner->m_modal || handled;
}
Exemplo n.º 2
0
void Indigo::Render::UILayer::on_losecursor()
{
	for (OOBase::Vector<OOBase::WeakPtr<UIDrawable>,OOBase::ThreadLocalAllocator>::iterator i=m_cursor_hits.begin();i;++i)
	{
		OOBase::SharedPtr<UIDrawable> d = i->lock();
		if (d)
			d->on_cursorenter(false);
	}
	m_cursor_hits.clear();
}