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"
27 #define _(String) gettext(String)
28 #define gettext_noop(String) String
29 #define N_(String) gettext_noop (String)
36 DeInterlaceWindow::DeInterlaceWindow(DeInterlaceMain *client)
37 : PluginClientWindow(client,
44 this->client = client;
45 adaptive=0; dominance_top=0; dominance_bottom=0; threshold=0;
49 DeInterlaceWindow::~DeInterlaceWindow()
53 void DeInterlaceWindow::create_objects()
56 add_tool(new BC_Title(x, y, _("Select deinterlacing mode")));
58 add_tool(mode = new DeInterlaceMode(client, this, x, y));
59 mode->create_objects();
61 optional_controls_x=x;
62 optional_controls_y=y;
64 char string[BCTEXTLEN];
65 get_status_string(string, 0);
66 add_tool(status = new BC_Title(x, y, string));
69 set_mode(client->config.mode,0);
72 void DeInterlaceWindow::get_status_string(char *string, int changed_rows)
74 sprintf(string, _("Changed rows: %d\n"), changed_rows);
77 int DeInterlaceWindow::set_mode(int mode, int recursive)
80 client->config.mode = mode;
82 /* Restore position of controls */
83 x=optional_controls_x;
84 y=optional_controls_y;
85 if (adaptive) { delete adaptive; adaptive=0; }
86 if (threshold) { delete threshold; threshold=0; }
87 if (dominance_top) { delete dominance_top; dominance_top=0; }
88 if (dominance_bottom) { delete dominance_bottom; dominance_bottom=0; }
90 /* Display Dominance controls */
93 case DEINTERLACE_KEEP:
94 case DEINTERLACE_BOBWEAVE:
95 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Keep top field")));
97 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y, _("Keep bottom field")));
100 case DEINTERLACE_AVG_1F:
101 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Average top fields")));
103 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y,"Average bottom fields"));
106 case DEINTERLACE_SWAP:
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_TEMPORALSWAP:
113 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Top field first")));
115 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y, _("Bottom field first")));
118 case DEINTERLACE_NONE:
119 case DEINTERLACE_AVG:
124 if (dominance_top&&dominance_bottom) {
125 dominance_top->update(client->config.dominance?0:BC_Toggle::TOGGLE_CHECKED);
126 dominance_bottom->update(client->config.dominance?BC_Toggle::TOGGLE_CHECKED:0);
129 /* Display Threshold and adaptive controls */
131 case DEINTERLACE_AVG_1F:
132 add_subwindow(adaptive = new DeInterlaceAdaptive(client, x, y));
134 add_subwindow(threshold = new DeInterlaceThreshold(client, x + 150, y));
135 add_subwindow(threshold->title_caption=new BC_Title(x+150, y + 50, _("Threshold")));
136 adaptive->update(client->config.adaptive?BC_Toggle::TOGGLE_CHECKED:0);
138 case DEINTERLACE_BOBWEAVE:
139 add_subwindow(threshold = new DeInterlaceThreshold(client, x + 150, y));
140 add_subwindow(threshold->title_caption=new BC_Title(x+150, y + 50, _("Bob Threshold")));
142 case DEINTERLACE_NONE:
143 case DEINTERLACE_KEEP:
144 case DEINTERLACE_AVG:
145 case DEINTERLACE_SWAP:
146 case DEINTERLACE_TEMPORALSWAP:
154 client->send_configure_change();
159 DeInterlaceOption::DeInterlaceOption(DeInterlaceMain *client,
160 DeInterlaceWindow *window,
165 : BC_Radial(x, y, client->config.mode == output, text)
167 this->client = client;
168 this->window = window;
169 this->output = output;
172 DeInterlaceOption::~DeInterlaceOption()
175 int DeInterlaceOption::handle_event()
177 window->set_mode(output, 0);
182 DeInterlaceAdaptive::DeInterlaceAdaptive(DeInterlaceMain *client, int x, int y)
183 : BC_CheckBox(x, y, client->config.adaptive, _("Adaptive"))
185 this->client = client;
187 int DeInterlaceAdaptive::handle_event()
189 client->config.adaptive = get_value();
190 client->send_configure_change();
194 DeInterlaceDominanceTop::DeInterlaceDominanceTop(DeInterlaceMain *client, DeInterlaceWindow *window, int x, int y, char * title)
195 : BC_Radial(x, y, client->config.dominance, title)
197 this->client = client;
198 this->window = window;
201 int DeInterlaceDominanceTop::handle_event()
203 client->config.dominance = (get_value()==0);
204 window->dominance_bottom->update(client->config.dominance?BC_Toggle::TOGGLE_CHECKED:0);
205 client->send_configure_change();
210 DeInterlaceDominanceBottom::DeInterlaceDominanceBottom(DeInterlaceMain *client, DeInterlaceWindow *window, int x, int y, const char * title)
211 : BC_Radial(x, y, client->config.dominance, title)
213 this->client = client;
214 this->window = window;
216 int DeInterlaceDominanceBottom::handle_event()
219 client->config.dominance = (get_value() != 0 );
220 window->dominance_top->update(client->config.dominance?0:BC_Toggle::TOGGLE_CHECKED);
221 client->send_configure_change();
226 DeInterlaceThreshold::DeInterlaceThreshold(DeInterlaceMain *client, int x, int y)
227 : BC_IPot(x, y, client->config.threshold, 0, 100)
229 this->client = client;
232 int DeInterlaceThreshold::handle_event()
234 client->config.threshold = get_value();
235 client->send_configure_change();
239 DeInterlaceThreshold::~DeInterlaceThreshold()
241 if (title_caption) delete title_caption;
244 DeInterlaceMode::DeInterlaceMode(DeInterlaceMain*plugin,
245 DeInterlaceWindow *gui,
248 : BC_PopupMenu(x, y, 200, to_text(plugin->config.mode), 1)
250 this->plugin = plugin;
253 void DeInterlaceMode::create_objects()
255 add_item(new BC_MenuItem(to_text(DEINTERLACE_NONE)));
256 add_item(new BC_MenuItem(to_text(DEINTERLACE_KEEP)));
257 add_item(new BC_MenuItem(to_text(DEINTERLACE_AVG)));
258 add_item(new BC_MenuItem(to_text(DEINTERLACE_AVG_1F)));
259 add_item(new BC_MenuItem(to_text(DEINTERLACE_BOBWEAVE)));
260 add_item(new BC_MenuItem(to_text(DEINTERLACE_SWAP)));
261 add_item(new BC_MenuItem(to_text(DEINTERLACE_TEMPORALSWAP)));
264 char* DeInterlaceMode::to_text(int mode)
268 case DEINTERLACE_KEEP:
269 return _("Duplicate one field");
270 case DEINTERLACE_AVG_1F:
271 return _("Average one field");
272 case DEINTERLACE_AVG:
273 return _("Average both fields");
274 case DEINTERLACE_BOBWEAVE:
275 return _("Bob & Weave");
276 case DEINTERLACE_SWAP:
277 return _("Spatial field swap");
278 case DEINTERLACE_TEMPORALSWAP:
279 return _("Temporal field swap");
281 return _("Do Nothing");
284 int DeInterlaceMode::from_text(char *text)
286 if(!strcmp(text, to_text(DEINTERLACE_KEEP)))
287 return DEINTERLACE_KEEP;
288 if(!strcmp(text, to_text(DEINTERLACE_AVG)))
289 return DEINTERLACE_AVG;
290 if(!strcmp(text, to_text(DEINTERLACE_AVG_1F)))
291 return DEINTERLACE_AVG_1F;
292 if(!strcmp(text, to_text(DEINTERLACE_BOBWEAVE)))
293 return DEINTERLACE_BOBWEAVE;
294 if(!strcmp(text, to_text(DEINTERLACE_SWAP)))
295 return DEINTERLACE_SWAP;
296 if(!strcmp(text, to_text(DEINTERLACE_TEMPORALSWAP)))
297 return DEINTERLACE_TEMPORALSWAP;
298 return DEINTERLACE_NONE;
301 int DeInterlaceMode::handle_event()
303 plugin->config.mode = from_text(get_text());
304 gui->set_mode(plugin->config.mode,0);
305 plugin->send_configure_change();