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);
58 WINDOW_CLOSE_EVENT(DeInterlaceWindow)
60 void DeInterlaceWindow::get_status_string(char *string, int changed_rows)
62 sprintf(string, _("Changed rows: %d\n"), changed_rows);
65 int DeInterlaceWindow::set_mode(int mode, int recursive)
68 client->config.mode = mode;
70 /* Restore position of controls */
71 x=optional_controls_x;
72 y=optional_controls_y;
73 if (adaptive) { delete adaptive; adaptive=0; }
74 if (threshold) { delete threshold; threshold=0; }
75 if (dominance_top) { delete dominance_top; dominance_top=0; }
76 if (dominance_bottom) { delete dominance_bottom; dominance_bottom=0; }
78 /* Display Dominance controls */
81 case DEINTERLACE_KEEP:
82 case DEINTERLACE_BOBWEAVE:
83 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Keep top field")));
85 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y, _("Keep bottom field")));
88 case DEINTERLACE_AVG_1F:
89 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Average top fields")));
91 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y,"Average bottom fields"));
94 case DEINTERLACE_SWAP:
95 add_subwindow(dominance_top = new DeInterlaceDominanceTop(client, this, x, y, _("Top field first")));
97 add_subwindow(dominance_bottom = new DeInterlaceDominanceBottom(client, this, x, y, _("Bottom field first")));
100 case DEINTERLACE_TEMPORALSWAP:
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_NONE:
107 case DEINTERLACE_AVG:
112 if (dominance_top&&dominance_bottom) {
113 dominance_top->update(client->config.dominance?0:BC_Toggle::TOGGLE_CHECKED);
114 dominance_bottom->update(client->config.dominance?BC_Toggle::TOGGLE_CHECKED:0);
117 /* Display Threshold and adaptive controls */
119 case DEINTERLACE_AVG_1F:
120 add_subwindow(adaptive = new DeInterlaceAdaptive(client, x, y));
122 add_subwindow(threshold = new DeInterlaceThreshold(client, x + 150, y));
123 add_subwindow(threshold->title_caption=new BC_Title(x+150, y + 50, _("Threshold")));
124 adaptive->update(client->config.adaptive?BC_Toggle::TOGGLE_CHECKED:0);
126 case DEINTERLACE_BOBWEAVE:
127 add_subwindow(threshold = new DeInterlaceThreshold(client, x + 150, y));
128 add_subwindow(threshold->title_caption=new BC_Title(x+150, y + 50, _("Bob Threshold")));
130 case DEINTERLACE_NONE:
131 case DEINTERLACE_KEEP:
132 case DEINTERLACE_AVG:
133 case DEINTERLACE_SWAP:
134 case DEINTERLACE_TEMPORALSWAP:
142 client->send_configure_change();
147 DeInterlaceOption::DeInterlaceOption(DeInterlaceMain *client,
148 DeInterlaceWindow *window,
153 : BC_Radial(x, y, client->config.mode == output, text)
155 this->client = client;
156 this->window = window;
157 this->output = output;
160 DeInterlaceOption::~DeInterlaceOption()
163 int DeInterlaceOption::handle_event()
165 window->set_mode(output, 0);
170 DeInterlaceAdaptive::DeInterlaceAdaptive(DeInterlaceMain *client, int x, int y)
171 : BC_CheckBox(x, y, client->config.adaptive, _("Adaptive"))
173 this->client = client;
175 int DeInterlaceAdaptive::handle_event()
177 client->config.adaptive = get_value();
178 client->send_configure_change();
182 DeInterlaceDominanceTop::DeInterlaceDominanceTop(DeInterlaceMain *client, DeInterlaceWindow *window, int x, int y, char * title)
183 : BC_Radial(x, y, client->config.dominance, title)
185 this->client = client;
186 this->window = window;
189 int DeInterlaceDominanceTop::handle_event()
191 client->config.dominance = (get_value()==0);
192 window->dominance_bottom->update(client->config.dominance?BC_Toggle::TOGGLE_CHECKED:0);
193 client->send_configure_change();
198 DeInterlaceDominanceBottom::DeInterlaceDominanceBottom(DeInterlaceMain *client, DeInterlaceWindow *window, int x, int y, char * title)
199 : BC_Radial(x, y, client->config.dominance, title)
201 this->client = client;
202 this->window = window;
204 int DeInterlaceDominanceBottom::handle_event()
207 client->config.dominance = (get_value() != 0 );
208 window->dominance_top->update(client->config.dominance?0:BC_Toggle::TOGGLE_CHECKED);
209 client->send_configure_change();
214 DeInterlaceThreshold::DeInterlaceThreshold(DeInterlaceMain *client, int x, int y)
215 : BC_IPot(x, y, client->config.threshold, 0, 100)
217 this->client = client;
220 int DeInterlaceThreshold::handle_event()
222 client->config.threshold = get_value();
223 client->send_configure_change();
227 DeInterlaceThreshold::~DeInterlaceThreshold()
229 if (title_caption) delete title_caption;
232 DeInterlaceMode::DeInterlaceMode(DeInterlaceMain*plugin,
233 DeInterlaceWindow *gui,
236 : BC_PopupMenu(x, y, 200, to_text(plugin->config.mode), 1)
238 this->plugin = plugin;
241 void DeInterlaceMode::create_objects()
243 add_item(new BC_MenuItem(to_text(DEINTERLACE_NONE)));
244 add_item(new BC_MenuItem(to_text(DEINTERLACE_KEEP)));
245 add_item(new BC_MenuItem(to_text(DEINTERLACE_AVG)));
246 add_item(new BC_MenuItem(to_text(DEINTERLACE_AVG_1F)));
247 add_item(new BC_MenuItem(to_text(DEINTERLACE_BOBWEAVE)));
248 add_item(new BC_MenuItem(to_text(DEINTERLACE_SWAP)));
249 add_item(new BC_MenuItem(to_text(DEINTERLACE_TEMPORALSWAP)));
252 char* DeInterlaceMode::to_text(int mode)
256 case DEINTERLACE_KEEP:
257 return _("Duplicate one field");
258 case DEINTERLACE_AVG_1F:
259 return _("Average one field");
260 case DEINTERLACE_AVG:
261 return _("Average both fields");
262 case DEINTERLACE_BOBWEAVE:
263 return _("Bob & Weave");
264 case DEINTERLACE_SWAP:
265 return _("Spatial field swap");
266 case DEINTERLACE_TEMPORALSWAP:
267 return _("Temporal field swap");
269 return _("Do Nothing");
272 int DeInterlaceMode::from_text(char *text)
274 if(!strcmp(text, to_text(DEINTERLACE_KEEP)))
275 return DEINTERLACE_KEEP;
276 if(!strcmp(text, to_text(DEINTERLACE_AVG)))
277 return DEINTERLACE_AVG;
278 if(!strcmp(text, to_text(DEINTERLACE_AVG_1F)))
279 return DEINTERLACE_AVG_1F;
280 if(!strcmp(text, to_text(DEINTERLACE_BOBWEAVE)))
281 return DEINTERLACE_BOBWEAVE;
282 if(!strcmp(text, to_text(DEINTERLACE_SWAP)))
283 return DEINTERLACE_SWAP;
284 if(!strcmp(text, to_text(DEINTERLACE_TEMPORALSWAP)))
285 return DEINTERLACE_TEMPORALSWAP;
286 return DEINTERLACE_NONE;
289 int DeInterlaceMode::handle_event()
291 plugin->config.mode = from_text(get_text());
292 gui->set_mode(plugin->config.mode,0);
293 plugin->send_configure_change();