X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbclistbox.C;h=7c032b6a0bbb9b31cde88505fd9d8da70864c9e0;hp=e85cb599d00915743081ba8eeab9fe3351c4401b;hb=20002b54e92573aafc97cbc3a85ec529b35bb191;hpb=0d37fdc03a4c5eeffef41d15490ebc528079ea52 diff --git a/cinelerra-5.1/guicast/bclistbox.C b/cinelerra-5.1/guicast/bclistbox.C index e85cb599..7c032b6a 100644 --- a/cinelerra-5.1/guicast/bclistbox.C +++ b/cinelerra-5.1/guicast/bclistbox.C @@ -287,8 +287,8 @@ BC_ListBox::BC_ListBox(int x, int y, int w, int h, yscrollbar = 0; current_cursor = ARROW_CURSOR; gui = 0; - view_h = 0; - view_w = 0; + view_w = items_w = 0; + view_h = items_h = 0; title_h = 0; active = 0; is_suggestions = 0; @@ -300,19 +300,26 @@ BC_ListBox::BC_ListBox(int x, int y, int w, int h, bg_tile = 0; bg_draw = 1; drag_popup = 0; + dragged_title = 0; selection_number1 = -1; selection_number2 = -1; bg_surface = 0; bg_pixmap = 0; row_height = row_ascent = row_descent = 0; - + selection_start = 0; + selection_center = 0; + selection_end = -1; + selection_number = -1; current_operation = NO_OPERATION; button_highlighted = 0; + button_releases = 0; list_highlighted = 0; disabled = 0; + scroll_repeat = 0; allow_drag_scroll = 1; process_drag = 1; + for( int i=0; i<32; ++i ) default_column_width[i] = 0; sort_column = -1; sort_order = 0; @@ -359,8 +366,11 @@ BC_ListBox::BC_ListBox(int x, int y, int w, int h, drag_icon_vframe = 0; drag_column_icon_vframe = 0; - - + drag_cursor_x = 0; + drag_column_w = 0; + temp_display_format = display_format; + rect_x1 = rect_x2 = 0; + rect_y1 = rect_y2 = 0; // reset the search engine //printf("BC_ListBox::BC_ListBox 4\n"); @@ -744,6 +754,19 @@ void BC_ListBox::set_is_suggestions(int value) { this->is_suggestions = value; } +void BC_ListBox::set_scroll_repeat() +{ + if( scroll_repeat ) return; + scroll_repeat = 1; + set_repeat(get_resources()->scroll_repeat); +} + +void BC_ListBox::unset_scroll_repeat() +{ + if( !scroll_repeat ) return; + scroll_repeat = 0; + unset_repeat(get_resources()->scroll_repeat); +} void BC_ListBox::set_use_button(int value) { @@ -2443,6 +2466,14 @@ int BC_ListBox::button_press_event() if( debug ) printf("BC_ListBox::button_press_event %d\n", __LINE__); } + if( current_operation != NO_OPERATION ) { + switch( current_operation ) { + case DRAG_ITEM: + case COLUMN_DRAG: + return drag_stop_event(); + } + } + // Wheel mouse pressed if( get_buttonpress() == 4 ) { if( current_operation == NO_OPERATION ) { @@ -2627,6 +2658,7 @@ int BC_ListBox::button_release_event() int cursor_x, cursor_y; int do_event = 0; new_value = 0; + unset_scroll_repeat(); //printf("BC_ListBox::button_release_event 1 %d\n", current_operation); switch( current_operation ) { @@ -2644,7 +2676,6 @@ int BC_ListBox::button_release_event() case BUTTON_DOWN_SELECT: case SELECT: //printf("BC_ListBox::button_release_event 10\n"); - unset_repeat(get_resources()->scroll_repeat); current_operation = NO_OPERATION; if( gui ) { translate_coordinates(top_level->event_win, gui->win, @@ -2679,7 +2710,6 @@ int BC_ListBox::button_release_event() case SELECT_RECT: - unset_repeat(get_resources()->scroll_repeat); if( data ) { // Demote selections from rectangle selection promote_selections(data, 2, 1); @@ -2877,9 +2907,8 @@ int BC_ListBox::cursor_motion_event() break; } case SELECT_RECT: { - if( test_drag_scroll(get_cursor_x(), get_cursor_y()) ) { - set_repeat(get_resources()->scroll_repeat); - } + if( test_drag_scroll(get_cursor_x(), get_cursor_y()) ) + set_scroll_repeat(); int old_x1 = MIN(rect_x1, rect_x2); int old_x2 = MAX(rect_x1, rect_x2); @@ -2930,11 +2959,8 @@ int BC_ListBox::cursor_motion_event() case SELECT: { int old_highlighted_item = highlighted_item; - if( test_drag_scroll(get_cursor_x(), - get_cursor_y()) ) { - set_repeat(get_resources()->scroll_repeat); - } - + if( test_drag_scroll(get_cursor_x(), get_cursor_y()) ) + set_scroll_repeat(); highlighted_item = selection_number = get_cursor_item(data, get_cursor_x(), get_cursor_y(), &highlighted_ptr); @@ -3126,29 +3152,22 @@ int BC_ListBox::drag_start_event() int cx, cy; get_abs_cursor(cx, cy); if( item_return->icon_vframe ) { - cx -= item_return->icon_vframe->get_w() / 2, - cy -= item_return->icon_vframe->get_h() / 2; drag_popup = new BC_DragWindow(this, item_return->icon_vframe, cx, cy); } else -// this probably works not! if( item_return->icon ) { - cx -= item_return->icon->get_w() / 2, - cy -= item_return->icon->get_h() / 2; drag_popup = new BC_DragWindow(this, item_return->icon, cx, cy); } else { - cx -= drag_icon_vframe->get_w() / 2, - cy -= drag_icon_vframe->get_h() / 2; drag_popup = new BC_DragWindow(this, drag_icon_vframe, cx, cy); } current_operation = DRAG_ITEM; // require shift down for scrolling if( allow_drag < 0 && shift_down() ) - set_repeat(get_resources()->scroll_repeat); + set_scroll_repeat(); return 1; } } @@ -3215,9 +3234,10 @@ int BC_ListBox::drag_motion_event() int BC_ListBox::drag_stop_event() { + int result = 0; + unset_scroll_repeat(); switch( current_operation ) { case DRAG_ITEM: - unset_repeat(get_resources()->scroll_repeat); // Inside window boundary if( top_level->cursor_x > 0 && top_level->cursor_x < gui->get_w() - drag_popup->get_w() / 2 && @@ -3229,9 +3249,9 @@ int BC_ListBox::drag_stop_event() if( display_format == LISTBOX_ICONS ) { reposition_item(data, selection_number, - top_level->cursor_x + drag_popup->get_offset_x() - + top_level->cursor_x - drag_popup->get_w() / 2 - LISTBOX_MARGIN - 2 + xposition, - top_level->cursor_y + drag_popup->get_offset_y() - + top_level->cursor_y - drag_popup->get_h() / 2 - LISTBOX_MARGIN - 2 + yposition); } else @@ -3255,13 +3275,8 @@ int BC_ListBox::drag_stop_event() } else drag_popup->drag_failure_event(); - - delete drag_popup; - flush(); - drag_popup = 0; - current_operation = NO_OPERATION; - new_value = 0; - return 1; + result = 1; + break; case COLUMN_DRAG: if( dragged_title != highlighted_title ) { @@ -3271,13 +3286,18 @@ int BC_ListBox::drag_stop_event() else drag_popup->drag_failure_event(); } + result = 1; + } + + if( result ) { current_operation = NO_OPERATION; delete drag_popup; flush(); drag_popup = 0; - return 1; + new_value = 0; } - return 0; + + return result; } BC_DragWindow* BC_ListBox::get_drag_popup()