remove whitespace at eol
[goodguy/history.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         210,
46         230,
47         210,
48         230,
49         0)
50 {
51         this->client = client;
52 }
53
54 IVTCWindow::~IVTCWindow()
55 {
56 }
57
58 void IVTCWindow::create_objects()
59 {
60         int x = 10, y = 10;
61
62         add_tool(new BC_Title(x, y, _("Pattern offset:")));
63         y += 20;
64         add_tool(frame_offset = new IVTCOffset(client, x, y));
65         y += 30;
66         add_tool(first_field = new IVTCFieldOrder(client, x, y));
67 //      y += 30;
68 //      add_tool(automatic = new IVTCAuto(client, x, y));
69         y += 40;
70         add_subwindow(new BC_Title(x, y, _("Pattern:")));
71         y += 20;
72         for(int i = 0; i < TOTAL_PATTERNS; i++)
73         {
74                 add_subwindow(pattern[i] = new IVTCPattern(client,
75                         this,
76                         i,
77                         _(pattern_text[i]),
78                         x,
79                         y));
80                 y += 20;
81         }
82
83         if(client->config.pattern == IVTCConfig::AUTOMATIC)
84         {
85                 frame_offset->disable();
86                 first_field->disable();
87         }
88 //      y += 30;
89 //      add_tool(new BC_Title(x, y, _("Field threshold:")));
90 //      y += 20;
91 //      add_tool(threshold = new IVTCAutoThreshold(client, x, y));
92         show_window();
93         flush();
94 }
95
96
97
98 IVTCOffset::IVTCOffset(IVTCMain *client, int x, int y)
99  : BC_TextBox(x,
100         y,
101         190,
102         1,
103         client->config.frame_offset)
104 {
105         this->client = client;
106 }
107 IVTCOffset::~IVTCOffset()
108 {
109 }
110 int IVTCOffset::handle_event()
111 {
112         client->config.frame_offset = atol(get_text());
113         client->send_configure_change();
114         return 1;
115 }
116
117
118
119
120 IVTCFieldOrder::IVTCFieldOrder(IVTCMain *client, int x, int y)
121  : BC_CheckBox(x, y, client->config.first_field, _("Odd field first"))
122 {
123         this->client = client;
124 }
125 IVTCFieldOrder::~IVTCFieldOrder()
126 {
127 }
128 int IVTCFieldOrder::handle_event()
129 {
130         client->config.first_field = get_value();
131         client->send_configure_change();
132         return 1;
133 }
134
135
136 IVTCAuto::IVTCAuto(IVTCMain *client, int x, int y)
137  : BC_CheckBox(x, y, client->config.automatic, _("Automatic IVTC"))
138 {
139         this->client = client;
140 }
141 IVTCAuto::~IVTCAuto()
142 {
143 }
144 int IVTCAuto::handle_event()
145 {
146         client->config.automatic = get_value();
147         client->send_configure_change();
148         return 1;
149 }
150
151 IVTCPattern::IVTCPattern(IVTCMain *client,
152         IVTCWindow *window,
153         int number,
154         char *text,
155         int x,
156         int y)
157  : BC_Radial(x, y, client->config.pattern == number, text)
158 {
159         this->window = window;
160         this->client = client;
161         this->number = number;
162 }
163 IVTCPattern::~IVTCPattern()
164 {
165 }
166 int IVTCPattern::handle_event()
167 {
168         client->config.pattern = number;
169         if(number == IVTCConfig::AUTOMATIC)
170         {
171                 window->frame_offset->disable();
172                 window->first_field->disable();
173         }
174         else
175         {
176                 window->frame_offset->enable();
177                 window->first_field->enable();
178         }
179
180         for(int i = 0; i < TOTAL_PATTERNS; i++)
181         {
182                 if(i != number) window->pattern[i]->update(0);
183         }
184         update(1);
185         client->send_configure_change();
186         return 1;
187 }
188
189
190
191 IVTCAutoThreshold::IVTCAutoThreshold(IVTCMain *client, int x, int y)
192  : BC_TextBox(x, y, 190, 1, client->config.auto_threshold)
193 {
194         this->client = client;
195 }
196 IVTCAutoThreshold::~IVTCAutoThreshold()
197 {
198 }
199 int IVTCAutoThreshold::handle_event()
200 {
201         client->config.auto_threshold = atof(get_text());
202         client->send_configure_change();
203         return 1;
204 }
205