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"
23 #include "deinterwindow-cv.h"
28 DeInterlaceWindow::DeInterlaceWindow(DeInterlaceMain *client)
29 : PluginClientWindow(client,
36 this->client = client;
37 adaptive=0; dominance_top=0; dominance_bottom=0; threshold=0;
41 DeInterlaceWindow::~DeInterlaceWindow()
45 void DeInterlaceWindow::create_objects()
48 int ys10 = yS(10), ys25 = yS(25);
49 int x = xs10, y = ys10;
50 add_tool(new BC_Title(x, y, _("Select deinterlacing mode")));
52 add_tool(mode = new DeInterlaceMode(client, this, x, y));
53 mode->create_objects();
55 optional_controls_x=x;
56 optional_controls_y=y;
58 char string[BCTEXTLEN];
59 get_status_string(string, 0);
60 add_tool(status = new BC_Title(x, y, string));
63 set_mode(client->config.mode,0);
66 void DeInterlaceWindow::get_status_string(char *string, int changed_rows)
68 sprintf(string, _("Changed rows: %d\n"), changed_rows);
71 int DeInterlaceWindow::set_mode(int mode, int recursive)
74 client->config.mode = mode;
76 /* Restore position of controls */
77 x=optional_controls_x;
78 y=optional_controls_y;
79 if (adaptive) { delete adaptive; adaptive=0; }
80 if (threshold) { delete threshold; threshold=0; }
81 if (dominance_top) { delete dominance_top; dominance_top=0; }
82 if (dominance_bottom) { delete dominance_bottom; dominance_bottom=0; }
84 /* Display Dominance controls */
87 case DEINTERLACE_KEEP:
88 case DEINTERLACE_BOBWEAVE:
89 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Keep top field")));
91 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y, _("Keep bottom field")));
94 case DEINTERLACE_AVG_1F:
95 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Average top fields")));
97 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y,_("Average bottom fields")));
100 case DEINTERLACE_SWAP:
101 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Top field first")));
103 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y, _("Bottom field first")));
106 case DEINTERLACE_TEMPORALSWAP:
107 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Top field first")));
109 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y, _("Bottom field first")));
112 case DEINTERLACE_NONE:
113 case DEINTERLACE_AVG:
118 if (dominance_top&&dominance_bottom) {
119 dominance_top->update(client->config.dominance?0:BC_Toggle::TOGGLE_CHECKED);
120 dominance_bottom->update(client->config.dominance?BC_Toggle::TOGGLE_CHECKED:0);
123 /* Display Threshold and adaptive controls */
125 case DEINTERLACE_AVG_1F:
126 add_subwindow(adaptive = new DeInterlaceAdaptive(client, x, y));
128 add_subwindow(threshold = new DeInterlaceThreshold(client, x + xS(150), y));
129 add_subwindow(threshold->title_caption=new BC_Title(x+xS(150), y + yS(50), _("Threshold")));
130 adaptive->update(client->config.adaptive?BC_Toggle::TOGGLE_CHECKED:0);
132 case DEINTERLACE_BOBWEAVE:
133 add_subwindow(threshold = new DeInterlaceThreshold(client, x + xS(150), y));
134 add_subwindow(threshold->title_caption=new BC_Title(x+xS(150), y + yS(50), _("Bob Threshold")));
136 case DEINTERLACE_NONE:
137 case DEINTERLACE_KEEP:
138 case DEINTERLACE_AVG:
139 case DEINTERLACE_SWAP:
140 case DEINTERLACE_TEMPORALSWAP:
148 client->send_configure_change();
153 DeInterlaceOption::DeInterlaceOption(DeInterlaceMain *client,
154 DeInterlaceWindow *window,
159 : BC_Radial(x, y, client->config.mode == output, text)
161 this->client = client;
162 this->window = window;
163 this->output = output;
166 DeInterlaceOption::~DeInterlaceOption()
169 int DeInterlaceOption::handle_event()
171 window->set_mode(output, 0);
176 DeInterlaceAdaptive::DeInterlaceAdaptive(DeInterlaceMain *client, int x, int y)
177 : BC_CheckBox(x, y, client->config.adaptive, _("Adaptive"))
179 this->client = client;
181 int DeInterlaceAdaptive::handle_event()
183 client->config.adaptive = get_value();
184 client->send_configure_change();
188 DeInterlaceDominanceTop::DeInterlaceDominanceTop(DeInterlaceMain *client, DeInterlaceWindow *window, int x, int y, char * title)
189 : BC_Radial(x, y, client->config.dominance, title)
191 this->client = client;
192 this->window = window;
195 int DeInterlaceDominanceTop::handle_event()
197 client->config.dominance = (get_value()==0);
198 window->dominance_bottom->update(client->config.dominance?BC_Toggle::TOGGLE_CHECKED:0);
199 client->send_configure_change();
204 DeInterlaceDominanceBottom::DeInterlaceDominanceBottom(DeInterlaceMain *client, DeInterlaceWindow *window, int x, int y, const char * title)
205 : BC_Radial(x, y, client->config.dominance, title)
207 this->client = client;
208 this->window = window;
210 int DeInterlaceDominanceBottom::handle_event()
213 client->config.dominance = (get_value() != 0 );
214 window->dominance_top->update(client->config.dominance?0:BC_Toggle::TOGGLE_CHECKED);
215 client->send_configure_change();
220 DeInterlaceThreshold::DeInterlaceThreshold(DeInterlaceMain *client, int x, int y)
221 : BC_IPot(x, y, client->config.threshold, 0, 100)
223 this->client = client;
226 int DeInterlaceThreshold::handle_event()
228 client->config.threshold = get_value();
229 client->send_configure_change();
233 DeInterlaceThreshold::~DeInterlaceThreshold()
235 if (title_caption) delete title_caption;
238 DeInterlaceMode::DeInterlaceMode(DeInterlaceMain*plugin,
239 DeInterlaceWindow *gui,
242 : BC_PopupMenu(x, y, xS(200), to_text(plugin->config.mode), 1)
244 this->plugin = plugin;
247 void DeInterlaceMode::create_objects()
249 add_item(new BC_MenuItem(to_text(DEINTERLACE_NONE)));
250 add_item(new BC_MenuItem(to_text(DEINTERLACE_KEEP)));
251 add_item(new BC_MenuItem(to_text(DEINTERLACE_AVG)));
252 add_item(new BC_MenuItem(to_text(DEINTERLACE_AVG_1F)));
253 add_item(new BC_MenuItem(to_text(DEINTERLACE_BOBWEAVE)));
254 add_item(new BC_MenuItem(to_text(DEINTERLACE_SWAP)));
255 add_item(new BC_MenuItem(to_text(DEINTERLACE_TEMPORALSWAP)));
258 char* DeInterlaceMode::to_text(int mode)
262 case DEINTERLACE_KEEP:
263 return _("Duplicate one field");
264 case DEINTERLACE_AVG_1F:
265 return _("Average one field");
266 case DEINTERLACE_AVG:
267 return _("Average both fields");
268 case DEINTERLACE_BOBWEAVE:
269 return _("Bob & Weave");
270 case DEINTERLACE_SWAP:
271 return _("Spatial field swap");
272 case DEINTERLACE_TEMPORALSWAP:
273 return _("Temporal field swap");
275 return _("Do Nothing");
278 int DeInterlaceMode::from_text(char *text)
280 if(!strcmp(text, to_text(DEINTERLACE_KEEP)))
281 return DEINTERLACE_KEEP;
282 if(!strcmp(text, to_text(DEINTERLACE_AVG)))
283 return DEINTERLACE_AVG;
284 if(!strcmp(text, to_text(DEINTERLACE_AVG_1F)))
285 return DEINTERLACE_AVG_1F;
286 if(!strcmp(text, to_text(DEINTERLACE_BOBWEAVE)))
287 return DEINTERLACE_BOBWEAVE;
288 if(!strcmp(text, to_text(DEINTERLACE_SWAP)))
289 return DEINTERLACE_SWAP;
290 if(!strcmp(text, to_text(DEINTERLACE_TEMPORALSWAP)))
291 return DEINTERLACE_TEMPORALSWAP;
292 return DEINTERLACE_NONE;
295 int DeInterlaceMode::handle_event()
297 plugin->config.mode = from_text(get_text());
298 gui->set_mode(plugin->config.mode,0);
299 plugin->send_configure_change();