Skip to content

Commit ac79dbd

Browse files
authored
Disable process functions when not used (#1146)
1 parent f8a9ed9 commit ac79dbd

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

.github/workflows/export-optimized.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ env:
1111
# Which godot version to use for exporting.
1212
GODOT_VERSION: 4.4
1313
# Which godot release to use for exporting. (stable/rc/beta/alpha)
14-
GODOT_RELEASE: beta1
14+
GODOT_RELEASE: beta3
1515
# Used in the editor config file name. Do not change this for patch releases.
1616
GODOT_FEATURE_VERSION: 4.4
1717
# Commit hash
18-
GODOT_COMMIT_HASH: d33da79d3
18+
GODOT_COMMIT_HASH: 06acfccf89
1919
PROJECT_NAME: GodSVG
2020
GODOT_REPO: https://github.com/godotengine/godot.git
2121
BUILD_OPTIONS: target=template_release lto=full production=yes deprecated=no minizip=no brotli=no vulkan=no openxr=no use_volk=no disable_3d=yes modules_enabled_by_default=no module_freetype_enabled=yes module_gdscript_enabled=yes module_svg_enabled=yes module_jpg_enabled=yes module_text_server_adv_enabled=yes graphite=no module_webp_enabled=yes

src/ui_parts/display.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ unique_name_in_owner = true
116116
disable_3d = true
117117
handle_input_locally = false
118118
gui_snap_controls_to_pixels = false
119-
size = Vector2i(1040, 595)
119+
size = Vector2i(450, 2)
120120
size_2d_override_stretch = true
121121
render_target_update_mode = 4
122122
script = ExtResource("9_4xrk7")

src/ui_parts/element_container.gd

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ const autoscroll_speed = 1500.0
1010

1111
func _ready():
1212
State.requested_scroll_to_element_editor.connect(scroll_to_view_element_editor)
13+
set_dragging(false)
14+
15+
func set_dragging(new_state: bool) -> void:
16+
covering_rect.visible = new_state
17+
set_process(new_state)
1318

1419
func _process(delta: float) -> void:
1520
if State.proposed_drop_xid.is_empty():
@@ -76,10 +81,10 @@ func update_proposed_xid() -> void:
7681
func _notification(what: int) -> void:
7782
if is_inside_tree() and HandlerGUI.menu_stack.is_empty():
7883
if what == NOTIFICATION_DRAG_BEGIN:
79-
covering_rect.show()
80-
update_proposed_xid()
84+
set_dragging(true)
85+
update_proposed_xid()
8186
elif what == NOTIFICATION_DRAG_END:
82-
covering_rect.hide()
87+
set_dragging(false)
8388
State.set_selection_dragged(false)
8489
State.clear_proposed_drop_xid()
8590

src/ui_parts/tab_bar.gd

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var scrolling_backwards := false
1616
var scrolling_forwards := false
1717
var active_controls: Array[Control] = []
1818

19-
var is_dragging := false
19+
# Processing is enabled only when dragging.
2020
var proposed_drop_idx := -1:
2121
set(new_value):
2222
if proposed_drop_idx != new_value:
@@ -36,6 +36,7 @@ func _ready() -> void:
3636
Configs.language_changed.connect(queue_redraw)
3737
mouse_entered.connect(_on_mouse_entered)
3838
mouse_exited.connect(_on_mouse_exited)
39+
set_process(false)
3940

4041
func _draw() -> void:
4142
var background_stylebox: StyleBoxFlat =\
@@ -225,18 +226,19 @@ func _gui_input(event: InputEvent) -> void:
225226
scrolling_backwards = false
226227
scrolling_forwards = false
227228

229+
# Autoscroll when the dragged tab is hovered beyond the tabs area.
228230
func _process(_delta: float) -> void:
229231
var mouse_pos := get_local_mouse_position()
230232
var scroll_forwards_area_rect := get_scroll_forwards_area_rect()
231233
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 -\
233235
scroll_forwards_area_rect.size.x)) and scroll_forwards_area_rect.has_area():
234236
scroll_forwards()
235237
return
236238

237239
var scroll_backwards_area_rect := get_scroll_backwards_area_rect()
238240
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\
240242
scroll_backwards_area_rect.has_area():
241243
scroll_backwards()
242244
return
@@ -461,7 +463,7 @@ func get_drop_index_at(pos: Vector2) -> int:
461463
if not tab_rect.has_area() or tab_width * (idx + 0.5) - current_scroll +\
462464
scroll_backwards_button_width > pos.x:
463465
return idx
464-
return -1
466+
return Configs.savedata.get_tab_count()
465467

466468
func _get_drag_data(at_position: Vector2) -> Variant:
467469
var tab_index_at_position := get_tab_index_at(at_position)
@@ -484,7 +486,7 @@ func _get_drag_data(at_position: Vector2) -> Variant:
484486
label.size.x = tab_width - 8
485487

486488
set_drag_preview(preview)
487-
is_dragging = true
489+
set_process(true)
488490
return TabDropData.new(tab_index_at_position)
489491

490492
func _can_drop_data(at_position: Vector2, data: Variant) -> bool:
@@ -502,10 +504,10 @@ func _can_drop_data(at_position: Vector2, data: Variant) -> bool:
502504
func _drop_data(at_position: Vector2, data: Variant) -> void:
503505
if not data is TabDropData:
504506
return
505-
is_dragging = false
507+
set_process(false)
506508
Configs.savedata.move_tab(data.index, get_drop_index_at(at_position))
507509

508510
func _notification(what: int) -> void:
509511
if what == NOTIFICATION_DRAG_END:
510-
is_dragging = false
512+
set_process(false)
511513
proposed_drop_idx = -1

0 commit comments

Comments
 (0)