@@ -16,7 +16,7 @@ var scrolling_backwards := false
16
16
var scrolling_forwards := false
17
17
var active_controls : Array [Control ] = []
18
18
19
- var is_dragging := false
19
+ # Processing is enabled only when dragging.
20
20
var proposed_drop_idx := - 1 :
21
21
set (new_value ):
22
22
if proposed_drop_idx != new_value :
@@ -36,6 +36,7 @@ func _ready() -> void:
36
36
Configs .language_changed .connect (queue_redraw )
37
37
mouse_entered .connect (_on_mouse_entered )
38
38
mouse_exited .connect (_on_mouse_exited )
39
+ set_process (false )
39
40
40
41
func _draw () -> void :
41
42
var background_stylebox : StyleBoxFlat = \
@@ -225,18 +226,19 @@ func _gui_input(event: InputEvent) -> void:
225
226
scrolling_backwards = false
226
227
scrolling_forwards = false
227
228
229
+ # Autoscroll when the dragged tab is hovered beyond the tabs area.
228
230
func _process (_delta : float ) -> void :
229
231
var mouse_pos := get_local_mouse_position ()
230
232
var scroll_forwards_area_rect := get_scroll_forwards_area_rect ()
231
233
if ((scrolling_forwards and scroll_forwards_area_rect .has_point (mouse_pos )) or \
232
- (is_dragging and mouse_pos .x > size .x - get_add_button_rect ().size .x - \
234
+ (mouse_pos .x > size .x - get_add_button_rect ().size .x - \
233
235
scroll_forwards_area_rect .size .x )) and scroll_forwards_area_rect .has_area ():
234
236
scroll_forwards ()
235
237
return
236
238
237
239
var scroll_backwards_area_rect := get_scroll_backwards_area_rect ()
238
240
if ((scrolling_backwards and scroll_backwards_area_rect .has_point (mouse_pos )) or \
239
- (is_dragging and mouse_pos .x < scroll_backwards_area_rect .size .x )) and \
241
+ (mouse_pos .x < scroll_backwards_area_rect .size .x )) and \
240
242
scroll_backwards_area_rect .has_area ():
241
243
scroll_backwards ()
242
244
return
@@ -461,7 +463,7 @@ func get_drop_index_at(pos: Vector2) -> int:
461
463
if not tab_rect .has_area () or tab_width * (idx + 0.5 ) - current_scroll + \
462
464
scroll_backwards_button_width > pos .x :
463
465
return idx
464
- return - 1
466
+ return Configs . savedata . get_tab_count ()
465
467
466
468
func _get_drag_data (at_position : Vector2 ) -> Variant :
467
469
var tab_index_at_position := get_tab_index_at (at_position )
@@ -484,7 +486,7 @@ func _get_drag_data(at_position: Vector2) -> Variant:
484
486
label .size .x = tab_width - 8
485
487
486
488
set_drag_preview (preview )
487
- is_dragging = true
489
+ set_process ( true )
488
490
return TabDropData .new (tab_index_at_position )
489
491
490
492
func _can_drop_data (at_position : Vector2 , data : Variant ) -> bool :
@@ -502,10 +504,10 @@ func _can_drop_data(at_position: Vector2, data: Variant) -> bool:
502
504
func _drop_data (at_position : Vector2 , data : Variant ) -> void :
503
505
if not data is TabDropData :
504
506
return
505
- is_dragging = false
507
+ set_process ( false )
506
508
Configs .savedata .move_tab (data .index , get_drop_index_at (at_position ))
507
509
508
510
func _notification (what : int ) -> void :
509
511
if what == NOTIFICATION_DRAG_END :
510
- is_dragging = false
512
+ set_process ( false )
511
513
proposed_drop_idx = - 1
0 commit comments