3 * Copyright (C) 2016 Eric Olson
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 #include "bcdisplayinfo.h"
23 #include "edlsession.h"
24 #include "yuv411win.h"
27 yuv411Window::yuv411Window(yuv411Main *client)
28 : PluginClientWindow(client, xS(260), yS(250), xS(260), yS(250), 0)
30 this->client = client;
34 yuv411Window::~yuv411Window()
38 void yuv411Window::create_objects()
40 int xs10 = xS(10), xs90 = xS(90);
41 int ys10 = yS(10), ys30 = yS(30);
42 int x = xs10, y = ys10, x1=xs90;
43 add_tool(avg_vertical = new yuv411Toggle(client,
44 &(client->config.avg_vertical),
45 _("Vertical average"),
49 add_tool(int_horizontal = new yuv411Toggle(client,
50 &(client->config.int_horizontal),
51 _("Horizontal interpolate"),
55 add_tool(inpainting = new yuv411Toggle(client,
56 &(client->config.inpainting),
57 _("Inpainting method"),
61 add_subwindow(new BC_Title(x, y, _("Offset:")));
62 add_subwindow(offset=new yuv411Offset(client,x1,y));
64 add_subwindow(new BC_Title(x, y, _("Threshold:")));
65 add_subwindow(thresh=new yuv411Thresh(client,x1,y));
67 add_subwindow(new BC_Title(x, y, _("Bias:")));
68 add_subwindow(bias=new yuv411Bias(client,x1,y));
70 int y1 = get_h() - yuv411Reset::calculate_h() - yS(20);
71 add_subwindow(reset = new yuv411Reset(client, this, x, y1+ys10));
75 yuv_warning = new BC_Title(x, y, _("Warning: colormodel not YUV"),MEDIUMFONT,RED);
76 add_subwindow(yuv_warning);
77 EDL *edl = client->get_edl();
78 colormodel = edl->session->color_model;
79 switch( colormodel ) {
82 yuv_warning->hide_window();
87 void yuv411Window::update()
89 avg_vertical->update(client->config.avg_vertical);
90 int_horizontal->update(client->config.int_horizontal);
91 inpainting->update(client->config.inpainting);
92 offset->update(client->config.offset);
93 thresh->update(client->config.thresh);
94 bias->update(client->config.bias);
97 int yuv411Window::close_event()
103 yuv411Toggle::yuv411Toggle(yuv411Main *client, int *output, char *string, int x, int y)
104 : BC_CheckBox(x, y, *output, string)
106 this->client = client;
107 this->output = output;
109 yuv411Toggle::~yuv411Toggle()
112 int yuv411Toggle::handle_event()
114 *output = get_value();
115 ((yuv411Window*)client->thread->window)->update_enables();
116 client->send_configure_change();
120 yuv411Offset::yuv411Offset(yuv411Main *client, int x, int y)
121 : BC_FSlider(x+xS(60), y, 0, xS(100), yS(100), (float)0, (float)2,
122 (float)client->config.offset)
124 this->client = client;
127 int yuv411Offset::handle_event()
129 client->config.offset = get_value();
130 client->send_configure_change();
134 yuv411Thresh::yuv411Thresh(yuv411Main *client, int x, int y)
135 : BC_FSlider(x+xS(60), y, 0, xS(100), yS(100), (float)1, (float)100,
136 (float)client->config.thresh)
138 this->client = client;
141 int yuv411Thresh::handle_event()
143 client->config.thresh = get_value();
144 client->send_configure_change();
148 yuv411Bias::yuv411Bias(yuv411Main *client, int x, int y)
149 : BC_FSlider(x+xS(60), y, 0, xS(100), yS(100), (float)0, (float)25,
150 (float)client->config.bias)
152 this->client = client;
156 int yuv411Bias::handle_event()
158 client->config.bias = get_value();
159 client->send_configure_change();
163 yuv411Reset::yuv411Reset(yuv411Main *client, yuv411Window *window, int x, int y)
164 : BC_GenericButton(x, y, _("Reset"))
166 this->client = client;
167 this->window = window;
169 yuv411Reset::~yuv411Reset()
172 int yuv411Reset::handle_event()
174 client->config.reset();
176 window->update_enables();
177 client->send_configure_change();
182 void yuv411Window::update_enables()
184 yuv411Config &config = client->config;
185 if( !config.int_horizontal && config.inpainting ) {
186 config.inpainting = 0;
187 inpainting->set_value(0);
189 if( config.int_horizontal ) {
190 inpainting->enable();
191 offset->show_window();
194 inpainting->disable();
195 offset->hide_window();
197 if( config.int_horizontal && config.inpainting ) {
198 thresh->show_window();
202 thresh->hide_window();
207 void yuv411Window::show_warning(int warn)
210 yuv_warning->show_window();
212 yuv_warning->hide_window();