ui::Point GameModel::AdjustZoomCoords(ui::Point position) { if (!GetZoomEnabled()) return position; int zoomFactor = GetZoomFactor(); ui::Point zoomWindowPosition = GetZoomWindowPosition(); ui::Point zoomWindowSize = ui::Point(GetZoomSize()*zoomFactor, GetZoomSize()*zoomFactor); if (position.X >= zoomWindowPosition.X && position.X >= zoomWindowPosition.Y && position.X <= zoomWindowPosition.X+zoomWindowSize.X && position.Y <= zoomWindowPosition.Y+zoomWindowSize.Y) return ((position-zoomWindowPosition)/GetZoomFactor())+GetZoomPosition(); return position; }
bool GameModel::MouseInZoom(ui::Point position) { if (!GetZoomEnabled()) return false; int zoomFactor = GetZoomFactor(); ui::Point zoomWindowPosition = GetZoomWindowPosition(); ui::Point zoomWindowSize = ui::Point(GetZoomSize()*zoomFactor, GetZoomSize()*zoomFactor); if (position.X >= zoomWindowPosition.X && position.X >= zoomWindowPosition.Y && position.X <= zoomWindowPosition.X+zoomWindowSize.X && position.Y <= zoomWindowPosition.Y+zoomWindowSize.Y) return true; return false; }
void SlideShowLayerAnim::LoadImage() { Texture2D *tex = new Texture2D(mImageFileNames[mCurImage]); Vec2 zoomSize = GetZoomSize(ZoomModeFit,MakeVec2(800,600),tex->GetSize()); Rect rect; rect.mMin[0] = (800 - zoomSize[0]) / 2; rect.mMin[1] = (600 - zoomSize[1]) / 2; rect.mMax = rect.mMin + zoomSize; ImageLayer *layer = new ImageLayer(rect,tex); ConstLayerAnim *imageLayerAnim = new ConstLayerAnim(layer); layer->Unref(); tex->Unref(); if(mLayerAnim) { const LayerAnim *prevLayerAnim = mLayerAnim; mLayerAnim = new SlideLayerAnim(prevLayerAnim, imageLayerAnim, MakeRect(0,0,800,600), SlideTransition::SlideOffToBottom, AnimCurve::EaseIn, .5f); imageLayerAnim->Unref(); prevLayerAnim->Unref(); } else { mLayerAnim = imageLayerAnim; } }