PKGBUILD fix libva/vdpau deps
[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, 280, 190, 280, 190, 0) //195 was 150
37 {
38         this->client = client;
39 }
40
41 SharpenWindow::~SharpenWindow()
42 {
43 }
44
45 void SharpenWindow::create_objects()
46 {
47         int x = 10, y = 10;
48         int x1 = 0; int clrBtn_w = 50;
49         int defaultBtn_w = 100;
50
51         add_tool(new BC_Title(x, y, _("Sharpness")));
52         y += 20;
53         add_tool(sharpen_slider = new SharpenSlider(client, &(client->config.sharpness), x, y));
54         x1 = x + sharpen_slider->get_w() + 10;
55         add_subwindow(sharpen_sliderClr = new SharpenSliderClr(client, this, x1, y, clrBtn_w));
56
57         y += 30;
58         add_tool(sharpen_interlace = new SharpenInterlace(client, x, y));
59         y += 30;
60         add_tool(sharpen_horizontal = new SharpenHorizontal(client, x, y));
61         y += 30;
62         add_tool(sharpen_luminance = new SharpenLuminance(client, x, y));
63         y += 40;
64         add_tool(reset = new SharpenReset(client, this, x, y));
65         add_subwindow(default_settings = new SharpenDefaultSettings(client, this,
66                 (280 - 10 - defaultBtn_w), y, defaultBtn_w));
67
68         show_window();
69         flush();
70 }
71
72 void SharpenWindow::update_gui(int clear)
73 {
74         switch(clear) {
75                 case RESET_SHARPEN_SLIDER :
76                         sharpen_slider->update(client->config.sharpness);
77                         break;
78                 case RESET_ALL :
79                 case RESET_DEFAULT_SETTINGS :
80                 default:
81                         sharpen_slider->update(client->config.sharpness);
82                         sharpen_interlace->update(client->config.interlace);
83                         sharpen_horizontal->update(client->config.horizontal);
84                         sharpen_luminance->update(client->config.luminance);
85                         break;
86         }
87 }
88
89 SharpenSlider::SharpenSlider(SharpenMain *client, float *output, int x, int y)
90  : BC_ISlider(x,
91         y,
92         0,
93         200,
94         200,
95         0,
96         MAXSHARPNESS,
97         (int)*output,
98         0,
99         0,
100         0)
101 {
102         this->client = client;
103         this->output = output;
104 }
105 SharpenSlider::~SharpenSlider()
106 {
107 }
108 int SharpenSlider::handle_event()
109 {
110         *output = get_value();
111         client->send_configure_change();
112         return 1;
113 }
114
115
116 SharpenInterlace::SharpenInterlace(SharpenMain *client, int x, int y)
117  : BC_CheckBox(x, y, client->config.interlace, _("Interlace"))
118 {
119         this->client = client;
120 }
121 SharpenInterlace::~SharpenInterlace()
122 {
123 }
124 int SharpenInterlace::handle_event()
125 {
126         client->config.interlace = get_value();
127         client->send_configure_change();
128         return 1;
129 }
130
131
132 SharpenHorizontal::SharpenHorizontal(SharpenMain *client, int x, int y)
133  : BC_CheckBox(x, y, client->config.horizontal, _("Horizontal only"))
134 {
135         this->client = client;
136 }
137 SharpenHorizontal::~SharpenHorizontal()
138 {
139 }
140 int SharpenHorizontal::handle_event()
141 {
142         client->config.horizontal = get_value();
143         client->send_configure_change();
144         return 1;
145 }
146
147
148 SharpenLuminance::SharpenLuminance(SharpenMain *client, int x, int y)
149  : BC_CheckBox(x, y, client->config.luminance, _("Luminance only"))
150 {
151         this->client = client;
152 }
153 SharpenLuminance::~SharpenLuminance()
154 {
155 }
156 int SharpenLuminance::handle_event()
157 {
158         client->config.luminance = get_value();
159         client->send_configure_change();
160         return 1;
161 }
162
163
164 SharpenReset::SharpenReset(SharpenMain *client, SharpenWindow *gui, int x, int y)
165  : BC_GenericButton(x, y, _("Reset"))
166 {
167         this->client = client;
168         this->gui = gui;
169 }
170 SharpenReset::~SharpenReset()
171 {
172 }
173 int SharpenReset::handle_event()
174 {
175         client->config.reset(RESET_ALL);
176         gui->update_gui(RESET_ALL);
177         client->send_configure_change();
178         return 1;
179 }
180
181
182 SharpenDefaultSettings::SharpenDefaultSettings(SharpenMain *client, SharpenWindow *gui, int x, int y, int w)
183  : BC_GenericButton(x, y, w, _("Default"))
184 {
185         this->client = client;
186         this->gui = gui;
187 }
188 SharpenDefaultSettings::~SharpenDefaultSettings()
189 {
190 }
191 int SharpenDefaultSettings::handle_event()
192 {
193         client->config.reset(RESET_DEFAULT_SETTINGS);
194         gui->update_gui(RESET_DEFAULT_SETTINGS);
195         client->send_configure_change();
196         return 1;
197 }
198
199
200 SharpenSliderClr::SharpenSliderClr(SharpenMain *client, SharpenWindow *gui, int x, int y, int w)
201  : BC_GenericButton(x, y, w, _("⌂"))
202 {
203         this->client = client;
204         this->gui = gui;
205 }
206 SharpenSliderClr::~SharpenSliderClr()
207 {
208 }
209 int SharpenSliderClr::handle_event()
210 {
211         client->config.reset(RESET_SHARPEN_SLIDER);
212         gui->update_gui(RESET_SHARPEN_SLIDER);
213         client->send_configure_change();
214         return 1;
215 }
216