From 0dc0135f9aed5bc37a852839aa1db58f16603d24 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 27 Jan 2012 19:23:26 +0000 Subject: [PATCH] Select the appropriate entry in the zoom dropdown when the zoom is changed externally so that keyboard navigation works. Updates #1433. Originally committed to SVN as r6379. --- aegisub/src/video_display.cpp | 23 ++++++++++++++++------- aegisub/src/video_display.h | 4 +++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/aegisub/src/video_display.cpp b/aegisub/src/video_display.cpp index 7d8645faf..0a2dfb0dd 100644 --- a/aegisub/src/video_display.cpp +++ b/aegisub/src/video_display.cpp @@ -110,7 +110,7 @@ VideoDisplay::VideoDisplay( { zoomBox->SetValue(wxString::Format("%g%%", zoomValue * 100.)); zoomBox->Bind(wxEVT_COMMAND_COMBOBOX_SELECTED, &VideoDisplay::SetZoomFromBox, this); - zoomBox->Bind(wxEVT_COMMAND_TEXT_ENTER, &VideoDisplay::SetZoomFromBox, this); + zoomBox->Bind(wxEVT_COMMAND_TEXT_ENTER, &VideoDisplay::SetZoomFromBoxText, this); con->videoController->Bind(EVT_FRAME_READY, &VideoDisplay::UploadFrameData, this); slots.push_back(con->videoController->AddVideoOpenListener(&VideoDisplay::OnVideoOpen, this)); @@ -395,20 +395,29 @@ void VideoDisplay::OnKeyDown(wxKeyEvent &event) { void VideoDisplay::SetZoom(double value) { zoomValue = std::max(value, .125); - zoomBox->SetValue(wxString::Format("%g%%", zoomValue * 100.)); + zoomBox->SetSelection(value / .125 - 1); + zoomBox->ChangeValue(wxString::Format("%g%%", zoomValue * 100.)); UpdateSize(true); } void VideoDisplay::SetZoomFromBox(wxCommandEvent &) { - wxString strValue = zoomBox->GetValue(); - strValue.EndsWith("%", &strValue); - double value; - if (strValue.ToDouble(&value)) { - zoomValue = value / 100.; + int sel = zoomBox->GetSelection(); + if (sel != wxNOT_FOUND) { + zoomValue = (sel + 1) * .125; UpdateSize(true); } } +void VideoDisplay::SetZoomFromBoxText(wxCommandEvent &) { + wxString strValue = zoomBox->GetValue(); + if (strValue.EndsWith("%")) + strValue.RemoveLast(); + + double value; + if (strValue.ToDouble(&value)) + SetZoom(value / 100.); +} + void VideoDisplay::SetTool(VisualToolBase *new_tool) { toolBar->ClearTools(); toolBar->Realize(); diff --git a/aegisub/src/video_display.h b/aegisub/src/video_display.h index 8c152a07d..7d23096a9 100644 --- a/aegisub/src/video_display.h +++ b/aegisub/src/video_display.h @@ -132,8 +132,10 @@ class VideoDisplay : public wxGLCanvas { /// @brief Set the size of the display based on the current zoom and video resolution /// @param force Force the size to be set based on zoom even in detached mode void UpdateSize(bool force = false); - /// @brief Set the zoom level to that indicated by the dropdown + /// Set the zoom level to that indicated by the dropdown void SetZoomFromBox(wxCommandEvent&); + /// Set the zoom level to that indicated by the text + void SetZoomFromBoxText(wxCommandEvent&); /// @brief Key event handler void OnKeyDown(wxKeyEvent &event);