Added mouse drag support for the images.

This commit is contained in:
Relintai 2022-12-10 19:46:15 +01:00
parent 9678547bdc
commit 1fe8fb0469
2 changed files with 50 additions and 15 deletions

View File

@ -0,0 +1,33 @@
extends VBoxContainer
var mouse_down : bool = false
var mouse_pointer : int = 0
var hscrollbar : HScrollBar
var vscrollbar : VScrollBar
func _gui_input(event: InputEvent) -> void:
if event.is_echo():
return
if event is InputEventMouseButton:
var iemb : InputEventMouseButton = event
mouse_down = iemb.pressed
mouse_pointer == event.device
elif event is InputEventMouseMotion:
var iemm : InputEventMouseMotion = event
if !mouse_down || mouse_pointer != event.device:
return
hscrollbar.value -= iemm.relative.x
vscrollbar.value -= iemm.relative.y
func _notification(what: int) -> void:
if what == NOTIFICATION_READY:
var sc : ScrollContainer = get_parent()
hscrollbar = sc.get_h_scrollbar()
vscrollbar = sc.get_v_scrollbar()

View File

@ -1,20 +1,22 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=4 format=2]
[ext_resource path="res://sort/Sort.gd" type="Script" id=1]
[ext_resource path="res://sort/GifLoader.tscn" type="PackedScene" id=2]
[ext_resource path="res://sort/ScrollImageContainer.gd" type="Script" id=3]
[node name="Sort" type="VBoxContainer"]
margin_right = 1024.0
margin_bottom = 600.0
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
[node name="ScrollContainer" type="ScrollContainer" parent="."]
margin_right = 1024.0
margin_right = 600.0
margin_bottom = 500.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer"]
script = ExtResource( 3 )
[node name="TextureRect" type="TextureRect" parent="ScrollContainer/VBoxContainer"]
@ -31,53 +33,53 @@ margin_bottom = 18.0
[node name="Categories" type="HBoxContainer" parent="."]
margin_top = 504.0
margin_right = 1024.0
margin_right = 600.0
margin_bottom = 524.0
size_flags_horizontal = 3
[node name="Categories" type="OptionButton" parent="Categories"]
margin_right = 1000.0
margin_right = 576.0
margin_bottom = 20.0
size_flags_horizontal = 3
[node name="Add" type="Button" parent="Categories"]
margin_left = 1004.0
margin_right = 1024.0
margin_left = 580.0
margin_right = 600.0
margin_bottom = 20.0
text = "+"
[node name="SubCategoies" type="HBoxContainer" parent="."]
margin_top = 528.0
margin_right = 1024.0
margin_right = 600.0
margin_bottom = 548.0
size_flags_horizontal = 3
[node name="SubCategoies" type="OptionButton" parent="SubCategoies"]
margin_right = 1000.0
margin_right = 576.0
margin_bottom = 20.0
size_flags_horizontal = 3
[node name="Add" type="Button" parent="SubCategoies"]
margin_left = 1004.0
margin_right = 1024.0
margin_left = 580.0
margin_right = 600.0
margin_bottom = 20.0
text = "+"
[node name="Apply" type="Button" parent="."]
margin_top = 552.0
margin_right = 1024.0
margin_right = 600.0
margin_bottom = 572.0
text = "Apply"
[node name="Skip" type="Button" parent="."]
margin_top = 576.0
margin_right = 1024.0
margin_right = 600.0
margin_bottom = 596.0
text = "Skip"
[node name="Control" type="Control" parent="."]
margin_top = 600.0
margin_right = 1024.0
margin_right = 600.0
margin_bottom = 600.0
[node name="NewCategoryPopup" type="ConfirmationDialog" parent="Control"]