2019-12-29 22:24:37 +00:00
|
|
|
extends ConfirmationDialog
|
|
|
|
|
2020-05-01 17:47:10 +00:00
|
|
|
|
2021-01-26 22:45:12 +00:00
|
|
|
var aspect_ratio := 1.0
|
|
|
|
|
|
|
|
onready var width_value : SpinBox = find_node("WidthValue")
|
|
|
|
onready var height_value : SpinBox = find_node("HeightValue")
|
|
|
|
onready var width_value_perc : SpinBox = find_node("WidthValuePerc")
|
|
|
|
onready var height_value_perc : SpinBox = find_node("HeightValuePerc")
|
|
|
|
onready var interpolation_type : OptionButton = find_node("InterpolationType")
|
|
|
|
onready var ratio_box : BaseButton = find_node("AspectRatioButton")
|
|
|
|
|
|
|
|
|
|
|
|
func _on_ScaleImage_about_to_show() -> void:
|
|
|
|
width_value.value = Global.current_project.size.x
|
|
|
|
height_value.value = Global.current_project.size.y
|
|
|
|
width_value_perc.value = 100
|
|
|
|
height_value_perc.value = 100
|
|
|
|
aspect_ratio = width_value.value / height_value.value
|
|
|
|
|
|
|
|
|
2019-12-29 22:24:37 +00:00
|
|
|
func _on_ScaleImage_confirmed() -> void:
|
2021-01-26 22:45:12 +00:00
|
|
|
var width : int = width_value.value
|
|
|
|
var height : int = height_value.value
|
|
|
|
var interpolation : int = interpolation_type.selected
|
2020-06-13 15:57:28 +00:00
|
|
|
DrawingAlgos.scale_image(width, height, interpolation)
|
2020-07-29 17:06:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_ScaleImage_popup_hide() -> void:
|
|
|
|
Global.dialog_open(false)
|
2021-01-26 22:45:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_WidthValue_value_changed(value : float) -> void:
|
|
|
|
if ratio_box.pressed:
|
|
|
|
height_value.value = width_value.value / aspect_ratio
|
|
|
|
width_value_perc.value = (value * 100) / Global.current_project.size.x
|
|
|
|
|
|
|
|
|
|
|
|
func _on_HeightValue_value_changed(value : float) -> void:
|
|
|
|
if ratio_box.pressed:
|
|
|
|
width_value.value = height_value.value * aspect_ratio
|
|
|
|
height_value_perc.value = (value * 100) / Global.current_project.size.y
|
|
|
|
|
|
|
|
|
|
|
|
func _on_WidthValuePerc_value_changed(value : float) -> void:
|
|
|
|
width_value.value = (Global.current_project.size.x * value) / 100
|
|
|
|
|
|
|
|
|
|
|
|
func _on_HeightValuePerc_value_changed(value : float) -> void:
|
|
|
|
height_value.value = (Global.current_project.size.y * value) / 100
|
|
|
|
|
|
|
|
|
|
|
|
func _on_AspectRatioButton_toggled(button_pressed : bool) -> void:
|
|
|
|
if button_pressed:
|
|
|
|
height_value.value = width_value.value / aspect_ratio
|