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