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 "mainsession.h"
32 #include "mwindowgui.h"
34 #include "vwindowgui.h"
39 ClipEdit::ClipEdit(MWindow *mwindow, AWindow *awindow, VWindow *vwindow)
42 this->mwindow = mwindow;
43 this->awindow = awindow;
44 this->vwindow = vwindow;
54 // After the window is closed and deleted, this is called.
55 void ClipEdit::handle_close_event(int result)
61 if(create_it) // new_edl =
62 mwindow->edl->add_clip(clip);
64 // Copy clip to existing clip in EDL
66 original->copy_session(clip);
69 // mwindow->vwindow->gui->update_sources(mwindow->vwindow->gui->source->get_text());
72 mwindow->awindow->gui->lock_window();
73 mwindow->awindow->gui->update_assets();
74 mwindow->awindow->gui->flush();
75 mwindow->awindow->gui->unlock_window();
77 // Change VWindow to it if vwindow was called
78 // But this doesn't let you easily create a lot of clips.
79 if(vwindow && create_it)
81 // vwindow->change_source(new_edl);
86 mwindow->session->clip_number--;
91 // For creating new clips, the original was copied in add_clip.
92 // For editing old clips, the original was transferred to another variable.
93 if(!create_it) clip->remove_user();
100 // User creates the window and initializes it here.
101 BC_Window* ClipEdit::new_gui()
107 this->clip = new EDL(mwindow->edl);
108 clip->create_objects();
109 clip->copy_all(original);
113 window = new ClipEditWindow(mwindow, this);
114 window->create_objects();
120 void ClipEdit::edit_clip(EDL *clip)
122 // Allow more than one window so we don't have to delete the clip in handle_event
131 void ClipEdit::create_clip(EDL *clip)
133 // Allow more than one window so we don't have to delete the clip in handle_event
149 ClipEditWindow::ClipEditWindow(MWindow *mwindow, ClipEdit *thread)
150 : BC_Window(_(PROGRAM_NAME ": Clip Info"),
151 mwindow->gui->get_abs_cursor_x(1) - 400 / 2,
152 mwindow->gui->get_abs_cursor_y(1) - 350 / 2,
161 this->mwindow = mwindow;
162 this->thread = thread;
165 ClipEditWindow::~ClipEditWindow()
170 void ClipEditWindow::create_objects()
172 lock_window("ClipEditWindow::create_objects");
173 this->create_it = thread->create_it;
178 BC_TextBox *titlebox;
181 add_subwindow(title = new BC_Title(x1, y, _("Title:")));
182 y += title->get_h() + 5;
183 add_subwindow(titlebox = new ClipEditTitle(this, x1, y, get_w() - x1 * 2));
184 y += titlebox->get_h() + 10;
185 add_subwindow(title = new BC_Title(x1, y, _("Comments:")));
186 y += title->get_h() + 5;
187 add_subwindow(textbox = new ClipEditComments(this,
191 BC_TextBox::pixels_to_rows(this,
193 get_h() - 10 - BC_OKButton::calculate_h() - y)));
197 add_subwindow(new BC_OKButton(this));
198 add_subwindow(new BC_CancelButton(this));
200 titlebox->activate();
208 ClipEditTitle::ClipEditTitle(ClipEditWindow *window, int x, int y, int w)
209 : BC_TextBox(x, y, w, 1, window->thread->clip->local_session->clip_title)
211 this->window = window;
214 int ClipEditTitle::handle_event()
216 strcpy(window->thread->clip->local_session->clip_title, get_text());
224 ClipEditComments::ClipEditComments(ClipEditWindow *window, int x, int y, int w, int rows)
225 : BC_TextBox(x, y, w, rows, window->thread->clip->local_session->clip_notes)
227 this->window = window;
230 int ClipEditComments::handle_event()
232 strcpy(window->thread->clip->local_session->clip_notes, get_text());