Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / recordbatches.h
1 /*
2  * CINELERRA
3  * Copyright (C) 2016-2020 William Morrow
4  *
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.
9  *
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.
14  *
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
18  * USA
19  */
20
21 #ifndef RECORDBATCHES_H
22 #define RECORDBATCHES_H
23
24 #include "arraylist.h"
25 #include "batch.h"
26 #include "bclistbox.h"
27 #include "bclistboxitem.inc"
28 #include "channeldb.inc"
29 #include "guicast.h"
30 #include "record.inc"
31 #include "recordbatches.inc"
32 #include "timeentry.h"
33
34 #include <string.h>
35
36 class RecordBatchesGUI;
37
38 class RecordBatches
39 {
40 public:
41         RecordBatchesGUI *gui;
42         MWindow *mwindow;
43 //  Don't want to interrupt recording to edit a different batch.
44         int current_item; // Current batch being recorded.
45         int editing_item; // Current batch being edited.
46         int batch_active;
47         static const char* default_batch_titles[];
48         const char *batch_titles[BATCH_COLUMNS];
49         static const int default_columnwidth[];
50         int column_widths[BATCH_COLUMNS];
51         ArrayList<BC_ListBoxItem*> data[BATCH_COLUMNS];
52         ArrayList<Batch*> batches;
53         double early_margin, late_margin;
54         char default_directory[BCTEXTLEN];
55
56         void load_defaults(ChannelDB *channeldb, Record *record=0);
57         void save_defaults(ChannelDB *channeldb);
58         void save_default_channel(ChannelDB *channeldb);
59         Batch *&operator [](int i) { return batches.values[i]; }
60         Batch* get_current_batch() { return batches.values[current_item]; }
61         Batch* get_editing_batch() { return batches.values[editing_item]; }
62         double *get_early_margin() { return &early_margin; }
63         double *get_late_margin() { return &late_margin; }
64         char *get_default_directory() { return default_directory; }
65         int total() { return batches.total; }
66         void append(Batch *batch) { batches.append(batch); }
67         void remove(Batch *batch);
68         void clear();
69         RecordBatches(MWindow *mwindow);
70         ~RecordBatches();
71 };
72
73 class RecordBatchesGUI : public BC_ListBox
74 {
75 public:
76         RecordBatches &batches;
77         int dragging_item;
78
79         int handle_event();
80         virtual int selection_changed() = 0;
81         int update(int highlighted_item, int recalc_positions);
82         int update() { return update(get_highlighted_item(), 0); }
83         int column_resize_event();
84         int drag_start_event();
85         int drag_motion_event();
86         int drag_stop_event();
87         void set_row_color(int i, int color);
88         void calculate_batches(int selection_number);
89         void update_batch_news(int item);
90         void update_batches(int selection_item);
91         void update_batches() { return update_batches(get_selection_number(0, 0)); }
92         int editing_batch() { return batches.editing_item; }
93         int set_editing_batch(int i) { return batches.editing_item=i; }
94         int current_batch() { return batches.current_item; }
95         int set_current_batch(int i) { return batches.current_item=i; }
96         int count() { return batches.data[0].total; }
97         Batch* get_current_batch() { return batches.get_current_batch(); }
98         Batch* get_editing_batch() { return batches.get_editing_batch(); }
99         RecordBatchesGUI(RecordBatches &batches, int x, int y, int w, int h);
100
101         class Dir : public BC_TextBox {
102         public:
103                 RecordBatches &batches;
104                 char (&directory)[BCTEXTLEN];
105                 ArrayList<BC_ListBoxItem*> *dir_entries;
106                 char entries_dir[BCTEXTLEN];
107
108                 int handle_event();
109                 void load_dirs(const char *path);
110                 char *get_directory() { return directory; }
111
112                 Dir(RecordBatches &batches, const char *dir, int x, int y);
113                 ~Dir();
114         };
115
116         class Path : public BC_TextBox {
117         public:
118                 RecordBatches &batches;
119
120                 int handle_event();
121
122                 Path(RecordBatches &batches, int x, int y);
123                 ~Path();
124         };
125
126         class StartTime : public TimeEntry {
127         public:
128                 RecordBatches &batches;
129                 int handle_event();
130                 StartTime(BC_Window *win, RecordBatches &batches,
131                         int x, int y, int w=DEFAULT_TIMEW);
132         };
133
134         class Duration : public TimeEntry
135         {
136         public:
137                 RecordBatches &batches;
138                 int handle_event();
139                 Duration(BC_Window *win, RecordBatches &batches,
140                         int x, int y, int w=DEFAULT_TIMEW);
141         };
142
143         class Margin : public TimeEntry
144         {
145                 RecordBatches &batches;
146                 int handle_event();
147                 Margin(BC_Window *win, RecordBatches &batches, int x, int y);
148         };
149
150         class Sources
151         {
152         public:
153                 ArrayList<BC_ListBoxItem*> sources;
154         };
155
156         class Source : protected Sources, public BC_PopupTextBox {
157         public:
158                 RecordBatches &batches;
159                 int handle_event();
160                 Source(BC_Window *win, RecordBatches &batches, int x, int y);
161         };
162
163         class News : public BC_TextBox {
164         public:
165                 RecordBatches &batches;
166                 int handle_event();
167                 News(RecordBatches &batches, int x, int y);
168         };
169
170         class NewBatch : public BC_GenericButton {
171         public:
172                 RecordBatches &batches;
173                 int handle_event();
174                 NewBatch(RecordBatches &batches, int x, int y);
175         };
176
177         class DeleteBatch : public BC_GenericButton {
178         public:
179                 RecordBatches &batches;
180                 int handle_event();
181                 DeleteBatch(RecordBatches &batches, int x, int y);
182         };
183
184         class StartBatches : public BC_GenericButton {
185         public:
186                 RecordBatches &batches;
187                 int handle_event();
188                 StartBatches(RecordBatches &batches, int x, int y);
189         };
190
191         class StopBatches : public BC_GenericButton {
192         public:
193                 RecordBatches &batches;
194                 int handle_event();
195                 StopBatches(RecordBatches &batches, int x, int y);
196         };
197
198         class ActivateBatch : public BC_GenericButton {
199         public:
200                 RecordBatches &batches;
201                 int handle_event();
202                 ActivateBatch(RecordBatches &batches, int x, int y);
203         };
204
205         class ClearBatch : public BC_GenericButton {
206         public:
207                 RecordBatches &batches;
208                 int handle_event();
209                 ClearBatch(RecordBatches &batches, int x, int y);
210         };
211 };
212
213 #endif