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.
This commit is contained in:
Thomas Goyne 2012-01-27 19:23:26 +00:00
parent 2d5df24fd6
commit 0dc0135f9a
2 changed files with 19 additions and 8 deletions

View File

@ -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();

View File

@ -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);