4 #include "mwindowgui.h"
6 #include "resizetrackthread.h"
12 #define _(String) gettext(String)
13 #define gettext_noop(String) String
14 #define N_(String) gettext_noop (String)
20 ResizeTrackThread::ResizeTrackThread(MWindow *mwindow, int track_number)
23 this->mwindow = mwindow;
24 this->track_number = track_number;
28 ResizeTrackThread::~ResizeTrackThread()
32 window->lock_window();
34 window->unlock_window();
40 void ResizeTrackThread::start_window(Track *track, int track_number)
42 this->track_number = track_number;
43 w1 = w = track->track_w;
44 h1 = h = track->track_h;
45 w_scale = h_scale = 1;
50 void ResizeTrackThread::run()
52 ResizeTrackWindow *window = this->window =
53 new ResizeTrackWindow(mwindow,
55 mwindow->gui->get_abs_cursor_x(),
56 mwindow->gui->get_abs_cursor_y());
57 window->create_objects();
58 int result = window->run_window();
65 Track *track = mwindow->edl->tracks->get_item_number(track_number);
69 mwindow->resize_track(track, w, h);
77 ResizeTrackWindow::ResizeTrackWindow(MWindow *mwindow,
78 ResizeTrackThread *thread,
81 : BC_Window(PROGRAM_NAME ": Resize Track",
92 this->mwindow = mwindow;
93 this->thread = thread;
96 ResizeTrackWindow::~ResizeTrackWindow()
100 void ResizeTrackWindow::create_objects()
104 add_subwindow(new BC_Title(x, y, _("Size:")));
106 add_subwindow(w = new ResizeTrackWidth(this,
111 add_subwindow(new BC_Title(x, y, _("x")));
113 add_subwindow(h = new ResizeTrackHeight(this,
118 add_subwindow(new FrameSizePulldown(mwindow,
126 add_subwindow(new BC_Title(x, y, _("Scale:")));
128 add_subwindow(w_scale = new ResizeTrackScaleW(this,
133 add_subwindow(new BC_Title(x, y, _("x")));
135 add_subwindow(h_scale = new ResizeTrackScaleH(this,
140 add_subwindow(new BC_OKButton(this));
141 add_subwindow(new BC_CancelButton(this));
147 void ResizeTrackWindow::update(int changed_scale,
151 //printf("ResizeTrackWindow::update %d %d %d\n", changed_scale, changed_size, changed_all);
152 if(changed_scale || changed_all)
154 thread->w = (int)(thread->w1 * thread->w_scale);
155 w->update((int64_t)thread->w);
156 thread->h = (int)(thread->h1 * thread->h_scale);
157 h->update((int64_t)thread->h);
160 if(changed_size || changed_all)
162 thread->w_scale = (double)thread->w / thread->w1;
163 w_scale->update((float)thread->w_scale);
164 thread->h_scale = (double)thread->h / thread->h1;
165 h_scale->update((float)thread->h_scale);
173 ResizeTrackWidth::ResizeTrackWidth(ResizeTrackWindow *gui,
174 ResizeTrackThread *thread,
177 : BC_TextBox(x, y, 90, 1, thread->w)
180 this->thread = thread;
182 int ResizeTrackWidth::handle_event()
184 thread->w = atol(get_text());
185 gui->update(0, 1, 0);
189 ResizeTrackHeight::ResizeTrackHeight(ResizeTrackWindow *gui,
190 ResizeTrackThread *thread,
193 : BC_TextBox(x, y, 90, 1, thread->h)
196 this->thread = thread;
198 int ResizeTrackHeight::handle_event()
200 thread->h = atol(get_text());
201 gui->update(0, 1, 0);
206 ResizeTrackScaleW::ResizeTrackScaleW(ResizeTrackWindow *gui,
207 ResizeTrackThread *thread,
210 : BC_TextBox(x, y, 90, 1, (float)thread->w_scale)
213 this->thread = thread;
215 int ResizeTrackScaleW::handle_event()
217 thread->w_scale = atof(get_text());
218 gui->update(1, 0, 0);
222 ResizeTrackScaleH::ResizeTrackScaleH(ResizeTrackWindow *gui,
223 ResizeTrackThread *thread,
226 : BC_TextBox(x, y, 90, 1, (float)thread->h_scale)
229 this->thread = thread;
231 int ResizeTrackScaleH::handle_event()
233 thread->h_scale = atof(get_text());
234 gui->update(1, 0, 0);