vicon drag tweaks, proxy drag fix, vicon mouseover, binfolder around sort fix, draw_r...
[goodguy/history.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 class ViewPopup : public BC_Popup {
13 public:
14         VIconThread *vt;
15         int keypress_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 VIFrame {
23         unsigned char *img_data;
24         VFrame *vfrm;
25 public:
26         VIFrame(int ww, int hh, int vcmdl) {
27                 int size = BC_CModels::calculate_datasize(ww, hh, -1, vcmdl);
28                 img_data = new unsigned char[size];
29                 vfrm = new VFrame(img_data, -1, ww, hh, vcmdl, -1);
30         }
31         ~VIFrame() { delete vfrm;  delete [] img_data; }
32
33         operator VFrame *() { return vfrm; }
34 };
35
36 class VIcon
37 {
38 public:
39         int vw, vh, in_use, hidden;
40         ArrayList<VIFrame *> images;
41         int64_t seq_no;
42         double cycle_start, age, frame_rate;
43         int audio_size, playing_audio;
44         uint8_t *audio_data;
45
46         int64_t vframes() { return images.size(); }
47         void reset() { seq_no = 0; cycle_start = 0; age = 0; }
48         void reset(double rate) { reset(); frame_rate = rate; }
49         void clear_images() { images.remove_all_objects(); }
50         void init_audio(int audio_size);
51
52         virtual int64_t set_seq_no(int64_t no) { return seq_no = no; }
53         virtual VFrame *frame() { return *images[seq_no]; }
54         virtual int get_vx() { return 0; }
55         virtual int get_vy() { return 0; }
56         virtual void load_audio() {}
57         virtual void start_audio() {}
58         virtual void stop_audio() {}
59
60         void add_image(VFrame *frm, int ww, int hh, int vcmdl);
61         void draw_vframe(VIconThread *vt, BC_WindowBase *wdw, int x, int y);
62         void dump(const char *dir);
63
64         VIcon(int vw=VICON_WIDTH, int vh=VICON_HEIGHT, double rate=VICON_RATE);
65         virtual ~VIcon();
66 };
67
68 class VIconThread : public Thread
69 {
70 public:
71         int done, interrupted;
72         BC_WindowBase *wdw;
73         Timer *timer;
74         Condition *draw_lock;
75         ViewPopup *view_win;
76         VIcon *viewing, *vicon;
77         int view_w, view_h;
78         int draw_x0, draw_y0;
79         int draw_x1, draw_y1;
80         int img_dirty, win_dirty;
81         double refresh_rate;
82         int64_t stop_age;
83
84         ArrayList<VIcon *>t_heap;
85         VIcon *low_vicon();
86         void add_vicon(VIcon *vicon);
87         int del_vicon(VIcon *&vicon);
88         void run();
89         void flash();
90         int draw(VIcon *vicon);
91         int update_view();
92         void draw_images();
93         void start_drawing();
94         void stop_drawing();
95         void reset_images();
96         void remove_vicon(int i);
97         int keypress_event(int key);
98         void set_drawing_area(int x0, int y0, int x1, int y1);
99         void set_view_popup(VIcon *vicon);
100         void hide_vicons(int v=1);
101
102         ViewPopup *new_view_window(VFrame *frame);
103         virtual bool visible(VIcon *vicon, int x, int y);
104         virtual void drawing_started() {}
105         virtual void drawing_stopped() {}
106
107         VIconThread(BC_WindowBase *wdw, int vw=4*VICON_WIDTH, int vh=4*VICON_HEIGHT);
108         ~VIconThread();
109 };
110
111 #endif