add BC_SCALE env var for hi def monitors, cleanup theme data
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / ivtc / ivtcwindow.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #include "bcdisplayinfo.h"
23 #include "ivtcwindow.h"
24 #include "language.h"
25
26
27 static const char *pattern_text[] =
28 {
29         "A  B  BC  CD  D",
30         "AB  BC  CD  DE  EF",
31         "Automatic",
32         N_("A  B  BC  CD  D"),
33         N_("AB  BC  CD  DE  EF"),
34         N_("Automatic")
35 };
36
37
38
39
40
41
42
43 IVTCWindow::IVTCWindow(IVTCMain *client)
44  : PluginClientWindow(client,
45         xS(210),
46         yS(230),
47         xS(210),
48         yS(230),
49         0)
50 {
51         this->client = client;
52 }
53
54 IVTCWindow::~IVTCWindow()
55 {
56 }
57
58 void IVTCWindow::create_objects()
59 {
60         int xs10 = xS(10);
61         int ys10 = yS(10), ys20 = yS(20), ys30 = yS(30), ys40 = yS(40);
62         int x = xs10, y = ys10;
63
64         add_tool(new BC_Title(x, y, _("Pattern offset:")));
65         y += ys20;
66         add_tool(frame_offset = new IVTCOffset(client, x, y));
67         y += ys30;
68         add_tool(first_field = new IVTCFieldOrder(client, x, y));
69 //      y += ys30;
70 //      add_tool(automatic = new IVTCAuto(client, x, y));
71         y += ys40;
72         add_subwindow(new BC_Title(x, y, _("Pattern:")));
73         y += ys20;
74         for(int i = 0; i < TOTAL_PATTERNS; i++)
75         {
76                 add_subwindow(pattern[i] = new IVTCPattern(client,
77                         this,
78                         i,
79                         _(pattern_text[i]),
80                         x,
81                         y));
82                 y += ys20;
83         }
84
85         if(client->config.pattern == IVTCConfig::AUTOMATIC)
86         {
87                 frame_offset->disable();
88                 first_field->disable();
89         }
90 //      y += ys30;
91 //      add_tool(new BC_Title(x, y, _("Field threshold:")));
92 //      y += ys20;
93 //      add_tool(threshold = new IVTCAutoThreshold(client, x, y));
94         show_window();
95         flush();
96 }
97
98
99
100 IVTCOffset::IVTCOffset(IVTCMain *client, int x, int y)
101  : BC_TextBox(x,
102         y,
103         xS(190),
104         1,
105         client->config.frame_offset)
106 {
107         this->client = client;
108 }
109 IVTCOffset::~IVTCOffset()
110 {
111 }
112 int IVTCOffset::handle_event()
113 {
114         client->config.frame_offset = atol(get_text());
115         client->send_configure_change();
116         return 1;
117 }
118
119
120
121
122 IVTCFieldOrder::IVTCFieldOrder(IVTCMain *client, int x, int y)
123  : BC_CheckBox(x, y, client->config.first_field, _("Odd field first"))
124 {
125         this->client = client;
126 }
127 IVTCFieldOrder::~IVTCFieldOrder()
128 {
129 }
130 int IVTCFieldOrder::handle_event()
131 {
132         client->config.first_field = get_value();
133         client->send_configure_change();
134         return 1;
135 }
136
137
138 IVTCAuto::IVTCAuto(IVTCMain *client, int x, int y)
139  : BC_CheckBox(x, y, client->config.automatic, _("Automatic IVTC"))
140 {
141         this->client = client;
142 }
143 IVTCAuto::~IVTCAuto()
144 {
145 }
146 int IVTCAuto::handle_event()
147 {
148         client->config.automatic = get_value();
149         client->send_configure_change();
150         return 1;
151 }
152
153 IVTCPattern::IVTCPattern(IVTCMain *client,
154         IVTCWindow *window,
155         int number,
156         char *text,
157         int x,
158         int y)
159  : BC_Radial(x, y, client->config.pattern == number, text)
160 {
161         this->window = window;
162         this->client = client;
163         this->number = number;
164 }
165 IVTCPattern::~IVTCPattern()
166 {
167 }
168 int IVTCPattern::handle_event()
169 {
170         client->config.pattern = number;
171         if(number == IVTCConfig::AUTOMATIC)
172         {
173                 window->frame_offset->disable();
174                 window->first_field->disable();
175         }
176         else
177         {
178                 window->frame_offset->enable();
179                 window->first_field->enable();
180         }
181
182         for(int i = 0; i < TOTAL_PATTERNS; i++)
183         {
184                 if(i != number) window->pattern[i]->update(0);
185         }
186         update(1);
187         client->send_configure_change();
188         return 1;
189 }
190
191
192
193 IVTCAutoThreshold::IVTCAutoThreshold(IVTCMain *client, int x, int y)
194  : BC_TextBox(x, y, xS(190), 1, client->config.auto_threshold)
195 {
196         this->client = client;
197 }
198 IVTCAutoThreshold::~IVTCAutoThreshold()
199 {
200 }
201 int IVTCAutoThreshold::handle_event()
202 {
203         client->config.auto_threshold = atof(get_text());
204         client->send_configure_change();
205         return 1;
206 }
207