diff --git a/addons/block_code/ui/blocks/control_block/control_block.tscn b/addons/block_code/ui/blocks/control_block/control_block.tscn index c234cb20..bf85d1ba 100644 --- a/addons/block_code/ui/blocks/control_block/control_block.tscn +++ b/addons/block_code/ui/blocks/control_block/control_block.tscn @@ -47,6 +47,7 @@ layout_mode = 2 script = ExtResource("2_tx0qr") color = Color(1, 1, 1, 1) shift_bottom = 20.0 +block_type = 4 [node name="DragDropArea" parent="VBoxContainer/MarginContainer/Rows/Row" instance=ExtResource("3_21e8n")] layout_mode = 2 @@ -92,6 +93,8 @@ size_flags_horizontal = 0 script = ExtResource("2_tx0qr") color = Color(1, 1, 1, 1) shift_top = 20.0 +block_type = 4 +control_part = 1 [node name="SnapPoint" parent="VBoxContainer" instance=ExtResource("3_nhryi")] layout_mode = 2 diff --git a/addons/block_code/ui/blocks/entry_block/entry_block.gd b/addons/block_code/ui/blocks/entry_block/entry_block.gd index 22a8b58d..3f8eb703 100644 --- a/addons/block_code/ui/blocks/entry_block/entry_block.gd +++ b/addons/block_code/ui/blocks/entry_block/entry_block.gd @@ -9,6 +9,7 @@ extends StatementBlock func _ready(): super() bottom_snap = null + _background.show_top = true static func get_block_class(): diff --git a/addons/block_code/ui/blocks/entry_block/entry_block.tscn b/addons/block_code/ui/blocks/entry_block/entry_block.tscn index 3419c956..d65c7470 100644 --- a/addons/block_code/ui/blocks/entry_block/entry_block.tscn +++ b/addons/block_code/ui/blocks/entry_block/entry_block.tscn @@ -19,6 +19,12 @@ layout_mode = 2 mouse_filter = 2 theme_override_constants/separation = 0 +[node name="DragDropArea2" parent="VBoxContainer" instance=ExtResource("3_swkpp")] +custom_minimum_size = Vector2(80, 16) +layout_mode = 2 +size_flags_horizontal = 0 +mouse_default_cursor_shape = 2 + [node name="TopMarginContainer" type="MarginContainer" parent="VBoxContainer"] custom_minimum_size = Vector2(0, 30) layout_mode = 2 @@ -35,7 +41,8 @@ layout_mode = 2 mouse_filter = 1 script = ExtResource("2_yrw8l") color = Color(1, 1, 1, 1) -show_top = false +is_round_top = true +block_type = 1 [node name="DragDropArea" parent="VBoxContainer/TopMarginContainer" instance=ExtResource("3_swkpp")] layout_mode = 2 @@ -56,4 +63,8 @@ layout_mode = 2 [node name="SnapPoint" parent="VBoxContainer" instance=ExtResource("4_yj206")] layout_mode = 2 +[node name="MarginContainer" type="MarginContainer" parent="VBoxContainer"] +layout_mode = 2 + +[connection signal="drag_started" from="VBoxContainer/DragDropArea2" to="." method="_on_drag_drop_area_drag_started"] [connection signal="drag_started" from="VBoxContainer/TopMarginContainer/DragDropArea" to="." method="_on_drag_drop_area_drag_started"] diff --git a/addons/block_code/ui/blocks/parameter_block/parameter_block.gd b/addons/block_code/ui/blocks/parameter_block/parameter_block.gd index f12ebf1b..968b71f5 100644 --- a/addons/block_code/ui/blocks/parameter_block/parameter_block.gd +++ b/addons/block_code/ui/blocks/parameter_block/parameter_block.gd @@ -6,6 +6,7 @@ const Constants = preload("res://addons/block_code/ui/constants.gd") const Util = preload("res://addons/block_code/ui/util.gd") const ParameterOutput = preload("res://addons/block_code/ui/blocks/utilities/parameter_output/parameter_output.gd") +@onready var _background := $Background @onready var _panel := $Panel var args_to_add_after_format: Dictionary # Only used when loading @@ -18,16 +19,22 @@ var _panel_focus: StyleBox func _ready(): super() - _panel_normal = _panel.get_theme_stylebox("panel").duplicate() - _panel_normal.bg_color = color - _panel_normal.border_color = color.darkened(0.2) + if not definition == null and definition.variant_type == Variant.Type.TYPE_BOOL: + _background.visible = true + _background.is_pointy = true + _background.color = color + _panel.visible = false + else: + _panel_normal = _panel.get_theme_stylebox("panel").duplicate() + _panel_normal.bg_color = color + _panel_normal.border_color = color.darkened(0.2) - _panel_focus = _panel.get_theme_stylebox("panel").duplicate() - _panel_focus.bg_color = color - _panel_focus.border_color = Constants.FOCUS_BORDER_COLOR + _panel_focus = _panel.get_theme_stylebox("panel").duplicate() + _panel_focus.bg_color = color + _panel_focus.border_color = Constants.FOCUS_BORDER_COLOR - if not Util.node_is_part_of_edited_scene(self): - _panel.add_theme_stylebox_override("panel", _panel_normal) + if not Util.node_is_part_of_edited_scene(self): + _panel.add_theme_stylebox_override("panel", _panel_normal) func _on_drag_drop_area_drag_started(offset: Vector2) -> void: @@ -43,8 +50,10 @@ static func get_scene_path(): func _on_focus_entered(): - _panel.add_theme_stylebox_override("panel", _panel_focus) + if not definition == null and not definition.variant_type == Variant.Type.TYPE_BOOL: + _panel.add_theme_stylebox_override("panel", _panel_focus) func _on_focus_exited(): - _panel.add_theme_stylebox_override("panel", _panel_normal) + if not definition == null and not definition.variant_type == Variant.Type.TYPE_BOOL: + _panel.add_theme_stylebox_override("panel", _panel_normal) diff --git a/addons/block_code/ui/blocks/parameter_block/parameter_block.tscn b/addons/block_code/ui/blocks/parameter_block/parameter_block.tscn index 4109d0c8..4a822ef6 100644 --- a/addons/block_code/ui/blocks/parameter_block/parameter_block.tscn +++ b/addons/block_code/ui/blocks/parameter_block/parameter_block.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=5 format=3 uid="uid://clipm2dd28jde"] +[gd_scene load_steps=6 format=3 uid="uid://clipm2dd28jde"] [ext_resource type="Script" path="res://addons/block_code/ui/blocks/parameter_block/parameter_block.gd" id="1_0hajy"] [ext_resource type="PackedScene" uid="uid://c7puyxpqcq6xo" path="res://addons/block_code/ui/blocks/utilities/drag_drop_area/drag_drop_area.tscn" id="2_0eadx"] +[ext_resource type="Script" path="res://addons/block_code/ui/blocks/utilities/background/background.gd" id="2_2q1xr"] [ext_resource type="PackedScene" uid="uid://b1xvp3u11h41s" path="res://addons/block_code/ui/blocks/utilities/template_editor/template_editor.tscn" id="3_shl1a"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dbera"] @@ -14,6 +15,10 @@ corner_radius_top_left = 16 corner_radius_top_right = 16 corner_radius_bottom_right = 16 corner_radius_bottom_left = 16 +expand_margin_left = 2.0 +expand_margin_top = 2.0 +expand_margin_right = 2.0 +expand_margin_bottom = 2.0 [node name="ParameterBlock" type="MarginContainer" node_paths=PackedStringArray("template_editor")] offset_right = 16.0 @@ -24,6 +29,15 @@ mouse_filter = 2 script = ExtResource("1_0hajy") template_editor = NodePath("MarginContainer/TemplateEditor") +[node name="Background" type="Control" parent="."] +unique_name_in_owner = true +visible = false +layout_mode = 2 +script = ExtResource("2_2q1xr") +color = Color(1, 1, 1, 1) +show_top = false +show_bottom = false + [node name="Panel" type="Panel" parent="."] unique_name_in_owner = true layout_mode = 2 @@ -36,15 +50,15 @@ mouse_default_cursor_shape = 2 [node name="MarginContainer" type="MarginContainer" parent="."] layout_mode = 2 mouse_filter = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 6 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 6 [node name="TemplateEditor" parent="MarginContainer" instance=ExtResource("3_shl1a")] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 0 -theme_override_constants/margin_left = 10 -theme_override_constants/margin_top = 8 -theme_override_constants/margin_right = 10 -theme_override_constants/margin_bottom = 8 [connection signal="focus_entered" from="." to="." method="_on_focus_entered"] [connection signal="focus_exited" from="." to="." method="_on_focus_exited"] diff --git a/addons/block_code/ui/blocks/utilities/background/background.gd b/addons/block_code/ui/blocks/utilities/background/background.gd index adf74799..ff4b5639 100644 --- a/addons/block_code/ui/blocks/utilities/background/background.gd +++ b/addons/block_code/ui/blocks/utilities/background/background.gd @@ -3,6 +3,12 @@ extends Control const BlockTreeUtil = preload("res://addons/block_code/ui/block_tree_util.gd") const Constants = preload("res://addons/block_code/ui/constants.gd") +const Types = preload("res://addons/block_code/types/types.gd") + +enum ControlPart { + TOP, + BOTTOM, +} var outline_color: Color var parent_block: Block @@ -10,9 +16,15 @@ var parent_block: Block @export var color: Color: set = _set_color +@export var draw_outline: bool = true: + set = _set_draw_outline + @export var show_top: bool = true: set = _set_show_top +@export var show_bottom: bool = true: + set = _set_show_bottom + ## Horizontally shift the top knob @export var shift_top: float = 0.0: set = _set_shift_top @@ -21,6 +33,20 @@ var parent_block: Block @export var shift_bottom: float = 0.0: set = _set_shift_bottom +@export var is_round_top: bool = false: + set = _set_is_round_top + +@export var block_type: Types.BlockType = Types.BlockType.STATEMENT: + set = _set_block_type + +## Only relevant if block_type is CONTROL. +@export var control_part: ControlPart = ControlPart.TOP: + set = _set_control_part + +## Only relevant if block_type is VALUE. +@export var is_pointy: bool = false: + set = _set_is_pointy + func _set_color(new_color): color = new_color @@ -28,11 +54,21 @@ func _set_color(new_color): queue_redraw() +func _set_draw_outline(new_outline): + draw_outline = new_outline + queue_redraw() + + func _set_show_top(new_show_top): show_top = new_show_top queue_redraw() +func _set_show_bottom(new_show_bottom): + show_bottom = new_show_bottom + queue_redraw() + + func _set_shift_top(new_shift_top): shift_top = new_shift_top queue_redraw() @@ -43,67 +79,187 @@ func _set_shift_bottom(new_shift_bottom): queue_redraw() +func _set_is_round_top(new_is_round_top): + is_round_top = new_is_round_top + queue_redraw() + + +func _set_is_pointy(new_is_pointy): + is_pointy = new_is_pointy + queue_redraw() + + +func _set_block_type(new_block_type): + block_type = new_block_type + queue_redraw() + + +func _set_control_part(new_control_part): + control_part = new_control_part + queue_redraw() + + func _ready(): + # I think the parent block should get the child but this works parent_block = BlockTreeUtil.get_parent_block(self) - parent_block.focus_entered.connect(queue_redraw) - parent_block.focus_exited.connect(queue_redraw) + + if not parent_block == null: + parent_block.focus_entered.connect(queue_redraw) + parent_block.focus_exited.connect(queue_redraw) func _draw(): + if block_type == Types.BlockType.ENTRY: + # FIXME draw entry + pass + elif block_type == Types.BlockType.CONTROL: + if control_part == ControlPart.TOP: + # FIXME draw control top + pass + else: + # FIXME draw control bottom + pass + elif block_type == Types.BlockType.VALUE: + if is_pointy: + # FIXME draw pointy value + pass + else: + # FIXME draw round value + pass + elif block_type == Types.BlockType.STATEMENT: + # FIXME draw statement + pass + return _old_draw() + + +func _old_draw(): + var top_left_align := Constants.KNOB_X + shift_top + var bottom_left_align := Constants.KNOB_X + shift_bottom + var top_knob: PackedVector2Array var fill_polygon: PackedVector2Array fill_polygon.append(Vector2(0.0, 0.0)) + if show_top: - fill_polygon.append(Vector2(Constants.KNOB_X + shift_top, 0.0)) - fill_polygon.append(Vector2(Constants.KNOB_X + Constants.KNOB_Z + shift_top, Constants.KNOB_H)) - fill_polygon.append(Vector2(Constants.KNOB_X + Constants.KNOB_Z + Constants.KNOB_W + shift_top, Constants.KNOB_H)) - fill_polygon.append(Vector2(Constants.KNOB_X + Constants.KNOB_Z * 2 + Constants.KNOB_W + shift_top, 0.0)) - - fill_polygon.append(Vector2(size.x, 0.0)) - fill_polygon.append(Vector2(size.x, size.y)) - fill_polygon.append(Vector2(Constants.KNOB_X + Constants.KNOB_Z * 2 + Constants.KNOB_W + shift_bottom, size.y)) - fill_polygon.append(Vector2(Constants.KNOB_X + Constants.KNOB_Z + Constants.KNOB_W + shift_bottom, size.y + Constants.KNOB_H)) - fill_polygon.append(Vector2(Constants.KNOB_X + Constants.KNOB_Z + shift_bottom, size.y + Constants.KNOB_H)) - fill_polygon.append(Vector2(Constants.KNOB_X + shift_bottom, size.y)) - fill_polygon.append(Vector2(0.0, size.y)) - fill_polygon.append(Vector2(0.0, 0.0)) + if is_round_top: + top_knob.append_array( + [ + Vector2(5, -4.012612), + Vector2(10, -7.240165), + Vector2(15, -9.822201), + Vector2(20, -11.84718), + Vector2(25, -13.37339), + Vector2(30, -14.43944), + Vector2(35, -15.06994), + Vector2(40, -15.27864), + Vector2(45, -15.06994), + Vector2(50, -14.43944), + Vector2(55, -13.37339), + Vector2(60, -11.84718), + Vector2(65, -9.822201), + Vector2(70, -7.240165), + Vector2(75, -4.012612), + Vector2(80, 0) + ] + ) + else: + top_knob.append(Vector2(top_left_align, 0.0)) + top_knob.append(Vector2(top_left_align + Constants.KNOB_Z, Constants.KNOB_H)) + top_knob.append(Vector2(top_left_align + Constants.KNOB_Z + Constants.KNOB_W, Constants.KNOB_H)) + top_knob.append(Vector2(top_left_align + Constants.KNOB_Z * 2 + Constants.KNOB_W, 0.0)) + fill_polygon.append_array(top_knob) - var stroke_polygon: PackedVector2Array - var edge_polygon: PackedVector2Array - var outline_middle = Constants.OUTLINE_WIDTH / 2 + # Right side + if is_pointy: + # Top + fill_polygon.append(Vector2(size.x - Constants.POINTY_WIDTH, 0.0)) - if shift_top > 0: - stroke_polygon.append(Vector2(shift_top - outline_middle, 0.0)) - else: - stroke_polygon.append(Vector2(shift_top, 0.0)) + # Middle + fill_polygon.append(Vector2(size.x, size.y / 2.0)) - if show_top: - stroke_polygon.append(Vector2(Constants.KNOB_X + shift_top, 0.0)) - stroke_polygon.append(Vector2(Constants.KNOB_X + Constants.KNOB_Z + shift_top, Constants.KNOB_H)) - stroke_polygon.append(Vector2(Constants.KNOB_X + Constants.KNOB_Z + Constants.KNOB_W + shift_top, Constants.KNOB_H)) - stroke_polygon.append(Vector2(Constants.KNOB_X + Constants.KNOB_Z * 2 + Constants.KNOB_W + shift_top, 0.0)) - - stroke_polygon.append(Vector2(size.x, 0.0)) - stroke_polygon.append(Vector2(size.x, size.y)) - stroke_polygon.append(Vector2(Constants.KNOB_X + Constants.KNOB_Z * 2 + Constants.KNOB_W + shift_bottom, size.y)) - stroke_polygon.append(Vector2(Constants.KNOB_X + Constants.KNOB_Z + Constants.KNOB_W + shift_bottom, size.y + Constants.KNOB_H)) - stroke_polygon.append(Vector2(Constants.KNOB_X + Constants.KNOB_Z + shift_bottom, size.y + Constants.KNOB_H)) - stroke_polygon.append(Vector2(Constants.KNOB_X + shift_bottom, size.y)) - - if shift_bottom > 0: - stroke_polygon.append(Vector2(shift_bottom - outline_middle, size.y)) + # Bottom + fill_polygon.append(Vector2(size.x - Constants.POINTY_WIDTH, size.y)) else: - stroke_polygon.append(Vector2(shift_bottom, size.y)) + fill_polygon.append(Vector2(size.x, 0.0)) + fill_polygon.append(Vector2(size.x, size.y)) - if shift_top > 0: - edge_polygon.append(Vector2(0.0, 0.0)) - else: - edge_polygon.append(Vector2(0.0, 0.0 - outline_middle)) + if show_bottom: + fill_polygon.append(Vector2(bottom_left_align + Constants.KNOB_Z * 2 + Constants.KNOB_W, size.y)) + fill_polygon.append(Vector2(bottom_left_align + Constants.KNOB_Z + Constants.KNOB_W, size.y + Constants.KNOB_H)) + fill_polygon.append(Vector2(bottom_left_align + Constants.KNOB_Z, size.y + Constants.KNOB_H)) + fill_polygon.append(Vector2(bottom_left_align, size.y)) - if shift_bottom > 0: - edge_polygon.append(Vector2(0.0, size.y)) + # Left side + if is_pointy: + # Bottom + fill_polygon.append(Vector2(Constants.POINTY_WIDTH, size.y)) + + # Middle + fill_polygon.append(Vector2(0.0, size.y / 2.0)) + + # Top + fill_polygon.append(Vector2(Constants.POINTY_WIDTH, 0.0)) else: - edge_polygon.append(Vector2(0.0, size.y + outline_middle)) + fill_polygon.append(Vector2(0.0, size.y)) + fill_polygon.append(Vector2(0.0, 0.0)) draw_colored_polygon(fill_polygon, color) - draw_polyline(stroke_polygon, Constants.FOCUS_BORDER_COLOR if parent_block.has_focus() else outline_color, Constants.OUTLINE_WIDTH) - draw_polyline(edge_polygon, Constants.FOCUS_BORDER_COLOR if parent_block.has_focus() else outline_color, Constants.OUTLINE_WIDTH) + + if draw_outline: + var stroke_polygon: PackedVector2Array + var edge_polygon: PackedVector2Array + var outline_middle := Constants.OUTLINE_WIDTH / 2 + + # Top line + if is_pointy: + stroke_polygon.append(Vector2(shift_top - (0.0 if not shift_top > 0 else outline_middle) + Constants.POINTY_WIDTH, 0.0)) + else: + stroke_polygon.append(Vector2(shift_top - (0.0 if not shift_top > 0 else outline_middle), 0.0)) + + if show_top: + stroke_polygon.append_array(top_knob) + + # Right line + if is_pointy: + # Top + stroke_polygon.append(Vector2(size.x - Constants.POINTY_WIDTH, 0.0)) + + # Middle + stroke_polygon.append(Vector2(size.x, size.y / 2.0)) + + # Bottom + stroke_polygon.append(Vector2(size.x - Constants.POINTY_WIDTH, size.y)) + else: + stroke_polygon.append(Vector2(size.x, 0.0)) + stroke_polygon.append(Vector2(size.x, size.y)) + + if show_bottom: + stroke_polygon.append(Vector2(bottom_left_align + Constants.KNOB_Z * 2 + Constants.KNOB_W, size.y)) + stroke_polygon.append(Vector2(bottom_left_align + Constants.KNOB_Z + Constants.KNOB_W, size.y + Constants.KNOB_H)) + stroke_polygon.append(Vector2(bottom_left_align + Constants.KNOB_Z, size.y + Constants.KNOB_H)) + stroke_polygon.append(Vector2(bottom_left_align, size.y)) + + # Left line + if is_pointy: + stroke_polygon.append(Vector2(shift_bottom - (outline_middle if shift_bottom > 0 else 0.0) + Constants.POINTY_WIDTH, size.y)) + edge_polygon.append(Vector2(Constants.POINTY_WIDTH + outline_middle, 0.0)) + + # Top + edge_polygon.append(Vector2(Constants.POINTY_WIDTH, 0.0)) + + # Middle + edge_polygon.append(Vector2(0.0, size.y / 2.0)) + + # Bottom + edge_polygon.append(Vector2(Constants.POINTY_WIDTH, size.y)) + edge_polygon.append(Vector2(Constants.POINTY_WIDTH + outline_middle, size.y)) + else: + stroke_polygon.append(Vector2(shift_bottom - (outline_middle if shift_bottom > 0 else 0.0), size.y)) + edge_polygon.append(Vector2(0.0, 0.0 - (0.0 if shift_top > 0 else outline_middle))) + edge_polygon.append(Vector2(0.0, size.y + (0.0 if shift_bottom > 0 else outline_middle))) + + if parent_block == null: + draw_polyline(stroke_polygon, outline_color, Constants.OUTLINE_WIDTH) + draw_polyline(edge_polygon, outline_color, Constants.OUTLINE_WIDTH) + else: + draw_polyline(stroke_polygon, Constants.FOCUS_BORDER_COLOR if parent_block.has_focus() else outline_color, Constants.OUTLINE_WIDTH) + draw_polyline(edge_polygon, Constants.FOCUS_BORDER_COLOR if parent_block.has_focus() else outline_color, Constants.OUTLINE_WIDTH) diff --git a/addons/block_code/ui/blocks/utilities/background/gutter.gd b/addons/block_code/ui/blocks/utilities/background/gutter.gd index 30e09a95..1d24117e 100644 --- a/addons/block_code/ui/blocks/utilities/background/gutter.gd +++ b/addons/block_code/ui/blocks/utilities/background/gutter.gd @@ -10,6 +10,9 @@ var parent_block: Block @export var color: Color: set = _set_color +@export var is_pointy: bool = false: + set = _set_is_pointy + func _set_color(new_color): color = new_color @@ -17,6 +20,11 @@ func _set_color(new_color): queue_redraw() +func _set_is_pointy(new_is_pointy): + is_pointy = new_is_pointy + queue_redraw() + + func _ready(): parent_block = BlockTreeUtil.get_parent_block(self) parent_block.focus_entered.connect(queue_redraw) @@ -25,20 +33,20 @@ func _ready(): func _draw(): var fill_polygon: PackedVector2Array - fill_polygon.append(Vector2(0.0, 0.0)) - fill_polygon.append(Vector2(size.x, 0.0)) - fill_polygon.append(Vector2(size.x, size.y)) - fill_polygon.append(Vector2(0.0, size.y)) - fill_polygon.append(Vector2(0.0, 0.0)) + fill_polygon.append(Vector2(Constants.POINTY_WIDTH if is_pointy else 0.0, 0.0)) + fill_polygon.append(Vector2(size.x + (Constants.POINTY_WIDTH if is_pointy else 0.0), 0.0)) + fill_polygon.append(Vector2(size.x + (Constants.POINTY_WIDTH if is_pointy else 0.0), size.y)) + fill_polygon.append(Vector2(Constants.POINTY_WIDTH if is_pointy else 0.0, size.y)) + fill_polygon.append(Vector2(Constants.POINTY_WIDTH if is_pointy else 0.0, 0.0)) var left_polygon: PackedVector2Array var right_polygon: PackedVector2Array - left_polygon.append(Vector2(0.0, 0.0)) - left_polygon.append(Vector2(0.0, size.y)) + left_polygon.append(Vector2(Constants.POINTY_WIDTH if is_pointy else 0.0, 0.0)) + left_polygon.append(Vector2(Constants.POINTY_WIDTH if is_pointy else 0.0, size.y)) - right_polygon.append(Vector2(size.x, 0.0)) - right_polygon.append(Vector2(size.x, size.y)) + right_polygon.append(Vector2(size.x + (Constants.POINTY_WIDTH if is_pointy else 0.0), 0.0)) + right_polygon.append(Vector2(size.x + (Constants.POINTY_WIDTH if is_pointy else 0.0), size.y)) draw_colored_polygon(fill_polygon, color) draw_polyline(left_polygon, Constants.FOCUS_BORDER_COLOR if parent_block.has_focus() else outline_color, Constants.OUTLINE_WIDTH) diff --git a/addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.gd b/addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.gd index 29db8b1c..b9022e60 100644 --- a/addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.gd +++ b/addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.gd @@ -21,6 +21,7 @@ var default_value: Variant var _drag_start: Vector2 = Vector2.INF +@onready var _background := %Background @onready var _panel := %Panel @onready var snap_point := %SnapPoint @onready var _input_switcher := %InputSwitcher @@ -216,6 +217,7 @@ func _update_visible_input(): TYPE_VECTOR2: _switch_input(_vector2_input) TYPE_BOOL: + _background.is_pointy = true _switch_input(_bool_input) _: _switch_input(_text_input) @@ -224,7 +226,8 @@ func _update_visible_input(): func _switch_input(node: Node): for c in _input_switcher.get_children(): c.visible = c == node - _panel.visible = node not in [_option_input] + _panel.visible = not node == null and node not in [_option_input] and node not in [_bool_input] + _background.visible = node in [_bool_input] func _update_option_input(current_value: Variant = null): diff --git a/addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.tscn b/addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.tscn index a243ac9a..f3483a66 100644 --- a/addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.tscn +++ b/addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=12 format=3 uid="uid://cjvxs6euc6xbm"] +[gd_scene load_steps=13 format=3 uid="uid://cjvxs6euc6xbm"] [ext_resource type="Script" path="res://addons/block_code/ui/blocks/utilities/parameter_input/parameter_input.gd" id="1_rgmxn"] +[ext_resource type="Script" path="res://addons/block_code/ui/blocks/utilities/background/background.gd" id="2_5dmag"] [ext_resource type="PackedScene" uid="uid://c7puyxpqcq6xo" path="res://addons/block_code/ui/blocks/utilities/drag_drop_area/drag_drop_area.tscn" id="2_05gck"] [ext_resource type="PackedScene" uid="uid://b1oge52xhjqnu" path="res://addons/block_code/ui/blocks/utilities/snap_point/snap_point.tscn" id="2_6esp3"] @@ -41,6 +42,17 @@ grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rgmxn") +[node name="Background" type="Control" parent="."] +unique_name_in_owner = true +visible = false +layout_mode = 2 +script = ExtResource("2_5dmag") +color = Color(1, 1, 1, 1) +draw_outline = false +show_top = false +show_bottom = false +block_type = 3 + [node name="Panel" type="Panel" parent="."] unique_name_in_owner = true layout_mode = 2 @@ -226,7 +238,6 @@ action_mode = 1 selected = 0 item_count = 2 popup/item_0/text = "false" -popup/item_0/id = 0 popup/item_1/text = "true" popup/item_1/id = 1 diff --git a/addons/block_code/ui/constants.gd b/addons/block_code/ui/constants.gd index edfb077a..9ce6579a 100644 --- a/addons/block_code/ui/constants.gd +++ b/addons/block_code/ui/constants.gd @@ -6,6 +6,7 @@ const KNOB_X = 10.0 const KNOB_W = 20.0 const KNOB_H = 5.0 const KNOB_Z = 5.0 +const POINTY_WIDTH = 15.0 const CONTROL_MARGIN = 20.0 const OUTLINE_WIDTH = 3.0 const MINIMUM_SNAP_DISTANCE = 80.0