Skip to content

Commit 9d10248

Browse files
authored
Merge pull request #270 from DoomTas3r/category-icons
Custom category icons, tooltips, and removed labels Fix #131
2 parents f3eea03 + 59de3cc commit 9d10248

34 files changed

+1002
-52
lines changed

addons/block_code/ui/picker/categories/block_category_button.gd

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@ signal selected
99
var category: BlockCategory
1010

1111
@onready var _panel := %Panel
12-
@onready var _label := %Label
12+
@onready var _button := %Button
1313

1414

1515
func _ready():
1616
if not category:
1717
category = BlockCategory.new("Example", Color.RED)
18+
var category_title = category.name.get_slice(" |", 0)
1819

1920
if not self.is_part_of_edited_scene():
20-
var new_stylebox: StyleBoxFlat = _panel.get_theme_stylebox("panel").duplicate()
21-
new_stylebox.bg_color = category.color
22-
_panel.add_theme_stylebox_override("panel", new_stylebox)
21+
var texture = load("res://addons/block_code/ui/picker/categories/icons/" + category_title.to_lower() + ".svg")
22+
_button.icon = texture
23+
_panel.modulate = category.color
2324

24-
_label.text = tr(category.name)
25+
_button.tooltip_text = tr(category_title)
2526

2627

2728
func _on_button_pressed():
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,52 @@
1-
[gd_scene load_steps=7 format=3 uid="uid://bdtetj0gs45hv"]
1+
[gd_scene load_steps=8 format=3 uid="uid://bdtetj0gs45hv"]
22

33
[ext_resource type="Script" path="res://addons/block_code/ui/picker/categories/block_category_button.gd" id="1_pxxnl"]
4+
[ext_resource type="Texture2D" uid="uid://g10ct6m5goi6" path="res://addons/block_code/ui/picker/categories/icons/file_broken.svg" id="2_0c1ke"]
45

5-
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_eogpc"]
6-
bg_color = Color(1, 0, 0, 1)
7-
corner_radius_top_left = 100
8-
corner_radius_top_right = 100
9-
corner_radius_bottom_right = 100
10-
corner_radius_bottom_left = 100
6+
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_w0e7p"]
7+
bg_color = Color(1, 1, 1, 1)
8+
corner_radius_top_left = 5
9+
corner_radius_top_right = 5
10+
corner_radius_bottom_right = 5
11+
corner_radius_bottom_left = 5
1112

12-
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ousiv"]
13+
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_dgecf"]
1314

1415
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_fyk0j"]
1516
bg_color = Color(1, 1, 1, 0.196078)
17+
corner_radius_top_left = 5
18+
corner_radius_top_right = 5
19+
corner_radius_bottom_right = 5
20+
corner_radius_bottom_left = 5
1621

1722
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ha83k"]
1823
bg_color = Color(1, 1, 1, 0.392157)
24+
corner_radius_top_left = 5
25+
corner_radius_top_right = 5
26+
corner_radius_bottom_right = 5
27+
corner_radius_bottom_left = 5
1928

20-
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_dgecf"]
29+
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ousiv"]
2130

2231
[node name="BlockCategoryButton" type="MarginContainer"]
23-
custom_minimum_size = Vector2(150, 0)
24-
offset_right = 148.0
25-
offset_bottom = 32.0
2632
script = ExtResource("1_pxxnl")
2733

28-
[node name="HBoxContainer" type="HBoxContainer" parent="."]
29-
layout_mode = 2
30-
31-
[node name="MarginContainer" type="MarginContainer" parent="HBoxContainer"]
32-
custom_minimum_size = Vector2(40, 40)
33-
layout_mode = 2
34-
theme_override_constants/margin_left = 8
35-
theme_override_constants/margin_top = 8
36-
theme_override_constants/margin_right = 8
37-
theme_override_constants/margin_bottom = 8
38-
39-
[node name="Panel" type="Panel" parent="HBoxContainer/MarginContainer"]
34+
[node name="Panel" type="Panel" parent="."]
4035
unique_name_in_owner = true
4136
layout_mode = 2
42-
theme_override_styles/panel = SubResource("StyleBoxFlat_eogpc")
43-
44-
[node name="Label" type="Label" parent="HBoxContainer"]
45-
unique_name_in_owner = true
46-
layout_mode = 2
47-
text = "Example"
37+
theme_override_styles/panel = SubResource("StyleBoxFlat_w0e7p")
4838

4939
[node name="Button" type="Button" parent="."]
40+
unique_name_in_owner = true
5041
layout_mode = 2
42+
size_flags_horizontal = 4
43+
tooltip_text = "Example"
5144
mouse_default_cursor_shape = 2
52-
theme_override_styles/normal = SubResource("StyleBoxEmpty_ousiv")
45+
theme_override_styles/focus = SubResource("StyleBoxEmpty_dgecf")
5346
theme_override_styles/hover = SubResource("StyleBoxFlat_fyk0j")
5447
theme_override_styles/pressed = SubResource("StyleBoxFlat_ha83k")
55-
theme_override_styles/focus = SubResource("StyleBoxEmpty_dgecf")
48+
theme_override_styles/normal = SubResource("StyleBoxEmpty_ousiv")
49+
icon = ExtResource("2_0c1ke")
50+
icon_alignment = 1
5651

5752
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://d0agg8648xht3"
6+
path="res://.godot/imported/communication.svg-1c0c83fe5e428cef3e6d7d530d940e5a.ctex"
7+
metadata={
8+
"has_editor_variant": true,
9+
"vram_texture": false
10+
}
11+
12+
[deps]
13+
14+
source_file="res://addons/block_code/ui/picker/categories/icons/communication.svg"
15+
dest_files=["res://.godot/imported/communication.svg-1c0c83fe5e428cef3e6d7d530d940e5a.ctex"]
16+
17+
[params]
18+
19+
compress/mode=0
20+
compress/high_quality=false
21+
compress/lossy_quality=0.7
22+
compress/hdr_compression=1
23+
compress/normal_map=0
24+
compress/channel_pack=0
25+
mipmaps/generate=false
26+
mipmaps/limit=-1
27+
roughness/mode=0
28+
roughness/src_normal=""
29+
process/fix_alpha_border=true
30+
process/premult_alpha=false
31+
process/normal_map_invert_y=false
32+
process/hdr_as_srgb=false
33+
process/hdr_clamp_exposure=false
34+
process/size_limit=0
35+
detect_3d/compress_to=1
36+
svg/scale=1.0
37+
editor/scale_with_editor_scale=true
38+
editor/convert_colors_with_editor_theme=false
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://g10ct6m5goi6"
6+
path="res://.godot/imported/file_broken.svg-b3a1f0e4d54ed488e76a2c99c48cdeac.ctex"
7+
metadata={
8+
"has_editor_variant": true,
9+
"vram_texture": false
10+
}
11+
12+
[deps]
13+
14+
source_file="res://addons/block_code/ui/picker/categories/icons/file_broken.svg"
15+
dest_files=["res://.godot/imported/file_broken.svg-b3a1f0e4d54ed488e76a2c99c48cdeac.ctex"]
16+
17+
[params]
18+
19+
compress/mode=0
20+
compress/high_quality=false
21+
compress/lossy_quality=0.7
22+
compress/hdr_compression=1
23+
compress/normal_map=0
24+
compress/channel_pack=0
25+
mipmaps/generate=false
26+
mipmaps/limit=-1
27+
roughness/mode=0
28+
roughness/src_normal=""
29+
process/fix_alpha_border=true
30+
process/premult_alpha=false
31+
process/normal_map_invert_y=false
32+
process/hdr_as_srgb=false
33+
process/hdr_clamp_exposure=false
34+
process/size_limit=0
35+
detect_3d/compress_to=1
36+
svg/scale=1.0
37+
editor/scale_with_editor_scale=true
38+
editor/convert_colors_with_editor_theme=false
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://bfvq21qp2l363"
6+
path="res://.godot/imported/graphics.svg-cb4f23d8db2eb8b1314d97d84a9d0f87.ctex"
7+
metadata={
8+
"has_editor_variant": true,
9+
"vram_texture": false
10+
}
11+
12+
[deps]
13+
14+
source_file="res://addons/block_code/ui/picker/categories/icons/graphics.svg"
15+
dest_files=["res://.godot/imported/graphics.svg-cb4f23d8db2eb8b1314d97d84a9d0f87.ctex"]
16+
17+
[params]
18+
19+
compress/mode=0
20+
compress/high_quality=false
21+
compress/lossy_quality=0.7
22+
compress/hdr_compression=1
23+
compress/normal_map=0
24+
compress/channel_pack=0
25+
mipmaps/generate=false
26+
mipmaps/limit=-1
27+
roughness/mode=0
28+
roughness/src_normal=""
29+
process/fix_alpha_border=true
30+
process/premult_alpha=false
31+
process/normal_map_invert_y=false
32+
process/hdr_as_srgb=false
33+
process/hdr_clamp_exposure=false
34+
process/size_limit=0
35+
detect_3d/compress_to=1
36+
svg/scale=1.0
37+
editor/scale_with_editor_scale=true
38+
editor/convert_colors_with_editor_theme=false
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://bw76iiilnqfsn"
6+
path="res://.godot/imported/info.svg-ea93806d088f2cc7be28fcec5db89f8b.ctex"
7+
metadata={
8+
"has_editor_variant": true,
9+
"vram_texture": false
10+
}
11+
12+
[deps]
13+
14+
source_file="res://addons/block_code/ui/picker/categories/icons/info.svg"
15+
dest_files=["res://.godot/imported/info.svg-ea93806d088f2cc7be28fcec5db89f8b.ctex"]
16+
17+
[params]
18+
19+
compress/mode=0
20+
compress/high_quality=false
21+
compress/lossy_quality=0.7
22+
compress/hdr_compression=1
23+
compress/normal_map=0
24+
compress/channel_pack=0
25+
mipmaps/generate=false
26+
mipmaps/limit=-1
27+
roughness/mode=0
28+
roughness/src_normal=""
29+
process/fix_alpha_border=true
30+
process/premult_alpha=false
31+
process/normal_map_invert_y=false
32+
process/hdr_as_srgb=false
33+
process/hdr_clamp_exposure=false
34+
process/size_limit=0
35+
detect_3d/compress_to=1
36+
svg/scale=1.0
37+
editor/scale_with_editor_scale=true
38+
editor/convert_colors_with_editor_theme=false
Loading

0 commit comments

Comments
 (0)