Example #1
0
GUIComponent *GUIComponent::get_component_at(const Point &point)
{
	if (is_visible() == false)
	{
		return 0;
	}
	else
	{
		Rect parent_rect = get_size();
		if( parent_rect.contains(point) )  
		{
			std::vector<GUIComponent *> children = get_child_components();
			std::size_t pos, size = children.size();

			for( pos=size; pos>0; pos-- )
			{
				GUIComponent *child = children[pos-1];
				if(child->is_visible())
				{
					if (child->get_geometry().contains(point))
					{
						Point P = point;
						P.x -= child->get_geometry().left;
						P.y -= child->get_geometry().top;
						GUIComponent *comp = child->get_component_at(P);
						if (comp)
							return comp;
						else
							return child;
					}
				}
			}
			return this;
		}
		else
		{
			return 0;
		}
	}
}