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