mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-03-13 23:05:20 +00:00
Pivot remembering and algorithm re-arrangement (#724)
* Make pivot remember it's last position * formatting * Re-arranged algorithms According to their speed * Accidentally left popup visible
This commit is contained in:
parent
cca36b52e4
commit
7381311e71
2 changed files with 33 additions and 14 deletions
|
@ -2,7 +2,7 @@ extends ImageEffect
|
||||||
|
|
||||||
var live_preview: bool = true
|
var live_preview: bool = true
|
||||||
var shader: Shader = preload("res://src/Shaders/Rotation.shader")
|
var shader: Shader = preload("res://src/Shaders/Rotation.shader")
|
||||||
var pivot := Vector2.ZERO
|
var pivot := Vector2.INF
|
||||||
|
|
||||||
onready var type_option_button: OptionButton = $VBoxContainer/HBoxContainer2/TypeOptionButton
|
onready var type_option_button: OptionButton = $VBoxContainer/HBoxContainer2/TypeOptionButton
|
||||||
onready var angle_hslider: HSlider = $VBoxContainer/AngleOptions/AngleHSlider
|
onready var angle_hslider: HSlider = $VBoxContainer/AngleOptions/AngleHSlider
|
||||||
|
@ -12,10 +12,12 @@ onready var wait_time_spinbox = $VBoxContainer/WaitSettings/WaitTime
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
# Algorithms are arranged according to their speed
|
||||||
|
type_option_button.add_item("Nearest neighbour (Shader)")
|
||||||
|
type_option_button.add_item("Nearest neighbour")
|
||||||
type_option_button.add_item("Rotxel")
|
type_option_button.add_item("Rotxel")
|
||||||
type_option_button.add_item("Upscale, Rotate and Downscale")
|
type_option_button.add_item("Upscale, Rotate and Downscale")
|
||||||
type_option_button.add_item("Nearest neighbour")
|
type_option_button.emit_signal("item_selected", 0)
|
||||||
type_option_button.add_item("Nearest neighbour (Shader)")
|
|
||||||
|
|
||||||
|
|
||||||
func set_nodes() -> void:
|
func set_nodes() -> void:
|
||||||
|
@ -25,9 +27,8 @@ func set_nodes() -> void:
|
||||||
|
|
||||||
|
|
||||||
func _about_to_show() -> void:
|
func _about_to_show() -> void:
|
||||||
$VBoxContainer/Pivot/Options.visible = false
|
if pivot == Vector2.INF:
|
||||||
$VBoxContainer/Pivot/TogglePivot.pressed = false
|
decide_pivot()
|
||||||
decide_pivot()
|
|
||||||
confirmed = false
|
confirmed = false
|
||||||
._about_to_show()
|
._about_to_show()
|
||||||
wait_apply_timer.wait_time = wait_time_spinbox.value / 1000.0
|
wait_apply_timer.wait_time = wait_time_spinbox.value / 1000.0
|
||||||
|
@ -58,6 +59,9 @@ func decide_pivot():
|
||||||
if int(selection_rectangle.end.y - selection_rectangle.position.y) % 2 == 0:
|
if int(selection_rectangle.end.y - selection_rectangle.position.y) % 2 == 0:
|
||||||
pivot.y -= 0.5
|
pivot.y -= 0.5
|
||||||
|
|
||||||
|
$VBoxContainer/Pivot/Options/X/XPivot.value = pivot.x
|
||||||
|
$VBoxContainer/Pivot/Options/Y/YPivot.value = pivot.y
|
||||||
|
|
||||||
|
|
||||||
func commit_action(_cel: Image, _project: Project = Global.current_project) -> void:
|
func commit_action(_cel: Image, _project: Project = Global.current_project) -> void:
|
||||||
var angle: float = deg2rad(angle_hslider.value)
|
var angle: float = deg2rad(angle_hslider.value)
|
||||||
|
@ -185,16 +189,18 @@ func _on_quick_change_angle_pressed(change_type: String) -> void:
|
||||||
func _on_TogglePivot_toggled(button_pressed: bool) -> void:
|
func _on_TogglePivot_toggled(button_pressed: bool) -> void:
|
||||||
$VBoxContainer/Pivot/Options.visible = button_pressed
|
$VBoxContainer/Pivot/Options.visible = button_pressed
|
||||||
if button_pressed:
|
if button_pressed:
|
||||||
$VBoxContainer/Pivot/TogglePivot.text = "Pivot Options: (v)"
|
$VBoxContainer/Pivot/TitleButtons/TogglePivot.text = "Pivot Options: (v)"
|
||||||
$VBoxContainer/Pivot/TogglePivot.focus_mode = 0
|
$VBoxContainer/Pivot/TitleButtons/TogglePivot.focus_mode = 0
|
||||||
$VBoxContainer/Pivot/Options/X/XPivot.value = pivot.x
|
|
||||||
$VBoxContainer/Pivot/Options/Y/YPivot.value = pivot.y
|
|
||||||
else:
|
else:
|
||||||
$VBoxContainer/Pivot/TogglePivot.text = "Pivot Options: (>)"
|
$VBoxContainer/Pivot/TitleButtons/TogglePivot.text = "Pivot Options: (>)"
|
||||||
$VBoxContainer/Pivot/TogglePivot.focus_mode = 0
|
$VBoxContainer/Pivot/TitleButtons/TogglePivot.focus_mode = 0
|
||||||
rect_size.y += 1 # Reset rect_size of dialog
|
rect_size.y += 1 # Reset rect_size of dialog
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Centre_pressed() -> void:
|
||||||
|
decide_pivot()
|
||||||
|
|
||||||
|
|
||||||
func _on_Pivot_value_changed(value: float, is_x: bool) -> void:
|
func _on_Pivot_value_changed(value: float, is_x: bool) -> void:
|
||||||
if is_x:
|
if is_x:
|
||||||
pivot.x = value
|
pivot.x = value
|
||||||
|
|
|
@ -113,15 +113,27 @@ margin_top = 290.0
|
||||||
margin_right = 326.0
|
margin_right = 326.0
|
||||||
margin_bottom = 310.0
|
margin_bottom = 310.0
|
||||||
|
|
||||||
[node name="TogglePivot" type="Button" parent="VBoxContainer/Pivot"]
|
[node name="TitleButtons" type="HBoxContainer" parent="VBoxContainer/Pivot"]
|
||||||
margin_right = 326.0
|
margin_right = 326.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
|
|
||||||
|
[node name="TogglePivot" type="Button" parent="VBoxContainer/Pivot/TitleButtons"]
|
||||||
|
margin_right = 268.0
|
||||||
|
margin_bottom = 20.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 2
|
size_flags_vertical = 2
|
||||||
toggle_mode = true
|
toggle_mode = true
|
||||||
text = "Pivot Options (>)"
|
text = "Pivot Options (>)"
|
||||||
flat = true
|
flat = true
|
||||||
align = 0
|
align = 0
|
||||||
|
|
||||||
|
[node name="Centre" type="Button" parent="VBoxContainer/Pivot/TitleButtons"]
|
||||||
|
margin_left = 272.0
|
||||||
|
margin_right = 326.0
|
||||||
|
margin_bottom = 20.0
|
||||||
|
hint_tooltip = "Centers the pivot (if selection is present then it's centre is selected instead)"
|
||||||
|
text = "Center"
|
||||||
|
|
||||||
[node name="Options" type="VBoxContainer" parent="VBoxContainer/Pivot"]
|
[node name="Options" type="VBoxContainer" parent="VBoxContainer/Pivot"]
|
||||||
visible = false
|
visible = false
|
||||||
margin_top = 24.0
|
margin_top = 24.0
|
||||||
|
@ -296,7 +308,8 @@ selected = 0
|
||||||
[connection signal="toggled" from="VBoxContainer/LiveSettings/LiveCheckbox" to="." method="_on_LiveCheckbox_toggled"]
|
[connection signal="toggled" from="VBoxContainer/LiveSettings/LiveCheckbox" to="." method="_on_LiveCheckbox_toggled"]
|
||||||
[connection signal="value_changed" from="VBoxContainer/WaitSettings/WaitTime" to="." method="_on_WaitTime_value_changed"]
|
[connection signal="value_changed" from="VBoxContainer/WaitSettings/WaitTime" to="." method="_on_WaitTime_value_changed"]
|
||||||
[connection signal="item_selected" from="VBoxContainer/HBoxContainer2/TypeOptionButton" to="." method="_on_TypeOptionButton_item_selected"]
|
[connection signal="item_selected" from="VBoxContainer/HBoxContainer2/TypeOptionButton" to="." method="_on_TypeOptionButton_item_selected"]
|
||||||
[connection signal="toggled" from="VBoxContainer/Pivot/TogglePivot" to="." method="_on_TogglePivot_toggled"]
|
[connection signal="toggled" from="VBoxContainer/Pivot/TitleButtons/TogglePivot" to="." method="_on_TogglePivot_toggled"]
|
||||||
|
[connection signal="pressed" from="VBoxContainer/Pivot/TitleButtons/Centre" to="." method="_on_Centre_pressed"]
|
||||||
[connection signal="value_changed" from="VBoxContainer/Pivot/Options/X/XPivot" to="." method="_on_Pivot_value_changed" binds= [ true ]]
|
[connection signal="value_changed" from="VBoxContainer/Pivot/Options/X/XPivot" to="." method="_on_Pivot_value_changed" binds= [ true ]]
|
||||||
[connection signal="value_changed" from="VBoxContainer/Pivot/Options/Y/YPivot" to="." method="_on_Pivot_value_changed" binds= [ false ]]
|
[connection signal="value_changed" from="VBoxContainer/Pivot/Options/Y/YPivot" to="." method="_on_Pivot_value_changed" binds= [ false ]]
|
||||||
[connection signal="value_changed" from="VBoxContainer/AngleOptions/AngleHSlider" to="." method="_on_HSlider_value_changed"]
|
[connection signal="value_changed" from="VBoxContainer/AngleOptions/AngleHSlider" to="." method="_on_HSlider_value_changed"]
|
||||||
|
|
Loading…
Add table
Reference in a new issue