Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

resizetrackthread.C

Go to the documentation of this file.
00001 #include "edl.h"
00002 #include "language.h"
00003 #include "mainundo.h"
00004 #include "mwindow.h"
00005 #include "mwindowgui.h"
00006 #include "new.h"
00007 #include "resizetrackthread.h"
00008 #include "track.h"
00009 #include "tracks.h"
00010 
00011 
00012 
00013 
00014 
00015 
00016 ResizeTrackThread::ResizeTrackThread(MWindow *mwindow, int track_number)
00017  : Thread()
00018 {
00019         this->mwindow = mwindow;
00020         this->track_number = track_number;
00021         window = 0;
00022 }
00023 
00024 ResizeTrackThread::~ResizeTrackThread()
00025 {
00026         if(window)
00027         {
00028                 window->lock_window();
00029                 window->set_done(1);
00030                 window->unlock_window();
00031         }
00032 
00033         Thread::join();
00034 }
00035 
00036 void ResizeTrackThread::start_window(Track *track, int track_number)
00037 {
00038         this->track_number = track_number;
00039         w1 = w = track->track_w;
00040         h1 = h = track->track_h;
00041         w_scale = h_scale = 1;
00042         start();
00043 }
00044 
00045 
00046 void ResizeTrackThread::run()
00047 {
00048         ResizeTrackWindow *window = this->window = 
00049                 new ResizeTrackWindow(mwindow, 
00050                         this,
00051                         mwindow->gui->get_abs_cursor_x(1),
00052                         mwindow->gui->get_abs_cursor_y(1));
00053         window->create_objects();
00054         int result = window->run_window();
00055         this->window = 0;
00056         delete window;
00057 
00058 
00059         if(!result)
00060         {
00061                 Track *track = mwindow->edl->tracks->get_item_number(track_number);
00062 
00063                 if(track)
00064                 {
00065                         mwindow->resize_track(track, w, h);
00066                 }
00067         }
00068 }
00069 
00070 
00071 
00072 
00073 ResizeTrackWindow::ResizeTrackWindow(MWindow *mwindow, 
00074         ResizeTrackThread *thread,
00075         int x,
00076         int y)
00077  : BC_Window(PROGRAM_NAME ": Resize Track", 
00078                                 x - 320 / 2,
00079                                 y - get_resources()->ok_images[0]->get_h() + 100 / 2,
00080                                 320, 
00081                                 get_resources()->ok_images[0]->get_h() + 100, 
00082                                 320, 
00083                                 get_resources()->ok_images[0]->get_h() + 100, 
00084                                 0,
00085                                 0, 
00086                                 1)
00087 {
00088         this->mwindow = mwindow;
00089         this->thread = thread;
00090 }
00091 
00092 ResizeTrackWindow::~ResizeTrackWindow()
00093 {
00094 }
00095 
00096 void ResizeTrackWindow::create_objects()
00097 {
00098         int x = 10, y = 10;
00099 
00100         add_subwindow(new BC_Title(x, y, _("Size:")));
00101         x += 50;
00102         add_subwindow(w = new ResizeTrackWidth(this, 
00103                 thread,
00104                 x,
00105                 y));
00106         x += 100;
00107         add_subwindow(new BC_Title(x, y, _("x")));
00108         x += 15;
00109         add_subwindow(h = new ResizeTrackHeight(this, 
00110                 thread,
00111                 x,
00112                 y));
00113         x += 100;
00114         add_subwindow(new FrameSizePulldown(mwindow, 
00115                 w, 
00116                 h, 
00117                 x, 
00118                 y));
00119 
00120         y += 30;
00121         x = 10;
00122         add_subwindow(new BC_Title(x, y, _("Scale:")));
00123         x += 50;
00124         add_subwindow(w_scale = new ResizeTrackScaleW(this, 
00125                 thread,
00126                 x,
00127                 y));
00128         x += 100;
00129         add_subwindow(new BC_Title(x, y, _("x")));
00130         x += 15;
00131         add_subwindow(h_scale = new ResizeTrackScaleH(this, 
00132                 thread,
00133                 x,
00134                 y));
00135 
00136         add_subwindow(new BC_OKButton(this));
00137         add_subwindow(new BC_CancelButton(this));
00138 
00139         show_window();
00140         flush();
00141 }
00142 
00143 void ResizeTrackWindow::update(int changed_scale, 
00144         int changed_size, 
00145         int changed_all)
00146 {
00147 //printf("ResizeTrackWindow::update %d %d %d\n", changed_scale, changed_size, changed_all);
00148         if(changed_scale || changed_all)
00149         {
00150                 thread->w = (int)(thread->w1 * thread->w_scale);
00151                 w->update((int64_t)thread->w);
00152                 thread->h = (int)(thread->h1 * thread->h_scale);
00153                 h->update((int64_t)thread->h);
00154         }
00155         else
00156         if(changed_size || changed_all)
00157         {
00158                 thread->w_scale = (double)thread->w / thread->w1;
00159                 w_scale->update((float)thread->w_scale);
00160                 thread->h_scale = (double)thread->h / thread->h1;
00161                 h_scale->update((float)thread->h_scale);
00162         }
00163 }
00164 
00165 
00166 
00167 
00168 
00169 ResizeTrackWidth::ResizeTrackWidth(ResizeTrackWindow *gui, 
00170         ResizeTrackThread *thread,
00171         int x,
00172         int y)
00173  : BC_TextBox(x, y, 90, 1, thread->w)
00174 {
00175         this->gui = gui;
00176         this->thread = thread;
00177 }
00178 int ResizeTrackWidth::handle_event()
00179 {
00180         thread->w = atol(get_text());
00181         gui->update(0, 1, 0);
00182         return 1;
00183 }
00184 
00185 ResizeTrackHeight::ResizeTrackHeight(ResizeTrackWindow *gui, 
00186         ResizeTrackThread *thread,
00187         int x,
00188         int y)
00189  : BC_TextBox(x, y, 90, 1, thread->h)
00190 {
00191         this->gui = gui;
00192         this->thread = thread;
00193 }
00194 int ResizeTrackHeight::handle_event()
00195 {
00196         thread->h = atol(get_text());
00197         gui->update(0, 1, 0);
00198         return 1;
00199 }
00200 
00201 
00202 ResizeTrackScaleW::ResizeTrackScaleW(ResizeTrackWindow *gui, 
00203         ResizeTrackThread *thread,
00204         int x,
00205         int y)
00206  : BC_TextBox(x, y, 90, 1, (float)thread->w_scale)
00207 {
00208         this->gui = gui;
00209         this->thread = thread;
00210 }
00211 int ResizeTrackScaleW::handle_event()
00212 {
00213         thread->w_scale = atof(get_text());
00214         gui->update(1, 0, 0);
00215         return 1;
00216 }
00217 
00218 ResizeTrackScaleH::ResizeTrackScaleH(ResizeTrackWindow *gui, 
00219         ResizeTrackThread *thread,
00220         int x,
00221         int y)
00222  : BC_TextBox(x, y, 90, 1, (float)thread->h_scale)
00223 {
00224         this->gui = gui;
00225         this->thread = thread;
00226 }
00227 int ResizeTrackScaleH::handle_event()
00228 {
00229         thread->h_scale = atof(get_text());
00230         gui->update(1, 0, 0);
00231         return 1;
00232 }
00233 
00234 
00235 
00236 
00237 
00238 
00239 

Generated on Sun Jan 8 13:39:00 2006 for Cinelerra-svn by  doxygen 1.4.4