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

clipedit.C

Go to the documentation of this file.
00001 #include "awindow.h"
00002 #include "awindowgui.h"
00003 #include "clipedit.h"
00004 #include "edl.h"
00005 #include "fonts.h"
00006 #include "language.h"
00007 #include "localsession.h"
00008 #include "mainsession.h"
00009 #include "mwindow.h"
00010 #include "mwindowgui.h"
00011 #include "vwindow.h"
00012 #include "vwindowgui.h"
00013 
00014 
00015 
00016 
00017 ClipEdit::ClipEdit(MWindow *mwindow, AWindow *awindow, VWindow *vwindow)
00018  : Thread()
00019 {
00020         this->mwindow = mwindow;
00021         this->awindow = awindow;
00022         this->vwindow = vwindow;
00023         this->clip = 0;
00024         this->create_it = 0;
00025 }
00026 
00027 ClipEdit::~ClipEdit()
00028 {
00029 }
00030 
00031 void ClipEdit::edit_clip(EDL *clip)
00032 {
00033 // Allow more than one window so we don't have to delete the clip in handle_event
00034         if(clip)
00035         {
00036                 this->clip = clip;
00037                 this->create_it = 0;
00038                 Thread::start();
00039         }
00040 }
00041 
00042 void ClipEdit::create_clip(EDL *clip)
00043 {
00044 // Allow more than one window so we don't have to delete the clip in handle_event
00045         if(clip)
00046         {
00047                 this->clip = clip;
00048                 this->create_it = 1;
00049                 Thread::start();
00050         }
00051 }
00052 
00053 void ClipEdit::run()
00054 {
00055         if(clip)
00056         {
00057                 EDL *original = clip;
00058                 if(!create_it)
00059                 {
00060                         clip = new EDL(mwindow->edl);
00061                         clip->create_objects();
00062                         clip->copy_all(original);
00063                 }
00064 
00065 
00066 
00067 
00068 
00069 
00070 
00071 
00072                 ClipEditWindow *window = new ClipEditWindow(mwindow, this);
00073                 window->create_objects();
00074                 int result = window->run_window();
00075                 
00076                 if(!result)
00077                 {
00078                         EDL *new_edl = 0;
00079 // Add to EDL
00080                         if(create_it)
00081                                 new_edl = mwindow->edl->add_clip(window->clip);
00082 
00083 // Copy clip to existing clip in EDL
00084                         if(!create_it)
00085                                 original->copy_session(clip);
00086 
00087 
00088 //                      mwindow->vwindow->gui->update_sources(mwindow->vwindow->gui->source->get_text());
00089 
00090 
00091                         mwindow->awindow->gui->lock_window();
00092                         mwindow->awindow->gui->update_assets();
00093                         mwindow->awindow->gui->flush();
00094                         mwindow->awindow->gui->unlock_window();
00095 
00096 // Change VWindow to it if vwindow was called
00097 // But this doesn't let you easily create a lot of clips.
00098                         if(vwindow && create_it)
00099                         {
00100 //                              vwindow->change_source(new_edl);
00101                         }
00102                 }
00103                 else
00104                 {
00105                         mwindow->session->clip_number--;
00106                 }
00107                 
00108 
00109 
00110 // For creating new clips, the original was copied in add_clip.
00111 // For editing old clips, the original was transferred to another variable.
00112                 delete window->clip;
00113                 delete window;
00114                 clip = 0;
00115                 create_it = 0;
00116         }
00117 }
00118 
00119 
00120 
00121 
00122 
00123 
00124 
00125 ClipEditWindow::ClipEditWindow(MWindow *mwindow, ClipEdit *thread)
00126  : BC_Window(PROGRAM_NAME ": Clip Info", 
00127         mwindow->gui->get_abs_cursor_x(1) - 400 / 2,
00128         mwindow->gui->get_abs_cursor_y(1) - 350 / 2,
00129         400, 
00130         350,
00131         400,
00132         430,
00133         0,
00134         0,
00135         1)
00136 {
00137         this->mwindow = mwindow;
00138         this->thread = thread;
00139 }
00140 
00141 ClipEditWindow::~ClipEditWindow()
00142 {
00143 }
00144 
00145         
00146 void ClipEditWindow::create_objects()
00147 {
00148         this->clip = thread->clip;
00149         this->create_it = thread->create_it;
00150 
00151         int x = 10, y = 10;
00152         int x1 = x;
00153         BC_TextBox *textbox;
00154         BC_TextBox *titlebox;
00155         BC_Title *title;
00156 
00157         add_subwindow(title = new BC_Title(x1, y, _("Title:")));
00158         y += title->get_h() + 5;
00159         add_subwindow(titlebox = new ClipEditTitle(this, x1, y, get_w() - x1 * 2));
00160         y += titlebox->get_h() + 10;
00161         add_subwindow(title = new BC_Title(x1, y, _("Comments:")));
00162         y += title->get_h() + 5;
00163         add_subwindow(textbox = new ClipEditComments(this, 
00164                 x1, 
00165                 y, 
00166                 get_w() - x1 * 2, 
00167                 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, get_h() - 10 - 40 - y)));
00168 
00169 
00170 
00171         add_subwindow(new BC_OKButton(this));
00172         add_subwindow(new BC_CancelButton(this));
00173         show_window();
00174         titlebox->activate();
00175 }
00176 
00177 
00178 
00179 
00180 
00181 ClipEditTitle::ClipEditTitle(ClipEditWindow *window, int x, int y, int w)
00182  : BC_TextBox(x, y, w, 1, window->clip->local_session->clip_title)
00183 {
00184         this->window = window;
00185 }
00186 
00187 int ClipEditTitle::handle_event()
00188 {
00189         strcpy(window->clip->local_session->clip_title, get_text());
00190         return 1;
00191 }
00192 
00193 
00194 
00195 
00196 
00197 ClipEditComments::ClipEditComments(ClipEditWindow *window, int x, int y, int w, int rows)
00198  : BC_TextBox(x, y, w, rows, window->clip->local_session->clip_notes)
00199 {
00200         this->window = window;
00201 }
00202 
00203 int ClipEditComments::handle_event()
00204 {
00205         strcpy(window->clip->local_session->clip_notes, get_text());
00206         return 1;
00207 }

Generated on Sun Jan 8 13:38:51 2006 for Cinelerra-svn by  doxygen 1.4.4