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 add_tool(new BC_Title(x, y, _("Select deinterlacing mode")));
50 add_tool(mode = new DeInterlaceMode(client, this, x, y));
51 mode->create_objects();
53 optional_controls_x=x;
54 optional_controls_y=y;
56 char string[BCTEXTLEN];
57 get_status_string(string, 0);
58 add_tool(status = new BC_Title(x, y, string));
61 set_mode(client->config.mode,0);
64 void DeInterlaceWindow::get_status_string(char *string, int changed_rows)
66 sprintf(string, _("Changed rows: %d\n"), changed_rows);
69 int DeInterlaceWindow::set_mode(int mode, int recursive)
72 client->config.mode = mode;
74 /* Restore position of controls */
75 x=optional_controls_x;
76 y=optional_controls_y;
77 if (adaptive) { delete adaptive; adaptive=0; }
78 if (threshold) { delete threshold; threshold=0; }
79 if (dominance_top) { delete dominance_top; dominance_top=0; }
80 if (dominance_bottom) { delete dominance_bottom; dominance_bottom=0; }
82 /* Display Dominance controls */
85 case DEINTERLACE_KEEP:
86 case DEINTERLACE_BOBWEAVE:
87 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Keep top field")));
89 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y, _("Keep bottom field")));
92 case DEINTERLACE_AVG_1F:
93 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Average top fields")));
95 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y,_("Average bottom fields")));
98 case DEINTERLACE_SWAP:
99 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Top field first")));
101 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y, _("Bottom field first")));
104 case DEINTERLACE_TEMPORALSWAP:
105 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Top field first")));
107 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y, _("Bottom field first")));
110 case DEINTERLACE_NONE:
111 case DEINTERLACE_AVG:
116 if (dominance_top&&dominance_bottom) {
117 dominance_top->update(client->config.dominance?0:BC_Toggle::TOGGLE_CHECKED);
118 dominance_bottom->update(client->config.dominance?BC_Toggle::TOGGLE_CHECKED:0);
121 /* Display Threshold and adaptive controls */
123 case DEINTERLACE_AVG_1F:
124 add_subwindow(adaptive = new DeInterlaceAdaptive(client, x, y));
126 add_subwindow(threshold = new DeInterlaceThreshold(client, x + 150, y));
127 add_subwindow(threshold->title_caption=new BC_Title(x+150, y + 50, _("Threshold")));
128 adaptive->update(client->config.adaptive?BC_Toggle::TOGGLE_CHECKED:0);
130 case DEINTERLACE_BOBWEAVE:
131 add_subwindow(threshold = new DeInterlaceThreshold(client, x + 150, y));
132 add_subwindow(threshold->title_caption=new BC_Title(x+150, y + 50, _("Bob Threshold")));
134 case DEINTERLACE_NONE:
135 case DEINTERLACE_KEEP:
136 case DEINTERLACE_AVG:
137 case DEINTERLACE_SWAP:
138 case DEINTERLACE_TEMPORALSWAP:
146 client->send_configure_change();
151 DeInterlaceOption::DeInterlaceOption(DeInterlaceMain *client,
152 DeInterlaceWindow *window,
157 : BC_Radial(x, y, client->config.mode == output, text)
159 this->client = client;
160 this->window = window;
161 this->output = output;
164 DeInterlaceOption::~DeInterlaceOption()
167 int DeInterlaceOption::handle_event()
169 window->set_mode(output, 0);
174 DeInterlaceAdaptive::DeInterlaceAdaptive(DeInterlaceMain *client, int x, int y)
175 : BC_CheckBox(x, y, client->config.adaptive, _("Adaptive"))
177 this->client = client;
179 int DeInterlaceAdaptive::handle_event()
181 client->config.adaptive = get_value();
182 client->send_configure_change();
186 DeInterlaceDominanceTop::DeInterlaceDominanceTop(DeInterlaceMain *client, DeInterlaceWindow *window, int x, int y, char * title)
187 : BC_Radial(x, y, client->config.dominance, title)
189 this->client = client;
190 this->window = window;
193 int DeInterlaceDominanceTop::handle_event()
195 client->config.dominance = (get_value()==0);
196 window->dominance_bottom->update(client->config.dominance?BC_Toggle::TOGGLE_CHECKED:0);
197 client->send_configure_change();
202 DeInterlaceDominanceBottom::DeInterlaceDominanceBottom(DeInterlaceMain *client, DeInterlaceWindow *window, int x, int y, const char * title)
203 : BC_Radial(x, y, client->config.dominance, title)
205 this->client = client;
206 this->window = window;
208 int DeInterlaceDominanceBottom::handle_event()
211 client->config.dominance = (get_value() != 0 );
212 window->dominance_top->update(client->config.dominance?0:BC_Toggle::TOGGLE_CHECKED);
213 client->send_configure_change();
218 DeInterlaceThreshold::DeInterlaceThreshold(DeInterlaceMain *client, int x, int y)
219 : BC_IPot(x, y, client->config.threshold, 0, 100)
221 this->client = client;
224 int DeInterlaceThreshold::handle_event()
226 client->config.threshold = get_value();
227 client->send_configure_change();
231 DeInterlaceThreshold::~DeInterlaceThreshold()
233 if (title_caption) delete title_caption;
236 DeInterlaceMode::DeInterlaceMode(DeInterlaceMain*plugin,
237 DeInterlaceWindow *gui,
240 : BC_PopupMenu(x, y, 200, to_text(plugin->config.mode), 1)
242 this->plugin = plugin;
245 void DeInterlaceMode::create_objects()
247 add_item(new BC_MenuItem(to_text(DEINTERLACE_NONE)));
248 add_item(new BC_MenuItem(to_text(DEINTERLACE_KEEP)));
249 add_item(new BC_MenuItem(to_text(DEINTERLACE_AVG)));
250 add_item(new BC_MenuItem(to_text(DEINTERLACE_AVG_1F)));
251 add_item(new BC_MenuItem(to_text(DEINTERLACE_BOBWEAVE)));
252 add_item(new BC_MenuItem(to_text(DEINTERLACE_SWAP)));
253 add_item(new BC_MenuItem(to_text(DEINTERLACE_TEMPORALSWAP)));
256 char* DeInterlaceMode::to_text(int mode)
260 case DEINTERLACE_KEEP:
261 return _("Duplicate one field");
262 case DEINTERLACE_AVG_1F:
263 return _("Average one field");
264 case DEINTERLACE_AVG:
265 return _("Average both fields");
266 case DEINTERLACE_BOBWEAVE:
267 return _("Bob & Weave");
268 case DEINTERLACE_SWAP:
269 return _("Spatial field swap");
270 case DEINTERLACE_TEMPORALSWAP:
271 return _("Temporal field swap");
273 return _("Do Nothing");
276 int DeInterlaceMode::from_text(char *text)
278 if(!strcmp(text, to_text(DEINTERLACE_KEEP)))
279 return DEINTERLACE_KEEP;
280 if(!strcmp(text, to_text(DEINTERLACE_AVG)))
281 return DEINTERLACE_AVG;
282 if(!strcmp(text, to_text(DEINTERLACE_AVG_1F)))
283 return DEINTERLACE_AVG_1F;
284 if(!strcmp(text, to_text(DEINTERLACE_BOBWEAVE)))
285 return DEINTERLACE_BOBWEAVE;
286 if(!strcmp(text, to_text(DEINTERLACE_SWAP)))
287 return DEINTERLACE_SWAP;
288 if(!strcmp(text, to_text(DEINTERLACE_TEMPORALSWAP)))
289 return DEINTERLACE_TEMPORALSWAP;
290 return DEINTERLACE_NONE;
293 int DeInterlaceMode::handle_event()
295 plugin->config.mode = from_text(get_text());
296 gui->set_mode(plugin->config.mode,0);
297 plugin->send_configure_change();