X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fmenuattachtransition.C;h=143bcdb9a79655cae094ca34d4af376d39b993c8;hb=60f8df69db9ddd8148bfc41a17bb0955b52a45e6;hp=fa1e89659bf52c0b0c09b723350534d3c6bfe95a;hpb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/menuattachtransition.C b/cinelerra-5.1/cinelerra/menuattachtransition.C index fa1e8965..143bcdb9 100644 --- a/cinelerra-5.1/cinelerra/menuattachtransition.C +++ b/cinelerra-5.1/cinelerra/menuattachtransition.C @@ -2,21 +2,21 @@ /* * CINELERRA * Copyright (C) 2008 Adam Williams - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * */ #include "datatype.h" @@ -61,6 +61,7 @@ TransitionDialogThread::TransitionDialogThread(MWindow *mwindow, int data_type) { this->mwindow = mwindow; this->data_type = data_type; + this->number = -1; } TransitionDialogThread::~TransitionDialogThread() @@ -72,23 +73,21 @@ void TransitionDialogThread::start() { if(!transition_names.total) { -// Construct listbox names + strcpy(transition_title, data_type == TRACK_AUDIO ? + mwindow->edl->session->default_atransition : + mwindow->edl->session->default_vtransition); + +// Construct listbox names ArrayList plugindb; - mwindow->search_plugindb(data_type == TRACK_AUDIO, - data_type == TRACK_VIDEO, - 0, - 1, - 0, - plugindb); - for(int i = 0; i < plugindb.total; i++) - transition_names.append(new BC_ListBoxItem(_(plugindb.values[i]->title))); + mwindow->search_plugindb(data_type == TRACK_AUDIO, + data_type == TRACK_VIDEO, 0, 1, 0, plugindb); + for(int i = 0; i < plugindb.total; i++) { + const char *title = plugindb.values[i]->title; + if( !strcmp(transition_title, title) ) number = i; + transition_names.append(new BC_ListBoxItem(_(title))); + } } - if(data_type == TRACK_AUDIO) - strcpy(transition_title, mwindow->edl->session->default_atransition); - else - strcpy(transition_title, mwindow->edl->session->default_vtransition); - mwindow->gui->unlock_window(); BC_DialogThread::start(); mwindow->gui->lock_window("TransitionDialogThread::start"); @@ -103,10 +102,7 @@ BC_Window* TransitionDialogThread::new_gui() mwindow->session->transitiondialog_w / 2; int y = mwindow->gui->get_abs_cursor_y(0) - mwindow->session->transitiondialog_h / 2; - TransitionDialog *window = new TransitionDialog(mwindow, - this, - x, - y); + TransitionDialog *window = new TransitionDialog(mwindow, this, x, y); window->create_objects(); mwindow->gui->unlock_window(); return window; @@ -122,20 +118,12 @@ void TransitionDialogThread::handle_close_event(int result) -TransitionDialog::TransitionDialog(MWindow *mwindow, - TransitionDialogThread *thread, - int x, - int y) - : BC_Window(_("Attach Transition"), - x, - y, +TransitionDialog::TransitionDialog(MWindow *mwindow, + TransitionDialogThread *thread, int x, int y) + : BC_Window(_("Attach Transition"), x, y, mwindow->session->transitiondialog_w, - mwindow->session->transitiondialog_h, - 320, - 240, - 1, - 0, - 1) + mwindow->session->transitiondialog_h, + 320, 240, 1, 0, 1) { this->mwindow = mwindow; this->thread = thread; @@ -145,20 +133,23 @@ void TransitionDialog::create_objects() { int x = 10; int y = 10; - + lock_window("TransitionDialog::create_objects"); add_subwindow(name_title = new BC_Title(x, y, _("Select transition from list"))); y += name_title->get_h() + 5; - add_subwindow(name_list = new TransitionDialogName(thread, - &thread->transition_names, - x, + add_subwindow(name_list = new TransitionDialogName(thread, + &thread->transition_names, + x, y, get_w() - x - x, get_h() - y - BC_OKButton::calculate_h() - 10)); + if( thread->number >= 0 ) { + name_list->update_selection(&thread->transition_names, thread->number, 0); + name_list->draw_items(0); + } add_subwindow(new BC_OKButton(this)); add_subwindow(new BC_CancelButton(this)); show_window(); - flush(); unlock_window(); } @@ -170,7 +161,7 @@ int TransitionDialog::resize_event(int w, int h) name_title->reposition_window(x, y); y += name_title->get_h() + 5; - name_list->reposition_window(x, + name_list->reposition_window(x, y, w - x - x, h - y - BC_OKButton::calculate_h() - 10); @@ -180,16 +171,12 @@ int TransitionDialog::resize_event(int w, int h) -TransitionDialogName::TransitionDialogName(TransitionDialogThread *thread, - ArrayList *standalone_data, - int x, - int y, - int w, - int h) - : BC_ListBox(x, - y, - w, - h, +TransitionDialogName::TransitionDialogName(TransitionDialogThread *thread, + ArrayList *standalone_data, int x, int y, int w, int h) + : BC_ListBox(x, + y, + w, + h, LISTBOX_TEXT, standalone_data) { @@ -204,9 +191,9 @@ int TransitionDialogName::handle_event() int TransitionDialogName::selection_changed() { - int number = get_selection_number(0, 0); - strcpy(thread->transition_title, - thread->transition_names.values[number]->get_text()); + thread->number = get_selection_number(0, 0); + strcpy(thread->transition_title, + thread->transition_names.values[thread->number]->get_text()); return 1; }