tags tweak, rework canvas lock/refresh, vgui/cgui segv if closed while playing
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / canvas.h
index 9a78095eacea972c62543eafe57028edc0e39d21..775df7d016c0bfd4455d933deb20aecbc92cce63 100644 (file)
 #ifndef CANVAS_H
 #define CANVAS_H
 
+#include "canvas.inc"
 #include "edl.inc"
 #include "guicast.h"
 #include "mwindow.inc"
 #include "videodevice.inc"
-
 // Output for all X11 video
 
-class CanvasOutput;
-class CanvasFullScreen;
-class CanvasXScroll;
-class CanvasYScroll;
-class CanvasPopup;
-class CanvasFullScreenPopup;
-class CanvasToggleControls;
-
 // The EDL arguments can be set to 0 if the canvas_w and canvas_h are used
 class Canvas
 {
 public:
-       Canvas(MWindow *mwindow,
-               BC_WindowBase *subwindow,
-               int x,
-               int y,
-               int w,
-               int h,
-               int output_w,
-               int output_h,
+       Canvas(MWindow *mwindow, BC_WindowBase *subwindow,
+               int x, int y, int w, int h,
+               int output_w, int output_h,
                int use_scrollbars);
        virtual ~Canvas();
 
        void reset();
 // Get dimensions given a zoom
        void calculate_sizes(float aspect_ratio,
-               int output_w,
-               int output_h,
-               float zoom,
-               int &w,
-               int &h);
-// Lock access to the canvas pointer.
-// Must be called before get_canvas or locking the canvas.
-       void lock_canvas(const char *location);
+               int output_w, int output_h, float zoom,
+               int &w, int &h);
+// Lock canvas pointer and window
+       BC_WindowBase *lock_canvas(const char *loc);
        void unlock_canvas();
-       int is_locked();
 
        void create_objects(EDL *edl);
        void set_cursor(int cursor);
@@ -88,21 +70,23 @@ public:
        virtual void status_event() {};
 
 
-       virtual void reset_camera() {};
-       virtual void reset_projector() {};
-       virtual void zoom_resize_window(float percentage) {};
-       virtual void zoom_auto() {};
-       virtual int cursor_leave_event() { return 0; };
-       virtual int cursor_enter_event() { return 0; };
-       virtual int button_release_event() { return 0; };
+       virtual void reset_camera() {}
+       virtual void reset_projector() {}
+       virtual void camera_keyframe() {}
+       virtual void projector_keyframe() {}
+       virtual void zoom_resize_window(float percentage) {}
+       virtual void zoom_auto() {}
+       virtual int cursor_leave_event() { return 0; }
+       virtual int cursor_enter_event() { return 0; }
+       virtual int button_release_event() { return 0; }
        virtual int button_press_event();
-       virtual int cursor_motion_event() { return 0; };
+       virtual int cursor_motion_event() { return 0; }
        virtual int need_overlays() { return 1; }
-       virtual void draw_overlays() { };
-       virtual void toggle_controls() { } ;
-       virtual int get_cwindow_controls() { return 0; };
-       virtual int get_fullscreen() { return 0; }
-       virtual void set_fullscreen(int value) { };
+       virtual void draw_overlays() {}
+       virtual void toggle_controls() {}
+       virtual int get_cwindow_controls() { return 0; }
+       virtual int get_fullscreen();
+       virtual void set_fullscreen(int value);
 
        int cursor_leave_event_base(BC_WindowBase *caller);
        int cursor_enter_event_base(BC_WindowBase *caller);
@@ -131,6 +115,7 @@ public:
 // passing -1 causes automatic size detection
                int canvas_w = -1,
                int canvas_h = -1);
+       void update_geometry(EDL *edl, int x, int y, int w, int h);
        void reposition_window(EDL *edl, int x, int y, int w, int h);
        virtual void reset_translation() {};
        virtual void close_source() {};
@@ -147,7 +132,7 @@ public:
        void update_refresh(VideoDevice *device, VFrame *output_frame);
 // Redraws the refresh_frame
        virtual void draw_refresh(int flush = 1) {};
-       virtual void clear(int flush=1);
+       virtual void clear(int flash=1);
 
 // Get top left offset of canvas relative to output.
 // Normally negative.  Can be positive if output is smaller than canvas.
@@ -186,6 +171,9 @@ public:
        int get_buttonpress();
 // Gets whatever video surface is enabled
        BC_WindowBase* get_canvas();
+// draw_refresh, with/without locks
+       int refresh(int flush);
+       int redraw(int flush);
 
 // The owner of the canvas
        BC_WindowBase *subwindow;
@@ -213,6 +201,7 @@ public:
 // For cases where video is not enabled on the canvas but processing is
 // occurring for a single frame, this causes the status to update.
        int is_processing;
+       int is_fullscreen;
 // Cursor is inside video surface
        int cursor_inside;
        int view_x;
@@ -227,7 +216,8 @@ public:
 private:
        void get_scrollbars(EDL *edl,
                int &canvas_x, int &canvas_y, int &canvas_w, int &canvas_h);
-       Mutex *canvas_lock;
+// Lock access to the canvas pointer.
+       Condition *canvas_lock;
 };
 
 
@@ -334,6 +324,22 @@ public:
        CanvasToggleControls *toggle_controls;
 };
 
+class CanvasZoomSize : public BC_MenuItem
+{
+public:
+       CanvasZoomSize(Canvas *canvas);
+
+       Canvas *canvas;
+};
+
+class CanvasSizeSubMenu : public BC_SubMenu
+{
+public:
+       CanvasSizeSubMenu(CanvasZoomSize *zoom_size);
+
+       CanvasZoomSize *zoom_size;
+};
+
 class CanvasPopupSize : public BC_MenuItem
 {
 public:
@@ -368,6 +374,22 @@ public:
        Canvas *canvas;
 };
 
+class CanvasPopupCameraKeyframe : public BC_MenuItem
+{
+public:
+       CanvasPopupCameraKeyframe(Canvas *canvas);
+       int handle_event();
+       Canvas *canvas;
+};
+
+class CanvasPopupProjectorKeyframe : public BC_MenuItem
+{
+public:
+       CanvasPopupProjectorKeyframe(Canvas *canvas);
+       int handle_event();
+       Canvas *canvas;
+};
+
 class CanvasToggleControls : public BC_MenuItem
 {
 public: