menuattachtransition fixes
authorGood Guy <[email protected]>
Mon, 25 Apr 2016 17:30:37 +0000 (11:30 -0600)
committerGood Guy <[email protected]>
Mon, 25 Apr 2016 17:30:37 +0000 (11:30 -0600)
cinelerra-5.1/cinelerra/menuattachtransition.C
cinelerra-5.1/cinelerra/menuattachtransition.h
cinelerra-5.1/plugins/shapewipe/shapewipe.C

index fa1e89659bf52c0b0c09b723350534d3c6bfe95a..57090f0368495eda0b245c2db839864415dc9d40 100644 (file)
@@ -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)
        {
+               strcpy(transition_title, data_type == TRACK_AUDIO ?
+                       mwindow->edl->session->default_atransition :
+                       mwindow->edl->session->default_vtransition);
+
 // Construct listbox names     
                ArrayList<PluginServer*> 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)));
+                       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;
@@ -123,19 +119,11 @@ void TransitionDialogThread::handle_close_event(int result)
 
 
 TransitionDialog::TransitionDialog(MWindow *mwindow, 
-       TransitionDialogThread *thread,
-       int x,
-       int y)
- : BC_Window(_("Attach Transition"), 
-       x,
-       y,
+       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)
+       320, 240, 1, 0, 1)
 {
        this->mwindow = mwindow;
        this->thread = thread;
@@ -155,10 +143,13 @@ void TransitionDialog::create_objects()
                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();
 }
 
@@ -181,11 +172,7 @@ int TransitionDialog::resize_event(int w, int h)
 
 
 TransitionDialogName::TransitionDialogName(TransitionDialogThread *thread, 
-       ArrayList<BC_ListBoxItem*> *standalone_data, 
-       int x,
-       int y, 
-       int w, 
-       int h)
+       ArrayList<BC_ListBoxItem*> *standalone_data, int x, int y, int w, int h)
  : BC_ListBox(x, 
        y, 
        w, 
@@ -204,9 +191,9 @@ int TransitionDialogName::handle_event()
 
 int TransitionDialogName::selection_changed()
 {
-       int number = get_selection_number(0, 0);
+       thread->number = get_selection_number(0, 0);
        strcpy(thread->transition_title, 
-               thread->transition_names.values[number]->get_text());
+               thread->transition_names.values[thread->number]->get_text());
        return 1;
 }
 
index 1e02fd5125ea7a0c1c0a94624261357a9c36f1d8..00980cd396cf42047a4b04e0d9c4f7f1b6ec1d3d 100644 (file)
@@ -60,6 +60,7 @@ public:
        char transition_title[BCTEXTLEN];
        MWindow *mwindow;
        int data_type;
+       int number;
        ArrayList<BC_ListBoxItem*> transition_names;
 };
 
index 1656e7f1d62bfb219c74abca3f537b403a12ac7e..bb91c5ecc6cd345113758cb4d23827f94d994588 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "bcdisplayinfo.h"
 #include "bchash.h"
+#include "cstrdup.h"
 #include "edl.inc"
 #include "filesystem.h"
 #include "filexml.h"
@@ -332,6 +333,8 @@ ShapeWipeMain::ShapeWipeMain(PluginServer *server)
        preserve_aspect = 0;
        last_preserve_aspect = 0;
        shapes_initialized = 0;
+       shape_paths.set_array_delete();
+       shape_titles.set_array_delete();
 }
 
 ShapeWipeMain::~ShapeWipeMain()
@@ -399,8 +402,8 @@ void ShapeWipeMain::init_shapes()
                        FileItem *file_item = fs.get_entry(i);
                        if(!file_item->get_is_dir())
                        {
-                               shape_paths.append(strdup(file_item->get_path()));
-                               char *ptr = strdup(file_item->get_name());
+                               shape_paths.append(cstrdup(file_item->get_path()));
+                               char *ptr = cstrdup(file_item->get_name());
                                char *ptr2 = strrchr(ptr, '.');
                                if(ptr2) *ptr2 = 0;
                                shape_titles.append(ptr);
@@ -610,26 +613,40 @@ void ShapeWipeMain::reset_pattern_image()
        type *in_row; \
        type *out_row; \
        \
-       for(j = 0; j < h; j++) \
-       { \
-               in_row = (type*) in_rows[j]; \
-               out_row = (type*)out_rows[j]; \
-               pattern_row = pattern_image[j]; \
-               \
-               col_offset = 0; \
-               for(k = 0; k < w; k++) \
-               { \
-                       value = pattern_row[k]; \
-                       if ((direction == 0 && value >= threshold) || \
-                       (direction == 1 && value <= threshold)) \
-                       { \
+       if( !direction ) { \
+               for(j = 0; j < h; j++) { \
+                       in_row = (type*) in_rows[j]; \
+                       out_row = (type*)out_rows[j]; \
+                       pattern_row = pattern_image[j]; \
+                       \
+                       col_offset = 0; \
+                       for(k = 0; k < w; k++, col_offset += components ) { \
+                               value = pattern_row[k]; \
+                               if (value < threshold) continue; \
+                               out_row[col_offset]     = in_row[col_offset]; \
+                               out_row[col_offset + 1] = in_row[col_offset + 1]; \
+                               out_row[col_offset + 2] = in_row[col_offset + 2]; \
+                               if(components == 4) \
+                                       out_row[col_offset + 3] = in_row[col_offset + 3]; \
+                       } \
+               } \
+       } \
+       else { \
+               for(j = 0; j < h; j++) { \
+                       in_row = (type*) in_rows[j]; \
+                       out_row = (type*)out_rows[j]; \
+                       pattern_row = pattern_image[j]; \
+                       \
+                       col_offset = 0; \
+                       for(k = 0; k < w; k++, col_offset += components ) { \
+                               value = pattern_row[k]; \
+                               if (value > threshold) continue; \
                                out_row[col_offset]     = in_row[col_offset]; \
                                out_row[col_offset + 1] = in_row[col_offset + 1]; \
                                out_row[col_offset + 2] = in_row[col_offset + 2]; \
                                if(components == 4) \
                                        out_row[col_offset + 3] = in_row[col_offset + 3]; \
                        } \
-                       col_offset += components; \
                } \
        } \
 }