Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/block_code/ui/blocks/entry_block/entry_block.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ extends StatementBlock
func _ready():
super()
bottom_snap = null
_background.show_top = true


static func get_block_class():
Expand Down
12 changes: 11 additions & 1 deletion addons/block_code/ui/blocks/entry_block/entry_block.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,7 +41,7 @@ layout_mode = 2
mouse_filter = 1
script = ExtResource("2_yrw8l")
color = Color(1, 1, 1, 1)
show_top = false
top_variant = 1

[node name="DragDropArea" parent="VBoxContainer/TopMarginContainer" instance=ExtResource("3_swkpp")]
layout_mode = 2
Expand All @@ -56,4 +62,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"]
29 changes: 19 additions & 10 deletions addons/block_code/ui/blocks/parameter_block/parameter_block.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.variant = 3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use enumerators rather than integers. For example:

enum BackgroundVariant { ROUND, POINTY, ... }

_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:
Expand All @@ -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)
24 changes: 19 additions & 5 deletions addons/block_code/ui/blocks/parameter_block/parameter_block.tscn
Original file line number Diff line number Diff line change
@@ -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"]
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"]
Expand Down
Loading