From 31de29284d7d33becb1648ebf2247dcbe9d2322a Mon Sep 17 00:00:00 2001 From: Jim Stichnoth Date: Tue, 22 Jan 2013 22:40:20 -0800 Subject: [PATCH] Improve the Manual Zoom experience during video playback. Add new ZOOM* actions to the TV Playback context (with no predefined key bindings), to get away from overloading other key bindings. The old overloads are left intact, but the ZOOM actions are preferred. Double the maximum zoom in/out factors. Remove the behavior of wrapping back to 1.0 when trying to zoom in or out beyond the maximum factor. --- mythtv/libs/libmythtv/tv_actions.h | 12 ++++++ mythtv/libs/libmythtv/tv_play.cpp | 47 +++++++++++++++++++++++- mythtv/libs/libmythtv/videooutwindow.cpp | 20 ++-------- 3 files changed, 62 insertions(+), 17 deletions(-) diff --git a/mythtv/libs/libmythtv/tv_actions.h b/mythtv/libs/libmythtv/tv_actions.h index 39717d686cd..45a514a4611 100644 --- a/mythtv/libs/libmythtv/tv_actions.h +++ b/mythtv/libs/libmythtv/tv_actions.h @@ -121,4 +121,16 @@ #define ACTION_3DTOPANDBOTTOM "3DTOPANDBOTTOM" #define ACTION_3DTOPANDBOTTOMDISCARD "3DTOPANDBOTTOMDISCARD" +/* Zoom mode */ +#define ACTION_ZOOMUP "ZOOMUP" +#define ACTION_ZOOMDOWN "ZOOMDOWN" +#define ACTION_ZOOMLEFT "ZOOMLEFT" +#define ACTION_ZOOMRIGHT "ZOOMRIGHT" +#define ACTION_ZOOMASPECTUP "ZOOMASPECTUP" +#define ACTION_ZOOMASPECTDOWN "ZOOMASPECTDOWN" +#define ACTION_ZOOMIN "ZOOMIN" +#define ACTION_ZOOMOUT "ZOOMOUT" +#define ACTION_ZOOMQUIT "ZOOMQUIT" +#define ACTION_ZOOMCOMMIT "ZOOMCOMMIT" + #endif // TV_ACTIONS_H diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp index ff2b21e6d6f..85662226fb3 100644 --- a/mythtv/libs/libmythtv/tv_play.cpp +++ b/mythtv/libs/libmythtv/tv_play.cpp @@ -810,6 +810,28 @@ void TV::InitKeys(void) "Switch title"), ""); REG_KEY("TV Playback", ACTION_SWITCHANGLE, QT_TRANSLATE_NOOP("MythControls", "Switch angle"), ""); + REG_KEY("TV Playback", ACTION_ZOOMUP, QT_TRANSLATE_NOOP("MythControls", + "Zoom mode - shift up"), ""); + REG_KEY("TV Playback", ACTION_ZOOMDOWN, QT_TRANSLATE_NOOP("MythControls", + "Zoom mode - shift down"), ""); + REG_KEY("TV Playback", ACTION_ZOOMLEFT, QT_TRANSLATE_NOOP("MythControls", + "Zoom mode - shift left"), ""); + REG_KEY("TV Playback", ACTION_ZOOMRIGHT, QT_TRANSLATE_NOOP("MythControls", + "Zoom mode - shift right"), ""); + REG_KEY("TV Playback", ACTION_ZOOMASPECTUP, + QT_TRANSLATE_NOOP("MythControls", + "Zoom mode - increase aspect ratio"), ""); + REG_KEY("TV Playback", ACTION_ZOOMASPECTDOWN, + QT_TRANSLATE_NOOP("MythControls", + "Zoom mode - decrease aspect ratio"), ""); + REG_KEY("TV Playback", ACTION_ZOOMIN, QT_TRANSLATE_NOOP("MythControls", + "Zoom mode - zoom in"), ""); + REG_KEY("TV Playback", ACTION_ZOOMOUT, QT_TRANSLATE_NOOP("MythControls", + "Zoom mode - zoom out"), ""); + REG_KEY("TV Playback", ACTION_ZOOMQUIT, QT_TRANSLATE_NOOP("MythControls", + "Zoom mode - quit and abandon changes"), ""); + REG_KEY("TV Playback", ACTION_ZOOMCOMMIT, QT_TRANSLATE_NOOP("MythControls", + "Zoom mode - commit changes"), ""); /* Interactive Television keys */ REG_KEY("TV Playback", ACTION_MENURED, QT_TRANSLATE_NOOP("MythControls", @@ -3949,7 +3971,30 @@ bool TV::ManualZoomHandleAction(PlayerContext *actx, const QStringList &actions) bool end_manual_zoom = false; bool handled = true; - if (has_action(ACTION_UP, actions) || + if (has_action(ACTION_ZOOMUP, actions)) + actx->player->Zoom(kZoomUp); + else if (has_action(ACTION_ZOOMDOWN, actions)) + actx->player->Zoom(kZoomDown); + else if (has_action(ACTION_ZOOMLEFT, actions)) + actx->player->Zoom(kZoomLeft); + else if (has_action(ACTION_ZOOMRIGHT, actions)) + actx->player->Zoom(kZoomRight); + else if (has_action(ACTION_ZOOMASPECTUP, actions)) + actx->player->Zoom(kZoomAspectUp); + else if (has_action(ACTION_ZOOMASPECTDOWN, actions)) + actx->player->Zoom(kZoomAspectDown); + else if (has_action(ACTION_ZOOMIN, actions)) + actx->player->Zoom(kZoomIn); + else if (has_action(ACTION_ZOOMOUT, actions)) + actx->player->Zoom(kZoomOut); + else if (has_action(ACTION_ZOOMQUIT, actions)) + { + actx->player->Zoom(kZoomHome); + end_manual_zoom = true; + } + else if (has_action(ACTION_ZOOMCOMMIT, actions)) + SetManualZoom(actx, false, tr("Zoom Committed")); + else if (has_action(ACTION_UP, actions) || has_action(ACTION_CHANNELUP, actions)) { actx->player->Zoom(kZoomUp); diff --git a/mythtv/libs/libmythtv/videooutwindow.cpp b/mythtv/libs/libmythtv/videooutwindow.cpp index c4ceae4bd57..ed265092e50 100644 --- a/mythtv/libs/libmythtv/videooutwindow.cpp +++ b/mythtv/libs/libmythtv/videooutwindow.cpp @@ -47,10 +47,10 @@ static QSize fix_alignment(QSize raw); static float fix_aspect(float raw); static float snap(float value, float snapto, float diff); -const float VideoOutWindow::kManualZoomMaxHorizontalZoom = 2.0f; -const float VideoOutWindow::kManualZoomMaxVerticalZoom = 2.0f; -const float VideoOutWindow::kManualZoomMinHorizontalZoom = 0.5f; -const float VideoOutWindow::kManualZoomMinVerticalZoom = 0.5f; +const float VideoOutWindow::kManualZoomMaxHorizontalZoom = 4.0f; +const float VideoOutWindow::kManualZoomMaxVerticalZoom = 4.0f; +const float VideoOutWindow::kManualZoomMinHorizontalZoom = 0.25f; +const float VideoOutWindow::kManualZoomMinVerticalZoom = 0.25f; const int VideoOutWindow::kManualZoomMaxMove = 50; VideoOutWindow::VideoOutWindow() : @@ -890,12 +890,6 @@ void VideoOutWindow::Zoom(ZoomDirection direction) mz_scale_h *= 1.025f; mz_scale_v *= 1.025f; } - else - { - float ratio = mz_scale_v / mz_scale_h; - mz_scale_h = 1.0f; - mz_scale_v = ratio * mz_scale_h; - } } else if (kZoomOut == direction) { @@ -905,12 +899,6 @@ void VideoOutWindow::Zoom(ZoomDirection direction) mz_scale_h *= 1.0f / 1.025f; mz_scale_v *= 1.0f / 1.025f; } - else - { - float ratio = mz_scale_v / mz_scale_h; - mz_scale_h = 1.0f; - mz_scale_v = ratio * mz_scale_h; - } } else if (kZoomAspectUp == direction) {