1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-20 12:33:14 +00:00

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.
This commit is contained in:
Emmanouil Papadeas 2022-11-10 17:36:09 +02:00
parent 927e4f45a6
commit 8732d366bf
3 changed files with 32 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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