Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / bcfilebox.C
index 54e6bbf5de5c6d65c88cf43a37b3e9b4c76573a4..638081f5166a0c861d0139f88fab3801008e17cc 100644 (file)
@@ -90,14 +90,8 @@ int BC_FileBoxListBox::selection_changed()
                filebox->column_of_type(FILEBOX_NAME), 0);
 
        if(item) {
-               char path[BCTEXTLEN];
-               strcpy(path, item->get_text());
-               filebox->textbox->update(path);
-               filebox->fs->extract_dir(filebox->directory, path);
-               filebox->fs->extract_name(filebox->filename, path);
-               filebox->fs->complete_path(path);
-               strcpy(filebox->current_path, path);
-               strcpy(filebox->submitted_path, path);
+               filebox->textbox->update(item->get_text());
+               filebox->update_paths(item->get_text());
        }
        return 1;
 }
@@ -172,11 +166,11 @@ BC_FileBoxTextBox::~BC_FileBoxTextBox()
 
 int BC_FileBoxTextBox::handle_event()
 {
-       int result = 0;
-       if(get_keypress() != RETURN)
-       {
+       int key = get_keypress(), result = 1;
+       if( !key || key == RETURN ) // not a text update
+               filebox->update_paths(filebox->textbox->get_text());
+       else
                result = calculate_suggestions(&filebox->list_column[0]);
-       }
        return result;
 }
 
@@ -448,7 +442,7 @@ BC_FileBox::BC_FileBox(int x, int y, const char *init_path,
  : BC_Window(title, x, y,
        BC_WindowBase::get_resources()->filebox_w,
        BC_WindowBase::get_resources()->filebox_h,
-       xS(400), yS(300), 1, 0, 1)
+       xS(450), yS(350), 1, 0, 1)
 {
        fs = new FileSystem;
 //     if(want_directory)
@@ -714,28 +708,28 @@ int BC_FileBox::resize_event(int w, int h)
 {
        draw_background(0, 0, w, h);
        flash(0);
+       int dw = w - get_w();
+       int dh = h - get_h();
 
 // OK button handles resize event itself
 //     ok_button->reposition_window(ok_button->get_x(),
-//             h - (get_h() - ok_button->get_y()));
-//     cancel_button->reposition_window(w - (get_w() - cancel_button->get_x()),
-//             h - (get_h() - cancel_button->get_y()));
+//             ok_button->get_y() + dh);
+//     cancel_button->reposition_window(cancel_button->get_x() + dw,
+//             cancel_button->get_y() + dh);
        if(usethis_button)
                usethis_button->reposition_window(w / 2 - xS(50),
-                       h - (get_h() - usethis_button->get_y()));
+                       usethis_button->get_y() + dh);
 
 
-       if(filter_popup) filter_popup->reposition_window(w - (get_w() - filter_popup->get_x()),
-               h - (get_h() - filter_popup->get_y()),
-               w - xS(30),
-               0);
+       if(filter_popup)
+               filter_popup->reposition_window(filter_popup->get_x() + dw,
+                       filter_popup->get_y() + dh, w - xS(30), 0);
 
-       if(filter_title) filter_title->reposition_window(filter_title->get_x(),
-               h - (get_h() - filter_title->get_y()));
+       if(filter_title)
+               filter_title->reposition_window(filter_title->get_x(),
+                       filter_title->get_y() + dh);
        if(filter_text) filter_text->reposition_window(filter_text->get_x(),
-               h - (get_h() - filter_text->get_y()),
-               w - (get_w() - filter_text->get_w()),
-               1);
+               filter_text->get_y() + dh, filter_text->get_w() + dw, 1);
        directory_title->reposition_window(
                directory_title->get_x(), directory_title->get_y(),
                get_w()-directory_title->get_x() - recent_popup->get_w()-xS(20), 1);
@@ -744,30 +738,22 @@ int BC_FileBox::resize_event(int w, int h)
                directory_title->get_y(),
                directory_title->get_w() + recent_popup->get_w(), xS(200));
        search_text->reposition_window(
-               search_text->get_x(),
-               search_text->get_y(),
-               get_w() - search_text->get_x() -  xS(40),
-               1);
+               search_text->get_x(), search_text->get_y(),
+               get_w() - search_text->get_x() -  xS(40), 1);
        file_title->reposition_window(file_title->get_x(),
-               h - (get_h() - file_title->get_y()));
+               file_title->get_y() + dh);
        textbox->reposition_window(textbox->get_x(),
-               h - (get_h() - textbox->get_y()),
-               w - (get_w() - textbox->get_w()),
-               1);
-       listbox->reposition_window(listbox->get_x(),
-               listbox->get_y(),
-               w - (get_w() - listbox->get_w()),
-               h - (get_h() - listbox->get_h()),
-               0);
-       int dx = w - get_w();
-       icon_button->reposition_window(icon_button->get_x()+dx, icon_button->get_y());
-       text_button->reposition_window(text_button->get_x()+dx, text_button->get_y());
-       folder_button->reposition_window(folder_button->get_x()+dx, folder_button->get_y());
-       rename_button->reposition_window(rename_button->get_x()+dx, rename_button->get_y());
-       reload_button->reposition_window(reload_button->get_x()+dx, reload_button->get_y());
-       delete_button->reposition_window(delete_button->get_x()+dx, delete_button->get_y());
-       updir_button->reposition_window(updir_button->get_x()+dx, updir_button->get_y());
-       szfmt_button->reposition_window(szfmt_button->get_x()+dx, szfmt_button->get_y());
+               textbox->get_y() + dh, textbox->get_w() + dw, 1);
+       listbox->reposition_window(listbox->get_x(), listbox->get_y(),
+               listbox->get_w() + dw, listbox->get_h() + dh, 0);
+       icon_button->reposition_window(icon_button->get_x()+dw, icon_button->get_y());
+       text_button->reposition_window(text_button->get_x()+dw, text_button->get_y());
+       folder_button->reposition_window(folder_button->get_x()+dw, folder_button->get_y());
+       rename_button->reposition_window(rename_button->get_x()+dw, rename_button->get_y());
+       reload_button->reposition_window(reload_button->get_x()+dw, reload_button->get_y());
+       delete_button->reposition_window(delete_button->get_x()+dw, delete_button->get_y());
+       updir_button->reposition_window(updir_button->get_x()+dw, updir_button->get_y());
+       szfmt_button->reposition_window(szfmt_button->get_x()+dw, szfmt_button->get_y());
        set_w(w);  set_h(h);
        get_resources()->filebox_w = get_w();
        get_resources()->filebox_h = get_h();
@@ -794,7 +780,7 @@ int BC_FileBox::keypress_event()
                set_done(1);
                return 1;
        }
-       return 0;
+       return context_help_check_and_show();
 }
 
 int BC_FileBox::close_event()
@@ -1017,6 +1003,17 @@ int BC_FileBox::update_filter(const char *filter)
 }
 
 
+void BC_FileBox::update_paths(const char *text)
+{
+       char path[BCTEXTLEN];
+       strncpy(path, text, sizeof(path)-1);
+       fs->extract_dir(directory, path);
+       fs->extract_name(filename, path);
+       fs->complete_path(path);
+       strcpy(current_path, path);
+       strcpy(submitted_path, path);
+}
+
 void BC_FileBox::move_column(int src, int dst)
 {
        if(src != dst)
@@ -1325,24 +1322,19 @@ int BC_FileBox::get_y_margin()
 char* BC_FileBox::get_path(int selection)
 {
        if(selection == 0)
-       {
                return get_submitted_path();
-       }
-       else
-       {
-               BC_ListBoxItem *item = listbox->get_selection(
-                       column_of_type(FILEBOX_NAME), selection - 1);
-               if(item)
-               {
-                       fs->join_names(string, directory, item->get_text());
-                       return string;
-               }
+       BC_ListBoxItem *item = listbox->get_selection(
+               column_of_type(FILEBOX_NAME), selection - 1);
+       if( item ) {
+               fs->join_names(string, directory, item->get_text());
+               return string;
        }
        return 0;
 }
 
 char* BC_FileBox::get_submitted_path()
 {
+       update_paths(textbox->get_text());
        return submitted_path;
 }