X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbclistbox.C;h=960226f8bfffc43116fb4134706efaef1555186b;hp=6468b89fa4537bbfe9fb24ddbdc59252e62f3b2c;hb=a4de4732339bf38b5b225c533be1bdf60748f04a;hpb=0d49253b107e67067b6143958fee3f8e4c0e0b6c diff --git a/cinelerra-5.1/guicast/bclistbox.C b/cinelerra-5.1/guicast/bclistbox.C index 6468b89f..960226f8 100644 --- a/cinelerra-5.1/guicast/bclistbox.C +++ b/cinelerra-5.1/guicast/bclistbox.C @@ -432,6 +432,7 @@ BC_ListBox::BC_ListBox(int x, // reset the search engine //printf("BC_ListBox::BC_ListBox 4\n"); + show_query = 0; reset_query(); //printf("BC_ListBox::BC_ListBox 5\n"); } @@ -732,9 +733,10 @@ void BC_ListBox::calculate_last_coords_recursive( // Lowest right icon coordinate. current_icon_x = item->icon_x; if(current_icon_x > *icon_x) *icon_x = current_icon_x; - if(current_icon_x + get_item_w(item) > *next_icon_x) + if(current_icon_x + get_item_w(item) > *next_icon_x) { *next_icon_x = current_icon_x + get_item_w(item); - + *next_icon_y = 0; + } current_icon_y = item->icon_y + get_item_h(item); if(current_icon_y > *next_icon_y) *next_icon_y = current_icon_y; @@ -1129,8 +1131,8 @@ int BC_ListBox::get_items_height(ArrayList *data, int x, y, w, h; BC_ListBoxItem *item = data[master_column].values[j]; - if(display_format == LISTBOX_ICONS) - { + if( display_format == LISTBOX_ICONS || + display_format == LISTBOX_ICON_LIST ) { get_icon_mask(item, x, y, w, h); if(y + h + yposition > highest) highest = y + h + yposition; @@ -1141,8 +1143,6 @@ int BC_ListBox::get_items_height(ArrayList *data, { get_text_mask(item, x, y, w, h); *result += h; - - // Descend into sublist if(item->get_sublist() && item->get_expand()) @@ -1154,9 +1154,7 @@ int BC_ListBox::get_items_height(ArrayList *data, } } - if((display_format == LISTBOX_TEXT || - display_format == LISTBOX_ICON_LIST) && - top_level) + if( display_format == LISTBOX_TEXT && top_level ) { highest = LISTBOX_MARGIN + *result; } @@ -1364,6 +1362,8 @@ int BC_ListBox::get_text_mask(BC_ListBoxItem *item, { w = get_text_width(MEDIUMFONT, item->text) + LISTBOX_MARGIN * 2; h = row_height; + int ih = get_icon_h(item); + if( h < ih ) h = ih; } return 0; } @@ -2419,9 +2419,8 @@ int BC_ListBox::get_cursor_item(ArrayList *data, } } } - else + else if( gui ) { // Text is treed - { // Cursor is inside items rectangle if(cursor_x >= 0 && cursor_x < (yscrollbar ? @@ -2483,12 +2482,11 @@ int BC_ListBox::repeat_event(int64_t duration) case NO_OPERATION: // Show tooltip - if(button_highlighted && is_popup && !tooltip_done && + if(button_highlighted && is_popup && tooltip_text && tooltip_text[0] != 0 && duration == get_resources()->tooltip_delay) { show_tooltip(); - tooltip_done = 1; return 1; } break; @@ -3926,8 +3924,6 @@ int BC_ListBox::reposition_window(int x, int y, int w, int h, int flush) if(!is_popup) { - if(w != -1) popup_w = w; - if(h != -1) popup_h = h; if(xscrollbar) xscrollbar->reposition_window(get_xscroll_x(), get_xscroll_y(), @@ -3948,6 +3944,7 @@ int BC_ListBox::reposition_window(int x, int y, int w, int h, int flush) int BC_ListBox::deactivate() { + hide_tooltip(); // printf("BC_ListBox::deactivate %d this=%p gui=%p active=%d\n", // __LINE__, // this, @@ -3983,69 +3980,45 @@ int BC_ListBox::deactivate() int BC_ListBox::activate(int take_focus) { -//printf("BC_ListBox::activate %d %p\n", __LINE__, this); - if(!active) - { - if(take_focus) - { - top_level->active_subwindow = this; - active = 1; - } - - button_releases = 0; - -// Test for existence of GUI in case this was previously called without -// take_focus & again with take_focus - if(is_popup && !gui) - { - Window tempwin; - int x, y; - int new_x, new_y; - y = get_y() + get_h(); - if(justify == LISTBOX_RIGHT) - { - x = get_x() - popup_w + get_w(); - } - else - { - x = get_x(); - } - - - XTranslateCoordinates(top_level->display, - parent_window->win, - top_level->rootwin, - x, - y, - &new_x, - &new_y, - &tempwin); - - if(new_x < 0) new_x = 0; - if(new_y + popup_h > top_level->get_root_h(0)) - new_y -= get_h() + popup_h; - - add_subwindow(gui = new BC_Popup(this, - new_x, - new_y, - popup_w, - popup_h, - -1, - 0, - 0)); -// Avoid top going out of screen - if(new_y < 0 ) - new_y = 2; -//printf("BC_ListBox::activate %d this=%p %p\n", __LINE__, this, gui->win); - draw_items(1); - gui->show_window(1); - } -//printf("BC_ListBox::activate %d %p\n", __LINE__, this); -//sleep(1); - } + if( active ) return 0; + active = 1; + if( take_focus ) + set_active_subwindow(this); + button_releases = 0; + if( !is_popup || gui ) return 0; + int wx = get_x(), wy = get_y() + get_h(); + if( justify == LISTBOX_RIGHT ) wx += get_w() - popup_w; + Window xwin; + int abs_x, abs_y; + XTranslateCoordinates(top_level->display, + parent_window->win, top_level->rootwin, + wx, wy, &abs_x, &abs_y, &xwin); + if( x <= 0 ) x = 2; + if( y <= 0 ) y = 2; + return activate(abs_x, abs_y); +} + +int BC_ListBox::activate(int x, int y, int w, int h) +{ + if( !is_popup || gui ) return 0; + active = 1; + if(w != -1) popup_w = w; + if(h != -1) popup_h = h; + reset_query(); + if( y + popup_h > top_level->get_root_h(0) ) + y -= get_h() + popup_h; + add_subwindow(gui = new BC_Popup(this, + x, y, popup_w, popup_h, -1, 0, 0)); + draw_items(1); + gui->show_window(1); return 0; } +int BC_ListBox::is_active() +{ + return active; +} + int BC_ListBox::keypress_event() { if(!active) return 0; @@ -4061,7 +4034,6 @@ int BC_ListBox::keypress_event() { case ESC: case RETURN: - case BACKSPACE: top_level->deactivate(); // If user is manipulating popup with keyboard, don't pass on event. @@ -4162,7 +4134,12 @@ int BC_ListBox::keypress_event() if(query_len > 0) query[--query_len] = 0; new_selection = query_list(); } - + if( show_query ) { + if( query_len > 0 ) + show_tooltip(query); + else + hide_tooltip(); + } redraw = 1; result = 1; } @@ -4429,9 +4406,14 @@ void BC_ListBox::draw_text_recursive(ArrayList *data, gui->set_color(row_color); gui->draw_box(x, y, column_width, h); gui->set_color(BLACK); - int yy = y, xx = x + column_width-1; - gui->draw_line(x, yy, xx, yy); - yy = y + row_height; + int xx = x + column_width-1; + gui->draw_line(x, y, xx, y); + int hh = row_height; + if( display_format == LISTBOX_ICON_LIST ) { + int ih = get_icon_h(item); + if( ih > hh ) hh = ih; + } + int yy = y + hh-1; gui->draw_line(x, yy, xx, yy); }