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)
61 for( int i=0; name_ok && i<mwindow->edl->clips.size(); ++i ) {
62 if( !strcasecmp(clip->local_session->clip_title,
63 mwindow->edl->clips[i]->local_session->clip_title) &&
64 (create_it || strcasecmp(clip->local_session->clip_title,
65 original->local_session->clip_title)) )
69 eprintf(_("A clip with that name already exists."));
77 mwindow->edl->add_clip(clip);
78 else // Copy clip to existing clip in EDL
79 original->copy_session(clip);
80 // mwindow->vwindow->gui->update_sources(mwindow->vwindow->gui->source->get_text());
81 mwindow->awindow->gui->async_update_assets();
83 // Change VWindow to it if vwindow was called
84 // But this doesn't let you easily create a lot of clips.
85 if( vwindow && create_it ) {
86 // vwindow->change_source(new_edl);
88 mwindow->session->update_clip_number();
91 // always a copy from new_gui
99 // User creates the window and initializes it here.
100 BC_Window* ClipEdit::new_gui()
103 this->clip = new EDL(mwindow->edl);
104 clip->create_objects();
105 clip->copy_all(original);
107 window = new ClipEditWindow(mwindow, this);
108 window->create_objects();
114 void ClipEdit::edit_clip(EDL *clip, int x, int y)
120 this->x = x; this->y = y;
124 void ClipEdit::create_clip(EDL *clip, int x, int y)
130 this->x = x; this->y = y;
134 #define CEW_W xS(400)
135 #define CEW_H yS(350)
137 ClipEditWindow::ClipEditWindow(MWindow *mwindow, ClipEdit *thread)
138 : BC_Window(_(PROGRAM_NAME ": Clip Info"),
139 thread->x - CEW_W/2, thread->y - CEW_H/2,
140 CEW_W, CEW_H, CEW_W, CEW_H, 0, 0, 1)
142 this->mwindow = mwindow;
143 this->thread = thread;
144 // *** CONTEXT_HELP ***
145 context_help_set_keyword("Workflow with OpenEDL and Nested Clips");
148 ClipEditWindow::~ClipEditWindow()
153 void ClipEditWindow::create_objects()
156 int ys5 = yS(5), ys10 = yS(10);
157 lock_window("ClipEditWindow::create_objects");
158 this->create_it = thread->create_it;
160 int x = xs10, y = ys10;
165 add_subwindow(title = new BC_Title(x1, y, _("Title:")));
166 y += title->get_h() + ys5;
167 add_subwindow(titlebox = new ClipEditTitle(this, x1, y, get_w() - x1 * 2));
169 int end = strlen(titlebox->get_text());
170 titlebox->set_selection(0, end, end);
172 y += titlebox->get_h() + ys10;
173 add_subwindow(title = new BC_Title(x1, y, _("Comments:")));
174 y += title->get_h() + ys5;
175 add_subwindow(textbox = new ClipEditComments(this,
179 BC_TextBox::pixels_to_rows(this,
181 get_h() - ys10 - BC_OKButton::calculate_h() - y)));
185 add_subwindow(new BC_OKButton(this));
186 add_subwindow(new BC_CancelButton(this));
188 titlebox->activate();
196 ClipEditTitle::ClipEditTitle(ClipEditWindow *window, int x, int y, int w)
197 : BC_TextBox(x, y, w, 1, window->thread->clip->local_session->clip_title)
199 this->window = window;
202 int ClipEditTitle::handle_event()
204 strcpy(window->thread->clip->local_session->clip_title, get_text());
212 ClipEditComments::ClipEditComments(ClipEditWindow *window, int x, int y, int w, int rows)
213 : BC_TextBox(x, y, w, rows, window->thread->clip->local_session->clip_notes)
215 this->window = window;
218 int ClipEditComments::handle_event()
220 strcpy(window->thread->clip->local_session->clip_notes, get_text());