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;
53 // After the window is closed and deleted, this is called.
54 void ClipEdit::handle_close_event(int result)
60 if(create_it) // new_edl =
61 mwindow->edl->add_clip(clip);
63 // Copy clip to existing clip in EDL
65 original->copy_session(clip);
68 // mwindow->vwindow->gui->update_sources(mwindow->vwindow->gui->source->get_text());
71 mwindow->awindow->gui->lock_window();
72 mwindow->awindow->gui->update_assets();
73 mwindow->awindow->gui->flush();
74 mwindow->awindow->gui->unlock_window();
76 // Change VWindow to it if vwindow was called
77 // But this doesn't let you easily create a lot of clips.
78 if(vwindow && create_it)
80 // vwindow->change_source(new_edl);
85 mwindow->session->clip_number--;
90 // For creating new clips, the original was copied in add_clip.
91 // For editing old clips, the original was transferred to another variable.
92 if(!create_it) delete clip;
99 // User creates the window and initializes it here.
100 BC_Window* ClipEdit::new_gui()
106 this->clip = new EDL(mwindow->edl);
107 clip->create_objects();
108 clip->copy_all(original);
112 window = new ClipEditWindow(mwindow, this);
113 window->create_objects();
119 void ClipEdit::edit_clip(EDL *clip)
121 // Allow more than one window so we don't have to delete the clip in handle_event
130 void ClipEdit::create_clip(EDL *clip)
132 // Allow more than one window so we don't have to delete the clip in handle_event
148 ClipEditWindow::ClipEditWindow(MWindow *mwindow, ClipEdit *thread)
149 : BC_Window(PROGRAM_NAME ": Clip Info",
150 mwindow->gui->get_abs_cursor_x(1) - 400 / 2,
151 mwindow->gui->get_abs_cursor_y(1) - 350 / 2,
160 this->mwindow = mwindow;
161 this->thread = thread;
164 ClipEditWindow::~ClipEditWindow()
169 void ClipEditWindow::create_objects()
171 lock_window("ClipEditWindow::create_objects");
172 this->create_it = thread->create_it;
177 BC_TextBox *titlebox;
180 add_subwindow(title = new BC_Title(x1, y, _("Title:")));
181 y += title->get_h() + 5;
182 add_subwindow(titlebox = new ClipEditTitle(this, x1, y, get_w() - x1 * 2));
183 y += titlebox->get_h() + 10;
184 add_subwindow(title = new BC_Title(x1, y, _("Comments:")));
185 y += title->get_h() + 5;
186 add_subwindow(textbox = new ClipEditComments(this,
190 BC_TextBox::pixels_to_rows(this,
192 get_h() - 10 - BC_OKButton::calculate_h() - y)));
196 add_subwindow(new BC_OKButton(this));
197 add_subwindow(new BC_CancelButton(this));
199 titlebox->activate();
207 ClipEditTitle::ClipEditTitle(ClipEditWindow *window, int x, int y, int w)
208 : BC_TextBox(x, y, w, 1, window->thread->clip->local_session->clip_title)
210 this->window = window;
213 int ClipEditTitle::handle_event()
215 strcpy(window->thread->clip->local_session->clip_title, get_text());
223 ClipEditComments::ClipEditComments(ClipEditWindow *window, int x, int y, int w, int rows)
224 : BC_TextBox(x, y, w, rows, window->thread->clip->local_session->clip_notes)
226 this->window = window;
229 int ClipEditComments::handle_event()
231 strcpy(window->thread->clip->local_session->clip_notes, get_text());