Fix to video loading, but probably only for me...

Originally committed to SVN as r885.
This commit is contained in:
Rodrigo Braz Monteiro 2007-01-23 20:50:41 +00:00
parent 83cdb12457
commit 19ea57a544
4 changed files with 21 additions and 7 deletions

View file

@ -123,7 +123,9 @@ VideoContext::~VideoContext () {
//////////////// ////////////////
// Get Instance // Get Instance
VideoContext *VideoContext::Get() { VideoContext *VideoContext::Get() {
if (!instance) instance = new VideoContext; if (!instance) {
instance = new VideoContext;
}
return instance; return instance;
} }
@ -277,8 +279,8 @@ void VideoContext::SetVideo(const wxString &filename) {
Options.AddToRecentList(filename,_T("Recent vid")); Options.AddToRecentList(filename,_T("Recent vid"));
// Get frame // Get frame
UpdateDisplays(true);
frame_n = 0; frame_n = 0;
//UpdateDisplays(true);
Refresh(true,true); Refresh(true,true);
} }

View file

@ -36,7 +36,7 @@
//////////// ////////////
// Includes // Includes
#include "setup.h" #include <wx/glcanvas.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
#include <wx/image.h> #include <wx/image.h>
@ -78,8 +78,8 @@ enum {
// Event table // Event table
BEGIN_EVENT_TABLE(VideoDisplay, wxGLCanvas) BEGIN_EVENT_TABLE(VideoDisplay, wxGLCanvas)
EVT_MOUSE_EVENTS(VideoDisplay::OnMouseEvent) EVT_MOUSE_EVENTS(VideoDisplay::OnMouseEvent)
EVT_KEY_DOWN(VideoDisplay::OnKey)
EVT_LEAVE_WINDOW(VideoDisplay::OnMouseLeave) EVT_LEAVE_WINDOW(VideoDisplay::OnMouseLeave)
EVT_KEY_DOWN(VideoDisplay::OnKey)
EVT_PAINT(VideoDisplay::OnPaint) EVT_PAINT(VideoDisplay::OnPaint)
EVT_SIZE(VideoDisplay::OnSizeEvent) EVT_SIZE(VideoDisplay::OnSizeEvent)
EVT_ERASE_BACKGROUND(VideoDisplay::OnEraseBackground) 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) : wxGLCanvas (parent, id, attribList, pos, size, style, name)
{ {
// Set options // Set options
locked = false;
ControlSlider = NULL; ControlSlider = NULL;
PositionDisplay = NULL; PositionDisplay = NULL;
w=h=dx2=dy2=8;
dx1=dy1=0;
origSize = size; origSize = size;
zoomValue = 1.0; zoomValue = 1.0;
freeSize = false; freeSize = false;
@ -242,12 +245,15 @@ void VideoDisplay::UpdateSize() {
// Loaded? // Loaded?
VideoContext *con = VideoContext::Get(); VideoContext *con = VideoContext::Get();
if (!con->IsLoaded()) return; if (!con->IsLoaded()) return;
if (!IsShownOnScreen()) return;
// Get size // Get size
if (con->GetAspectRatioType() == 0) w = con->GetWidth() * zoomValue; if (con->GetAspectRatioType() == 0) w = con->GetWidth() * zoomValue;
else w = con->GetHeight() * zoomValue * con->GetAspectRatioValue(); else w = con->GetHeight() * zoomValue * con->GetAspectRatioValue();
h = con->GetHeight() * zoomValue; h = con->GetHeight() * zoomValue;
int _w,_h; int _w,_h;
if (w <= 1 || h <= 1) return;
locked = true;
// Set the size for this control // Set the size for this control
SetSizeHints(w,h,w,h); SetSizeHints(w,h,w,h);
@ -261,6 +267,7 @@ void VideoDisplay::UpdateSize() {
SetClientSize(w,h); SetClientSize(w,h);
// Refresh // Refresh
locked = false;
Refresh(false); Refresh(false);
} }
@ -288,13 +295,17 @@ void VideoDisplay::OnPaint(wxPaintEvent& event) {
////////////// //////////////
// Size Event // Size Event
void VideoDisplay::OnSizeEvent(wxSizeEvent &event) { void VideoDisplay::OnSizeEvent(wxSizeEvent &event) {
Refresh(false); //Refresh(false);
event.Skip();
} }
/////////////// ///////////////
// Mouse stuff // Mouse stuff
void VideoDisplay::OnMouseEvent(wxMouseEvent& event) { void VideoDisplay::OnMouseEvent(wxMouseEvent& event) {
// Locked?
if (locked) return;
// Disable when playing // Disable when playing
if (VideoContext::Get()->IsPlaying()) return; if (VideoContext::Get()->IsPlaying()) return;
@ -339,7 +350,7 @@ void VideoDisplay::OnKey(wxKeyEvent &event) {
void VideoDisplay::OnMouseLeave(wxMouseEvent& event) { void VideoDisplay::OnMouseLeave(wxMouseEvent& event) {
if (VideoContext::Get()->IsPlaying()) return; if (VideoContext::Get()->IsPlaying()) return;
visual->OnMouseEvent(event); visual->OnMouseEvent(event);
tracker->bTrackerEditing = 0; if (tracker) tracker->bTrackerEditing = 0;
} }

View file

@ -70,6 +70,7 @@ private:
wxSize origSize; wxSize origSize;
int w,h; int w,h;
int dx1,dx2,dy1,dy2; int dx1,dx2,dy1,dy2;
bool locked;
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
void OnKey(wxKeyEvent &event); void OnKey(wxKeyEvent &event);

View file

@ -756,7 +756,7 @@ void VideoDisplayVisual::OnMouseEvent (wxMouseEvent &event) {
SubtitlesGrid *grid = VideoContext::Get()->grid; SubtitlesGrid *grid = VideoContext::Get()->grid;
bool hasOverlay = false; bool hasOverlay = false;
bool realTime = Options.AsBool(_T("Video Visual Realtime")); bool realTime = Options.AsBool(_T("Video Visual Realtime"));
parent->tracker->OnMouseEvent(event); if (parent->tracker) parent->tracker->OnMouseEvent(event);
// Text of current coords // Text of current coords
int vx = (sw * x + w/2) / w; int vx = (sw * x + w/2) / w;