r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / clipedit.C
blobf82fbb431013bfc5cf039c450a09fb3833002089
1 #include "awindow.h"
2 #include "awindowgui.h"
3 #include "clipedit.h"
4 #include "edl.h"
5 #include "fonts.h"
6 #include "localsession.h"
7 #include "mainsession.h"
8 #include "mwindow.h"
9 #include "mwindowgui.h"
10 #include "vwindow.h"
11 #include "vwindowgui.h"
13 #include <libintl.h>
14 #define _(String) gettext(String)
15 #define gettext_noop(String) String
16 #define N_(String) gettext_noop (String)
20 ClipEdit::ClipEdit(MWindow *mwindow, AWindow *awindow, VWindow *vwindow)
21  : Thread()
23         this->mwindow = mwindow;
24         this->awindow = awindow;
25         this->vwindow = vwindow;
26         this->clip = 0;
27         this->create_it = 0;
30 ClipEdit::~ClipEdit()
34 void ClipEdit::edit_clip(EDL *clip)
36 // Allow more than one window so we don't have to delete the clip in handle_event
37         if(clip)
38         {
39                 this->clip = clip;
40                 this->create_it = 0;
41                 Thread::start();
42         }
45 void ClipEdit::create_clip(EDL *clip)
47 // Allow more than one window so we don't have to delete the clip in handle_event
48         if(clip)
49         {
50                 this->clip = clip;
51                 this->create_it = 1;
52                 Thread::start();
53         }
56 void ClipEdit::run()
58         if(clip)
59         {
60                 EDL *original = clip;
61                 if(!create_it)
62                 {
63                         clip = new EDL(mwindow->edl);
64                         clip->create_objects();
65                         clip->copy_all(original);
66                 }
75                 ClipEditWindow *window = new ClipEditWindow(mwindow, this);
76                 window->create_objects();
77                 int result = window->run_window();
78                 
79                 if(!result)
80                 {
81                         EDL *new_edl = 0;
82 // Add to EDL
83                         if(create_it)
84                                 new_edl = mwindow->edl->add_clip(window->clip);
86 // Copy clip to existing clip in EDL
87                         if(!create_it)
88                                 original->copy_session(clip);
91 //                      mwindow->vwindow->gui->update_sources(mwindow->vwindow->gui->source->get_text());
94                         mwindow->awindow->gui->lock_window();
95                         mwindow->awindow->gui->update_assets();
96                         mwindow->awindow->gui->flush();
97                         mwindow->awindow->gui->unlock_window();
99 // Change VWindow to it if vwindow was called
100 // But this doesn't let you easily create a lot of clips.
101                         if(vwindow && create_it)
102                         {
103 //                              vwindow->change_source(new_edl);
104                         }
105                 }
106                 else
107                 {
108                         mwindow->session->clip_number--;
109                 }
110                 
113 // For creating new clips, the original was copied in add_clip.
114 // For editing old clips, the original was transferred to another variable.
115                 delete window->clip;
116                 delete window;
117                 clip = 0;
118                 create_it = 0;
119         }
128 ClipEditWindow::ClipEditWindow(MWindow *mwindow, ClipEdit *thread)
129  : BC_Window(PROGRAM_NAME ": Clip Info", 
130         mwindow->gui->get_abs_cursor_x() - 400 / 2,
131         mwindow->gui->get_abs_cursor_y() - 350 / 2,
132         400, 
133         350,
134         400,
135         430,
136         0,
137         0,
138         1)
140         this->mwindow = mwindow;
141         this->thread = thread;
144 ClipEditWindow::~ClipEditWindow()
148         
149 void ClipEditWindow::create_objects()
151         this->clip = thread->clip;
152         this->create_it = thread->create_it;
154         int x = 10, y = 10;
155         int x1 = x;
156         BC_TextBox *textbox;
157         BC_Title *title;
159         add_subwindow(title = new BC_Title(x1, y, _("Title:")));
160         y += title->get_h() + 5;
161         add_subwindow(textbox = new ClipEditTitle(this, x1, y, get_w() - x1 * 2));
162         y += textbox->get_h() + 10;
163         add_subwindow(title = new BC_Title(x1, y, _("Comments:")));
164         y += title->get_h() + 5;
165         add_subwindow(textbox = new ClipEditComments(this, 
166                 x1, 
167                 y, 
168                 get_w() - x1 * 2, 
169                 BC_TextBox::pixels_to_rows(this, MEDIUMFONT, get_h() - 10 - 40 - y)));
173         add_subwindow(new BC_OKButton(this));
174         add_subwindow(new BC_CancelButton(this));
175         show_window();
182 ClipEditTitle::ClipEditTitle(ClipEditWindow *window, int x, int y, int w)
183  : BC_TextBox(x, y, w, 1, window->clip->local_session->clip_title)
185         this->window = window;
188 int ClipEditTitle::handle_event()
190         strcpy(window->clip->local_session->clip_title, get_text());
191         return 1;
198 ClipEditComments::ClipEditComments(ClipEditWindow *window, int x, int y, int w, int rows)
199  : BC_TextBox(x, y, w, rows, window->clip->local_session->clip_notes)
201         this->window = window;
204 int ClipEditComments::handle_event()
206         strcpy(window->clip->local_session->clip_notes, get_text());
207         return 1;