r136: This commit was manufactured by cvs2svn to create tag 'hv_1_1_8'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / clipedit.C
blob8468f4f33015a2ee971e5f61fbe7a92dcd31f04e
1 #include "awindow.h"
2 #include "awindowgui.h"
3 #include "clipedit.h"
4 #include "edl.h"
5 #include "fonts.h"
6 #include "language.h"
7 #include "localsession.h"
8 #include "mainsession.h"
9 #include "mwindow.h"
10 #include "mwindowgui.h"
11 #include "vwindow.h"
12 #include "vwindowgui.h"
17 ClipEdit::ClipEdit(MWindow *mwindow, AWindow *awindow, VWindow *vwindow)
18  : Thread()
20         this->mwindow = mwindow;
21         this->awindow = awindow;
22         this->vwindow = vwindow;
23         this->clip = 0;
24         this->create_it = 0;
27 ClipEdit::~ClipEdit()
31 void ClipEdit::edit_clip(EDL *clip)
33 // Allow more than one window so we don't have to delete the clip in handle_event
34         if(clip)
35         {
36                 this->clip = clip;
37                 this->create_it = 0;
38                 Thread::start();
39         }
42 void ClipEdit::create_clip(EDL *clip)
44 // Allow more than one window so we don't have to delete the clip in handle_event
45         if(clip)
46         {
47                 this->clip = clip;
48                 this->create_it = 1;
49                 Thread::start();
50         }
53 void ClipEdit::run()
55         if(clip)
56         {
57                 EDL *original = clip;
58                 if(!create_it)
59                 {
60                         clip = new EDL(mwindow->edl);
61                         clip->create_objects();
62                         clip->copy_all(original);
63                 }
72                 ClipEditWindow *window = new ClipEditWindow(mwindow, this);
73                 window->create_objects();
74                 int result = window->run_window();
75                 
76                 if(!result)
77                 {
78                         EDL *new_edl = 0;
79 // Add to EDL
80                         if(create_it)
81                                 new_edl = mwindow->edl->add_clip(window->clip);
83 // Copy clip to existing clip in EDL
84                         if(!create_it)
85                                 original->copy_session(clip);
88 //                      mwindow->vwindow->gui->update_sources(mwindow->vwindow->gui->source->get_text());
91                         mwindow->awindow->gui->lock_window();
92                         mwindow->awindow->gui->update_assets();
93                         mwindow->awindow->gui->flush();
94                         mwindow->awindow->gui->unlock_window();
96 // Change VWindow to it if vwindow was called
97 // But this doesn't let you easily create a lot of clips.
98                         if(vwindow && create_it)
99                         {
100 //                              vwindow->change_source(new_edl);
101                         }
102                 }
103                 else
104                 {
105                         mwindow->session->clip_number--;
106                 }
107                 
110 // For creating new clips, the original was copied in add_clip.
111 // For editing old clips, the original was transferred to another variable.
112                 delete window->clip;
113                 delete window;
114                 clip = 0;
115                 create_it = 0;
116         }
125 ClipEditWindow::ClipEditWindow(MWindow *mwindow, ClipEdit *thread)
126  : BC_Window(PROGRAM_NAME ": Clip Info", 
127         mwindow->gui->get_abs_cursor_x() - 400 / 2,
128         mwindow->gui->get_abs_cursor_y() - 350 / 2,
129         400, 
130         350,
131         400,
132         430,
133         0,
134         0,
135         1)
137         this->mwindow = mwindow;
138         this->thread = thread;
141 ClipEditWindow::~ClipEditWindow()
145         
146 void ClipEditWindow::create_objects()
148         this->clip = thread->clip;
149         this->create_it = thread->create_it;
151         int x = 10, y = 10;
152         int x1 = x;
153         BC_TextBox *textbox;
154         BC_Title *title;
156         add_subwindow(title = new BC_Title(x1, y, _("Title:")));
157         y += title->get_h() + 5;
158         add_subwindow(textbox = new ClipEditTitle(this, x1, y, get_w() - x1 * 2));
159         y += textbox->get_h() + 10;
160         add_subwindow(title = new BC_Title(x1, y, _("Comments:")));
161         y += title->get_h() + 5;
162         add_subwindow(textbox = new ClipEditComments(this, 
163                 x1, 
164                 y, 
165                 get_w() - x1 * 2, 
166                 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, get_h() - 10 - 40 - y)));
170         add_subwindow(new BC_OKButton(this));
171         add_subwindow(new BC_CancelButton(this));
172         show_window();
179 ClipEditTitle::ClipEditTitle(ClipEditWindow *window, int x, int y, int w)
180  : BC_TextBox(x, y, w, 1, window->clip->local_session->clip_title)
182         this->window = window;
185 int ClipEditTitle::handle_event()
187         strcpy(window->clip->local_session->clip_title, get_text());
188         return 1;
195 ClipEditComments::ClipEditComments(ClipEditWindow *window, int x, int y, int w, int rows)
196  : BC_TextBox(x, y, w, rows, window->clip->local_session->clip_notes)
198         this->window = window;
201 int ClipEditComments::handle_event()
203         strcpy(window->clip->local_session->clip_notes, get_text());
204         return 1;