diff --git a/docs/index.html b/docs/index.html index 5616fa59c..6dcd3d432 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2082,15 +2082,20 @@ Backspace, Alt + Up arrow - Select previous snapshot + Select previous image Control + Left arrow Control + Left arrow - Select next snapshot + Select next image Control + Right arrow Control + Right arrow + + Toogle image zoom + Control + Return + Control + Return + Remove from 'Recently Played' or 'Most Popular' folder Control + X diff --git a/src/common/PJoystickHandler.cxx b/src/common/PJoystickHandler.cxx index 5b38d8d51..b5ddb1cc3 100644 --- a/src/common/PJoystickHandler.cxx +++ b/src/common/PJoystickHandler.cxx @@ -1520,7 +1520,9 @@ PhysicalJoystickHandler::DefaultMenuMapping = { {Event::UINavNext, JOY_CTRL_NONE, JoyAxis::X, JoyDir::POS}, {Event::UITabNext, 0, JoyAxis::X, JoyDir::POS}, {Event::UIUp, JOY_CTRL_NONE, JoyAxis::Y, JoyDir::NEG}, + {Event::UIOK, 0 , JoyAxis::Y, JoyDir::NEG}, {Event::UIDown, JOY_CTRL_NONE, JoyAxis::Y, JoyDir::POS}, + {Event::UICancel, 0 , JoyAxis::Y, JoyDir::POS}, {Event::UINavPrev, JOY_CTRL_NONE, JoyAxis::NONE, JoyDir::NONE, 0, JoyHatDir::LEFT}, {Event::UINavNext, JOY_CTRL_NONE, JoyAxis::NONE, JoyDir::NONE, 0, JoyHatDir::RIGHT}, diff --git a/src/gui/LauncherDialog.cxx b/src/gui/LauncherDialog.cxx index 5ed2fe9b6..de9356c1d 100644 --- a/src/gui/LauncherDialog.cxx +++ b/src/gui/LauncherDialog.cxx @@ -839,6 +839,10 @@ void LauncherDialog::handleKeyDown(StellaKey key, StellaMod mod, bool repeated) myRomImageWidget->changeImage(1); break; + case KBDK_RETURN: + myRomImageWidget->toggleImageZoom(); + break; + default: handled = false; break; @@ -932,6 +936,11 @@ Event::Type LauncherDialog::getJoyAxisEvent(int stick, JoyAxis axis, JoyDir adir myEventHandled = true; break; + case Event::UIOK: + myRomImageWidget->toggleImageZoom(); + myEventHandled = true; + break; + default: break; } diff --git a/src/gui/RomImageWidget.cxx b/src/gui/RomImageWidget.cxx index cc8bd9626..458b85cf6 100644 --- a/src/gui/RomImageWidget.cxx +++ b/src/gui/RomImageWidget.cxx @@ -137,6 +137,7 @@ void RomImageWidget::parseProperties(const FSNode& node, bool full) }); } + myZoomMode = false; #ifdef IMAGE_SUPPORT if(!full) { @@ -211,6 +212,17 @@ bool RomImageWidget::changeImage(int direction) return false; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void RomImageWidget::toggleImageZoom() +{ +#ifdef IMAGE_SUPPORT + myMousePos = Common::Point(_w >> 1, myImageHeight >> 1); + myZoomMode = !myIsZoomed; + myZoomTimer = myZoomMode ? DELAY_TIME * REQUEST_SPEED : 0; + zoomSurfaces(!myIsZoomed); +#endif +} + #ifdef IMAGE_SUPPORT // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool RomImageWidget::getImageList(const string& propName, const string& romName, @@ -282,13 +294,14 @@ bool RomImageWidget::loadImage(const string& fileName) if(mySurfaceIsValid) { mySrcRect = mySurface->srcRect(); - zoomSurface(false, true); + zoomSurfaces(false, true); } if(mySurface) mySurface->setVisible(mySurfaceIsValid); - myZoomTimer = 0; + if (!myZoomMode) + myZoomTimer = 0; setDirty(); return mySurfaceIsValid; } @@ -351,7 +364,7 @@ bool RomImageWidget::loadJpg(const string& fileName) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void RomImageWidget::zoomSurface(bool zoomed, bool force) +void RomImageWidget::zoomSurfaces(bool zoomed, bool force) { if(zoomed != myIsZoomed || force) { @@ -395,15 +408,15 @@ void RomImageWidget::zoomSurface(bool zoomed, bool force) myFrameSurface->setDstSize(w + b * 2, h + b * 2); myFrameSurface->frameRect(0, 0, myFrameSurface->width(), myFrameSurface->height(), kColor); - myZoomTimer = DELAY_TIME * REQUEST_SPEED; + myZoomTimer = DELAY_TIME * REQUEST_SPEED; // zoom immediately } - posSurfaces(); + positionSurfaces(); setDirty(); } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void RomImageWidget::posSurfaces() +void RomImageWidget::positionSurfaces() { // Make sure when positioning the image surface that we take // the dialog surface position into account @@ -460,7 +473,7 @@ void RomImageWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount) else if(myMouseArea == Area::RIGHT) changeImage(1); else - zoomSurface(true); + zoomSurfaces(true); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -469,6 +482,7 @@ void RomImageWidget::handleMouseMoved(int x, int y) const Area oldArea = myMouseArea; myMousePos = Common::Point(x, y); + //myZoomMode = false; if(myZoomRect.contains(x, y)) myMouseArea = Area::ZOOM; @@ -484,15 +498,15 @@ void RomImageWidget::handleMouseMoved(int x, int y) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void RomImageWidget::tick() { - if(myMouseArea == Area::ZOOM) + if(myMouseArea == Area::ZOOM || myZoomMode) { myZoomTimer += REQUEST_SPEED; if(myZoomTimer >= DELAY_TIME * REQUEST_SPEED) - zoomSurface(true); + zoomSurfaces(true); } else { - zoomSurface(false); + zoomSurfaces(false); if(myZoomTimer) --myZoomTimer; } @@ -521,7 +535,7 @@ void RomImageWidget::drawWidget(bool hilite) if(mySurfaceIsValid) { s.fillRect(_x, _y, _w, myImageHeight, 0); - posSurfaces(); + positionSurfaces(); } else if(!mySurfaceErrorMsg.empty()) { diff --git a/src/gui/RomImageWidget.hxx b/src/gui/RomImageWidget.hxx index 36a5bcee8..3acc8d5a8 100644 --- a/src/gui/RomImageWidget.hxx +++ b/src/gui/RomImageWidget.hxx @@ -40,6 +40,8 @@ class RomImageWidget : public Widget void clearProperties(); void reloadProperties(const FSNode& node); bool changeImage(int direction = 1); + // Toggle zoom via keyboard + void toggleImageZoom(); uInt64 pendingLoadTime() { return myMaxLoadTime * timeFactor; } @@ -61,9 +63,9 @@ class RomImageWidget : public Widget bool loadPng(const string& fileName); bool loadJpg(const string& fileName); - void zoomSurface(bool zoomed, bool force = false); + void zoomSurfaces(bool zoomed, bool force = false); + void positionSurfaces(); #endif - void posSurfaces(); private: // Pending load time safety factor @@ -103,6 +105,9 @@ class RomImageWidget : public Widget // Zoom icon rectangle Common::Rect myZoomRect; + // True for keyboard zooming + bool myZoomMode{false}; + // Surface zoom status bool myIsZoomed{false};