8b52f0388c609d7635c1d42f3752a93c299e842e
[goodguy/history.git] / cinelerra-5.0 / plugins / greycstoration / greycstorationwindow.C
1 /*
2  * GreyCStoration plugin for Cinelerra
3  * Copyright (C) 2013 Slock Ruddy
4  * Copyright (C) 2014-2015 Nicola Ferralis <feranick at hotmail dot com>
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 "greycstorationwindow.h"
24
25 #include "language.h"
26 #define _(String) gettext(String)
27 #define gettext_noop(String) String
28 #define N_(String) gettext_noop (String)
29
30
31 // configuration window
32 GreyCStorationWindow::GreyCStorationWindow(GreyCStorationMain *client)
33  : PluginClientWindow(client, 300, 180, 300, 180, 0)
34 {
35         this->client = client;
36 }
37
38 GreyCStorationWindow::~GreyCStorationWindow()
39 {
40 }
41
42 // controls in window
43 void GreyCStorationWindow::create_objects()
44 {
45         int x = 10, y = 10;
46         BC_Title *title;
47         add_subwindow(title = new BC_Title(x, y + 10, _("Amplitude:")));
48         add_tool(greycamp_slider = new GreyCAmpSlider(client, &(client->config.amplitude), x+title->get_w(), y));
49
50         y += 30;
51         add_subwindow(title = new BC_Title(x, y + 10, _("Sharpness:")));
52         add_tool(greycsharp_slider = new GreyCSharpSlider(client, &(client->config.sharpness), x+title->get_w(), y));
53
54         y += 30;
55         add_subwindow(title = new BC_Title(x, y + 10, _("Anisotropy:")));
56         add_tool(greycani_slider = new GreyCAniSlider(client, &(client->config.anisotropy), x+title->get_w(), y));
57
58         y += 30;
59         add_subwindow(title = new BC_Title(x, y + 10, _("Noise scale:")));
60         add_tool(greycnoise_slider = new GreyCNoiseSlider(client, &(client->config.noise_scale), x+title->get_w(), y));
61
62
63         show_window();
64         flush();
65 }
66
67 int GreyCStorationWindow::close_event()
68 {
69         set_done(1);
70         return 1;
71 }
72
73
74 // amp slider implementation
75
76 GreyCAmpSlider::GreyCAmpSlider(GreyCStorationMain *client, float *output, int x, int y)
77  : BC_ISlider(x, y, 0, 200, 200, 0, 255, //MAX
78         (int)*output, 0, 0, 0)
79 {
80         this->client = client;
81         this->output = output;
82 }
83 GreyCAmpSlider::~GreyCAmpSlider()
84 {
85 }
86 int GreyCAmpSlider::handle_event()
87 {
88         *output = get_value();
89         client->send_configure_change();
90         return 1;
91 }
92
93 // sharpslider
94
95
96 GreyCSharpSlider::GreyCSharpSlider(GreyCStorationMain *client, float *output, int x, int y)
97  : BC_FSlider(x, y, 0, 200, 200, 0.0f, 1.0f, //MAX
98         (float)*output, 0, 0)
99 {
100         this->client = client;
101         this->output = output;
102 }
103
104 GreyCSharpSlider::~GreyCSharpSlider()
105 {
106 }
107
108 int GreyCSharpSlider::handle_event()
109 {
110         *output = get_value();
111         client->send_configure_change();
112         return 1;
113 }
114
115 // anislider
116
117
118 GreyCAniSlider::GreyCAniSlider(GreyCStorationMain *client, float *output, int x, int y)
119  : BC_FSlider(x, y, 0, 200, 200, 0.0f, 1.0f, //MAX
120         (float)*output, 0, 0)
121 {
122         this->client = client;
123         this->output = output;
124 }
125
126 GreyCAniSlider::~GreyCAniSlider()
127 {
128 }
129
130 int GreyCAniSlider::handle_event()
131 {
132         *output = get_value();
133         client->send_configure_change();
134         return 1;
135 }
136
137
138 // noise scale
139
140 GreyCNoiseSlider::GreyCNoiseSlider(GreyCStorationMain *client, float *output, int x, int y)
141  : BC_FSlider(x, y, 0, 200, 200, 0.0f, 10.0f, //MAX
142         (float)*output, 0, 0)
143 {
144         this->client = client;
145         this->output = output;
146 }
147
148 GreyCNoiseSlider::~GreyCNoiseSlider()
149 {
150 }
151
152 int GreyCNoiseSlider::handle_event()
153 {
154         *output = get_value();
155         client->send_configure_change();
156         return 1;
157 }