Skip to content

Commit

Permalink
Disable process functions when not used (#1146)
Browse files Browse the repository at this point in the history
  • Loading branch information
MewPurPur authored Feb 12, 2025
1 parent f8a9ed9 commit ac79dbd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/export-optimized.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ env:
# Which godot version to use for exporting.
GODOT_VERSION: 4.4
# Which godot release to use for exporting. (stable/rc/beta/alpha)
GODOT_RELEASE: beta1
GODOT_RELEASE: beta3
# Used in the editor config file name. Do not change this for patch releases.
GODOT_FEATURE_VERSION: 4.4
# Commit hash
GODOT_COMMIT_HASH: d33da79d3
GODOT_COMMIT_HASH: 06acfccf89
PROJECT_NAME: GodSVG
GODOT_REPO: https://github.com/godotengine/godot.git
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
Expand Down
2 changes: 1 addition & 1 deletion src/ui_parts/display.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ unique_name_in_owner = true
disable_3d = true
handle_input_locally = false
gui_snap_controls_to_pixels = false
size = Vector2i(1040, 595)
size = Vector2i(450, 2)
size_2d_override_stretch = true
render_target_update_mode = 4
script = ExtResource("9_4xrk7")
Expand Down
11 changes: 8 additions & 3 deletions src/ui_parts/element_container.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ const autoscroll_speed = 1500.0

func _ready():
State.requested_scroll_to_element_editor.connect(scroll_to_view_element_editor)
set_dragging(false)

func set_dragging(new_state: bool) -> void:
covering_rect.visible = new_state
set_process(new_state)

func _process(delta: float) -> void:
if State.proposed_drop_xid.is_empty():
Expand Down Expand Up @@ -76,10 +81,10 @@ func update_proposed_xid() -> void:
func _notification(what: int) -> void:
if is_inside_tree() and HandlerGUI.menu_stack.is_empty():
if what == NOTIFICATION_DRAG_BEGIN:
covering_rect.show()
update_proposed_xid()
set_dragging(true)
update_proposed_xid()
elif what == NOTIFICATION_DRAG_END:
covering_rect.hide()
set_dragging(false)
State.set_selection_dragged(false)
State.clear_proposed_drop_xid()

Expand Down
16 changes: 9 additions & 7 deletions src/ui_parts/tab_bar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var scrolling_backwards := false
var scrolling_forwards := false
var active_controls: Array[Control] = []

var is_dragging := false
# Processing is enabled only when dragging.
var proposed_drop_idx := -1:
set(new_value):
if proposed_drop_idx != new_value:
Expand All @@ -36,6 +36,7 @@ func _ready() -> void:
Configs.language_changed.connect(queue_redraw)
mouse_entered.connect(_on_mouse_entered)
mouse_exited.connect(_on_mouse_exited)
set_process(false)

func _draw() -> void:
var background_stylebox: StyleBoxFlat =\
Expand Down Expand Up @@ -225,18 +226,19 @@ func _gui_input(event: InputEvent) -> void:
scrolling_backwards = false
scrolling_forwards = false

# Autoscroll when the dragged tab is hovered beyond the tabs area.
func _process(_delta: float) -> void:
var mouse_pos := get_local_mouse_position()
var scroll_forwards_area_rect := get_scroll_forwards_area_rect()
if ((scrolling_forwards and scroll_forwards_area_rect.has_point(mouse_pos)) or\
(is_dragging and mouse_pos.x > size.x - get_add_button_rect().size.x -\
(mouse_pos.x > size.x - get_add_button_rect().size.x -\
scroll_forwards_area_rect.size.x)) and scroll_forwards_area_rect.has_area():
scroll_forwards()
return

var scroll_backwards_area_rect := get_scroll_backwards_area_rect()
if ((scrolling_backwards and scroll_backwards_area_rect.has_point(mouse_pos)) or\
(is_dragging and mouse_pos.x < scroll_backwards_area_rect.size.x)) and\
(mouse_pos.x < scroll_backwards_area_rect.size.x)) and\
scroll_backwards_area_rect.has_area():
scroll_backwards()
return
Expand Down Expand Up @@ -461,7 +463,7 @@ func get_drop_index_at(pos: Vector2) -> int:
if not tab_rect.has_area() or tab_width * (idx + 0.5) - current_scroll +\
scroll_backwards_button_width > pos.x:
return idx
return -1
return Configs.savedata.get_tab_count()

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

set_drag_preview(preview)
is_dragging = true
set_process(true)
return TabDropData.new(tab_index_at_position)

func _can_drop_data(at_position: Vector2, data: Variant) -> bool:
Expand All @@ -502,10 +504,10 @@ func _can_drop_data(at_position: Vector2, data: Variant) -> bool:
func _drop_data(at_position: Vector2, data: Variant) -> void:
if not data is TabDropData:
return
is_dragging = false
set_process(false)
Configs.savedata.move_tab(data.index, get_drop_index_at(at_position))

func _notification(what: int) -> void:
if what == NOTIFICATION_DRAG_END:
is_dragging = false
set_process(false)
proposed_drop_idx = -1

0 comments on commit ac79dbd

Please sign in to comment.