no longer need ffmpeg patch0 which was for Termux
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / sharpen / sharpenwindow.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 "language.h"
24 #include "sharpenwindow.h"
25
26
27
28
29
30
31
32
33
34
35 SharpenWindow::SharpenWindow(SharpenMain *client)
36  : PluginClientWindow(client, xS(420), yS(190), xS(420), yS(190), 0)
37 {
38         this->client = client;
39 }
40
41 SharpenWindow::~SharpenWindow()
42 {
43 }
44
45 void SharpenWindow::create_objects()
46 {
47         int xs10 = xS(10), xs100 = xS(100), xs200 = xS(200);
48         int ys10 = yS(10), ys30 = yS(30), ys40 = yS(40);
49         int x = xs10, y = ys10;
50         int x2 = xS(80), x3 = xS(180);
51         int clr_x = get_w()-x - xS(22); // note: clrBtn_w = 22
52         int defaultBtn_w = xs100;
53
54         BC_Bar *bar;
55
56         y += ys10;
57         add_tool(new BC_Title(x, y, _("Sharpness:")));
58         sharpen_text = new SharpenText(client, this, (x + x2), y);
59         sharpen_text->create_objects();
60         add_tool(sharpen_slider = new SharpenSlider(client, this, x3, y, xs200));
61         clr_x = x3 + sharpen_slider->get_w() + x;
62         add_subwindow(sharpen_Clr = new SharpenClr(client, this, clr_x, y));
63
64         y += ys30;
65         add_tool(sharpen_interlace = new SharpenInterlace(client, x, y));
66         y += ys30;
67         add_tool(sharpen_horizontal = new SharpenHorizontal(client, x, y));
68         y += ys30;
69         add_tool(sharpen_luminance = new SharpenLuminance(client, x, y));
70         y += ys40;
71
72 // Reset section
73         add_subwindow(bar = new BC_Bar(x, y, get_w()-2*x));
74         y += ys10;
75         add_tool(reset = new SharpenReset(client, this, x, y));
76         add_subwindow(default_settings = new SharpenDefaultSettings(client, this,
77                 (get_w() - xs10 - defaultBtn_w), y, defaultBtn_w));
78
79         show_window();
80         flush();
81 }
82
83 void SharpenWindow::update_gui(int clear)
84 {
85         switch(clear) {
86                 case RESET_SHARPEN :
87                         sharpen_text->update((int64_t)client->config.sharpness);
88                         sharpen_slider->update(client->config.sharpness);
89                         break;
90                 case RESET_ALL :
91                 case RESET_DEFAULT_SETTINGS :
92                 default:
93                         sharpen_text->update((int64_t)client->config.sharpness);
94                         sharpen_slider->update(client->config.sharpness);
95                         sharpen_interlace->update(client->config.interlace);
96                         sharpen_horizontal->update(client->config.horizontal);
97                         sharpen_luminance->update(client->config.luminance);
98                         break;
99         }
100 }
101
102 SharpenText::SharpenText(SharpenMain *client, SharpenWindow *gui, int x, int y)
103  : BC_TumbleTextBox(gui, client->config.sharpness,
104         0, MAXSHARPNESS, x, y, xS(60), 0)
105 {
106         this->client = client;
107         this->gui = gui;
108         set_increment(1);
109 }
110
111 SharpenText::~SharpenText()
112 {
113 }
114
115 int SharpenText::handle_event()
116 {
117         client->config.sharpness = atoi(get_text());
118         if(client->config.sharpness > MAXSHARPNESS)
119                 client->config.sharpness = MAXSHARPNESS;
120         else
121                 if(client->config.sharpness < 0) client->config.sharpness = 0;
122
123         gui->sharpen_slider->update((int64_t)client->config.sharpness);
124         client->send_configure_change();
125         return 1;
126 }
127
128 SharpenSlider::SharpenSlider(SharpenMain *client, SharpenWindow *gui, int x, int y, int w)
129  : BC_ISlider(x, y, 0, w, w, 0, MAXSHARPNESS, client->config.sharpness, 0, 0, 0)
130 {
131         this->client = client;
132         this->gui = gui;
133         enable_show_value(0); // Hide caption
134 }
135 SharpenSlider::~SharpenSlider()
136 {
137 }
138 int SharpenSlider::handle_event()
139 {
140         client->config.sharpness = get_value();
141         gui->sharpen_text->update(client->config.sharpness);
142         client->send_configure_change();
143         return 1;
144 }
145
146
147 SharpenInterlace::SharpenInterlace(SharpenMain *client, int x, int y)
148  : BC_CheckBox(x, y, client->config.interlace, _("Interlace"))
149 {
150         this->client = client;
151 }
152 SharpenInterlace::~SharpenInterlace()
153 {
154 }
155 int SharpenInterlace::handle_event()
156 {
157         client->config.interlace = get_value();
158         client->send_configure_change();
159         return 1;
160 }
161
162
163 SharpenHorizontal::SharpenHorizontal(SharpenMain *client, int x, int y)
164  : BC_CheckBox(x, y, client->config.horizontal, _("Horizontal only"))
165 {
166         this->client = client;
167 }
168 SharpenHorizontal::~SharpenHorizontal()
169 {
170 }
171 int SharpenHorizontal::handle_event()
172 {
173         client->config.horizontal = get_value();
174         client->send_configure_change();
175         return 1;
176 }
177
178
179 SharpenLuminance::SharpenLuminance(SharpenMain *client, int x, int y)
180  : BC_CheckBox(x, y, client->config.luminance, _("Luminance only"))
181 {
182         this->client = client;
183 }
184 SharpenLuminance::~SharpenLuminance()
185 {
186 }
187 int SharpenLuminance::handle_event()
188 {
189         client->config.luminance = get_value();
190         client->send_configure_change();
191         return 1;
192 }
193
194
195 SharpenReset::SharpenReset(SharpenMain *client, SharpenWindow *gui, int x, int y)
196  : BC_GenericButton(x, y, _("Reset"))
197 {
198         this->client = client;
199         this->gui = gui;
200 }
201 SharpenReset::~SharpenReset()
202 {
203 }
204 int SharpenReset::handle_event()
205 {
206         client->config.reset(RESET_ALL);
207         gui->update_gui(RESET_ALL);
208         client->send_configure_change();
209         return 1;
210 }
211
212
213 SharpenDefaultSettings::SharpenDefaultSettings(SharpenMain *client, SharpenWindow *gui, int x, int y, int w)
214  : BC_GenericButton(x, y, w, _("Default"))
215 {
216         this->client = client;
217         this->gui = gui;
218 }
219 SharpenDefaultSettings::~SharpenDefaultSettings()
220 {
221 }
222 int SharpenDefaultSettings::handle_event()
223 {
224         client->config.reset(RESET_DEFAULT_SETTINGS);
225         gui->update_gui(RESET_DEFAULT_SETTINGS);
226         client->send_configure_change();
227         return 1;
228 }
229
230
231 SharpenClr::SharpenClr(SharpenMain *client, SharpenWindow *gui, int x, int y)
232  : BC_Button(x, y, client->get_theme()->get_image_set("reset_button"))
233 {
234         this->client = client;
235         this->gui = gui;
236 }
237 SharpenClr::~SharpenClr()
238 {
239 }
240 int SharpenClr::handle_event()
241 {
242         client->config.reset(RESET_SHARPEN);
243         gui->update_gui(RESET_SHARPEN);
244         client->send_configure_change();
245         return 1;
246 }
247