tweak map media vicon popup timeline drag/select
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / vicon.h
1 #ifndef __VICON_H__
2 #define __VICON_H__
3
4 #include "arraylist.h"
5 #include "bccmodels.h"
6 #include "bcpopup.h"
7 #include "bcwindowbase.h"
8 #include "thread.h"
9 #include "vicon.inc"
10 #include "vframe.h"
11
12 typedef void VIconDrawVFrame(BC_WindowBase *wdw, VFrame *frame);
13
14 class ViewPopup : public BC_Popup {
15 public:
16         VIconThread *vt;
17         int keypress_event();
18         int button_press_event();
19         int button_release_event();
20         int cursor_motion_event();
21
22         ViewPopup(VIconThread *vt, VFrame *frame, int x, int y, int w, int h);
23         ~ViewPopup();
24 };
25
26 class VIFrame {
27         unsigned char *img_data;
28         VFrame *vfrm;
29 public:
30         VIFrame(int ww, int hh, int vcmdl) {
31                 int size = BC_CModels::calculate_datasize(ww, hh, -1, vcmdl);
32                 img_data = new unsigned char[size];
33                 vfrm = new VFrame(img_data, -1, ww, hh, vcmdl, -1);
34         }
35         ~VIFrame() { delete vfrm;  delete [] img_data; }
36
37         operator VFrame *() { return vfrm; }
38 };
39
40 class VIcon
41 {
42 public:
43         int vw, vh, in_use, hidden;
44         ArrayList<VIFrame *> images;
45         int64_t seq_no;
46         double cycle_start, age, frame_rate;
47         int audio_size, playing_audio;
48         uint8_t *audio_data;
49
50         int64_t vframes() { return images.size(); }
51         void reset() { seq_no = 0; cycle_start = 0; age = 0; }
52         void reset(double rate) { reset(); frame_rate = rate; }
53         void clear_images() { images.remove_all_objects(); }
54         void init_audio(int audio_size);
55
56         virtual int64_t set_seq_no(int64_t no) { return seq_no = no; }
57         virtual VFrame *frame() { return *images[seq_no]; }
58         virtual int get_vx() { return 0; }
59         virtual int get_vy() { return 0; }
60         virtual void load_audio() {}
61         virtual void start_audio() {}
62         virtual void stop_audio() {}
63
64         void add_image(VFrame *frm, int ww, int hh, int vcmdl);
65         void draw_vframe(VIconThread *vt, BC_WindowBase *wdw, int x, int y);
66         void dump(const char *dir);
67
68         VIcon(int vw=VICON_WIDTH, int vh=VICON_HEIGHT, double rate=VICON_RATE);
69         virtual ~VIcon();
70 };
71
72 class VIconThread : public Thread
73 {
74 public:
75         int done, interrupted;
76         BC_WindowBase *wdw;
77         Timer *timer;
78         Condition *draw_lock;
79         ViewPopup *view_win;
80         VIcon *viewing, *vicon;
81         int view_w, view_h;
82         int draw_x0, draw_y0;
83         int draw_x1, draw_y1;
84         int img_dirty, win_dirty;
85         double refresh_rate;
86         int64_t stop_age;
87
88         ArrayList<VIcon *>t_heap;
89         VIcon *low_vicon();
90         void add_vicon(VIcon *vicon);
91         int del_vicon(VIcon *vicon);
92         void run();
93         void flash();
94         int draw(VIcon *vicon);
95         int update_view();
96         void draw_images();
97         void start_drawing();
98         void stop_drawing();
99         void reset_images();
100         void remove_vicon(int i);
101         int keypress_event(int key);
102         void set_drawing_area(int x0, int y0, int x1, int y1);
103         void set_view_popup(VIcon *vicon, VIconDrawVFrame *draw_vfrm=0);
104         void close_view_popup();
105         void hide_vicons(int v=1);
106         ViewPopup *new_view_window(VFrame *frame);
107         virtual int popup_button_press(int x, int y) { return 0; }
108         virtual int popup_button_release(int x, int y) { return 0; }
109         virtual int popup_cursor_motion(int x, int y) { return 0; }
110
111         virtual bool visible(VIcon *vicon, int x, int y);
112         virtual void drawing_started() {}
113         virtual void drawing_stopped() {}
114         static VIconDrawVFrame draw_vframe;
115         VIconDrawVFrame *draw_vfrm;
116
117         VIconThread(BC_WindowBase *wdw, int vw=4*VICON_WIDTH, int vh=4*VICON_HEIGHT);
118         ~VIconThread();
119 };
120
121 #endif