From 564e270e54c5e9850909560ffc4b1b73437c362f Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sun, 5 Mar 2006 20:31:04 +0000 Subject: [PATCH] Pomyk's no focus on scrollbars patch Originally committed to SVN as r208. --- core/audio_box.cpp | 17 +++++++++++++++++ core/audio_box.h | 8 ++++++++ core/video_provider_lavc.cpp | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/core/audio_box.cpp b/core/audio_box.cpp index c6b8e983b..47bd6c4a8 100644 --- a/core/audio_box.cpp +++ b/core/audio_box.cpp @@ -61,6 +61,7 @@ wxPanel(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL|wxBORDER_RAISE // Controls audioScroll = new wxScrollBar(this,Audio_Scrollbar); + audioScroll->PushEventHandler(new FocusEvent()); audioScroll->SetToolTip(_("Seek bar")); Sash = new wxSashWindow(this,Audio_Sash,wxDefaultPosition,wxDefaultSize,wxCLIP_CHILDREN | wxSW_3DBORDER); sashSizer = new wxBoxSizer(wxVERTICAL); @@ -73,10 +74,13 @@ wxPanel(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL|wxBORDER_RAISE audioDisplay->ScrollBar = audioScroll; audioDisplay->box = this; HorizontalZoom = new wxSlider(this,Audio_Horizontal_Zoom,50,0,100,wxDefaultPosition,wxSize(-1,20),wxSL_VERTICAL); + HorizontalZoom->PushEventHandler(new FocusEvent()); HorizontalZoom->SetToolTip(_("Horizontal zoom")); VerticalZoom = new wxSlider(this,Audio_Vertical_Zoom,50,0,100,wxDefaultPosition,wxSize(-1,20),wxSL_VERTICAL|wxSL_INVERSE); + VerticalZoom->PushEventHandler(new FocusEvent()); VerticalZoom->SetToolTip(_("Vertical zoom")); VolumeBar = new wxSlider(this,Audio_Volume,50,0,100,wxDefaultPosition,wxSize(-1,20),wxSL_VERTICAL|wxSL_INVERSE); + VolumeBar->PushEventHandler(new FocusEvent()); VolumeBar->SetToolTip(_("Audio Volume")); VerticalLink = new ToggleBitmap(this,Audio_Vertical_Link,wxBITMAP(toggle_audio_link)); VerticalLink->SetToolTip(_("Link vertical zoom and volxmlume sliders")); @@ -587,3 +591,16 @@ void AudioBox::OnLeadOut(wxCommandEvent &event) { audioDisplay->SetFocus(); audioDisplay->AddLead(false,true); } + + +////////////////////////////////////////// +// Focus event handling for the scrollbar +BEGIN_EVENT_TABLE(FocusEvent,wxEvtHandler) + EVT_SET_FOCUS(FocusEvent::OnSetFocus) +END_EVENT_TABLE() + +void FocusEvent::OnSetFocus(wxFocusEvent &event) { + wxWindow *previous = event.GetWindow(); + if (previous) previous->SetFocus(); +} + diff --git a/core/audio_box.h b/core/audio_box.h index a23486179..ced354cb8 100644 --- a/core/audio_box.h +++ b/core/audio_box.h @@ -127,6 +127,14 @@ public: }; +class FocusEvent : public wxEvtHandler { + +private: + void OnSetFocus(wxFocusEvent &event); + DECLARE_EVENT_TABLE() +}; + + /////// // IDs enum { diff --git a/core/video_provider_lavc.cpp b/core/video_provider_lavc.cpp index b5c38f771..3ef5ad1ea 100644 --- a/core/video_provider_lavc.cpp +++ b/core/video_provider_lavc.cpp @@ -333,7 +333,7 @@ wxBitmap LAVCVideoProvider::GetFrame(int n) { if (mkv_ReadFrame(mkv.file,0,&rt,&startTime,&endTime,&filePos,&frameSize,&frameFlags) == 0) { result = av_seek_frame(formatContext,vidStream,filePos,AVSEEK_FLAG_BYTE | AVSEEK_FLAG_BACKWARD); int curpos = 0; - for (int i=0;i