From 8732d366bff99e01dd11ccf4f7938854cb131a92 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Thu, 10 Nov 2022 17:36:09 +0200 Subject: [PATCH] Use Control + Wheel to change brush size - implements #776 This is not editable in the shortcut settings and it is temporary way of doing this and it will change in Godot 4.x. --- src/Tools/Draw.tscn | 1 + src/UI/Canvas/CameraMovement.gd | 4 ++-- src/UI/Nodes/ValueSlider.gd | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/Tools/Draw.tscn b/src/Tools/Draw.tscn index 66ef3a129..9918f1f41 100644 --- a/src/Tools/Draw.tscn +++ b/src/Tools/Draw.tscn @@ -60,6 +60,7 @@ value = 1.0 allow_greater = true prefix = "Size:" suffix = "px" +is_global = true [node name="ColorInterpolation" parent="." index="3" instance=ExtResource( 1 )] visible = false diff --git a/src/UI/Canvas/CameraMovement.gd b/src/UI/Canvas/CameraMovement.gd index 21cc22a4c..738d5cc54 100644 --- a/src/UI/Canvas/CameraMovement.gd +++ b/src/UI/Canvas/CameraMovement.gd @@ -115,9 +115,9 @@ func _input(event: InputEvent) -> void: drag = true elif event.is_action_released("pan"): drag = false - elif event.is_action_pressed("zoom_in"): # Wheel Up Event + elif event.is_action_pressed("zoom_in", false, true): # Wheel Up Event zoom_camera(-1) - elif event.is_action_pressed("zoom_out"): # Wheel Down Event + elif event.is_action_pressed("zoom_out", false, true): # Wheel Down Event zoom_camera(1) elif event is InputEventMagnifyGesture: # Zoom Gesture on a Laptop touchpad diff --git a/src/UI/Nodes/ValueSlider.gd b/src/UI/Nodes/ValueSlider.gd index 96a433cd5..104921407 100644 --- a/src/UI/Nodes/ValueSlider.gd +++ b/src/UI/Nodes/ValueSlider.gd @@ -21,6 +21,10 @@ export var snap_by_default := false export var show_progress := true export var show_arrows := true setget _show_arrows_changed export var echo_arrow_time := 0.075 +# This will be replaced with input action strings in Godot 4.x +# Right now this is only used for changing the brush size with Control + Wheel +# In Godot 4.x, the shortcut will be editable +export var is_global := false var state := NORMAL var arrow_is_held := 0 # Used for arrow button echo behavior. Is 1 for ValueUp, -1 for ValueDown. @@ -30,6 +34,7 @@ onready var timer: Timer = $Timer func _ready() -> void: + set_process_input(is_global) _reset_display() if not Engine.editor_hint: # Pixelorama specific code $ValueUp.modulate = Global.modulate_icon_color @@ -41,6 +46,30 @@ func _notification(what: int) -> void: _reset_display() +func _input(event: InputEvent) -> void: + if not editable: + return + # Hardcode Control + Wheel as a global shortcut, if is_global is true + # In Godot 4.x this will change into two is_action() checks for incrementing + # and decrementing + if not event is InputEventMouseButton: + return + if not event.pressed: + return + if not event.control: + return + if event.button_index == BUTTON_WHEEL_UP: + if snap_by_default: + value += step if event.control else snap_step + else: + value += snap_step if event.control else step + elif event.button_index == BUTTON_WHEEL_DOWN: + if snap_by_default: + value -= step if event.control else snap_step + else: + value -= snap_step if event.control else step + + func _gui_input(event: InputEvent) -> void: if not editable: return