2 #include "edlsession.h"
7 #include "mwindowgui.h"
9 #include "resizetrackthread.h"
18 ResizeTrackThread::ResizeTrackThread(MWindow *mwindow, int track_number)
21 this->mwindow = mwindow;
22 this->track_number = track_number;
26 ResizeTrackThread::~ResizeTrackThread()
30 window->lock_window();
32 window->unlock_window();
38 void ResizeTrackThread::start_window(Track *track, int track_number)
40 this->track_number = track_number;
41 w1 = w = track->track_w;
42 h1 = h = track->track_h;
43 w_scale = h_scale = 1;
48 void ResizeTrackThread::run()
50 ResizeTrackWindow *window = this->window =
51 new ResizeTrackWindow(mwindow,
53 mwindow->gui->get_abs_cursor_x(1),
54 mwindow->gui->get_abs_cursor_y(1));
55 window->create_objects();
56 int result = window->run_window();
63 Track *track = mwindow->edl->tracks->get_item_number(track_number);
67 mwindow->resize_track(track, w, h);
73 mwindow->edl->session->playback_config->vconfig->driver == PLAYBACK_X11_GL)
75 MainError::show_error(
76 _("This track's dimensions are not multiples of 4 so\n"
77 "it can't be rendered by OpenGL."));
84 ResizeTrackWindow::ResizeTrackWindow(MWindow *mwindow,
85 ResizeTrackThread *thread,
88 : BC_Window(PROGRAM_NAME ": Resize Track",
90 y - get_resources()->ok_images[0]->get_h() + 100 / 2,
92 get_resources()->ok_images[0]->get_h() + 100,
94 get_resources()->ok_images[0]->get_h() + 100,
99 this->mwindow = mwindow;
100 this->thread = thread;
103 ResizeTrackWindow::~ResizeTrackWindow()
107 void ResizeTrackWindow::create_objects()
111 add_subwindow(new BC_Title(x, y, _("Size:")));
113 add_subwindow(w = new ResizeTrackWidth(this,
118 add_subwindow(new BC_Title(x, y, _("x")));
120 add_subwindow(h = new ResizeTrackHeight(this,
125 add_subwindow(new FrameSizePulldown(mwindow,
133 add_subwindow(new BC_Title(x, y, _("Scale:")));
135 add_subwindow(w_scale = new ResizeTrackScaleW(this,
140 add_subwindow(new BC_Title(x, y, _("x")));
142 add_subwindow(h_scale = new ResizeTrackScaleH(this,
147 add_subwindow(new BC_OKButton(this));
148 add_subwindow(new BC_CancelButton(this));
154 void ResizeTrackWindow::update(int changed_scale,
158 //printf("ResizeTrackWindow::update %d %d %d\n", changed_scale, changed_size, changed_all);
159 if(changed_scale || changed_all)
161 thread->w = (int)(thread->w1 * thread->w_scale);
162 w->update((int64_t)thread->w);
163 thread->h = (int)(thread->h1 * thread->h_scale);
164 h->update((int64_t)thread->h);
167 if(changed_size || changed_all)
169 thread->w_scale = (double)thread->w / thread->w1;
170 w_scale->update((float)thread->w_scale);
171 thread->h_scale = (double)thread->h / thread->h1;
172 h_scale->update((float)thread->h_scale);
180 ResizeTrackWidth::ResizeTrackWidth(ResizeTrackWindow *gui,
181 ResizeTrackThread *thread,
184 : BC_TextBox(x, y, 90, 1, thread->w)
187 this->thread = thread;
189 int ResizeTrackWidth::handle_event()
191 thread->w = atol(get_text());
192 gui->update(0, 1, 0);
196 ResizeTrackHeight::ResizeTrackHeight(ResizeTrackWindow *gui,
197 ResizeTrackThread *thread,
200 : BC_TextBox(x, y, 90, 1, thread->h)
203 this->thread = thread;
205 int ResizeTrackHeight::handle_event()
207 thread->h = atol(get_text());
208 gui->update(0, 1, 0);
213 ResizeTrackScaleW::ResizeTrackScaleW(ResizeTrackWindow *gui,
214 ResizeTrackThread *thread,
217 : BC_TextBox(x, y, 90, 1, (float)thread->w_scale)
220 this->thread = thread;
222 int ResizeTrackScaleW::handle_event()
224 thread->w_scale = atof(get_text());
225 gui->update(1, 0, 0);
229 ResizeTrackScaleH::ResizeTrackScaleH(ResizeTrackWindow *gui,
230 ResizeTrackThread *thread,
233 : BC_TextBox(x, y, 90, 1, (float)thread->h_scale)
236 this->thread = thread;
238 int ResizeTrackScaleH::handle_event()
240 thread->h_scale = atof(get_text());
241 gui->update(1, 0, 0);