confirm prefs update, fix bg_pixmap sz, plugin layout tweaks
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / preferencesthread.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef PREFERENCESTHREAD_H
23 #define PREFERENCESTHREAD_H
24
25 #include "bcdialog.h"
26 #include "edl.inc"
27 #include "guicast.h"
28 #include "mutex.inc"
29 #include "mwindow.inc"
30 #include "question.h"
31 #include "preferences.inc"
32 #include "preferencesthread.inc"
33
34
35 class PreferencesMenuitem : public BC_MenuItem
36 {
37 public:
38         PreferencesMenuitem(MWindow *mwindow);
39         ~PreferencesMenuitem();
40
41         int handle_event();
42
43         MWindow *mwindow;
44         PreferencesThread *thread;
45 };
46
47 class PreferencesThread : public BC_DialogThread
48 {
49 public:
50         PreferencesThread(MWindow *mwindow);
51         ~PreferencesThread();
52
53         BC_Window* new_gui();
54         void handle_close_event(int result);
55 // update rendering rates
56         void update_rates();
57 // update playback rate
58         int update_framerate();
59         int apply_settings();
60         const char* category_to_text(int category);
61         int text_to_category(const char *category);
62
63         const char *busy();
64         void confirm_update(const char *reason, int close);
65         PreferencesConfirmDialog *confirm_dialog;
66
67         int current_dialog;
68         int thread_running;
69         int redraw_indexes;
70         int redraw_meters;
71         int redraw_times;
72         int redraw_overlays;
73         int rerender;
74         int close_assets;
75         int reload_plugins;
76         PreferencesWindow *window;
77         MWindow *mwindow;
78 // Copy of mwindow preferences
79         Preferences *preferences;
80         EDL *edl;
81
82 // Categories
83 #define CATEGORIES 7
84         enum
85         {
86                 PLAYBACK_A,
87                 PLAYBACK_B,
88                 RECORD,
89                 PERFORMANCE,
90                 INTERFACE,
91                 APPEARANCE,
92                 ABOUT
93         };
94 };
95
96 class PreferencesDialog : public BC_SubWindow
97 {
98 public:
99         PreferencesDialog(MWindow *mwindow, PreferencesWindow *pwindow);
100         virtual ~PreferencesDialog();
101
102         virtual void create_objects() {}
103 // update playback rate
104         virtual int draw_framerate(int flush) { return 0; }
105 // update rendering rates
106         virtual void update_rates() {}
107         virtual int show_window(int flush) { return BC_SubWindow::show_window(flush); }
108
109         PreferencesWindow *pwindow;
110         MWindow *mwindow;
111         Preferences *preferences;
112 };
113
114 class PreferencesCategory;
115 class PreferencesButton;
116
117 class PreferencesWindow : public BC_Window
118 {
119 public:
120         PreferencesWindow(MWindow *mwindow,
121                 PreferencesThread *thread,
122                 int x, int y, int w, int h);
123         ~PreferencesWindow();
124
125         void create_objects();
126         int delete_current_dialog();
127         int set_current_dialog(int number);
128         int update_framerate();
129         void update_rates();
130         void show_dialog() { dialog->show_window(0); }
131         MWindow *mwindow;
132         PreferencesThread *thread;
133         ArrayList<BC_ListBoxItem*> categories;
134         PreferencesCategory *category;
135         PreferencesButton *category_button[CATEGORIES];
136
137 private:
138         PreferencesDialog *dialog;
139 };
140
141 class PreferencesButton : public BC_GenericButton
142 {
143 public:
144         PreferencesButton(MWindow *mwindow,
145                 PreferencesThread *thread,
146                 int x,
147                 int y,
148                 int category,
149                 const char *text,
150                 VFrame **images);
151
152         int handle_event();
153
154         MWindow *mwindow;
155         PreferencesThread *thread;
156         int category;
157 };
158
159 class PreferencesCategory : public BC_PopupTextBox
160 {
161 public:
162         PreferencesCategory(MWindow *mwindow, PreferencesThread *thread, int x, int y);
163         ~PreferencesCategory();
164         int handle_event();
165         MWindow *mwindow;
166         PreferencesThread *thread;
167 };
168
169 class PreferencesApply : public BC_GenericButton
170 {
171 public:
172         PreferencesApply(MWindow *mwindow, PreferencesThread *thread);
173         int handle_event();
174         int resize_event(int w, int h);
175         MWindow *mwindow;
176         PreferencesThread *thread;
177 };
178
179 class PreferencesOK : public BC_GenericButton
180 {
181 public:
182         PreferencesOK(MWindow *mwindow, PreferencesThread *thread);
183         ~PreferencesOK();
184         int keypress_event();
185         int handle_event();
186         int resize_event(int w, int h);
187         MWindow *mwindow;
188         PreferencesThread *thread;
189         PreferencesConfirmDialog *confirm_dialog;
190 };
191
192 class PreferencesConfirmDialog : public BC_DialogThread
193 {
194 public:
195         PreferencesConfirmDialog(PreferencesThread *thread,
196                 const char *reason, int close);
197         ~PreferencesConfirmDialog();
198         BC_Window *new_gui();
199         void handle_done_event(int result);
200
201         PreferencesThread *thread;
202         PreferencesConfirmWindow *qwindow;
203         char query[BCTEXTLEN];
204         int close;
205 };
206
207 class PreferencesConfirmWindow : public QuestionWindow
208 {
209 public:
210         PreferencesConfirmWindow(PreferencesConfirmDialog *dialog);
211         ~PreferencesConfirmWindow();
212
213         PreferencesConfirmDialog *dialog;
214 };
215
216
217 class PreferencesCancel : public BC_GenericButton
218 {
219 public:
220         PreferencesCancel(MWindow *mwindow, PreferencesThread *thread);
221         int keypress_event();
222         int handle_event();
223         int resize_event(int w, int h);
224         MWindow *mwindow;
225         PreferencesThread *thread;
226 };
227
228
229 #endif