additional TERMUX related mods from Andrew
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / dbwindow.h
1 #ifdef __I386__ || __x86-64__
2 #ifndef _DBWINDOW_H_
3 #define _DBWINDOW_H_
4
5 #include "canvas.h"
6 #include "condition.h"
7 #include "garbage.h"
8 #include "linklist.h"
9 #include "mutex.h"
10 #include "commercials.inc"
11 #include "dbwindow.inc"
12 #include "guicast.h"
13 #include "mediadb.h"
14 #include "mwindow.inc"
15 #include "vicon.h"
16
17 enum {
18         col_vicon, col_id, col_length, col_source,
19         col_title, col_start_time, col_access_time,
20         col_access_count, sizeof_col
21 };
22
23 class DbSearchItem : public BC_ListBoxItem {
24 public:
25         DbWindowVIcon *vicon;
26
27         DbSearchItem(const char *text, int color=-1);
28         ~DbSearchItem();
29 };
30
31 class DbWindow : public Thread
32 {
33 public:
34         MWindow *mwindow;
35         DbWindowGUI *gui;
36         Mutex *window_lock;
37         Mutex *db_lock;
38         class MDb : public Garbage, public MediaDb {
39                 DbWindow *dwin;
40         public:
41                 int attach_rd() { dwin->db_lock->lock();  attachDb(0);  return 0; }
42                 int attach_wr() { dwin->db_lock->lock();  attachDb(1);  return 0; }
43                 int detach() {  dwin->db_lock->unlock();  detachDb();   return 0; }
44
45                 MDb(DbWindow *d);
46                 ~MDb();
47         } *mdb;
48
49         void start();
50         void stop();
51         void run();
52
53         DbWindow(MWindow *mwindow);
54         ~DbWindow();
55 };
56
57 class DbWindowGUI : public BC_Window
58 {
59 public:
60         DbWindow *dwindow;
61
62         DbWindowText *search_text;
63         DbWindowTitleText *title_text;
64         DbWindowInfoText *info_text;
65         DbWindowMatchCase *match_case;
66         DbWindowStart *search_start;
67         DbWindowDeleteItems *del_items;
68         DbWindowCancel *cancel;
69         DbWindowList *search_list;
70         DbWindowCanvas *canvas;
71         DbWindowVIconThread *vicon_thread;
72
73         int title_text_enable;
74         int info_text_enable;
75         int match_case_enable;
76
77         int search_x, search_y, text_x, text_y;
78         int del_items_x, del_items_y;
79         int cancel_x, cancel_y, cancel_w, cancel_h;
80         int canvas_x, canvas_y, canvas_w, canvas_h;
81         int list_x, list_y, list_w, list_h;
82         int sort_column, sort_order;
83
84         const char *search_column_titles[sizeof_col];
85         int search_column_widths[sizeof_col];
86         int search_columns[sizeof_col];
87         ArrayList<DbSearchItem*> search_items[sizeof_col];
88         ArrayList<DbWindowItem*> search_results;
89
90         void create_objects();
91         void search(int n, const char *text);
92         void delete_items();
93         int close_event();
94         int resize_event(int x, int y);
95         int stop_drawing();
96         int start_drawing(int update=1);
97         void update();
98         static int cmpr_id_dn(const void *a, const void *b);
99         static int cmpr_id_up(const void *a, const void *b);
100         static int cmpr_length_dn(const void *a, const void *b);
101         static int cmpr_length_up(const void *a, const void *b);
102         static int cmpr_source_dn(const void *a, const void *b);
103         static int cmpr_source_up(const void *a, const void *b);
104         static int cmpr_Source_dn(const void *a, const void *b);
105         static int cmpr_Source_up(const void *a, const void *b);
106         static int cmpr_Title_dn(const void *a, const void *b);
107         static int cmpr_Title_up(const void *a, const void *b);
108         static int cmpr_title_dn(const void *a, const void *b);
109         static int cmpr_title_up(const void *a, const void *b);
110         static int cmpr_start_time_dn(const void *a, const void *b);
111         static int cmpr_start_time_up(const void *a, const void *b);
112         static int cmpr_access_time_dn(const void *a, const void *b);
113         static int cmpr_access_time_up(const void *a, const void *b);
114         static int cmpr_access_count_dn(const void *a, const void *b);
115         static int cmpr_access_count_up(const void *a, const void *b);
116         void sort_events(int column, int order);
117         void move_column(int src, int dst);
118
119         DbWindowGUI(DbWindow *dwindow);
120         ~DbWindowGUI();
121 private:
122         int search_string(const char *text, const char *sp);
123         void search_clips(MediaDb *mdb, int n, const char *text);
124         int delete_selection(MediaDb *mdb);
125 };
126
127 class DbWindowInfoText : public BC_CheckBox
128 {
129 public:
130         DbWindowGUI *gui;
131
132         int handle_event();
133         void update(int v) { set_value(gui->info_text_enable = v); }
134
135         DbWindowInfoText(DbWindowGUI *gui, int x, int y);
136         ~DbWindowInfoText();
137 };
138
139 class DbWindowTitleText : public BC_CheckBox
140 {
141 public:
142         DbWindowGUI *gui;
143
144         int handle_event();
145         void update(int v) { set_value(gui->title_text_enable = v); }
146
147         DbWindowTitleText(DbWindowGUI *gui, int x, int y);
148         ~DbWindowTitleText();
149 };
150
151 class DbWindowMatchCase : public BC_CheckBox
152 {
153 public:
154         DbWindowGUI *gui;
155
156         int handle_event();
157
158         DbWindowMatchCase(DbWindowGUI *gui, int x, int y);
159         ~DbWindowMatchCase();
160 };
161
162 class DbWindowText : public BC_TextBox
163 {
164 public:
165         DbWindowGUI *gui;
166
167         int handle_event();
168         int keypress_event();
169
170         DbWindowText(DbWindowGUI *gui, int x, int y, int w);
171         ~DbWindowText();
172 };
173
174 class DbWindowStart : public BC_GenericButton
175 {
176 public:
177         DbWindowGUI *gui;
178
179         int handle_event();
180
181         DbWindowStart(DbWindowGUI *gui, int x, int y);
182         ~DbWindowStart();
183 };
184
185 class DbWindowCancel : public BC_CancelButton
186 {
187 public:
188         DbWindowGUI *gui;
189
190         int handle_event();
191
192         DbWindowCancel(DbWindowGUI *gui, int x, int y);
193         ~DbWindowCancel();
194 };
195
196 class DbWindowDeleteItems : public BC_GenericButton
197 {
198 public:
199         DbWindowGUI *gui;
200
201         int handle_event();
202
203         DbWindowDeleteItems(DbWindowGUI *gui, int x, int y);
204         ~DbWindowDeleteItems();
205 };
206
207 class DbWindowList : public BC_ListBox
208 {
209 public:
210         DbWindowGUI *gui;
211
212         int handle_event();
213         int sort_order_event();
214         int keypress_event();
215         int move_column_event();
216         int selection_changed();
217         void set_view_popup(DbWindowVIcon *vicon);
218
219         int update_images();
220         int update();
221
222         DbWindowList(DbWindowGUI *gui, int x, int y, int w, int h);
223         ~DbWindowList();
224 };
225
226 class DbWindowCanvas : public Canvas
227 {
228 public:
229         DbWindowGUI *gui;
230
231         DbWindowCanvas(DbWindowGUI *gui, int x, int y, int w, int h);
232         ~DbWindowCanvas();
233         void flash_canvas();
234         void draw_frame(VFrame *frame, int x, int y, int w, int h);
235         int button_press_event() { return 0; }
236         int keypress_event() { return 0; }
237 };
238
239 class DbWindowVIcon : public VIcon
240 {
241 public:
242         DbWindowList *lbox;
243         DbSearchItem *item;
244
245         int clip_id, clip_size;
246         int frame_id, frames;
247         int prefix_size, suffix_offset;
248
249         VFrame *frame();
250         int64_t set_seq_no(int64_t no);
251         void load_frames(DbWindow::MDb *mdb);
252         void read_frames(DbWindow::MDb *mdb);
253
254         int get_vx();
255         int get_vy();
256
257         void update_image(DbWindowGUI *gui, int clip_id);
258         DbWindowVIcon();
259         ~DbWindowVIcon();
260 };
261
262 class DbWindowVIconThread : public VIconThread {
263 public:
264         DbWindowGUI *gui;
265         int list_update;
266
267         ArrayList <DbWindowVIcon *> vicons;
268         DbWindowVIcon *get_vicon(int i, DbSearchItem *item);
269         void drawing_started();
270
271         DbWindowVIconThread(DbWindowGUI *gui);
272         ~DbWindowVIconThread();
273 };
274
275 class DbWindowItem
276 {
277 public:
278         int no, id, access_count;
279         char *source, *title;
280         double length, start_time, access_time;
281
282         DbWindowItem(int id, const char *source, const char *title,
283                 double length, double start_time, double access_time,
284                 int access_count);
285         ~DbWindowItem();
286 };
287
288 class DbWindowScan : public BC_MenuItem
289 {
290 public:
291         MWindow *mwindow;
292         int handle_event();
293
294         DbWindowScan(MWindow *mwindow);
295         ~DbWindowScan();
296 };
297
298
299 #endif
300 #endif /* x86 */