diff --git a/aegisub/video_context.cpp b/aegisub/video_context.cpp index 1dd207a89..32f1ae36e 100644 --- a/aegisub/video_context.cpp +++ b/aegisub/video_context.cpp @@ -123,7 +123,9 @@ VideoContext::~VideoContext () { //////////////// // Get Instance VideoContext *VideoContext::Get() { - if (!instance) instance = new VideoContext; + if (!instance) { + instance = new VideoContext; + } return instance; } @@ -277,8 +279,8 @@ void VideoContext::SetVideo(const wxString &filename) { Options.AddToRecentList(filename,_T("Recent vid")); // Get frame - UpdateDisplays(true); frame_n = 0; + //UpdateDisplays(true); Refresh(true,true); } diff --git a/aegisub/video_display.cpp b/aegisub/video_display.cpp index 0bc3e1dbd..7bf07bd93 100644 --- a/aegisub/video_display.cpp +++ b/aegisub/video_display.cpp @@ -36,7 +36,7 @@ //////////// // Includes -#include "setup.h" +#include #include #include #include @@ -78,8 +78,8 @@ enum { // Event table BEGIN_EVENT_TABLE(VideoDisplay, wxGLCanvas) EVT_MOUSE_EVENTS(VideoDisplay::OnMouseEvent) - EVT_KEY_DOWN(VideoDisplay::OnKey) EVT_LEAVE_WINDOW(VideoDisplay::OnMouseLeave) + EVT_KEY_DOWN(VideoDisplay::OnKey) EVT_PAINT(VideoDisplay::OnPaint) EVT_SIZE(VideoDisplay::OnSizeEvent) EVT_ERASE_BACKGROUND(VideoDisplay::OnEraseBackground) @@ -100,8 +100,11 @@ VideoDisplay::VideoDisplay(wxWindow* parent, wxWindowID id, const wxPoint& pos, : wxGLCanvas (parent, id, attribList, pos, size, style, name) { // Set options + locked = false; ControlSlider = NULL; PositionDisplay = NULL; + w=h=dx2=dy2=8; + dx1=dy1=0; origSize = size; zoomValue = 1.0; freeSize = false; @@ -242,12 +245,15 @@ void VideoDisplay::UpdateSize() { // Loaded? VideoContext *con = VideoContext::Get(); if (!con->IsLoaded()) return; + if (!IsShownOnScreen()) return; // Get size if (con->GetAspectRatioType() == 0) w = con->GetWidth() * zoomValue; else w = con->GetHeight() * zoomValue * con->GetAspectRatioValue(); h = con->GetHeight() * zoomValue; int _w,_h; + if (w <= 1 || h <= 1) return; + locked = true; // Set the size for this control SetSizeHints(w,h,w,h); @@ -261,6 +267,7 @@ void VideoDisplay::UpdateSize() { SetClientSize(w,h); // Refresh + locked = false; Refresh(false); } @@ -288,13 +295,17 @@ void VideoDisplay::OnPaint(wxPaintEvent& event) { ////////////// // Size Event void VideoDisplay::OnSizeEvent(wxSizeEvent &event) { - Refresh(false); + //Refresh(false); + event.Skip(); } /////////////// // Mouse stuff void VideoDisplay::OnMouseEvent(wxMouseEvent& event) { + // Locked? + if (locked) return; + // Disable when playing if (VideoContext::Get()->IsPlaying()) return; @@ -339,7 +350,7 @@ void VideoDisplay::OnKey(wxKeyEvent &event) { void VideoDisplay::OnMouseLeave(wxMouseEvent& event) { if (VideoContext::Get()->IsPlaying()) return; visual->OnMouseEvent(event); - tracker->bTrackerEditing = 0; + if (tracker) tracker->bTrackerEditing = 0; } diff --git a/aegisub/video_display.h b/aegisub/video_display.h index 875e9f1d8..9bf7fdf85 100644 --- a/aegisub/video_display.h +++ b/aegisub/video_display.h @@ -70,6 +70,7 @@ private: wxSize origSize; int w,h; int dx1,dx2,dy1,dy2; + bool locked; void OnPaint(wxPaintEvent& event); void OnKey(wxKeyEvent &event); diff --git a/aegisub/video_display_visual.cpp b/aegisub/video_display_visual.cpp index 28159e23a..0a2abe804 100644 --- a/aegisub/video_display_visual.cpp +++ b/aegisub/video_display_visual.cpp @@ -756,7 +756,7 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) { SubtitlesGrid *grid = VideoContext::Get()->grid; bool hasOverlay = false; bool realTime = Options.AsBool(_T("Video Visual Realtime")); - parent->tracker->OnMouseEvent(event); + if (parent->tracker) parent->tracker->OnMouseEvent(event); // Text of current coords int vx = (sw * x + w/2) / w;