2 #include "edlsession.h"
7 #include "mwindowgui.h"
9 #include "resizetrackthread.h"
19 ResizeTrackThread::ResizeTrackThread(MWindow *mwindow, int track_number)
22 this->mwindow = mwindow;
23 this->track_number = track_number;
27 ResizeTrackThread::~ResizeTrackThread()
31 window->lock_window();
33 window->unlock_window();
39 void ResizeTrackThread::start_window(Track *track, int track_number)
41 this->track_number = track_number;
42 w1 = w = track->track_w;
43 h1 = h = track->track_h;
44 w_scale = h_scale = 1;
49 void ResizeTrackThread::run()
51 ResizeTrackWindow *window = this->window =
52 new ResizeTrackWindow(mwindow,
54 mwindow->gui->get_abs_cursor_x(1),
55 mwindow->gui->get_abs_cursor_y(1));
56 window->create_objects();
57 int result = window->run_window();
64 Track *track = mwindow->edl->tracks->get_item_number(track_number);
68 mwindow->resize_track(track, w, h);
74 mwindow->edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL)
76 MainError::show_error(
77 _("This track's dimensions are not multiples of 4 so\n"
78 "it can't be rendered by OpenGL."));
85 ResizeTrackWindow::ResizeTrackWindow(MWindow *mwindow,
86 ResizeTrackThread *thread,
89 : BC_Window(PROGRAM_NAME ": Resize Track",
91 y - get_resources()->ok_images[0]->get_h() + 100 / 2,
93 get_resources()->ok_images[0]->get_h() + 100,
95 get_resources()->ok_images[0]->get_h() + 100,
100 this->mwindow = mwindow;
101 this->thread = thread;
104 ResizeTrackWindow::~ResizeTrackWindow()
108 void ResizeTrackWindow::create_objects()
112 add_subwindow(new BC_Title(x, y, _("Size:")));
114 add_subwindow(w = new ResizeTrackWidth(this,
118 x += w->get_w() + 10;
119 add_subwindow(new BC_Title(x, y, _("x")));
121 add_subwindow(h = new ResizeTrackHeight(this,
126 FrameSizePulldown *pulldown;
127 add_subwindow(pulldown = new FrameSizePulldown(mwindow,
132 x += pulldown->get_w() + 5;
133 add_subwindow(new ResizeTrackSwap(this, thread, x, y));
138 add_subwindow(new BC_Title(x, y, _("Scale:")));
140 add_subwindow(w_scale = new ResizeTrackScaleW(this,
145 add_subwindow(new BC_Title(x, y, _("x")));
147 add_subwindow(h_scale = new ResizeTrackScaleH(this,
152 add_subwindow(new BC_OKButton(this));
153 add_subwindow(new BC_CancelButton(this));
159 void ResizeTrackWindow::update(int changed_scale,
163 //printf("ResizeTrackWindow::update %d %d %d\n", changed_scale, changed_size, changed_all);
164 if(changed_scale || changed_all)
166 thread->w = (int)(thread->w1 * thread->w_scale);
167 w->update((int64_t)thread->w);
168 thread->h = (int)(thread->h1 * thread->h_scale);
169 h->update((int64_t)thread->h);
172 if(changed_size || changed_all)
174 thread->w_scale = (double)thread->w / thread->w1;
175 w_scale->update((float)thread->w_scale);
176 thread->h_scale = (double)thread->h / thread->h1;
177 h_scale->update((float)thread->h_scale);
186 ResizeTrackSwap::ResizeTrackSwap(ResizeTrackWindow *gui,
187 ResizeTrackThread *thread,
190 : BC_Button(x, y, thread->mwindow->theme->get_image_set("swap_extents"))
192 this->thread = thread;
194 set_tooltip("Swap dimensions");
197 int ResizeTrackSwap::handle_event()
203 gui->w->update((int64_t)h);
204 gui->h->update((int64_t)w);
205 gui->update(0, 1, 0);
214 ResizeTrackWidth::ResizeTrackWidth(ResizeTrackWindow *gui,
215 ResizeTrackThread *thread,
218 : BC_TextBox(x, y, 90, 1, thread->w)
221 this->thread = thread;
223 int ResizeTrackWidth::handle_event()
225 thread->w = atol(get_text());
226 gui->update(0, 1, 0);
230 ResizeTrackHeight::ResizeTrackHeight(ResizeTrackWindow *gui,
231 ResizeTrackThread *thread,
234 : BC_TextBox(x, y, 90, 1, thread->h)
237 this->thread = thread;
239 int ResizeTrackHeight::handle_event()
241 thread->h = atol(get_text());
242 gui->update(0, 1, 0);
247 ResizeTrackScaleW::ResizeTrackScaleW(ResizeTrackWindow *gui,
248 ResizeTrackThread *thread,
251 : BC_TextBox(x, y, 90, 1, (float)thread->w_scale)
254 this->thread = thread;
256 int ResizeTrackScaleW::handle_event()
258 thread->w_scale = atof(get_text());
259 gui->update(1, 0, 0);
263 ResizeTrackScaleH::ResizeTrackScaleH(ResizeTrackWindow *gui,
264 ResizeTrackThread *thread,
267 : BC_TextBox(x, y, 90, 1, (float)thread->h_scale)
270 this->thread = thread;
272 int ResizeTrackScaleH::handle_event()
274 thread->h_scale = atof(get_text());
275 gui->update(1, 0, 0);