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