mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Add UI buttons for confirming and cancelling a transformation
Needed especially for users without a keyboard.
This commit is contained in:
parent
6863adf957
commit
e2971a8fe9
BIN
assets/graphics/misc/check_plain.png
Normal file
BIN
assets/graphics/misc/check_plain.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 176 B |
34
assets/graphics/misc/check_plain.png.import
Normal file
34
assets/graphics/misc/check_plain.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://d267xalp3p7ru"
|
||||
path="res://.godot/imported/check_plain.png-6f37534ee70be1593b3b1be7b4c80f23.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/graphics/misc/check_plain.png"
|
||||
dest_files=["res://.godot/imported/check_plain.png-6f37534ee70be1593b3b1be7b4c80f23.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
BIN
assets/graphics/misc/close.png
Normal file
BIN
assets/graphics/misc/close.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 153 B |
34
assets/graphics/misc/close.png.import
Normal file
34
assets/graphics/misc/close.png.import
Normal file
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bnc78807k1xjv"
|
||||
path="res://.godot/imported/close.png-5725622e3d74d3527ee26e70390098f4.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/graphics/misc/close.png"
|
||||
dest_files=["res://.godot/imported/close.png-5725622e3d74d3527ee26e70390098f4.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
|
@ -22,7 +22,8 @@ var _intersect := false ## Shift + Ctrl + Mouse Click
|
|||
var _content_transformation_check := false
|
||||
var _skip_slider_logic := false
|
||||
|
||||
@onready var selection_node: Node2D = Global.canvas.selection
|
||||
@onready var selection_node := Global.canvas.selection
|
||||
@onready var confirm_buttons := $ConfirmButtons as HBoxContainer
|
||||
@onready var position_sliders := $Position as ValueSliderV2
|
||||
@onready var size_sliders := $Size as ValueSliderV2
|
||||
@onready var timer := $Timer as Timer
|
||||
|
@ -30,11 +31,17 @@ var _skip_slider_logic := false
|
|||
|
||||
func _ready() -> void:
|
||||
super._ready()
|
||||
set_confirm_buttons_visibility()
|
||||
set_spinbox_values()
|
||||
refresh_options()
|
||||
selection_node.is_moving_content_changed.connect(set_confirm_buttons_visibility)
|
||||
|
||||
|
||||
## Ensure all items are added when we are selecting an option (bad things will happen otherwise)
|
||||
func set_confirm_buttons_visibility() -> void:
|
||||
confirm_buttons.visible = selection_node.is_moving_content
|
||||
|
||||
|
||||
## Ensure all items are added when we are selecting an option.
|
||||
func refresh_options() -> void:
|
||||
$Modes.clear()
|
||||
$Modes.add_item("Replace selection")
|
||||
|
@ -203,6 +210,16 @@ func apply_selection(_position: Vector2i) -> void:
|
|||
_intersect = true
|
||||
|
||||
|
||||
func _on_confirm_button_pressed() -> void:
|
||||
if selection_node.is_moving_content:
|
||||
selection_node.transform_content_confirm()
|
||||
|
||||
|
||||
func _on_cancel_button_pressed() -> void:
|
||||
if selection_node.is_moving_content:
|
||||
selection_node.transform_content_cancel()
|
||||
|
||||
|
||||
func _on_Modes_item_selected(index: int) -> void:
|
||||
_mode_selected = index
|
||||
save_config()
|
||||
|
|
|
@ -1,34 +1,85 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bd62qfjn380wf"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://bd62qfjn380wf"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://ctfgfelg0sho8" path="res://src/Tools/BaseTool.tscn" id="1"]
|
||||
[ext_resource type="Script" path="res://src/Tools/BaseSelectionTool.gd" id="2"]
|
||||
[ext_resource type="Texture2D" uid="uid://d267xalp3p7ru" path="res://assets/graphics/misc/check_plain.png" id="3_mtv71"]
|
||||
[ext_resource type="PackedScene" path="res://src/UI/Nodes/ValueSliderV2.tscn" id="4"]
|
||||
[ext_resource type="Texture2D" uid="uid://bnc78807k1xjv" path="res://assets/graphics/misc/close.png" id="4_ad04n"]
|
||||
|
||||
[sub_resource type="InputEventAction" id="InputEventAction_gfv4x"]
|
||||
action = &"transformation_confirm"
|
||||
|
||||
[sub_resource type="Shortcut" id="Shortcut_5gq73"]
|
||||
events = [SubResource("InputEventAction_gfv4x")]
|
||||
|
||||
[sub_resource type="InputEventAction" id="InputEventAction_nadbx"]
|
||||
action = &"transformation_cancel"
|
||||
|
||||
[sub_resource type="Shortcut" id="Shortcut_04tjd"]
|
||||
events = [SubResource("InputEventAction_nadbx")]
|
||||
|
||||
[node name="ToolOptions" instance=ExtResource("1")]
|
||||
script = ExtResource("2")
|
||||
|
||||
[node name="ModeLabel" type="Label" parent="." index="2"]
|
||||
[node name="ConfirmButtons" type="HBoxContainer" parent="." index="2"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ConfirmButton" type="Button" parent="ConfirmButtons" index="0"]
|
||||
custom_minimum_size = Vector2(0, 26)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
mouse_default_cursor_shape = 2
|
||||
shortcut = SubResource("Shortcut_5gq73")
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="ConfirmButtons/ConfirmButton" index="0" groups=["UIButtons"]]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("3_mtv71")
|
||||
stretch_mode = 3
|
||||
|
||||
[node name="CancelButton" type="Button" parent="ConfirmButtons" index="1"]
|
||||
custom_minimum_size = Vector2(0, 26)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
mouse_default_cursor_shape = 2
|
||||
shortcut = SubResource("Shortcut_04tjd")
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="ConfirmButtons/CancelButton" index="0" groups=["UIButtons"]]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("4_ad04n")
|
||||
stretch_mode = 3
|
||||
|
||||
[node name="ModeLabel" type="Label" parent="." index="3"]
|
||||
layout_mode = 2
|
||||
text = "Mode:"
|
||||
|
||||
[node name="Modes" type="OptionButton" parent="." index="3"]
|
||||
[node name="Modes" type="OptionButton" parent="." index="4"]
|
||||
layout_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
|
||||
[node name="PositionLabel" type="Label" parent="." index="4"]
|
||||
[node name="PositionLabel" type="Label" parent="." index="5"]
|
||||
layout_mode = 2
|
||||
text = "Position:"
|
||||
|
||||
[node name="Position" parent="." index="5" instance=ExtResource("4")]
|
||||
[node name="Position" parent="." index="6" instance=ExtResource("4")]
|
||||
layout_mode = 2
|
||||
allow_greater = true
|
||||
allow_lesser = true
|
||||
|
||||
[node name="SizeLabel" type="Label" parent="." index="6"]
|
||||
[node name="SizeLabel" type="Label" parent="." index="7"]
|
||||
layout_mode = 2
|
||||
text = "Size:"
|
||||
|
||||
[node name="Size" parent="." index="7" instance=ExtResource("4")]
|
||||
[node name="Size" parent="." index="8" instance=ExtResource("4")]
|
||||
layout_mode = 2
|
||||
value = Vector2(1, 1)
|
||||
min_value = Vector2(1, 1)
|
||||
|
@ -37,10 +88,12 @@ show_ratio = true
|
|||
prefix_x = "Width:"
|
||||
prefix_y = "Height:"
|
||||
|
||||
[node name="Timer" type="Timer" parent="." index="8"]
|
||||
[node name="Timer" type="Timer" parent="." index="9"]
|
||||
wait_time = 0.2
|
||||
one_shot = true
|
||||
|
||||
[connection signal="pressed" from="ConfirmButtons/ConfirmButton" to="." method="_on_confirm_button_pressed"]
|
||||
[connection signal="pressed" from="ConfirmButtons/CancelButton" to="." method="_on_cancel_button_pressed"]
|
||||
[connection signal="item_selected" from="Modes" to="." method="_on_Modes_item_selected"]
|
||||
[connection signal="value_changed" from="Position" to="." method="_on_Position_value_changed"]
|
||||
[connection signal="ratio_toggled" from="Size" to="." method="_on_Size_ratio_toggled"]
|
||||
|
|
|
@ -17,7 +17,7 @@ var layer_metadata_texture := ImageTexture.new()
|
|||
@onready var tile_mode := $TileMode as Node2D
|
||||
@onready var pixel_grid := $PixelGrid as Node2D
|
||||
@onready var grid := $Grid as Node2D
|
||||
@onready var selection := $Selection as Node2D
|
||||
@onready var selection := $Selection as SelectionNode
|
||||
@onready var onion_past := $OnionPast as Node2D
|
||||
@onready var onion_future := $OnionFuture as Node2D
|
||||
@onready var crop_rect := $CropRect as CropRect
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
class_name SelectionNode
|
||||
extends Node2D
|
||||
|
||||
signal is_moving_content_changed
|
||||
|
||||
enum SelectionOperation { ADD, SUBTRACT, INTERSECT }
|
||||
const KEY_MOVE_ACTION_NAMES: PackedStringArray = [&"ui_up", &"ui_down", &"ui_left", &"ui_right"]
|
||||
const CLIPBOARD_FILE_PATH := "user://clipboard.txt"
|
||||
|
@ -7,7 +10,10 @@ const CLIPBOARD_FILE_PATH := "user://clipboard.txt"
|
|||
# flags (additional properties of selection that can be toggled)
|
||||
var flag_tilemode := false
|
||||
|
||||
var is_moving_content := false
|
||||
var is_moving_content := false:
|
||||
set(value):
|
||||
is_moving_content = value
|
||||
is_moving_content_changed.emit()
|
||||
var arrow_key_move := false
|
||||
var is_pasting := false
|
||||
var big_bounding_rectangle := Rect2i():
|
||||
|
@ -100,12 +106,6 @@ func _input(event: InputEvent) -> void:
|
|||
image_current_pixel = canvas.current_pixel
|
||||
if Global.mirror_view:
|
||||
image_current_pixel.x = Global.current_project.size.x - image_current_pixel.x
|
||||
if is_moving_content:
|
||||
if Input.is_action_just_pressed("transformation_confirm"):
|
||||
transform_content_confirm()
|
||||
elif Input.is_action_just_pressed("transformation_cancel"):
|
||||
transform_content_cancel()
|
||||
|
||||
if not project.layers[project.current_layer].can_layer_get_drawn():
|
||||
return
|
||||
if event is InputEventKey:
|
||||
|
|
Loading…
Reference in a new issue