PKGBUILD fix libva/vdpau deps
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / unsharp / unsharpwindow.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 "unsharp.h"
25 #include "unsharpwindow.h"
26
27
28
29
30
31
32
33
34
35
36 UnsharpWindow::UnsharpWindow(UnsharpMain *plugin)
37  : PluginClientWindow(plugin, 285, 170, 285, 170, 0)
38 {
39         this->plugin = plugin;
40 }
41
42 UnsharpWindow::~UnsharpWindow()
43 {
44 }
45
46 void UnsharpWindow::create_objects()
47 {
48         int x = 10, y = 10, x1 = 90;
49         int x2 = 0; int clrBtn_w = 50;
50         int defaultBtn_w = 100;
51         BC_Title *title;
52
53         add_subwindow(title = new BC_Title(x, y + 10, _("Radius:")));
54         add_subwindow(radius = new UnsharpRadius(plugin, x + x1, y));
55         x2 = 285 - 10 - clrBtn_w;
56         add_subwindow(radiusClr = new UnsharpSliderClr(plugin, this, x2, y + 10, clrBtn_w, RESET_RADIUS));
57
58         y += 40;
59         add_subwindow(title = new BC_Title(x, y + 10, _("Amount:")));
60         add_subwindow(amount = new UnsharpAmount(plugin, x + x1, y));
61         add_subwindow(amountClr = new UnsharpSliderClr(plugin, this, x2, y + 10, clrBtn_w, RESET_AMOUNT));
62
63         y += 40;
64         add_subwindow(title = new BC_Title(x, y + 10, _("Threshold:")));
65         add_subwindow(threshold = new UnsharpThreshold(plugin, x + x1, y));
66         add_subwindow(thresholdClr = new UnsharpSliderClr(plugin, this, x2, y + 10, clrBtn_w, RESET_THRESHOLD));
67
68         y += 50;
69         add_subwindow(reset = new UnsharpReset(plugin, this, x, y));
70         add_subwindow(default_settings = new UnsharpDefaultSettings(plugin, this,
71                 (285 - 10 - defaultBtn_w), y, defaultBtn_w));
72
73         show_window();
74         flush();
75 }
76
77
78 void UnsharpWindow::update_gui(int clear)
79 {
80         switch(clear) {
81                 case RESET_RADIUS : radius->update(plugin->config.radius);
82                         break;
83                 case RESET_AMOUNT : amount->update(plugin->config.amount);
84                         break;
85                 case RESET_THRESHOLD : threshold->update(plugin->config.threshold);
86                         break;
87                 case RESET_ALL :
88                 case RESET_DEFAULT_SETTINGS :
89                 default:
90                         radius->update(plugin->config.radius);
91                         amount->update(plugin->config.amount);
92                         threshold->update(plugin->config.threshold);
93                         break;
94         }
95 }
96
97
98
99
100
101
102
103
104
105
106 UnsharpRadius::UnsharpRadius(UnsharpMain *plugin, int x, int y)
107  : BC_FPot(x, y, plugin->config.radius, 0.1, 120)
108 {
109         this->plugin = plugin;
110 }
111 int UnsharpRadius::handle_event()
112 {
113         plugin->config.radius = get_value();
114         plugin->send_configure_change();
115         return 1;
116 }
117
118 UnsharpAmount::UnsharpAmount(UnsharpMain *plugin, int x, int y)
119  : BC_FPot(x, y, plugin->config.amount, 0, 5)
120 {
121         this->plugin = plugin;
122 }
123 int UnsharpAmount::handle_event()
124 {
125         plugin->config.amount = get_value();
126         plugin->send_configure_change();
127         return 1;
128 }
129
130 UnsharpThreshold::UnsharpThreshold(UnsharpMain *plugin, int x, int y)
131  : BC_IPot(x, y, plugin->config.threshold, 0, 255)
132 {
133         this->plugin = plugin;
134 }
135 int UnsharpThreshold::handle_event()
136 {
137         plugin->config.threshold = get_value();
138         plugin->send_configure_change();
139         return 1;
140 }
141
142 UnsharpReset::UnsharpReset(UnsharpMain *plugin, UnsharpWindow *window, int x, int y)
143  : BC_GenericButton(x, y, _("Reset"))
144 {
145         this->plugin = plugin;
146         this->window = window;
147 }
148 UnsharpReset::~UnsharpReset()
149 {
150 }
151 int UnsharpReset::handle_event()
152 {
153         plugin->config.reset(RESET_ALL);
154         window->update_gui(RESET_ALL);
155         plugin->send_configure_change();
156         return 1;
157 }
158
159 UnsharpDefaultSettings::UnsharpDefaultSettings(UnsharpMain *plugin, UnsharpWindow *window, int x, int y, int w)
160  : BC_GenericButton(x, y, w, _("Default"))
161 {
162         this->plugin = plugin;
163         this->window = window;
164 }
165 UnsharpDefaultSettings::~UnsharpDefaultSettings()
166 {
167 }
168 int UnsharpDefaultSettings::handle_event()
169 {
170         plugin->config.reset(RESET_DEFAULT_SETTINGS);
171         window->update_gui(RESET_DEFAULT_SETTINGS);
172         plugin->send_configure_change();
173         return 1;
174 }
175
176 UnsharpSliderClr::UnsharpSliderClr(UnsharpMain *plugin, UnsharpWindow *window, int x, int y, int w, int clear)
177  : BC_GenericButton(x, y, w, _("⌂"))
178 {
179         this->plugin = plugin;
180         this->window = window;
181         this->clear = clear;
182 }
183 UnsharpSliderClr::~UnsharpSliderClr()
184 {
185 }
186 int UnsharpSliderClr::handle_event()
187 {
188         // clear==1 ==> Radius slider
189         // clear==2 ==> Amount slider
190         // clear==3 ==> Threshold slider
191         plugin->config.reset(clear);
192         window->update_gui(clear);
193         plugin->send_configure_change();
194         return 1;
195 }