Fix update on drag with GL canvas.
authorCarl Hetherington <cth@carlh.net>
Fri, 10 May 2019 15:37:16 +0000 (16:37 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 10 May 2019 22:43:55 +0000 (23:43 +0100)
src/wx/film_viewer.cc
src/wx/gl_video_view.cc
src/wx/gl_video_view.h
src/wx/simple_video_view.cc
src/wx/simple_video_view.h
src/wx/video_view.h

index 00bc06e9b7272e520402a3892a9dff2b153e0f12..cb12a78e2fc797266b973e7d8b65ea2788dc8cd6 100644 (file)
@@ -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 ();
 }
 
index f75d50f9dc8fd9716881458ee6cd8c0440fe66c1..b3f036ded57d30a3949724c447f5e399c7ecf4f0 100644 (file)
@@ -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");
 
index cdc9fd530ae3045157cdcf003d19421355df145d..54c64e4eae7c80c7ce31e441535a16a10ea0cca5 100644 (file)
@@ -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;
index d0b18d42102bcfa11462796243014bacc8824149..ef0c96ef2589a5baeb849301dc1104ceabfe3c19 100644 (file)
@@ -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 ();
+}
index 8b3ec9f0bda91233857c978b25116c99baf46d20..40924839fad7dc900f97c2b6bbb14a92ec810075 100644 (file)
@@ -36,6 +36,8 @@ public:
                return _panel;
        }
 
+       void update ();
+
 private:
        void paint ();
 
index 060d982f737c31499fb608f10d3145924a6dcb46..44969ad2d9c63cc49e0541d71afef358bbbd54d3 100644 (file)
@@ -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;
 };