summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-05-10 16:37:16 +0100
committerCarl Hetherington <cth@carlh.net>2019-05-10 23:43:55 +0100
commite153d7f5dc128d97160e41bdda3c4e4a05c7140b (patch)
tree707f9798a7a6ecd027bc64894351430c6da7b940
parent45b0314b61c3c3b588648fb410f82546a4e5b40c (diff)
Fix update on drag with GL canvas.
-rw-r--r--src/wx/film_viewer.cc5
-rw-r--r--src/wx/gl_video_view.cc20
-rw-r--r--src/wx/gl_video_view.h4
-rw-r--r--src/wx/simple_video_view.cc7
-rw-r--r--src/wx/simple_video_view.h2
-rw-r--r--src/wx/video_view.h1
6 files changed, 33 insertions, 6 deletions
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index 00bc06e9b..cb12a78e2 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -215,9 +215,8 @@ FilmViewer::recreate_butler ()
void
FilmViewer::refresh_view ()
{
- _state_timer.set ("refresh-view");
- _video_view->get()->Refresh ();
- _video_view->get()->Update ();
+ _state_timer.set ("update-view");
+ _video_view->update ();
_state_timer.unset ();
}
diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc
index f75d50f9d..b3f036ded 100644
--- a/src/wx/gl_video_view.cc
+++ b/src/wx/gl_video_view.cc
@@ -41,7 +41,7 @@ GLVideoView::GLVideoView (wxWindow *parent)
{
_canvas = new wxGLCanvas (parent, wxID_ANY, 0, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE);
_context = new wxGLContext (_canvas);
- _canvas->Bind (wxEVT_PAINT, boost::bind(&GLVideoView::paint, this, _1));
+ _canvas->Bind (wxEVT_PAINT, boost::bind(&GLVideoView::paint, this));
_canvas->Bind (wxEVT_SIZE, boost::bind(boost::ref(Sized)));
glGenTextures (1, &_id);
@@ -65,10 +65,26 @@ check_gl_error (char const * last)
}
void
-GLVideoView::paint (wxPaintEvent &)
+GLVideoView::paint ()
{
_canvas->SetCurrent (*_context);
wxPaintDC dc (_canvas);
+ draw ();
+}
+
+void
+GLVideoView::update ()
+{
+ if (!_canvas->IsShownOnScreen()) {
+ return;
+ }
+ wxClientDC dc (_canvas);
+ draw ();
+}
+
+void
+GLVideoView::draw ()
+{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
check_gl_error ("glClear");
diff --git a/src/wx/gl_video_view.h b/src/wx/gl_video_view.h
index cdc9fd530..54c64e4ea 100644
--- a/src/wx/gl_video_view.h
+++ b/src/wx/gl_video_view.h
@@ -37,9 +37,11 @@ public:
wxWindow* get () const {
return _canvas;
}
+ void update ();
private:
- void paint (wxPaintEvent& event);
+ void paint ();
+ void draw ();
wxGLCanvas* _canvas;
wxGLContext* _context;
diff --git a/src/wx/simple_video_view.cc b/src/wx/simple_video_view.cc
index d0b18d421..ef0c96ef2 100644
--- a/src/wx/simple_video_view.cc
+++ b/src/wx/simple_video_view.cc
@@ -118,3 +118,10 @@ SimpleVideoView::paint ()
dc.DrawRectangle (inter_position.x, inter_position.y + (panel_size.GetHeight() - out_size.height) / 2, inter_size.width, inter_size.height);
}
}
+
+void
+SimpleVideoView::update ()
+{
+ _panel->Refresh ();
+ _panel->Update ();
+}
diff --git a/src/wx/simple_video_view.h b/src/wx/simple_video_view.h
index 8b3ec9f0b..40924839f 100644
--- a/src/wx/simple_video_view.h
+++ b/src/wx/simple_video_view.h
@@ -36,6 +36,8 @@ public:
return _panel;
}
+ void update ();
+
private:
void paint ();
diff --git a/src/wx/video_view.h b/src/wx/video_view.h
index 060d982f7..44969ad2d 100644
--- a/src/wx/video_view.h
+++ b/src/wx/video_view.h
@@ -34,6 +34,7 @@ public:
virtual void set_image (boost::shared_ptr<const Image> image) = 0;
virtual wxWindow* get () const = 0;
+ virtual void update () = 0;
boost::signals2::signal<void()> Sized;
};