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, 1);
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 threshold->show_window(0);
131 adaptive->update(client->config.adaptive?BC_Toggle::TOGGLE_CHECKED:0);
133 case DEINTERLACE_BOBWEAVE:
134 add_subwindow(threshold = new DeInterlaceThreshold(client, x + xS(150), y));
135 add_subwindow(threshold->title_caption=new BC_Title(x+xS(150), y + yS(50), _("Bob Threshold")));
136 threshold->show_window(0);
138 case DEINTERLACE_NONE:
139 case DEINTERLACE_KEEP:
140 case DEINTERLACE_AVG:
141 case DEINTERLACE_SWAP:
142 case DEINTERLACE_TEMPORALSWAP:
150 client->send_configure_change();
155 DeInterlaceOption::DeInterlaceOption(DeInterlaceMain *client,
156 DeInterlaceWindow *window,
161 : BC_Radial(x, y, client->config.mode == output, text)
163 this->client = client;
164 this->window = window;
165 this->output = output;
168 DeInterlaceOption::~DeInterlaceOption()
171 int DeInterlaceOption::handle_event()
173 window->set_mode(output, 0);
178 DeInterlaceAdaptive::DeInterlaceAdaptive(DeInterlaceMain *client, int x, int y)
179 : BC_CheckBox(x, y, client->config.adaptive, _("Adaptive"))
181 this->client = client;
183 int DeInterlaceAdaptive::handle_event()
185 client->config.adaptive = get_value();
186 client->send_configure_change();
190 DeInterlaceDominanceTop::DeInterlaceDominanceTop(DeInterlaceMain *client, DeInterlaceWindow *window, int x, int y, char * title)
191 : BC_Radial(x, y, client->config.dominance, title)
193 this->client = client;
194 this->window = window;
197 int DeInterlaceDominanceTop::handle_event()
199 client->config.dominance = (get_value()==0);
200 window->dominance_bottom->update(client->config.dominance?BC_Toggle::TOGGLE_CHECKED:0);
201 client->send_configure_change();
206 DeInterlaceDominanceBottom::DeInterlaceDominanceBottom(DeInterlaceMain *client, DeInterlaceWindow *window, int x, int y, const char * title)
207 : BC_Radial(x, y, client->config.dominance, title)
209 this->client = client;
210 this->window = window;
212 int DeInterlaceDominanceBottom::handle_event()
215 client->config.dominance = (get_value() != 0 );
216 window->dominance_top->update(client->config.dominance?0:BC_Toggle::TOGGLE_CHECKED);
217 client->send_configure_change();
222 DeInterlaceThreshold::DeInterlaceThreshold(DeInterlaceMain *client, int x, int y)
223 : BC_IPot(x, y, client->config.threshold, 0, 100)
225 this->client = client;
228 int DeInterlaceThreshold::handle_event()
230 client->config.threshold = get_value();
231 client->send_configure_change();
235 DeInterlaceThreshold::~DeInterlaceThreshold()
237 if (title_caption) delete title_caption;
240 DeInterlaceMode::DeInterlaceMode(DeInterlaceMain*plugin,
241 DeInterlaceWindow *gui,
244 : BC_PopupMenu(x, y, xS(200), to_text(plugin->config.mode), 1)
246 this->plugin = plugin;
249 void DeInterlaceMode::create_objects()
251 add_item(new BC_MenuItem(to_text(DEINTERLACE_NONE)));
252 add_item(new BC_MenuItem(to_text(DEINTERLACE_KEEP)));
253 add_item(new BC_MenuItem(to_text(DEINTERLACE_AVG)));
254 add_item(new BC_MenuItem(to_text(DEINTERLACE_AVG_1F)));
255 add_item(new BC_MenuItem(to_text(DEINTERLACE_BOBWEAVE)));
256 add_item(new BC_MenuItem(to_text(DEINTERLACE_SWAP)));
257 add_item(new BC_MenuItem(to_text(DEINTERLACE_TEMPORALSWAP)));
260 char* DeInterlaceMode::to_text(int mode)
264 case DEINTERLACE_KEEP:
265 return _("Duplicate one field");
266 case DEINTERLACE_AVG_1F:
267 return _("Average one field");
268 case DEINTERLACE_AVG:
269 return _("Average both fields");
270 case DEINTERLACE_BOBWEAVE:
271 return _("Bob & Weave");
272 case DEINTERLACE_SWAP:
273 return _("Spatial field swap");
274 case DEINTERLACE_TEMPORALSWAP:
275 return _("Temporal field swap");
277 return _("Do Nothing");
280 int DeInterlaceMode::from_text(char *text)
282 if(!strcmp(text, to_text(DEINTERLACE_KEEP)))
283 return DEINTERLACE_KEEP;
284 if(!strcmp(text, to_text(DEINTERLACE_AVG)))
285 return DEINTERLACE_AVG;
286 if(!strcmp(text, to_text(DEINTERLACE_AVG_1F)))
287 return DEINTERLACE_AVG_1F;
288 if(!strcmp(text, to_text(DEINTERLACE_BOBWEAVE)))
289 return DEINTERLACE_BOBWEAVE;
290 if(!strcmp(text, to_text(DEINTERLACE_SWAP)))
291 return DEINTERLACE_SWAP;
292 if(!strcmp(text, to_text(DEINTERLACE_TEMPORALSWAP)))
293 return DEINTERLACE_TEMPORALSWAP;
294 return DEINTERLACE_NONE;
297 int DeInterlaceMode::handle_event()
299 plugin->config.mode = from_text(get_text());
300 gui->set_mode(plugin->config.mode,0);
301 plugin->send_configure_change();