void MapTilesFrame::zoomOut() { qDebug() << "zooming OUT . . . viewport coordinate: " << getViewportCoordinate(); qDebug() << "viewport size: " << size(); // ZoomEffect *ze = createZoomEffect(QPoint(width() / 2, height() / 2)); // ze->zoomOutEffect(); //以视口中心点为视点缩放(服务器坐标系) QPoint viewportCenterPoint(getViewportCoordinate().x() + getViewportWidth() / 2, getViewportCoordinate().y() - getViewportHeight() / 2); zoomOut(viewportCenterPoint); }
void MFXEditableTable::editItem(FXTableItem* item, FXint how) { if (item == 0) { editEnd(); return; } if (myWriteProtectedCols.find(myEditedCol) != myWriteProtectedCols.end()) { editEnd(); return; } FXTableItem* it = item; myPreviousText = item->getText(); FXint x = getColumnX(myEditedCol) + getRowHeader()->getWidth() + xpos; FXint y = getRowY(myEditedRow) + getColumnHeader()->getHeight() + ypos; FXIcon* icon = item->getIcon(); if (icon) { x += icon->getWidth() + 4; } FXint vw = getViewportWidth(); if (vertical->shown()) { vw -= vertical->getWidth(); } if (vw > getColumnWidth(myEditedCol)) { vw = getColumnWidth(myEditedCol) + x; } myEditor->setText(it->getText()); myEditor->move(x, y); myEditor->resize(vw - x + 1, getRowHeight(myEditedRow) + 1); myEditor->show(); myEditor->raise(); myEditor->setFocus(); if (how == 'I') { myEditor->killSelection(); myEditor->setCursorPos(0); } else if (how == 'A') { myEditor->killSelection(); myEditor->setCursorPos(myEditor->getText().length()); } else { myEditor->selectAll(); } myEditedItem = it; }
void TestMinigame::TestInstance::onMouseMove(int x, int y) { mx = (GLfloat)x / getViewportWidth() * -40 + 20; my = (GLfloat)y / getViewportHeight() * -40 + 20; }
void MapTilesFrame::setViewportCoordinate(const QPoint &requestedPos) { QPoint adjustedPoint; QPoint oldPoint(m_viewportCoordinate); adjustedPoint.rx() = qBound(0, requestedPos.x(), scaleMaps[getScaleLevel()].width - getViewportWidth()); adjustedPoint.ry() = qBound(getViewportHeight(), requestedPos.y(), scaleMaps[getScaleLevel()].height); m_viewportCoordinate = adjustedPoint; qDebug() << "Requested viewportPoint: " << requestedPos << ", adjustedPoint" << adjustedPoint; emit viewportCoordinateChanged(adjustedPoint, oldPoint); }
bool MapTilesFrame::isInCurrentViewport(QPoint serverCoordinate, int scaleLevel) { QPoint relativePoint(convertServerCoordinateToRelativeCoordinate(serverCoordinate, getScaleLevel(), scaleLevel)); return QRect(0,0,getViewportWidth(),getViewportHeight()).contains(relativePoint); }
QPoint MapTilesFrame::convertRelativeCoordinateToServerCoordinate(QPoint relativeCoordinate, int newScaleLevel, int oldScaleLevel) { QPoint nowPos(relativeCoordinate.x() * getViewportWidth() / width() + getViewportCoordinate().x(), getViewportCoordinate().y() - relativeCoordinate.y() * getViewportHeight() / height()); return nowPos * newScaleLevel / oldScaleLevel; }
QSize MapTilesFrame::getViewportSize() const { return QSize(getViewportWidth(), getViewportHeight()); }