From 5e2901971b8b546647f59871873447696cd9aa85 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Wed, 29 Jan 2025 21:51:55 +0200 Subject: [PATCH] Make RGBA bool uniforms in invert and desaturate buttons instead of checkboxes in layer effects They are now consistent with their image effect counterparts. --- src/Classes/ShaderLoader.gd | 48 +++++++++++++++---------- src/Shaders/Effects/Desaturate.gdshader | 2 +- src/Shaders/Effects/Invert.gdshader | 2 +- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/Classes/ShaderLoader.gd b/src/Classes/ShaderLoader.gd index b1399ae6c..68f342967 100644 --- a/src/Classes/ShaderLoader.gd +++ b/src/Classes/ShaderLoader.gd @@ -19,6 +19,7 @@ static func create_ui_for_shader_uniforms( var uniform_data: PackedStringArray = [] var description: String = "" var description_began := false + var color_button_hbox: HBoxContainer = null # Used for RGBA buttons, if they exist. for line in code: # Management of "end" tags if line.begins_with("// (end DESCRIPTION)"): @@ -270,26 +271,37 @@ static func create_ui_for_shader_uniforms( params, u_name, hbox, value_changed, parent_node, file_selected ) parent_node.add_child(hbox) - elif u_type == "bool": - var label := Label.new() - label.text = humanized_u_name - label.size_flags_horizontal = Control.SIZE_EXPAND_FILL - var checkbox := CheckBox.new() - checkbox.text = "On" - if u_value == "true": - checkbox.button_pressed = true - if params.has(u_name): - checkbox.button_pressed = params[u_name] + var button: BaseButton + if u_name in ["red", "green", "blue", "alpha"]: + button = Button.new() + button.text = u_name[0].to_upper() + button.toggle_mode = true + if is_instance_valid(color_button_hbox): + color_button_hbox.add_child(button) + else: + color_button_hbox = HBoxContainer.new() + color_button_hbox.add_child(button) + parent_node.add_child(color_button_hbox) else: - params[u_name] = checkbox.button_pressed - checkbox.toggled.connect(value_changed.bind(u_name)) - checkbox.size_flags_horizontal = Control.SIZE_EXPAND_FILL - checkbox.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND - var hbox := HBoxContainer.new() - hbox.add_child(label) - hbox.add_child(checkbox) - parent_node.add_child(hbox) + button = CheckBox.new() + var label := Label.new() + label.text = humanized_u_name + label.size_flags_horizontal = Control.SIZE_EXPAND_FILL + button.text = "On" + var hbox := HBoxContainer.new() + hbox.add_child(label) + hbox.add_child(button) + parent_node.add_child(hbox) + if u_value == "true": + button.button_pressed = true + if params.has(u_name): + button.button_pressed = params[u_name] + else: + params[u_name] = button.button_pressed + button.toggled.connect(value_changed.bind(u_name)) + button.size_flags_horizontal = Control.SIZE_EXPAND_FILL + button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND static func _vec2str_to_vector2(vec2: String) -> Vector2: diff --git a/src/Shaders/Effects/Desaturate.gdshader b/src/Shaders/Effects/Desaturate.gdshader index 057c783d1..30c20526d 100644 --- a/src/Shaders/Effects/Desaturate.gdshader +++ b/src/Shaders/Effects/Desaturate.gdshader @@ -2,8 +2,8 @@ shader_type canvas_item; render_mode unshaded; uniform bool red = true; -uniform bool blue = true; uniform bool green = true; +uniform bool blue = true; uniform bool alpha = false; uniform sampler2D selection : filter_nearest; diff --git a/src/Shaders/Effects/Invert.gdshader b/src/Shaders/Effects/Invert.gdshader index c23ef4a61..067bb238c 100644 --- a/src/Shaders/Effects/Invert.gdshader +++ b/src/Shaders/Effects/Invert.gdshader @@ -2,8 +2,8 @@ shader_type canvas_item; render_mode unshaded; uniform bool red = true; -uniform bool blue = true; uniform bool green = true; +uniform bool blue = true; uniform bool alpha = false; uniform sampler2D selection : filter_nearest;