X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbcfilebox.C;h=cbb5168e7c3c90a1f0e0b494a23f1ba2e9dc0c67;hp=7fba2ec63dfa468d6569d9073cabbf0dace5cc0e;hb=4c207ab325a8e8e6b79a9a18d4647273b5f59f93;hpb=269d410062641e8f0094e73f87a3d9900c69dfd4 diff --git a/cinelerra-5.1/guicast/bcfilebox.C b/cinelerra-5.1/guicast/bcfilebox.C index 7fba2ec6..cbb5168e 100644 --- a/cinelerra-5.1/guicast/bcfilebox.C +++ b/cinelerra-5.1/guicast/bcfilebox.C @@ -38,19 +38,15 @@ #include - - - - - BC_FileBoxRecent::BC_FileBoxRecent(BC_FileBox *filebox, int x, int y) - : BC_ListBox(x, y, 250, + : BC_ListBox(x, y, xS(250), filebox->get_text_height(MEDIUMFONT) * FILEBOX_HISTORY_SIZE + BC_ScrollBar::get_span(SCROLL_HORIZ) + LISTBOX_MARGIN * 2, LISTBOX_TEXT, &filebox->recent_dirs, 0, 0, 1, 0, 1) { this->filebox = filebox; + set_tooltip(_("Recent paths")); } int BC_FileBoxRecent::handle_event() @@ -64,15 +60,6 @@ int BC_FileBoxRecent::handle_event() } - - - - - - - - - BC_FileBoxListBox::BC_FileBoxListBox(int x, int y, BC_FileBox *filebox) : BC_ListBox(x, y, filebox->get_listbox_w(), filebox->get_listbox_h(y), filebox->get_display_mode(), filebox->list_column, @@ -103,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; } @@ -173,7 +154,7 @@ int BC_FileBoxListBox::evaluate_query(char *string) BC_FileBoxTextBox::BC_FileBoxTextBox(int x, int y, BC_FileBox *filebox) - : BC_TextBox(x, y, filebox->get_w() - 20, 1, + : BC_TextBox(x, y, filebox->get_w() - x - xS(20), 1, filebox->want_directory ? filebox->directory : filebox->filename) { this->filebox = filebox; @@ -185,17 +166,17 @@ 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; } -BC_FileBoxDirectoryText::BC_FileBoxDirectoryText(int x, int y, BC_FileBox *filebox) - : BC_TextBox(x, y, filebox->get_w() - 40, 1, filebox->fs->get_current_dir()) +BC_FileBoxDirectoryText::BC_FileBoxDirectoryText(int x, int y, int w, BC_FileBox *filebox) + : BC_TextBox(x, y, w, 1, filebox->fs->get_current_dir()) { this->filebox = filebox; } @@ -223,7 +204,7 @@ int BC_FileBoxDirectoryText::handle_event() BC_FileBoxSearchText::BC_FileBoxSearchText(int x, int y, BC_FileBox *filebox) - : BC_TextBox(x, y, filebox->get_w() - x - 40, 1, "") + : BC_TextBox(x, y, filebox->get_w() - x - xS(40), 1, "") { this->filebox = filebox; } @@ -236,7 +217,7 @@ int BC_FileBoxSearchText::handle_event() BC_FileBoxFilterText::BC_FileBoxFilterText(int x, int y, BC_FileBox *filebox) - : BC_TextBox(x, y, filebox->get_w() - x - 50, 1, filebox->get_resources()->filebox_filter) + : BC_TextBox(x, y, filebox->get_w() - x - xS(50), 1, filebox->get_resources()->filebox_filter) { this->filebox = filebox; } @@ -249,7 +230,7 @@ int BC_FileBoxFilterText::handle_event() BC_FileBoxFilterMenu::BC_FileBoxFilterMenu(int x, int y, BC_FileBox *filebox) - : BC_ListBox(x, y, filebox->get_w() - 30, 120, + : BC_ListBox(x, y, filebox->get_w() - xS(30), yS(120), LISTBOX_TEXT, &filebox->filter_list, 0, 0, 1, 0, 1) { this->filebox = filebox; @@ -461,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, - 400, 300, 1, 0, 1) + xS(400), yS(300), 1, 0, 1) { fs = new FileSystem; // if(want_directory) @@ -539,12 +520,12 @@ BC_FileBox::BC_FileBox(int x, int y, const char *init_path, if(h_padding == -1) { - h_padding = BC_WindowBase::get_resources()->ok_images[0]->get_h() - - 20; + h_padding = BC_WindowBase::get_resources()->ok_images[0]->get_h() - yS(20); } this->h_padding = h_padding; delete_thread = new BC_DeleteThread(this); rename_thread = 0; + y_margin = 0; } BC_FileBox::~BC_FileBox() @@ -566,10 +547,12 @@ BC_FileBox::~BC_FileBox() void BC_FileBox::create_objects() { + int xs5 = xS(5), xs10 = xS(10), xs20 = xS(20); + int ys5 = yS(5), ys10 = yS(10); lock_window("BC_FileBox::create_objects"); - int x = 10, y = 10; + int x = xs10, y = ys10; BC_Resources *resources = BC_WindowBase::get_resources(); - int directory_title_margin = MAX(20, + int directory_title_margin = MAX(xs20, resources->filebox_text_images[0]->get_h()); // Directories aren't filtered in FileSystem so skip this @@ -595,50 +578,52 @@ void BC_FileBox::create_objects() add_subwindow(new BC_Title(x, y, caption)); - x = get_w() - resources->filebox_icons_images[0]->get_w() - 10; + x = get_w() - resources->filebox_icons_images[0]->get_w() - xs10; add_subwindow(icon_button = new BC_FileBoxIcons(x, y, this)); - x -= resources->filebox_text_images[0]->get_w() + 5; + x -= resources->filebox_text_images[0]->get_w() + xs5; add_subwindow(text_button = new BC_FileBoxText(x, y, this)); - x -= resources->filebox_newfolder_images[0]->get_w() + 5; + x -= resources->filebox_newfolder_images[0]->get_w() + xs5; add_subwindow(folder_button = new BC_FileBoxNewfolder(x, y, this)); - x -= resources->filebox_delete_images[0]->get_w() + 5; + x -= resources->filebox_delete_images[0]->get_w() + xs5; add_subwindow(rename_button = new BC_FileBoxRename(x, y, this)); - x -= resources->filebox_delete_images[0]->get_w() + 5; + x -= resources->filebox_delete_images[0]->get_w() + xs5; add_subwindow(delete_button = new BC_FileBoxDelete(x, y, this)); - x -= resources->filebox_reload_images[0]->get_w() + 5; + x -= resources->filebox_reload_images[0]->get_w() + xs5; add_subwindow(reload_button = new BC_FileBoxReload(x, y, this)); - x -= resources->filebox_updir_images[0]->get_w() + 5; + x -= resources->filebox_updir_images[0]->get_w() + xs5; add_subwindow(updir_button = new BC_FileBoxUpdir(x, y, this)); - x -= resources->filebox_szfmt_images[0]->get_w() + 5; + x -= resources->filebox_szfmt_images[0]->get_w() + xs5; add_subwindow(szfmt_button = new BC_FileBoxSizeFormat(x, y, this)); - x = 10; - y += directory_title_margin + 3; + x = xs10; + y += directory_title_margin + yS(3); add_subwindow(recent_popup = new BC_FileBoxRecent(this, x, y)); - add_subwindow(directory_title = new BC_FileBoxDirectoryText(x, y, this)); - directory_title->reposition_window(x, y, get_w() - recent_popup->get_w() - 20, 1); - x += directory_title->get_w() + 8; - recent_popup->reposition_window(x, y, directory_title->get_w(), 200); + BC_Title *dir_title; + add_subwindow(dir_title = new BC_Title(x, y, _("Directory:"))); + int x1 = x + dir_title->get_w() + xs10, w1 = get_w()-x1 - recent_popup->get_w()-xs20; + add_subwindow(directory_title = new BC_FileBoxDirectoryText(x1, y, w1, this)); + x1 += directory_title->get_w() + xS(8); + recent_popup->reposition_window(x1, y, directory_title->get_w(), yS(200)); - x = 10; - y += directory_title->get_h() + 5; + x = xs10; + y += directory_title->get_h() + ys5; BC_Title *search_title; add_subwindow(search_title = new BC_Title(x, y, _("Search:"))); - x += search_title->get_w() + 10; + x += search_title->get_w() + xs10; add_subwindow(search_text = new BC_FileBoxSearchText(x, y, this)); - x = 10; - y += search_text->get_h() + 5; + x = xs10; + y += search_text->get_h() + ys5; int newest_id = 0, newest = -1; for(int i = 0; i < FILEBOX_HISTORY_SIZE; i++) { @@ -664,17 +649,21 @@ void BC_FileBox::create_objects() listbox = 0; create_listbox(x, y, get_display_mode()); - y += listbox->get_h() + 10; - add_subwindow(textbox = new BC_FileBoxTextBox(x, y, this)); - y += textbox->get_h() + 10; + y += listbox->get_h() + ys10; + add_subwindow(file_title = new BC_Title(x, y, _("File:"))); + x1 = x + file_title->get_w() + xs10; + add_subwindow(textbox = new BC_FileBoxTextBox(x1, y, this)); + y += textbox->get_h() + ys10; if(!want_directory) { add_subwindow(filter_title = new BC_Title(x, y, _("Specify filter:"))); - int x1 = x + filter_title->get_w() + 10; + int x1 = x + filter_title->get_w() + xs10; add_subwindow(filter_text = new BC_FileBoxFilterText(x1, y, this)); add_subwindow(filter_popup = new BC_FileBoxFilterMenu(x1 + filter_text->get_w(), y, this)); + y += filter_text->get_h() + ys10; } + y_margin = y; // listbox has to be active because refresh might be called from newfolder_thread listbox->activate(); @@ -684,17 +673,18 @@ void BC_FileBox::create_objects() refresh(); show_window(); + raise_window(); unlock_window(); } int BC_FileBox::get_listbox_w() { - return get_w() - 20; + return get_w() - xS(20); } int BC_FileBox::get_listbox_h(int y) { - int result = get_h() - y - h_padding - 10; + int result = get_h() - y - h_padding - yS(10); if(want_directory) result -= BC_WindowBase::get_resources()->dirbox_margin; else @@ -725,13 +715,13 @@ int BC_FileBox::resize_event(int w, int h) // cancel_button->reposition_window(w - (get_w() - cancel_button->get_x()), // h - (get_h() - cancel_button->get_y())); if(usethis_button) - usethis_button->reposition_window(w / 2 - 50, + usethis_button->reposition_window(w / 2 - xS(50), h - (get_h() - usethis_button->get_y())); if(filter_popup) filter_popup->reposition_window(w - (get_w() - filter_popup->get_x()), h - (get_h() - filter_popup->get_y()), - w - 30, + w - xS(30), 0); if(filter_title) filter_title->reposition_window(filter_title->get_x(), @@ -741,19 +731,19 @@ int BC_FileBox::resize_event(int w, int h) w - (get_w() - filter_text->get_w()), 1); directory_title->reposition_window( - directory_title->get_x(), - directory_title->get_y(), - get_w() - recent_popup->get_w() - 20, - 1); + directory_title->get_x(), directory_title->get_y(), + get_w()-directory_title->get_x() - recent_popup->get_w()-xS(20), 1); recent_popup->reposition_window( - directory_title->get_x() + directory_title->get_w() + 8, + directory_title->get_x() + directory_title->get_w() + xS(8), directory_title->get_y(), - directory_title->get_w() + recent_popup->get_w(), 200); + 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() - 40, + get_w() - search_text->get_x() - xS(40), 1); + file_title->reposition_window(file_title->get_x(), + h - (get_h() - file_title->get_y())); textbox->reposition_window(textbox->get_x(), h - (get_h() - textbox->get_y()), w - (get_w() - textbox->get_w()), @@ -775,6 +765,9 @@ int BC_FileBox::resize_event(int w, int h) set_w(w); set_h(h); get_resources()->filebox_w = get_w(); get_resources()->filebox_h = get_h(); + y_margin = filter_text ? + filter_text->get_y() + filter_text->get_h() + yS(10) : + textbox->get_y() + textbox->get_h() + yS(10) ; flush(); return 1; } @@ -1018,6 +1011,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) @@ -1318,27 +1322,27 @@ void BC_FileBox::create_listbox(int x, int y, int mode) add_subwindow(listbox = new BC_FileBoxListBox(x, y, this)); } +int BC_FileBox::get_y_margin() +{ + return 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; }