From d5e83124b0b5713e0002ec86a2a4d7e980eabac1 Mon Sep 17 00:00:00 2001 From: Jowan-Spooner Date: Sun, 25 Aug 2024 11:45:23 +0200 Subject: [PATCH 1/2] Fixes for node label alignment --- material_maker/nodes/generic/generic.gd | 38 ++++++++++++++++++------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/material_maker/nodes/generic/generic.gd b/material_maker/nodes/generic/generic.gd index 40a20d428..7ff82b9df 100644 --- a/material_maker/nodes/generic/generic.gd +++ b/material_maker/nodes/generic/generic.gd @@ -441,6 +441,7 @@ func update_node() -> void: # Inputs var inputs = generator.get_input_defs() var index = -1 + var input_labels := [] for i in range(inputs.size()): var input = inputs[i] var enable_left = false @@ -475,13 +476,12 @@ func update_node() -> void: if label != "": var label_widget : Label = Label.new() label_widget.text = label + label_widget.theme_type_variation = "MM_NodePropertyLabel" hsizer.add_child(label_widget) + input_labels.append(label_widget) set_slot(index, enable_left, type_left, color_left, false, 0, Color()) - var input_names_width : int = 0 - input_names_width = get_children().reduce( - func(accum, child): return max(child.get_child(0).size.x, accum) if child.get_child_count() else accum - , 0) + # Parameters if !generator.minimized: @@ -489,7 +489,7 @@ func update_node() -> void: index = -1 var previous_focus = null var first_focus = null - var labels := [] + var property_labels := [] for p in generator.get_parameter_defs(): if !p.has("name") or !p.has("type"): continue @@ -512,19 +512,22 @@ func update_node() -> void: while index >= get_child_count(): hsizer = HBoxContainer.new() hsizer.size_flags_horizontal = SIZE_EXPAND | SIZE_FILL - if input_names_width > 0: + if not input_labels.is_empty(): var empty_control : Control = Control.new() - empty_control.custom_minimum_size.x = input_names_width + empty_control.mouse_filter = Control.MOUSE_FILTER_IGNORE + input_labels.append(empty_control) hsizer.add_child(empty_control) add_child(hsizer) hsizer = get_child(index) hsizer.custom_minimum_size.y = 25 + if label != "": var label_widget = Label.new() label_widget.text = label - labels.append(label_widget) + property_labels.append(label_widget) label_widget.theme_type_variation = "MM_NodePropertyLabel" hsizer.add_child(label_widget) + control.size_flags_horizontal = SIZE_EXPAND | SIZE_FILL if hsizer != null: hsizer.add_child(control) @@ -535,16 +538,30 @@ func update_node() -> void: first_focus = control previous_focus = control - var label_max_width = labels.reduce(func(accum, label): return max(accum, label.size.x), 0) + var label_max_width = property_labels.reduce(func(accum, label): return max(accum, label.size.x), 0) label_max_width = min(100, label_max_width) - for label in labels: + for label in property_labels: label.custom_minimum_size.x = label_max_width label.size.x = label_max_width label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS + + var input_label_width : int = 0 + input_label_width = get_children().reduce( + func(accum, child): return max(child.get_child(0).size.x, accum) if child.get_child_count() else accum + , 0) + + if not property_labels.is_empty(): + input_label_width += 10 + + for i in input_labels: + i.custom_minimum_size.x = input_label_width + if first_focus != null: previous_focus.focus_next = first_focus.get_path() first_focus.focus_previous = previous_focus.get_path() initialize_properties() + + # Outputs var outputs = generator.get_output_defs() output_count = outputs.size() @@ -568,6 +585,7 @@ func update_node() -> void: hsizer = get_child(i) if hsizer.get_child_count() == 0: hsizer.custom_minimum_size.y = 25 if !generator.minimized else 12 + # Edit buttons if generator.is_editable(): for theme_stylebox in ["frame", "selected_frame"]: From 7f3d09a70bec54d18c21d6075b9a93df68f2c014 Mon Sep 17 00:00:00 2001 From: Jowan-Spooner Date: Sun, 25 Aug 2024 11:45:31 +0200 Subject: [PATCH 2/2] Fix for some float fields --- material_maker/widgets/float_edit/float_edit.gd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/material_maker/widgets/float_edit/float_edit.gd b/material_maker/widgets/float_edit/float_edit.gd index d218f2278..106c76ac1 100644 --- a/material_maker/widgets/float_edit/float_edit.gd +++ b/material_maker/widgets/float_edit/float_edit.gd @@ -2,6 +2,8 @@ extends Container var float_value: float = 0.5 @export var value: float = 0.5 : + get: + return float_value set(new_value): set_value(new_value)