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