4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "awindowgui.h"
24 #include "bcsignals.h"
29 #include "localsession.h"
30 #include "mainerror.h"
31 #include "mainsession.h"
33 #include "mwindowgui.h"
35 #include "vwindowgui.h"
41 ClipEdit::ClipEdit(MWindow *mwindow, AWindow *awindow, VWindow *vwindow)
44 this->mwindow = mwindow;
45 this->awindow = awindow;
46 this->vwindow = vwindow;
56 // After the window is closed and deleted, this is called.
57 void ClipEdit::handle_close_event(int result)
62 for( int i = 0; name_ok && i < mwindow->edl->clips.total; ++i ) {
63 if( !strcasecmp(clip->local_session->clip_title,
64 mwindow->edl->clips.values[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."));
79 mwindow->edl->add_clip(clip);
80 else // Copy clip to existing clip in EDL
81 original->copy_session(clip);
82 // mwindow->vwindow->gui->update_sources(mwindow->vwindow->gui->source->get_text());
83 mwindow->awindow->gui->async_update_assets();
85 // Change VWindow to it if vwindow was called
86 // But this doesn't let you easily create a lot of clips.
87 if(vwindow && create_it)
89 // vwindow->change_source(new_edl);
94 mwindow->session->clip_number--;
99 // For creating new clips, the original was copied in add_clip.
100 // For editing old clips, the original was transferred to another variable.
101 if(!create_it) clip->remove_user();
108 // User creates the window and initializes it here.
109 BC_Window* ClipEdit::new_gui()
115 this->clip = new EDL(mwindow->edl);
116 clip->create_objects();
117 clip->copy_all(original);
121 window = new ClipEditWindow(mwindow, this);
122 window->create_objects();
128 void ClipEdit::edit_clip(EDL *clip)
130 // Allow more than one window so we don't have to delete the clip in handle_event
139 void ClipEdit::create_clip(EDL *clip)
141 // Allow more than one window so we don't have to delete the clip in handle_event
157 ClipEditWindow::ClipEditWindow(MWindow *mwindow, ClipEdit *thread)
158 : BC_Window(_(PROGRAM_NAME ": Clip Info"),
159 mwindow->gui->get_abs_cursor_x(1) - 400 / 2,
160 mwindow->gui->get_abs_cursor_y(1) - 350 / 2,
169 this->mwindow = mwindow;
170 this->thread = thread;
173 ClipEditWindow::~ClipEditWindow()
178 void ClipEditWindow::create_objects()
180 lock_window("ClipEditWindow::create_objects");
181 this->create_it = thread->create_it;
188 add_subwindow(title = new BC_Title(x1, y, _("Title:")));
189 y += title->get_h() + 5;
190 add_subwindow(titlebox = new ClipEditTitle(this, x1, y, get_w() - x1 * 2));
192 int end = strlen(titlebox->get_text());
193 titlebox->set_selection(0, end, end);
195 y += titlebox->get_h() + 10;
196 add_subwindow(title = new BC_Title(x1, y, _("Comments:")));
197 y += title->get_h() + 5;
198 add_subwindow(textbox = new ClipEditComments(this,
202 BC_TextBox::pixels_to_rows(this,
204 get_h() - 10 - BC_OKButton::calculate_h() - y)));
208 add_subwindow(new BC_OKButton(this));
209 add_subwindow(new BC_CancelButton(this));
211 titlebox->activate();
219 ClipEditTitle::ClipEditTitle(ClipEditWindow *window, int x, int y, int w)
220 : BC_TextBox(x, y, w, 1, window->thread->clip->local_session->clip_title)
222 this->window = window;
225 int ClipEditTitle::handle_event()
227 strcpy(window->thread->clip->local_session->clip_title, get_text());
235 ClipEditComments::ClipEditComments(ClipEditWindow *window, int x, int y, int w, int rows)
236 : BC_TextBox(x, y, w, rows, window->thread->clip->local_session->clip_notes)
238 this->window = window;
241 int ClipEditComments::handle_event()
243 strcpy(window->thread->clip->local_session->clip_notes, get_text());