6bd1142fdf4c53041d345b23e59f96b524cf0253
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / translate / translatewin.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 "clip.h"
24 #include "language.h"
25 #include "translate.h"
26 #include "translatewin.h"
27
28
29
30
31
32
33
34
35
36
37
38
39
40 TranslateWin::TranslateWin(TranslateMain *client)
41  : PluginClientWindow(client,
42         xS(300),
43         yS(250),
44         xS(300),
45         yS(250),
46         0)
47 {
48         this->client = client;
49 }
50
51 TranslateWin::~TranslateWin()
52 {
53 }
54
55 void TranslateWin::create_objects()
56 {
57         int xs10 = xS(10), xs150 = xS(150);
58         int ys10 = yS(10), ys20 = yS(20), ys30 = yS(30), ys40 = yS(40);
59         int x = xs10, y = ys10;
60
61         add_tool(new BC_Title(x, y, _("In X:")));
62         y += ys20;
63         in_x = new TranslateCoord(this, client, x, y, &client->config.in_x);
64         in_x->create_objects();
65         y += ys30;
66
67         add_tool(new BC_Title(x, y, _("In Y:")));
68         y += ys20;
69         in_y = new TranslateCoord(this, client, x, y, &client->config.in_y);
70         in_y->create_objects();
71         y += ys30;
72
73         add_tool(new BC_Title(x, y, _("In W:")));
74         y += ys20;
75         in_w = new TranslateCoord(this, client, x, y, &client->config.in_w);
76         in_w->create_objects();
77         y += ys30;
78
79         add_tool(new BC_Title(x, y, _("In H:")));
80         y += ys20;
81         in_h = new TranslateCoord(this, client, x, y, &client->config.in_h);
82         in_h->create_objects();
83
84         y += ys40;
85         add_tool(reset = new TranslateReset(client, this, x, y));
86
87         x += xs150;
88         y = ys10;
89         add_tool(new BC_Title(x, y, _("Out X:")));
90         y += ys20;
91         out_x = new TranslateCoord(this, client, x, y, &client->config.out_x);
92         out_x->create_objects();
93         y += ys30;
94
95         add_tool(new BC_Title(x, y, _("Out Y:")));
96         y += ys20;
97         out_y = new TranslateCoord(this, client, x, y, &client->config.out_y);
98         out_y->create_objects();
99         y += ys30;
100
101         add_tool(new BC_Title(x, y, _("Out W:")));
102         y += ys20;
103         out_w = new TranslateCoord(this, client, x, y, &client->config.out_w);
104         out_w->create_objects();
105         y += ys30;
106
107         add_tool(new BC_Title(x, y, _("Out H:")));
108         y += ys20;
109         out_h = new TranslateCoord(this, client, x, y, &client->config.out_h);
110         out_h->create_objects();
111         y += ys30;
112
113         show_window();
114         flush();
115 }
116
117 void TranslateWin::update()
118 {
119         in_x->update((int64_t)client->config.in_x);
120         in_y->update((int64_t)client->config.in_y);
121         in_w->update((int64_t)client->config.in_w);
122         in_h->update((int64_t)client->config.in_h);
123         out_x->update((int64_t)client->config.out_x);
124         out_y->update((int64_t)client->config.out_y);
125         out_y->update((int64_t)client->config.out_y);
126         out_w->update((int64_t)client->config.out_w);
127         out_h->update((int64_t)client->config.out_h);
128 }
129
130
131
132 TranslateCoord::TranslateCoord(TranslateWin *win,
133         TranslateMain *client,
134         int x,
135         int y,
136         float *value)
137  : BC_TumbleTextBox(win,
138         (int)*value,
139         (int)0,
140         (int)10000,
141         x,
142         y,
143         xS(100))
144 {
145 //printf("TranslateWidth::TranslateWidth %f\n", client->config.w);
146         this->client = client;
147         this->win = win;
148         this->value = value;
149 }
150
151 TranslateCoord::~TranslateCoord()
152 {
153 }
154
155 int TranslateCoord::handle_event()
156 {
157         *value = atof(get_text());
158
159         client->send_configure_change();
160         return 1;
161 }
162
163 TranslateReset::TranslateReset(TranslateMain *client, TranslateWin *win, int x, int y)
164  : BC_GenericButton(x, y, _("Reset"))
165 {
166         this->client = client;
167         this->win = win;
168 }
169 TranslateReset::~TranslateReset()
170 {
171 }
172 int TranslateReset::handle_event()
173 {
174         client->config.reset();
175         win->update();
176         client->send_configure_change();
177         return 1;
178 }