QPoint LvlScene::getViewportPos() { QPoint vpPos(0,0); if(_viewPort) { vpPos.setX(this->_viewPort->horizontalScrollBar()->value()); vpPos.setY(this->_viewPort->verticalScrollBar()->value()); } return vpPos; }
/* returns the position of the top left corner of the widget in "window viewport coordinates" window viewport coordinates: top y = 0, bottom y = -viewport.h */ KPosition KWidget::getViewportPos () const { KPosition vpPos((int)matrix[TX], (int)matrix[TY]); if (parent) { return vpPos + parent->getViewportPos(); } return vpPos; }
// Sets the layer's position void CocosLayerView::setPosition(const ichigo::Point &pos) { LayerView::setPosition(pos); if (_ccLayer) { // Get the scene's viewport's position Point vpPos(0, 0); if (_parent) { vpPos = _parent->getPosition(); } // Set new position , take into account viewport position CCPoint newPos; newPos.x = pos.x + (vpPos.x * _viewportPosMultiplier.x); newPos.y = pos.y + (vpPos.y * _viewportPosMultiplier.y); // Set the position _ccLayer->setPosition(newPos); } }