1 #include "bcdisplayinfo.h"
2 #include "deinterwindow.h"
6 #define _(String) gettext(String)
7 #define gettext_noop(String) String
8 #define N_(String) gettext_noop (String)
12 PLUGIN_THREAD_OBJECT(DeInterlaceMain, DeInterlaceThread, DeInterlaceWindow)
17 DeInterlaceWindow::DeInterlaceWindow(DeInterlaceMain *client, int x, int y)
18 : BC_Window(client->gui_string,
29 this->client = client;
30 adaptive=0; dominance_top=0; dominance_bottom=0; threshold=0;
34 DeInterlaceWindow::~DeInterlaceWindow()
38 int DeInterlaceWindow::create_objects()
41 add_tool(new BC_Title(x, y, _("Select deinterlacing mode")));
43 add_tool(mode = new DeInterlaceMode(client, this, x, y));
44 mode->create_objects();
46 optional_controls_x=x;
47 optional_controls_y=y;
49 char string[BCTEXTLEN];
50 get_status_string(string, 0);
51 add_tool(status = new BC_Title(x, y, string));
54 set_mode(client->config.mode,0);
59 WINDOW_CLOSE_EVENT(DeInterlaceWindow)
61 void DeInterlaceWindow::get_status_string(char *string, int changed_rows)
63 sprintf(string, _("Changed rows: %d\n"), changed_rows);
66 int DeInterlaceWindow::set_mode(int mode, int recursive)
69 client->config.mode = mode;
71 /* Restore position of controls */
72 x=optional_controls_x;
73 y=optional_controls_y;
74 if (adaptive) { delete adaptive; adaptive=0; }
75 if (threshold) { delete threshold; threshold=0; }
76 if (dominance_top) { delete dominance_top; dominance_top=0; }
77 if (dominance_bottom) { delete dominance_bottom; dominance_bottom=0; }
79 /* Display Dominance controls */
82 case DEINTERLACE_KEEP:
83 case DEINTERLACE_BOBWEAVE:
84 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Keep top field")));
86 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y, _("Keep bottom field")));
89 case DEINTERLACE_AVG_1F:
90 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Average top fields")));
92 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y,"Average bottom fields"));
95 case DEINTERLACE_SWAP:
96 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Top field first")));
98 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y, _("Bottom field first")));
101 case DEINTERLACE_TEMPORALSWAP:
102 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Top field first")));
104 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y, _("Bottom field first")));
107 case DEINTERLACE_NONE:
108 case DEINTERLACE_AVG:
113 if (dominance_top&&dominance_bottom) {
114 dominance_top->update(client->config.dominance?0:BC_Toggle::TOGGLE_CHECKED);
115 dominance_bottom->update(client->config.dominance?BC_Toggle::TOGGLE_CHECKED:0);
118 /* Display Threshold and adaptive controls */
120 case DEINTERLACE_AVG_1F:
121 add_subwindow(adaptive = new DeInterlaceAdaptive(client, x, y));
123 add_subwindow(threshold = new DeInterlaceThreshold(client, x + 150, y));
124 add_subwindow(threshold->title_caption=new BC_Title(x+150, y + 50, _("Threshold")));
125 adaptive->update(client->config.adaptive?BC_Toggle::TOGGLE_CHECKED:0);
127 case DEINTERLACE_BOBWEAVE:
128 add_subwindow(threshold = new DeInterlaceThreshold(client, x + 150, y));
129 add_subwindow(threshold->title_caption=new BC_Title(x+150, y + 50, _("Bob Threshold")));
131 case DEINTERLACE_NONE:
132 case DEINTERLACE_KEEP:
133 case DEINTERLACE_AVG:
134 case DEINTERLACE_SWAP:
135 case DEINTERLACE_TEMPORALSWAP:
143 client->send_configure_change();
148 DeInterlaceOption::DeInterlaceOption(DeInterlaceMain *client,
149 DeInterlaceWindow *window,
154 : BC_Radial(x, y, client->config.mode == output, text)
156 this->client = client;
157 this->window = window;
158 this->output = output;
161 DeInterlaceOption::~DeInterlaceOption()
164 int DeInterlaceOption::handle_event()
166 window->set_mode(output, 0);
171 DeInterlaceAdaptive::DeInterlaceAdaptive(DeInterlaceMain *client, int x, int y)
172 : BC_CheckBox(x, y, client->config.adaptive, _("Adaptive") )
174 this->client = client;
176 int DeInterlaceAdaptive::handle_event()
178 client->config.adaptive = get_value();
179 client->send_configure_change();
183 DeInterlaceDominanceTop::DeInterlaceDominanceTop(DeInterlaceMain *client, DeInterlaceWindow *window, int x, int y, char * title)
184 : BC_Radial(x, y, client->config.dominance, title)
186 this->client = client;
187 this->window = window;
190 int DeInterlaceDominanceTop::handle_event()
192 client->config.dominance = (get_value()==0);
193 window->dominance_bottom->update(client->config.dominance?BC_Toggle::TOGGLE_CHECKED:0);
194 client->send_configure_change();
199 DeInterlaceDominanceBottom::DeInterlaceDominanceBottom(DeInterlaceMain *client, DeInterlaceWindow *window, int x, int y, char * title)
200 : BC_Radial(x, y, client->config.dominance, title)
202 this->client = client;
203 this->window = window;
205 int DeInterlaceDominanceBottom::handle_event()
208 client->config.dominance = (get_value() != 0 );
209 window->dominance_top->update(client->config.dominance?0:BC_Toggle::TOGGLE_CHECKED);
210 client->send_configure_change();
215 DeInterlaceThreshold::DeInterlaceThreshold(DeInterlaceMain *client, int x, int y)
216 : BC_IPot(x, y, client->config.threshold, 0, 100)
218 this->client = client;
221 int DeInterlaceThreshold::handle_event()
223 client->config.threshold = get_value();
224 client->send_configure_change();
228 DeInterlaceThreshold::~DeInterlaceThreshold()
230 if (title_caption) delete title_caption;
233 DeInterlaceMode::DeInterlaceMode(DeInterlaceMain*plugin,
234 DeInterlaceWindow *gui,
237 : BC_PopupMenu(x, y, 200, to_text(plugin->config.mode), 1)
239 this->plugin = plugin;
242 void DeInterlaceMode::create_objects()
244 add_item(new BC_MenuItem(to_text(DEINTERLACE_NONE)));
245 add_item(new BC_MenuItem(to_text(DEINTERLACE_KEEP)));
246 add_item(new BC_MenuItem(to_text(DEINTERLACE_AVG)));
247 add_item(new BC_MenuItem(to_text(DEINTERLACE_AVG_1F)));
248 add_item(new BC_MenuItem(to_text(DEINTERLACE_BOBWEAVE)));
249 add_item(new BC_MenuItem(to_text(DEINTERLACE_SWAP)));
250 add_item(new BC_MenuItem(to_text(DEINTERLACE_TEMPORALSWAP)));
253 char* DeInterlaceMode::to_text(int mode)
257 case DEINTERLACE_KEEP:
258 return _("Duplicate one field");
259 case DEINTERLACE_AVG_1F:
260 return _("Average one field");
261 case DEINTERLACE_AVG:
262 return _("Average both fields");
263 case DEINTERLACE_BOBWEAVE:
264 return _("Bob & Weave");
265 case DEINTERLACE_SWAP:
266 return _("Spatial field swap");
267 case DEINTERLACE_TEMPORALSWAP:
268 return _("Temporal field swap");
270 return _("Do Nothing");
273 int DeInterlaceMode::from_text(char *text)
275 if(!strcmp(text, to_text(DEINTERLACE_KEEP)))
276 return DEINTERLACE_KEEP;
277 if(!strcmp(text, to_text(DEINTERLACE_AVG)))
278 return DEINTERLACE_AVG;
279 if(!strcmp(text, to_text(DEINTERLACE_AVG_1F)))
280 return DEINTERLACE_AVG_1F;
281 if(!strcmp(text, to_text(DEINTERLACE_BOBWEAVE)))
282 return DEINTERLACE_BOBWEAVE;
283 if(!strcmp(text, to_text(DEINTERLACE_SWAP)))
284 return DEINTERLACE_SWAP;
285 if(!strcmp(text, to_text(DEINTERLACE_TEMPORALSWAP)))
286 return DEINTERLACE_TEMPORALSWAP;
287 return DEINTERLACE_NONE;
290 int DeInterlaceMode::handle_event()
292 plugin->config.mode = from_text(get_text());
293 gui->set_mode(plugin->config.mode,0);
294 plugin->send_configure_change();