4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5 * Copyright (C) 2003-2016 Cinelerra CV contributors
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "awindowgui.h"
25 #include "bcsignals.h"
30 #include "localsession.h"
31 #include "mainerror.h"
32 #include "mainsession.h"
34 #include "mwindowgui.h"
36 #include "vwindowgui.h"
42 ClipEdit::ClipEdit(MWindow *mwindow, AWindow *awindow, VWindow *vwindow)
45 this->mwindow = mwindow;
46 this->awindow = awindow;
47 this->vwindow = vwindow;
57 // After the window is closed and deleted, this is called.
58 void ClipEdit::handle_close_event(int result)
62 for( int i=0; name_ok && i<mwindow->edl->clips.size(); ++i ) {
63 if( !strcasecmp(clip->local_session->clip_title,
64 mwindow->edl->clips[i]->local_session->clip_title) &&
65 (create_it || strcasecmp(clip->local_session->clip_title,
66 original->local_session->clip_title)) )
70 eprintf(_("A clip with that name already exists."));
78 mwindow->edl->add_clip(clip);
79 else // Copy clip to existing clip in EDL
80 original->copy_session(clip);
81 // mwindow->vwindow->gui->update_sources(mwindow->vwindow->gui->source->get_text());
82 mwindow->awindow->gui->async_update_assets();
84 // Change VWindow to it if vwindow was called
85 // But this doesn't let you easily create a lot of clips.
86 if( vwindow && create_it ) {
87 // vwindow->change_source(new_edl);
89 mwindow->session->update_clip_number();
92 // always a copy from new_gui
100 // User creates the window and initializes it here.
101 BC_Window* ClipEdit::new_gui()
104 this->clip = new EDL(mwindow->edl);
105 clip->create_objects();
106 clip->copy_all(original);
108 window = new ClipEditWindow(mwindow, this);
109 window->create_objects();
115 void ClipEdit::edit_clip(EDL *clip, int x, int y)
121 this->x = x; this->y = y;
125 void ClipEdit::create_clip(EDL *clip, int x, int y)
131 this->x = x; this->y = y;
135 #define CEW_W xS(400)
136 #define CEW_H yS(350)
138 ClipEditWindow::ClipEditWindow(MWindow *mwindow, ClipEdit *thread)
139 : BC_Window(_(PROGRAM_NAME ": Clip Info"),
140 thread->x - CEW_W/2, thread->y - CEW_H/2,
141 CEW_W, CEW_H, CEW_W, CEW_H, 0, 0, 1)
143 this->mwindow = mwindow;
144 this->thread = thread;
145 // *** CONTEXT_HELP ***
146 context_help_set_keyword("Workflow with OpenEDL and Nested Clips");
149 ClipEditWindow::~ClipEditWindow()
154 void ClipEditWindow::create_objects()
157 int ys5 = yS(5), ys10 = yS(10);
158 lock_window("ClipEditWindow::create_objects");
159 this->create_it = thread->create_it;
161 int x = xs10, y = ys10;
166 add_subwindow(title = new BC_Title(x1, y, _("Title:")));
167 y += title->get_h() + ys5;
168 add_subwindow(titlebox = new ClipEditTitle(this, x1, y, get_w() - x1 * 2));
170 int end = strlen(titlebox->get_text());
171 titlebox->set_selection(0, end, end);
173 y += titlebox->get_h() + ys10;
174 add_subwindow(title = new BC_Title(x1, y, _("Comments:")));
175 y += title->get_h() + ys5;
176 add_subwindow(textbox = new ClipEditComments(this,
180 BC_TextBox::pixels_to_rows(this,
182 get_h() - ys10 - BC_OKButton::calculate_h() - y)));
186 add_subwindow(new BC_OKButton(this));
187 add_subwindow(new BC_CancelButton(this));
189 titlebox->activate();
197 ClipEditTitle::ClipEditTitle(ClipEditWindow *window, int x, int y, int w)
198 : BC_TextBox(x, y, w, 1, window->thread->clip->local_session->clip_title)
200 this->window = window;
203 int ClipEditTitle::handle_event()
205 strcpy(window->thread->clip->local_session->clip_title, get_text());
213 ClipEditComments::ClipEditComments(ClipEditWindow *window, int x, int y, int w, int rows)
214 : BC_TextBox(x, y, w, rows, window->thread->clip->local_session->clip_notes)
216 this->window = window;
219 int ClipEditComments::handle_event()
221 strcpy(window->thread->clip->local_session->clip_notes, get_text());