void RenderContainer::handleMouseMove(int button, int x, int y) { bool isabovesomething = false; std::list<RenderObject *>::const_iterator itr = _objlist.begin(); for (;itr != _objlist.end() ; ++itr) { RenderObject * current = *itr; if (!current->getVisible()) continue; if (!current->hitTest(x, y)) { continue; } if (_lasthoverobj!=current) { if (_lasthoverobj) _lasthoverobj->handleMouseLeave(button); current->handleMouseEnter(button); _lasthoverobj = current; } isabovesomething = true; if (current->handleMouseMove(button, x, y)) break; } if (!isabovesomething) { if (_lasthoverobj) _lasthoverobj->handleMouseLeave(button); _lasthoverobj = NULL; } }
void RenderContainer::handleMouseRelease(int button, int x, int y) { std::list<RenderObject *>::const_iterator itr = _objlist.begin(); for (;itr != _objlist.end() ; ++itr) { RenderObject * current = *itr; if (!current->getVisible()) continue; if (!current->hitTest(x, y)) continue; if (current->handleMouseRelease(button, x, y)) break; } }
void RenderContainer::renderObjects(IplImage* frame) { CvRect dirtyRT; dirtyRT.x = -1; dirtyRT.y = -1; std::list<RenderObject *>::const_iterator itr = _objlist.begin(); for (;itr != _objlist.end() ; ++itr) { RenderObject * current = *itr; if (!current->getVisible()) continue; CvRect ObjRect; ObjRect.x = current->getX(); ObjRect.y = current->getY(); ObjRect.width = current->getWidth(); ObjRect.height = current->getHeight(); if (!current->getDirtyFlag()) { CvRect intersect = cvRectIntersection(dirtyRT, ObjRect); if (intersect.width<=0 || intersect.height<=0) { continue; } } current->renderSelf(frame); dirtyRT.x = std::min(dirtyRT.x, ObjRect.x); dirtyRT.y = std::min(dirtyRT.y, ObjRect.y); int mergedRight = std::max(dirtyRT.x + dirtyRT.width, ObjRect.x + ObjRect.width); int mergedBottom = std::max(dirtyRT.y + dirtyRT.height, ObjRect.y + ObjRect.height); dirtyRT.width = mergedRight - dirtyRT.x; dirtyRT.height = mergedBottom - dirtyRT.y; } }