From 072c893c241a11961a8e5ae67efcb79afdccc223 Mon Sep 17 00:00:00 2001 From: LMW Date: Fri, 1 Aug 2025 19:11:03 +0800 Subject: [PATCH 1/2] Add button to reset tones levels --- material_maker/nodes/tones/tones.gd | 8 +++ material_maker/nodes/tones/tones.tscn | 18 ++++- material_maker/theme/default_theme_icons.svg | 71 ++++++++++++++++++-- 3 files changed, 90 insertions(+), 7 deletions(-) diff --git a/material_maker/nodes/tones/tones.gd b/material_maker/nodes/tones/tones.gd index 915cffd8d..5e46b497e 100644 --- a/material_maker/nodes/tones/tones.gd +++ b/material_maker/nodes/tones/tones.gd @@ -175,3 +175,11 @@ func _on_Auto_pressed(): cursor_in_min.update_value(float(in_min)/float(histogram_size-1)) cursor_in_mid.update_value(float(in_mid)/float(histogram_size-1)) cursor_in_max.update_value(float(in_max)/float(histogram_size-1)) + + +func _on_reset_pressed() -> void: + cursor_in_min.update_value(0.0) + cursor_in_mid.update_value(0.5) + cursor_in_max.update_value(1.0) + cursor_out_min.update_value(0.0) + cursor_out_max.update_value(1.0) diff --git a/material_maker/nodes/tones/tones.tscn b/material_maker/nodes/tones/tones.tscn index b67f30fa9..dbcff5ab1 100644 --- a/material_maker/nodes/tones/tones.tscn +++ b/material_maker/nodes/tones/tones.tscn @@ -1,13 +1,18 @@ -[gd_scene load_steps=5 format=3 uid="uid://7wslfieqleli"] +[gd_scene load_steps=7 format=3 uid="uid://7wslfieqleli"] [ext_resource type="PackedScene" uid="uid://0b6d65sghy3s" path="res://material_maker/widgets/histogram/histogram.tscn" id="1"] [ext_resource type="Script" uid="uid://nbk6k40bfmwi" path="res://material_maker/nodes/tones/tones.gd" id="2"] -[ext_resource type="Texture2D" uid="uid://c0j4px4n72di5" path="res://material_maker/icons/icons.tres" id="3"] +[ext_resource type="Texture2D" uid="uid://cvorvnes6fiq7" path="res://material_maker/icons/icons.svg" id="2_o4mha"] +[ext_resource type="Texture2D" uid="uid://1s0c37uoj4rf" path="res://material_maker/theme/default_theme_icons.svg" id="3_hpd32"] [sub_resource type="AtlasTexture" id="1"] -atlas = ExtResource("3") +atlas = ExtResource("2_o4mha") region = Rect2(16, 80, 16, 16) +[sub_resource type="AtlasTexture" id="AtlasTexture_jb2ll"] +atlas = ExtResource("3_hpd32") +region = Rect2(80, 192, 16, 16) + [node name="Tones" type="GraphNode"] offset_right = 192.0 offset_bottom = 141.0 @@ -77,6 +82,12 @@ size_flags_vertical = 4 tooltip_text = "Set levels automatically" texture_normal = SubResource("1") +[node name="Reset" type="TextureButton" parent="Bar"] +layout_mode = 2 +size_flags_vertical = 4 +tooltip_text = "Reset levels" +texture_normal = SubResource("AtlasTexture_jb2ll") + [node name="Spacer1" type="Control" parent="."] custom_minimum_size = Vector2(0, 4) layout_mode = 2 @@ -91,3 +102,4 @@ layout_mode = 2 [connection signal="item_selected" from="Bar/Mode" to="." method="_on_Mode_item_selected"] [connection signal="pressed" from="Bar/Auto" to="." method="_on_Auto_pressed"] +[connection signal="pressed" from="Bar/Reset" to="." method="_on_reset_pressed"] diff --git a/material_maker/theme/default_theme_icons.svg b/material_maker/theme/default_theme_icons.svg index 783e1c918..a5d6fe651 100644 --- a/material_maker/theme/default_theme_icons.svg +++ b/material_maker/theme/default_theme_icons.svg @@ -28,15 +28,15 @@ inkscape:deskcolor="#d1d1d1" inkscape:document-units="mm" showgrid="true" - inkscape:zoom="128" - inkscape:cx="55.242187" - inkscape:cy="37.707031" + inkscape:zoom="22.627417" + inkscape:cx="80.831144" + inkscape:cy="194.12291" inkscape:window-width="1152" inkscape:window-height="981" inkscape:window-x="0" inkscape:window-y="38" inkscape:window-maximized="0" - inkscape:current-layer="g27"> + inkscape:current-layer="g29"> + + + + + + + Date: Sun, 17 Aug 2025 16:48:22 +0800 Subject: [PATCH 2/2] Group Auto/Reset cursor actions for undoredo --- material_maker/nodes/tones/tones.gd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/material_maker/nodes/tones/tones.gd b/material_maker/nodes/tones/tones.gd index 5e46b497e..2c040cf7a 100644 --- a/material_maker/nodes/tones/tones.gd +++ b/material_maker/nodes/tones/tones.gd @@ -172,14 +172,18 @@ func _on_Auto_pressed(): if in_mid_value < value: in_mid = i in_mid_value = value + get_parent().undoredo.start_group() cursor_in_min.update_value(float(in_min)/float(histogram_size-1)) cursor_in_mid.update_value(float(in_mid)/float(histogram_size-1)) cursor_in_max.update_value(float(in_max)/float(histogram_size-1)) + get_parent().undoredo.end_group() func _on_reset_pressed() -> void: + get_parent().undoredo.start_group() cursor_in_min.update_value(0.0) cursor_in_mid.update_value(0.5) cursor_in_max.update_value(1.0) cursor_out_min.update_value(0.0) cursor_out_max.update_value(1.0) + get_parent().undoredo.end_group()