b209af3a60f019284d049284695ddf8393d9349e
[goodguy/history.git] / cinelerra-5.0 / guicast / vicon.h
1 #ifndef __VICON_H__
2 #define __VICON_H__
3
4 #include "arraylist.h"
5 #include "bcpopup.h"
6 #include "bcwindowbase.h"
7 #include "thread.h"
8 #include "vicon.inc"
9 #include "vframe.h"
10
11 class ViewPopup : public BC_Popup {
12 public:
13         VIconThread *vt;
14         int keypress_event();
15         int button_press_event();
16         void draw_vframe(VFrame *frame);
17
18         ViewPopup(VIconThread *vt, VFrame *frame, int x, int y, int w, int h);
19         ~ViewPopup();
20 };
21
22 class VIcon
23 {
24 public:
25         int vw, vh, vcmdl, in_use;
26         ArrayList<VFrame *> images;
27         int64_t seq_no;
28         double age, period;
29
30         double frame_rate() { return 1000/period; }
31         void frame_rate(double r) { period = 1000/r; }
32         int64_t vframes() { return images.size(); }
33         void clear_images() { images.remove_all_objects(); }
34
35         virtual VFrame *frame() { return images[seq_no]; }
36         virtual int64_t next_frame(int n) {
37                 age += n * period;
38                 if( (seq_no+=n) >= images.size() ) seq_no = 0;
39                 return seq_no;
40         }
41         virtual int get_vx() { return 0; }
42         virtual int get_vy() { return 0; }
43
44         void add_image(VFrame *frm, int ww, int hh, int vcmdl);
45         void draw_vframe(BC_WindowBase *wdw, int x, int y);
46         void dump(const char *dir);
47
48         VIcon(int vw=VICON_WIDTH, int vh=VICON_HEIGHT, double rate=24);
49         virtual ~VIcon();
50 };
51
52 class VIconThread : public Thread
53 {
54 public:
55         int done, interrupted;
56         BC_WindowBase *wdw;
57         Timer *timer;
58         Condition *draw_lock;
59         ViewPopup *view_win;
60         VIcon *viewing, *vicon;
61         int view_w, view_h;
62         int img_dirty, win_dirty;
63         int64_t draw_flash;
64
65         ArrayList<VIcon *>t_heap;
66         VIcon *low_vicon();
67         void add_vicon(VIcon *vicon, double age=0);
68         int del_vicon(VIcon *&vicon);
69         void run();
70         void flash();
71         int draw(VIcon *vicon);
72         int update_view();
73         void draw_images();
74         void start_drawing();
75         void stop_drawing();
76         void reset_images();
77         void remove_vicon(int i);
78         int keypress_event(int key);
79         void set_view_popup(VIcon *vicon);
80
81         ViewPopup *new_view_window(VFrame *frame);
82         virtual bool visible(VIcon *vicon, int x, int y);
83         virtual void drawing_started() {}
84         virtual void drawing_stopped() {}
85
86         VIconThread(BC_WindowBase *wdw, int vw=4*VICON_WIDTH, int vh=4*VICON_HEIGHT);
87         ~VIconThread();
88 };
89
90 #endif