add BC_SCALE env var for hi def monitors, cleanup theme data
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / timeavg / timeavgwindow.C
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 #include "bcdisplayinfo.h"
23 #include "language.h"
24 #include "timeavgwindow.h"
25
26
27
28 #define MAX_FRAMES 1024
29
30
31 TimeAvgWindow::TimeAvgWindow(TimeAvgMain *client)
32  : PluginClientWindow(client, xS(250), yS(400), xS(250), yS(400), 0)
33 {
34         this->client = client;
35 }
36
37 TimeAvgWindow::~TimeAvgWindow()
38 {
39 }
40
41 void TimeAvgWindow::create_objects()
42 {
43         int xs10 = xS(10);
44         int ys5 = yS(5), ys10 = yS(10), ys30 = yS(30);
45         int x = xs10, y = ys10;
46         BC_Bar *bar;
47         BC_Title *title;
48
49         add_tool(title = new BC_Title(x, y, _("Frame count:")));
50         y += title->get_h() + ys5;
51         add_tool(total_frames = new TimeAvgSlider(client, x, y));
52         y += ys30;
53         add_tool(paranoid = new TimeAvgParanoid(client, x, y));
54         y += ys30;
55         add_tool(no_subtract = new TimeAvgNoSubtract(client, x, y));
56         y += ys30;
57         add_tool(bar = new BC_Bar(x, y, get_w() - x * xS(2)));
58         y += bar->get_h() + ys5;
59
60
61
62         add_tool(avg = new TimeAvgAvg(client, this, x, y));
63         y += ys30;
64         add_tool(accum = new TimeAvgAccum(client, this, x, y));
65         y += ys30;
66         add_tool(bar = new BC_Bar(x, y, get_w() - x * xS(2)));
67         y += bar->get_h() + ys5;
68
69
70
71         add_tool(replace = new TimeAvgReplace(client, this, x, y));
72         y += ys30;
73         add_tool(new BC_Title(x, y, _("Threshold:")));
74         y += title->get_h() + ys5;
75         add_tool(threshold = new TimeThresholdSlider(client, x, y));
76         y += ys30;
77         add_tool(new BC_Title(x, y, _("Border:")));
78         y += title->get_h() + ys5;
79         add_tool(border = new TimeBorderSlider(client, x, y));
80         y += ys30;
81
82
83
84         add_tool(bar = new BC_Bar(x, y, get_w() - x * xS(2)));
85         y += bar->get_h() + ys5;
86
87
88         add_tool(greater = new TimeAvgGreater(client, this, x, y));
89         y += ys30;
90         add_tool(less = new TimeAvgLess(client, this, x, y));
91         y += ys30;
92
93         update_toggles();
94         show_window();
95         flush();
96 }
97
98 void TimeAvgWindow::update_toggles()
99 {
100         avg->update(client->config.mode == TimeAvgConfig::AVERAGE);
101         accum->update(client->config.mode == TimeAvgConfig::ACCUMULATE);
102         replace->update(client->config.mode == TimeAvgConfig::REPLACE);
103         greater->update(client->config.mode == TimeAvgConfig::GREATER);
104         less->update(client->config.mode == TimeAvgConfig::LESS);
105
106 //      if(client->config.mode == TimeAvgConfig::AVERAGE ||
107 //              client->config.mode == TimeAvgConfig::ACCUMULATE)
108 //      {
109 //              no_subtract->enable();
110 //      }
111 //      else
112 //      {
113 //              no_subtract->disable();
114 //      }
115
116         if(client->config.mode == TimeAvgConfig::REPLACE)
117         {
118                 threshold->enable();
119                 border->enable();
120         }
121         else
122         {
123                 threshold->disable();
124                 border->disable();
125         }
126 }
127
128
129 TimeAvgSlider::TimeAvgSlider(TimeAvgMain *client, int x, int y)
130  : BC_ISlider(x, y, 0, xS(190),yS(200), 1,MAX_FRAMES,
131         client->config.frames)
132 {
133         this->client = client;
134 }
135 TimeAvgSlider::~TimeAvgSlider()
136 {
137 }
138 int TimeAvgSlider::handle_event()
139 {
140         int result = get_value();
141         if(result < 1) result = 1;
142         client->config.frames = result;
143         client->send_configure_change();
144         return 1;
145 }
146
147
148
149 TimeThresholdSlider::TimeThresholdSlider(TimeAvgMain *client, int x, int y)
150  : BC_ISlider(x, y, 0, xS(190),yS(200), 1,255,
151         client->config.threshold)
152 {
153         this->client = client;
154 }
155 TimeThresholdSlider::~TimeThresholdSlider()
156 {
157 }
158 int TimeThresholdSlider::handle_event()
159 {
160         int result = get_value();
161         if(result < 1) result = 1;
162         client->config.threshold = result;
163         client->send_configure_change();
164         return 1;
165 }
166
167
168 TimeBorderSlider::TimeBorderSlider(TimeAvgMain *client, int x, int y)
169  : BC_ISlider(x, y, 0, xS(190),yS(200), 0,8,
170         client->config.border)
171 {
172         this->client = client;
173 }
174 TimeBorderSlider::~TimeBorderSlider()
175 {
176 }
177 int TimeBorderSlider::handle_event()
178 {
179         int result = get_value();
180         if(result < 0) result = 0;
181         client->config.border = result;
182         client->send_configure_change();
183         return 1;
184 }
185
186
187
188
189 TimeAvgAvg::TimeAvgAvg(TimeAvgMain *client, TimeAvgWindow *gui, int x, int y)
190  : BC_Radial(x, y,
191         client->config.mode == TimeAvgConfig::AVERAGE,
192         _("Average"))
193 {
194         this->client = client;
195         this->gui = gui;
196 }
197 int TimeAvgAvg::handle_event()
198 {
199         int result = get_value(); (void)result;
200         client->config.mode = TimeAvgConfig::AVERAGE;
201         gui->update_toggles();
202         client->send_configure_change();
203         return 1;
204 }
205
206
207
208
209 TimeAvgAccum::TimeAvgAccum(TimeAvgMain *client, TimeAvgWindow *gui, int x, int y)
210  : BC_Radial(x, y,
211         client->config.mode == TimeAvgConfig::ACCUMULATE,
212         _("Accumulate"))
213 {
214         this->client = client;
215         this->gui = gui;
216 }
217 int TimeAvgAccum::handle_event()
218 {
219         int result = get_value(); (void)result;
220         client->config.mode = TimeAvgConfig::ACCUMULATE;
221         gui->update_toggles();
222         client->send_configure_change();
223         return 1;
224 }
225
226
227
228 TimeAvgReplace::TimeAvgReplace(TimeAvgMain *client, TimeAvgWindow *gui, int x, int y)
229  : BC_Radial(x, y,
230         client->config.mode == TimeAvgConfig::REPLACE,
231         _("Replace"))
232 {
233         this->client = client;
234         this->gui = gui;
235 }
236 int TimeAvgReplace::handle_event()
237 {
238         int result = get_value(); (void)result;
239         client->config.mode = TimeAvgConfig::REPLACE;
240         gui->update_toggles();
241         client->send_configure_change();
242         return 1;
243 }
244
245
246 TimeAvgGreater::TimeAvgGreater(TimeAvgMain *client, TimeAvgWindow *gui, int x, int y)
247  : BC_Radial(x, y,
248         client->config.mode == TimeAvgConfig::GREATER,
249         _("Greater"))
250 {
251         this->client = client;
252         this->gui = gui;
253 }
254 int TimeAvgGreater::handle_event()
255 {
256         int result = get_value(); (void)result;
257         client->config.mode = TimeAvgConfig::GREATER;
258         gui->update_toggles();
259         client->send_configure_change();
260         return 1;
261 }
262
263
264 TimeAvgLess::TimeAvgLess(TimeAvgMain *client, TimeAvgWindow *gui, int x, int y)
265  : BC_Radial(x, y,
266         client->config.mode == TimeAvgConfig::LESS,
267         _("Less"))
268 {
269         this->client = client;
270         this->gui = gui;
271 }
272 int TimeAvgLess::handle_event()
273 {
274         int result = get_value(); (void)result;
275         client->config.mode = TimeAvgConfig::LESS;
276         gui->update_toggles();
277         client->send_configure_change();
278         return 1;
279 }
280
281
282
283 TimeAvgParanoid::TimeAvgParanoid(TimeAvgMain *client, int x, int y)
284  : BC_CheckBox(x, y,
285         client->config.paranoid,
286         _("Restart for every frame"))
287 {
288         this->client = client;
289 }
290 int TimeAvgParanoid::handle_event()
291 {
292         int result = get_value();
293         client->config.paranoid = result;
294         client->send_configure_change();
295         return 1;
296 }
297
298
299
300
301
302 TimeAvgNoSubtract::TimeAvgNoSubtract(TimeAvgMain *client, int x, int y)
303  : BC_CheckBox(x, y,
304         client->config.nosubtract,
305         _("Don't buffer frames"))
306 {
307         this->client = client;
308 }
309 int TimeAvgNoSubtract::handle_event()
310 {
311         int result = get_value();
312         client->config.nosubtract = result;
313         client->send_configure_change();
314         return 1;
315 }
316
317
318