From 05fa436b12570837ba560c7115965c827015d7a1 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Mon, 20 Mar 2023 01:59:15 +0200 Subject: [PATCH] Disable ValueSliderV2's ratio button when set to not editable And use a NinePatchRect for the ratio guides, for proper scaling. --- assets/graphics/misc/lock_aspect_guides.png | Bin 118 -> 121 bytes src/UI/Nodes/ValueSliderV2.gd | 1 + src/UI/Nodes/ValueSliderV2.tscn | 24 +++++++++++++------- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/assets/graphics/misc/lock_aspect_guides.png b/assets/graphics/misc/lock_aspect_guides.png index eb4d191c6a98708a3ffcce089f6efeddcd63400b..980dbaab56381b90286e55f3268cdee39ba99fdd 100644 GIT binary patch delta 103 zcmXS`oFJa0!@uyCI;+9m?4O)Xw1P>gTe~DWM4f DsJ|c@ delta 100 zcmb;{n;;&q$HB(H!0^k$cpi{qEDmyaVpw-h<|UA0;OXKRV$qwNus|%~&;S4b>z%r0 zbQp2YS2-iL$VV#F#np9jf(VbFK~w^dm+O_)f(*x%1QaEgePjmeW$<+Mb6Mw<&;$To Cogk?I diff --git a/src/UI/Nodes/ValueSliderV2.gd b/src/UI/Nodes/ValueSliderV2.gd index fd479da4d..4db15e845 100644 --- a/src/UI/Nodes/ValueSliderV2.gd +++ b/src/UI/Nodes/ValueSliderV2.gd @@ -69,6 +69,7 @@ func _set_editable(val: bool) -> void: editable = val for slider in get_sliders(): slider.editable = val + $Ratio/RatioButton.disabled = not val func _set_value(val: Vector2) -> void: diff --git a/src/UI/Nodes/ValueSliderV2.tscn b/src/UI/Nodes/ValueSliderV2.tscn index fd0223819..817770bdf 100644 --- a/src/UI/Nodes/ValueSliderV2.tscn +++ b/src/UI/Nodes/ValueSliderV2.tscn @@ -7,17 +7,17 @@ [ext_resource path="res://assets/graphics/misc/lock_aspect.png" type="Texture" id=5] [node name="ValueSliderV2" type="HBoxContainer"] -margin_right = 40.0 -margin_bottom = 40.0 +margin_right = 45.0 +margin_bottom = 52.0 script = ExtResource( 2 ) [node name="GridContainer" type="GridContainer" parent="."] -margin_right = 40.0 +margin_right = 45.0 margin_bottom = 52.0 size_flags_horizontal = 3 [node name="X" type="TextureProgress" parent="GridContainer"] -margin_right = 40.0 +margin_right = 45.0 margin_bottom = 24.0 rect_min_size = Vector2( 32, 24 ) mouse_default_cursor_shape = 2 @@ -33,7 +33,7 @@ prefix = "X:" [node name="Y" type="TextureProgress" parent="GridContainer"] margin_top = 28.0 -margin_right = 40.0 +margin_right = 45.0 margin_bottom = 52.0 rect_min_size = Vector2( 32, 24 ) mouse_default_cursor_shape = 2 @@ -47,13 +47,21 @@ stretch_margin_bottom = 3 script = ExtResource( 1 ) prefix = "Y:" -[node name="Ratio" type="TextureRect" parent="." groups=["UIButtons"]] +[node name="Ratio" type="Control" parent="."] visible = false margin_left = 36.0 margin_right = 52.0 margin_bottom = 52.0 rect_min_size = Vector2( 16, 0 ) + +[node name="RatioGuides" type="NinePatchRect" parent="Ratio" groups=["UIButtons"]] +anchor_bottom = 1.0 +margin_right = 9.0 +rect_min_size = Vector2( 9, 0 ) texture = ExtResource( 4 ) +region_rect = Rect2( 0, 0, 9, 44 ) +patch_margin_top = 15 +patch_margin_bottom = 13 [node name="RatioButton" type="TextureButton" parent="Ratio" groups=["UIButtons"]] anchor_left = 0.5 @@ -61,9 +69,9 @@ anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 margin_left = -8.0 -margin_top = -10.0 +margin_top = -8.0 margin_right = 8.0 -margin_bottom = 6.0 +margin_bottom = 8.0 hint_tooltip = "Lock aspect ratio" mouse_default_cursor_shape = 2 toggle_mode = true