X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbclistbox.C;h=54bab352a6f7a6b12db02067a4b21c36b5831db3;hb=a4387a272874bd4ed9f010684976f336fa3d0190;hp=b10cdf0860c7a22aceb2ee9f5844fff3a4524383;hpb=47ad0dcdda5b5ae53931025c581eef1782fc5e12;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/guicast/bclistbox.C b/cinelerra-5.1/guicast/bclistbox.C index b10cdf08..54bab352 100644 --- a/cinelerra-5.1/guicast/bclistbox.C +++ b/cinelerra-5.1/guicast/bclistbox.C @@ -656,8 +656,8 @@ void BC_ListBox::calculate_item_coords_recursive( if( temp_display_format == LISTBOX_ICON_LIST ) { for( int i=0; iicon ) { - if( data[0].get(i)->icon->get_h() > row_height ) - row_height = data[0].get(i)->icon->get_h(); + int icon_h = data[0].get(i)->icon->get_h() + 2*ICON_MARGIN; + if( row_height < icon_h ) row_height = icon_h; } } } @@ -918,14 +918,24 @@ int BC_ListBox::get_item_h(BC_ListBoxItem *item) } +int BC_ListBox::get_icon_x(BC_ListBoxItem *item) +{ + return get_item_x(item) + ICON_MARGIN; +} + +int BC_ListBox::get_icon_y(BC_ListBoxItem *item) +{ + return get_item_y(item) + ICON_MARGIN; +} + int BC_ListBox::get_icon_w(BC_ListBoxItem *item) { - return item->get_icon_w(); + return item->get_icon_w() + 2*ICON_MARGIN; } int BC_ListBox::get_icon_h(BC_ListBoxItem *item) { - return item->get_icon_h(); + return item->get_icon_h() + 2*ICON_MARGIN; } int BC_ListBox::get_text_w(BC_ListBoxItem *item) @@ -1041,6 +1051,11 @@ int BC_ListBox::set_xposition(int position) return 0; } +int BC_ListBox::is_highlighted() +{ + return list_highlighted; +} + void BC_ListBox::expand_item(BC_ListBoxItem *item, int expand) { if( item ) { @@ -1173,10 +1188,10 @@ int BC_ListBox::get_icon_mask(BC_ListBoxItem *item, case LISTBOX_ICONS: case LISTBOX_ICONS_PACKED: case LISTBOX_ICON_LIST: { - x = get_item_x(item); - y = get_item_y(item); - w = get_icon_w(item) + ICON_MARGIN * 2; - h = get_icon_h(item) + ICON_MARGIN * 2; + x = get_icon_x(item); + y = get_icon_y(item); + w = get_icon_w(item); + h = get_icon_h(item); break; } case LISTBOX_TEXT: default: { @@ -1200,15 +1215,15 @@ int BC_ListBox::get_text_mask(BC_ListBoxItem *item, case LISTBOX_ICONS: case LISTBOX_ICONS_PACKED: { if( icon_position == ICON_LEFT ) { - x += get_icon_w(item) + ICON_MARGIN * 2; + x += get_icon_w(item); y += get_icon_h(item) - get_text_h(item); } else { - y += get_icon_h(item) + ICON_MARGIN; + y += get_icon_h(item); } w = packed_icons ? - get_icon_w(item) + ICON_MARGIN * 4 : + get_icon_w(item) + ICON_MARGIN * 2 : get_text_w(item) + ICON_MARGIN * 2 ; h = get_text_h(item) + ICON_MARGIN * 2; break; } @@ -2093,8 +2108,7 @@ int BC_ListBox::get_cursor_item(ArrayList *data, int cursor_x, return j; } } - if( display_format == LISTBOX_ICONS ) return -1; - } // fall through + return -1; } case LISTBOX_TEXT: if( !gui ) break; // Text is treed @@ -2136,6 +2150,14 @@ int BC_ListBox::get_cursor_item(ArrayList *data, int cursor_x, return -1; } +// short version +int BC_ListBox::get_cursor_item() +{ + int rx, ry; + gui->get_relative_cursor(rx, ry); + return get_cursor_item(data, rx, ry, 0, 0); +} + int BC_ListBox::repeat_event(int64_t duration) { switch( current_operation ) { @@ -2696,7 +2718,6 @@ int BC_ListBox::button_press_event() int BC_ListBox::button_release_event() { int result = 0; - int cursor_x, cursor_y; int do_event = 0; new_value = 0; unset_scroll_repeat(); @@ -2719,11 +2740,7 @@ int BC_ListBox::button_release_event() //printf("BC_ListBox::button_release_event 10\n"); current_operation = NO_OPERATION; if( gui ) { - translate_coordinates(top_level->event_win, gui->win, - gui->get_cursor_x(), gui->get_cursor_y(), - &cursor_x, &cursor_y); - selection_number1 = selection_number = - get_cursor_item(data, cursor_x, cursor_y); + selection_number1 = selection_number = get_cursor_item(); //printf("BC_ListBox::button_release_event %d %d\n", selection_number2, selection_number1); } @@ -3135,7 +3152,8 @@ int BC_ListBox::cursor_motion_event() // Moved out of item area if( old_highlighted_item != highlighted_item ) { - redraw_items = 1; + if( !mouse_over_event(highlighted_item) ) + redraw_items = 1; } //printf("BC_ListBox::cursor_motion_event 1 %d\n", highlighted_item); @@ -3692,16 +3710,17 @@ int BC_ListBox::draw_items(int flush, int draw_bg) } // Draw icons gui->set_color(get_item_color(data, 0, i)); - if( item->icon ) - gui->pixmap->draw_pixmap(item->icon, - icon_x + ICON_MARGIN, icon_y + ICON_MARGIN); + VFrame *vicon = item->get_vicon_frame(); + if( vicon ) + gui->pixmap->draw_vframe(vicon, icon_x, icon_y); + else if( item->icon ) + gui->pixmap->draw_pixmap(item->icon, icon_x, icon_y); char item_text[BCTEXTLEN]; if( display_format == LISTBOX_ICONS_PACKED ) gui->truncate_text(item_text, item->text, text_w); else strcpy(item_text, item->text); - gui->draw_text(text_x + ICON_MARGIN, - text_y + ICON_MARGIN + get_baseline(item), item_text); + gui->draw_text(text_x, text_y + get_baseline(item), item_text); } else item->set_in_view(0); @@ -3819,8 +3838,14 @@ void BC_ListBox::draw_text_recursive(ArrayList *data, if( column == 0 && display_format == LISTBOX_ICON_LIST ) { - if( item->icon ) { - gui->pixmap->draw_pixmap(item->icon, x, y); + int ix = get_icon_x(item), iy = get_icon_y(item); + VFrame *vicon = item->get_vicon_frame(); + if( vicon ) { + gui->pixmap->draw_vframe(vicon, ix, iy); + x += vicon->get_w() + ICON_MARGIN; + } + else if( item->icon ) { + gui->pixmap->draw_pixmap(item->icon, ix, iy); x += item->icon->get_w() + ICON_MARGIN; } }