2 #include "awindowgui.h"
7 #include "localsession.h"
8 #include "mainsession.h"
10 #include "mwindowgui.h"
12 #include "vwindowgui.h"
18 ClipEdit::ClipEdit(MWindow *mwindow, AWindow *awindow, VWindow *vwindow)
21 this->mwindow = mwindow;
22 this->awindow = awindow;
23 this->vwindow = vwindow;
32 void ClipEdit::edit_clip(EDL *clip)
34 // Allow more than one window so we don't have to delete the clip in handle_event
43 void ClipEdit::create_clip(EDL *clip)
45 // Allow more than one window so we don't have to delete the clip in handle_event
61 clip = new EDL(mwindow->edl);
62 clip->create_objects();
63 clip->copy_all(original);
73 ClipEditWindow *window = new ClipEditWindow(mwindow, this);
75 window->create_objects();
77 int name_ok_or_cancel = 0;
79 while (!name_ok_or_cancel)
81 result = window->run_window();
83 name_ok_or_cancel = 1;
86 // Check if clip name is unique
87 name_ok_or_cancel = 1;
88 for (int i = 0; i < mwindow->edl->clips.total; i++)
90 if (!strcasecmp(clip->local_session->clip_title,
91 mwindow->edl->clips.values[i]->local_session->clip_title) &&
92 (create_it || strcasecmp(clip->local_session->clip_title,
93 original->local_session->clip_title)))
95 name_ok_or_cancel = 0;
97 if (!name_ok_or_cancel)
99 ErrorBox error(PROGRAM_NAME ": Error",
100 mwindow->gui->get_abs_cursor_x(1),
101 mwindow->gui->get_abs_cursor_y(1));
102 error.create_objects(_("A clip with that name already exists."));
104 window->titlebox->activate();
114 new_edl = mwindow->edl->add_clip(window->clip);
116 // Copy clip to existing clip in EDL
118 original->copy_session(clip);
121 // mwindow->vwindow->gui->update_sources(mwindow->vwindow->gui->source->get_text());
124 mwindow->awindow->gui->async_update_assets();
126 // Change VWindow to it if vwindow was called
127 // But this doesn't let you easily create a lot of clips.
128 if(vwindow && create_it)
130 // vwindow->change_source(new_edl);
135 mwindow->session->clip_number--;
140 // For creating new clips, the original was copied in add_clip.
141 // For editing old clips, the original was transferred to another variable.
155 ClipEditWindow::ClipEditWindow(MWindow *mwindow, ClipEdit *thread)
156 : BC_Window(PROGRAM_NAME ": Clip Info",
157 mwindow->gui->get_abs_cursor_x(1) - 400 / 2,
158 mwindow->gui->get_abs_cursor_y(1) - 350 / 2,
167 this->mwindow = mwindow;
168 this->thread = thread;
171 ClipEditWindow::~ClipEditWindow()
176 void ClipEditWindow::create_objects()
178 this->clip = thread->clip;
179 this->create_it = thread->create_it;
186 add_subwindow(title = new BC_Title(x1, y, _("Title:")));
187 y += title->get_h() + 5;
188 add_subwindow(titlebox = new ClipEditTitle(this, x1, y, get_w() - x1 * 2));
189 y += titlebox->get_h() + 10;
190 add_subwindow(title = new BC_Title(x1, y, _("Comments:")));
191 y += title->get_h() + 5;
192 add_subwindow(textbox = new ClipEditComments(this,
196 BC_TextBox::pixels_to_rows(this,
198 get_h() - 10 - BC_OKButton::calculate_h() - y)));
202 add_subwindow(new BC_OKButton(this));
203 add_subwindow(new BC_CancelButton(this));
205 titlebox->activate();
212 ClipEditTitle::ClipEditTitle(ClipEditWindow *window, int x, int y, int w)
213 : BC_TextBox(x, y, w, 1, window->clip->local_session->clip_title)
215 this->window = window;
218 int ClipEditTitle::handle_event()
220 strcpy(window->clip->local_session->clip_title, get_text());
228 ClipEditComments::ClipEditComments(ClipEditWindow *window, int x, int y, int w, int rows)
229 : BC_TextBox(x, y, w, rows, window->clip->local_session->clip_notes)
231 this->window = window;
234 int ClipEditComments::handle_event()
236 strcpy(window->clip->local_session->clip_notes, get_text());