r802: Remove renderframfsclient and renderfarmfsserver .h and .C from Makefile.am...
[cinelerra_cv/mob.git] / cinelerra / resizetrackthread.C
blob219301eb8b51467abdb0f23e088e21439f9d1027
1 #include "edl.h"
2 #include "language.h"
3 #include "mainundo.h"
4 #include "mwindow.h"
5 #include "mwindowgui.h"
6 #include "new.h"
7 #include "resizetrackthread.h"
8 #include "track.h"
9 #include "tracks.h"
16 ResizeTrackThread::ResizeTrackThread(MWindow *mwindow, int track_number)
17  : Thread()
19         this->mwindow = mwindow;
20         this->track_number = track_number;
21         window = 0;
24 ResizeTrackThread::~ResizeTrackThread()
26         if(window)
27         {
28                 window->lock_window();
29                 window->set_done(1);
30                 window->unlock_window();
31         }
33         Thread::join();
36 void ResizeTrackThread::start_window(Track *track, int track_number)
38         this->track_number = track_number;
39         w1 = w = track->track_w;
40         h1 = h = track->track_h;
41         w_scale = h_scale = 1;
42         start();
46 void ResizeTrackThread::run()
48         ResizeTrackWindow *window = this->window = 
49                 new ResizeTrackWindow(mwindow, 
50                         this,
51                         mwindow->gui->get_abs_cursor_x(1),
52                         mwindow->gui->get_abs_cursor_y(1));
53         window->create_objects();
54         int result = window->run_window();
55         this->window = 0;
56         delete window;
59         if(!result)
60         {
61                 Track *track = mwindow->edl->tracks->get_item_number(track_number);
63                 if(track)
64                 {
65                         mwindow->resize_track(track, w, h);
66                 }
67         }
73 ResizeTrackWindow::ResizeTrackWindow(MWindow *mwindow, 
74         ResizeTrackThread *thread,
75         int x,
76         int y)
77  : BC_Window(PROGRAM_NAME ": Resize Track", 
78                                 x - 320 / 2,
79                                 y - get_resources()->ok_images[0]->get_h() + 100 / 2,
80                                 320, 
81                                 get_resources()->ok_images[0]->get_h() + 100, 
82                                 320, 
83                                 get_resources()->ok_images[0]->get_h() + 100, 
84                                 0,
85                                 0, 
86                                 1)
88         this->mwindow = mwindow;
89         this->thread = thread;
92 ResizeTrackWindow::~ResizeTrackWindow()
96 void ResizeTrackWindow::create_objects()
98         int x = 10, y = 10;
100         add_subwindow(new BC_Title(x, y, _("Size:")));
101         x += 50;
102         add_subwindow(w = new ResizeTrackWidth(this, 
103                 thread,
104                 x,
105                 y));
106         x += 100;
107         add_subwindow(new BC_Title(x, y, _("x")));
108         x += 15;
109         add_subwindow(h = new ResizeTrackHeight(this, 
110                 thread,
111                 x,
112                 y));
113         x += 100;
114         add_subwindow(new FrameSizePulldown(mwindow, 
115                 w, 
116                 h, 
117                 x, 
118                 y));
120         y += 30;
121         x = 10;
122         add_subwindow(new BC_Title(x, y, _("Scale:")));
123         x += 50;
124         add_subwindow(w_scale = new ResizeTrackScaleW(this, 
125                 thread,
126                 x,
127                 y));
128         x += 100;
129         add_subwindow(new BC_Title(x, y, _("x")));
130         x += 15;
131         add_subwindow(h_scale = new ResizeTrackScaleH(this, 
132                 thread,
133                 x,
134                 y));
136         add_subwindow(new BC_OKButton(this));
137         add_subwindow(new BC_CancelButton(this));
139         show_window();
140         flush();
143 void ResizeTrackWindow::update(int changed_scale, 
144         int changed_size, 
145         int changed_all)
147 //printf("ResizeTrackWindow::update %d %d %d\n", changed_scale, changed_size, changed_all);
148         if(changed_scale || changed_all)
149         {
150                 thread->w = (int)(thread->w1 * thread->w_scale);
151                 w->update((int64_t)thread->w);
152                 thread->h = (int)(thread->h1 * thread->h_scale);
153                 h->update((int64_t)thread->h);
154         }
155         else
156         if(changed_size || changed_all)
157         {
158                 thread->w_scale = (double)thread->w / thread->w1;
159                 w_scale->update((float)thread->w_scale);
160                 thread->h_scale = (double)thread->h / thread->h1;
161                 h_scale->update((float)thread->h_scale);
162         }
169 ResizeTrackWidth::ResizeTrackWidth(ResizeTrackWindow *gui, 
170         ResizeTrackThread *thread,
171         int x,
172         int y)
173  : BC_TextBox(x, y, 90, 1, thread->w)
175         this->gui = gui;
176         this->thread = thread;
178 int ResizeTrackWidth::handle_event()
180         thread->w = atol(get_text());
181         gui->update(0, 1, 0);
182         return 1;
185 ResizeTrackHeight::ResizeTrackHeight(ResizeTrackWindow *gui, 
186         ResizeTrackThread *thread,
187         int x,
188         int y)
189  : BC_TextBox(x, y, 90, 1, thread->h)
191         this->gui = gui;
192         this->thread = thread;
194 int ResizeTrackHeight::handle_event()
196         thread->h = atol(get_text());
197         gui->update(0, 1, 0);
198         return 1;
202 ResizeTrackScaleW::ResizeTrackScaleW(ResizeTrackWindow *gui, 
203         ResizeTrackThread *thread,
204         int x,
205         int y)
206  : BC_TextBox(x, y, 90, 1, (float)thread->w_scale)
208         this->gui = gui;
209         this->thread = thread;
211 int ResizeTrackScaleW::handle_event()
213         thread->w_scale = atof(get_text());
214         gui->update(1, 0, 0);
215         return 1;
218 ResizeTrackScaleH::ResizeTrackScaleH(ResizeTrackWindow *gui, 
219         ResizeTrackThread *thread,
220         int x,
221         int y)
222  : BC_TextBox(x, y, 90, 1, (float)thread->h_scale)
224         this->gui = gui;
225         this->thread = thread;
227 int ResizeTrackScaleH::handle_event()
229         thread->h_scale = atof(get_text());
230         gui->update(1, 0, 0);
231         return 1;