3 * Copyright (C) 2016-2020 William Morrow
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 #include "arraylist.h"
26 #include "bccmodels.h"
28 #include "bcwindowbase.h"
33 class ViewPopup : public BC_Popup {
36 virtual int keypress_event();
37 virtual int button_press_event() { return 0; }
38 virtual int button_release_event() { return 0; }
39 virtual int cursor_motion_event() { return 0; }
40 virtual void draw_vframe(VFrame *frame);
42 ViewPopup(VIconThread *vt, int x, int y, int w, int h);
47 unsigned char *img_data;
49 VIFrame(int ww, int hh, int vcmdl) {
50 int size = BC_CModels::calculate_datasize(ww, hh, -1, vcmdl);
51 img_data = new unsigned char[size];
52 vfrm = new VFrame(img_data, -1, ww, hh, vcmdl, -1);
54 ~VIFrame() { delete vfrm; delete [] img_data; }
61 int w, h, in_use, hidden;
62 ArrayList<VIFrame *> images;
64 double cycle_start, age, frame_rate;
65 int audio_size, playing_audio;
68 int64_t vframes() { return images.size(); }
69 void reset() { seq_no = 0; cycle_start = 0; age = 0; }
70 void reset(double rate) { reset(); frame_rate = rate; }
71 void clear_images() { images.remove_all_objects(); }
72 void init_audio(int audio_size);
74 virtual int64_t set_seq_no(int64_t no) { return seq_no = no; }
75 virtual VFrame *frame() { return images[seq_no]->vfrm; }
76 virtual int get_vx() { return 0; }
77 virtual int get_vy() { return 0; }
78 virtual void load_audio() {}
79 virtual void start_audio() {}
80 virtual void stop_audio() {}
82 void add_image(VFrame *frm, int ww, int hh, int vcmdl);
83 void draw_vframe(VIconThread *vt, BC_WindowBase *wdw, int x, int y);
84 void dump(const char *dir);
86 VIcon(int vw=VICON_WIDTH, int vh=VICON_HEIGHT, double rate=VICON_RATE);
90 class VIconThread : public Thread
93 int done, interrupted;
98 VIcon *viewing, *vicon, *solo;
99 int vw, vh, view_w, view_h;
100 int draw_x0, draw_y0;
101 int draw_x1, draw_y1;
102 int img_dirty, win_dirty;
109 ArrayList<VIcon *>t_heap;
111 void add_vicon(VIcon *vicon);
112 int del_vicon(VIcon *vicon);
115 int draw(VIcon *vicon);
116 int update_view(int do_audio);
118 void start_drawing();
122 void remove_vicon(int i);
123 int keypress_event(int key);
124 int cursor_inside(int x, int y);
125 void set_drawing_area(int x0, int y0, int x1, int y1);
126 void set_view_popup(VIcon *vicon);
127 int zoom_scale(int dir);
128 void close_view_popup();
129 void hide_vicons(int v=1);
130 int show_vicon(VIcon *next);
131 virtual ViewPopup *new_view_window(ViewPopup *vpopup);
133 virtual bool visible(VIcon *vicon, int x, int y);
134 virtual void drawing_started() {}
135 virtual void drawing_stopped() {}
137 VIconThread(BC_WindowBase *wdw,
138 int vw=VICON_WIDTH, int vh=VICON_HEIGHT,
139 int view_w=4*VICON_WIDTH, int view_h=4*VICON_HEIGHT);