4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #include "bcdisplayinfo.h"
24 #include "timeavgwindow.h"
28 #define MAX_FRAMES 1024
31 TimeAvgWindow::TimeAvgWindow(TimeAvgMain *client)
32 : PluginClientWindow(client, 250, 400, 250, 400, 0)
34 this->client = client;
37 TimeAvgWindow::~TimeAvgWindow()
41 void TimeAvgWindow::create_objects()
47 add_tool(title = new BC_Title(x, y, _("Frame count:")));
48 y += title->get_h() + 5;
49 add_tool(total_frames = new TimeAvgSlider(client, x, y));
51 add_tool(paranoid = new TimeAvgParanoid(client, x, y));
53 add_tool(no_subtract = new TimeAvgNoSubtract(client, x, y));
55 add_tool(bar = new BC_Bar(x, y, get_w() - x * 2));
56 y += bar->get_h() + 5;
60 add_tool(avg = new TimeAvgAvg(client, this, x, y));
62 add_tool(accum = new TimeAvgAccum(client, this, x, y));
64 add_tool(bar = new BC_Bar(x, y, get_w() - x * 2));
65 y += bar->get_h() + 5;
69 add_tool(replace = new TimeAvgReplace(client, this, x, y));
71 add_tool(new BC_Title(x, y, _("Threshold:")));
72 y += title->get_h() + 5;
73 add_tool(threshold = new TimeThresholdSlider(client, x, y));
75 add_tool(new BC_Title(x, y, _("Border:")));
76 y += title->get_h() + 5;
77 add_tool(border = new TimeBorderSlider(client, x, y));
82 add_tool(bar = new BC_Bar(x, y, get_w() - x * 2));
83 y += bar->get_h() + 5;
86 add_tool(greater = new TimeAvgGreater(client, this, x, y));
88 add_tool(less = new TimeAvgLess(client, this, x, y));
96 void TimeAvgWindow::update_toggles()
98 avg->update(client->config.mode == TimeAvgConfig::AVERAGE);
99 accum->update(client->config.mode == TimeAvgConfig::ACCUMULATE);
100 replace->update(client->config.mode == TimeAvgConfig::REPLACE);
101 greater->update(client->config.mode == TimeAvgConfig::GREATER);
102 less->update(client->config.mode == TimeAvgConfig::LESS);
104 // if(client->config.mode == TimeAvgConfig::AVERAGE ||
105 // client->config.mode == TimeAvgConfig::ACCUMULATE)
107 // no_subtract->enable();
111 // no_subtract->disable();
114 if(client->config.mode == TimeAvgConfig::REPLACE)
121 threshold->disable();
127 TimeAvgSlider::TimeAvgSlider(TimeAvgMain *client, int x, int y)
135 client->config.frames)
137 this->client = client;
139 TimeAvgSlider::~TimeAvgSlider()
142 int TimeAvgSlider::handle_event()
144 int result = get_value();
145 if(result < 1) result = 1;
146 client->config.frames = result;
147 client->send_configure_change();
153 TimeThresholdSlider::TimeThresholdSlider(TimeAvgMain *client, int x, int y)
161 client->config.threshold)
163 this->client = client;
165 TimeThresholdSlider::~TimeThresholdSlider()
168 int TimeThresholdSlider::handle_event()
170 int result = get_value();
171 if(result < 1) result = 1;
172 client->config.threshold = result;
173 client->send_configure_change();
178 TimeBorderSlider::TimeBorderSlider(TimeAvgMain *client, int x, int y)
186 client->config.border)
188 this->client = client;
190 TimeBorderSlider::~TimeBorderSlider()
193 int TimeBorderSlider::handle_event()
195 int result = get_value();
196 if(result < 0) result = 0;
197 client->config.border = result;
198 client->send_configure_change();
205 TimeAvgAvg::TimeAvgAvg(TimeAvgMain *client, TimeAvgWindow *gui, int x, int y)
207 client->config.mode == TimeAvgConfig::AVERAGE,
210 this->client = client;
213 int TimeAvgAvg::handle_event()
215 int result = get_value(); (void)result;
216 client->config.mode = TimeAvgConfig::AVERAGE;
217 gui->update_toggles();
218 client->send_configure_change();
225 TimeAvgAccum::TimeAvgAccum(TimeAvgMain *client, TimeAvgWindow *gui, int x, int y)
227 client->config.mode == TimeAvgConfig::ACCUMULATE,
230 this->client = client;
233 int TimeAvgAccum::handle_event()
235 int result = get_value(); (void)result;
236 client->config.mode = TimeAvgConfig::ACCUMULATE;
237 gui->update_toggles();
238 client->send_configure_change();
244 TimeAvgReplace::TimeAvgReplace(TimeAvgMain *client, TimeAvgWindow *gui, int x, int y)
246 client->config.mode == TimeAvgConfig::REPLACE,
249 this->client = client;
252 int TimeAvgReplace::handle_event()
254 int result = get_value(); (void)result;
255 client->config.mode = TimeAvgConfig::REPLACE;
256 gui->update_toggles();
257 client->send_configure_change();
262 TimeAvgGreater::TimeAvgGreater(TimeAvgMain *client, TimeAvgWindow *gui, int x, int y)
264 client->config.mode == TimeAvgConfig::GREATER,
267 this->client = client;
270 int TimeAvgGreater::handle_event()
272 int result = get_value(); (void)result;
273 client->config.mode = TimeAvgConfig::GREATER;
274 gui->update_toggles();
275 client->send_configure_change();
280 TimeAvgLess::TimeAvgLess(TimeAvgMain *client, TimeAvgWindow *gui, int x, int y)
282 client->config.mode == TimeAvgConfig::LESS,
285 this->client = client;
288 int TimeAvgLess::handle_event()
290 int result = get_value(); (void)result;
291 client->config.mode = TimeAvgConfig::LESS;
292 gui->update_toggles();
293 client->send_configure_change();
299 TimeAvgParanoid::TimeAvgParanoid(TimeAvgMain *client, int x, int y)
301 client->config.paranoid,
302 _("Restart for every frame"))
304 this->client = client;
306 int TimeAvgParanoid::handle_event()
308 int result = get_value();
309 client->config.paranoid = result;
310 client->send_configure_change();
318 TimeAvgNoSubtract::TimeAvgNoSubtract(TimeAvgMain *client, int x, int y)
320 client->config.nosubtract,
321 _("Don't buffer frames"))
323 this->client = client;
325 int TimeAvgNoSubtract::handle_event()
327 int result = get_value();
328 client->config.nosubtract = result;
329 client->send_configure_change();