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