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, xS(250), yS(400), xS(250), yS(400), 0)
34 this->client = client;
37 TimeAvgWindow::~TimeAvgWindow()
41 void TimeAvgWindow::create_objects()
44 int ys5 = yS(5), ys10 = yS(10), ys30 = yS(30);
45 int x = xs10, y = ys10;
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));
53 add_tool(paranoid = new TimeAvgParanoid(client, x, y));
55 add_tool(no_subtract = new TimeAvgNoSubtract(client, x, y));
57 add_tool(bar = new BC_Bar(x, y, get_w() - x * xS(2)));
58 y += bar->get_h() + ys5;
62 add_tool(avg = new TimeAvgAvg(client, this, x, y));
64 add_tool(accum = new TimeAvgAccum(client, this, x, y));
66 add_tool(bar = new BC_Bar(x, y, get_w() - x * xS(2)));
67 y += bar->get_h() + ys5;
71 add_tool(replace = new TimeAvgReplace(client, this, x, y));
73 add_tool(new BC_Title(x, y, _("Threshold:")));
74 y += title->get_h() + ys5;
75 add_tool(threshold = new TimeThresholdSlider(client, x, y));
77 add_tool(new BC_Title(x, y, _("Border:")));
78 y += title->get_h() + ys5;
79 add_tool(border = new TimeBorderSlider(client, x, y));
84 add_tool(bar = new BC_Bar(x, y, get_w() - x * xS(2)));
85 y += bar->get_h() + ys5;
88 add_tool(greater = new TimeAvgGreater(client, this, x, y));
90 add_tool(less = new TimeAvgLess(client, this, x, y));
98 void TimeAvgWindow::update_toggles()
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);
106 // if(client->config.mode == TimeAvgConfig::AVERAGE ||
107 // client->config.mode == TimeAvgConfig::ACCUMULATE)
109 // no_subtract->enable();
113 // no_subtract->disable();
116 if(client->config.mode == TimeAvgConfig::REPLACE)
123 threshold->disable();
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)
133 this->client = client;
135 TimeAvgSlider::~TimeAvgSlider()
138 int TimeAvgSlider::handle_event()
140 int result = get_value();
141 if(result < 1) result = 1;
142 client->config.frames = result;
143 client->send_configure_change();
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)
153 this->client = client;
155 TimeThresholdSlider::~TimeThresholdSlider()
158 int TimeThresholdSlider::handle_event()
160 int result = get_value();
161 if(result < 1) result = 1;
162 client->config.threshold = result;
163 client->send_configure_change();
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)
172 this->client = client;
174 TimeBorderSlider::~TimeBorderSlider()
177 int TimeBorderSlider::handle_event()
179 int result = get_value();
180 if(result < 0) result = 0;
181 client->config.border = result;
182 client->send_configure_change();
189 TimeAvgAvg::TimeAvgAvg(TimeAvgMain *client, TimeAvgWindow *gui, int x, int y)
191 client->config.mode == TimeAvgConfig::AVERAGE,
194 this->client = client;
197 int TimeAvgAvg::handle_event()
199 int result = get_value(); (void)result;
200 client->config.mode = TimeAvgConfig::AVERAGE;
201 gui->update_toggles();
202 client->send_configure_change();
209 TimeAvgAccum::TimeAvgAccum(TimeAvgMain *client, TimeAvgWindow *gui, int x, int y)
211 client->config.mode == TimeAvgConfig::ACCUMULATE,
214 this->client = client;
217 int TimeAvgAccum::handle_event()
219 int result = get_value(); (void)result;
220 client->config.mode = TimeAvgConfig::ACCUMULATE;
221 gui->update_toggles();
222 client->send_configure_change();
228 TimeAvgReplace::TimeAvgReplace(TimeAvgMain *client, TimeAvgWindow *gui, int x, int y)
230 client->config.mode == TimeAvgConfig::REPLACE,
233 this->client = client;
236 int TimeAvgReplace::handle_event()
238 int result = get_value(); (void)result;
239 client->config.mode = TimeAvgConfig::REPLACE;
240 gui->update_toggles();
241 client->send_configure_change();
246 TimeAvgGreater::TimeAvgGreater(TimeAvgMain *client, TimeAvgWindow *gui, int x, int y)
248 client->config.mode == TimeAvgConfig::GREATER,
251 this->client = client;
254 int TimeAvgGreater::handle_event()
256 int result = get_value(); (void)result;
257 client->config.mode = TimeAvgConfig::GREATER;
258 gui->update_toggles();
259 client->send_configure_change();
264 TimeAvgLess::TimeAvgLess(TimeAvgMain *client, TimeAvgWindow *gui, int x, int y)
266 client->config.mode == TimeAvgConfig::LESS,
269 this->client = client;
272 int TimeAvgLess::handle_event()
274 int result = get_value(); (void)result;
275 client->config.mode = TimeAvgConfig::LESS;
276 gui->update_toggles();
277 client->send_configure_change();
283 TimeAvgParanoid::TimeAvgParanoid(TimeAvgMain *client, int x, int y)
285 client->config.paranoid,
286 _("Restart for every frame"))
288 this->client = client;
290 int TimeAvgParanoid::handle_event()
292 int result = get_value();
293 client->config.paranoid = result;
294 client->send_configure_change();
302 TimeAvgNoSubtract::TimeAvgNoSubtract(TimeAvgMain *client, int x, int y)
304 client->config.nosubtract,
305 _("Don't buffer frames"))
307 this->client = client;
309 int TimeAvgNoSubtract::handle_event()
311 int result = get_value();
312 client->config.nosubtract = result;
313 client->send_configure_change();