Skip to content

Commit

Permalink
Merge pull request #270 from DoomTas3r/category-icons
Browse files Browse the repository at this point in the history
Custom category icons, tooltips, and removed labels

Fix #131
  • Loading branch information
manuq authored Feb 6, 2025
2 parents f3eea03 + 59de3cc commit 9d10248
Show file tree
Hide file tree
Showing 34 changed files with 1,002 additions and 52 deletions.
11 changes: 6 additions & 5 deletions addons/block_code/ui/picker/categories/block_category_button.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ signal selected
var category: BlockCategory

@onready var _panel := %Panel
@onready var _label := %Label
@onready var _button := %Button


func _ready():
if not category:
category = BlockCategory.new("Example", Color.RED)
var category_title = category.name.get_slice(" |", 0)

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

_label.text = tr(category.name)
_button.tooltip_text = tr(category_title)


func _on_button_pressed():
Expand Down
59 changes: 27 additions & 32 deletions addons/block_code/ui/picker/categories/block_category_button.tscn
Original file line number Diff line number Diff line change
@@ -1,57 +1,52 @@
[gd_scene load_steps=7 format=3 uid="uid://bdtetj0gs45hv"]
[gd_scene load_steps=8 format=3 uid="uid://bdtetj0gs45hv"]

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

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_eogpc"]
bg_color = Color(1, 0, 0, 1)
corner_radius_top_left = 100
corner_radius_top_right = 100
corner_radius_bottom_right = 100
corner_radius_bottom_left = 100
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_w0e7p"]
bg_color = Color(1, 1, 1, 1)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ousiv"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_dgecf"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_fyk0j"]
bg_color = Color(1, 1, 1, 0.196078)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ha83k"]
bg_color = Color(1, 1, 1, 0.392157)
corner_radius_top_left = 5
corner_radius_top_right = 5
corner_radius_bottom_right = 5
corner_radius_bottom_left = 5

[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_dgecf"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ousiv"]

[node name="BlockCategoryButton" type="MarginContainer"]
custom_minimum_size = Vector2(150, 0)
offset_right = 148.0
offset_bottom = 32.0
script = ExtResource("1_pxxnl")

[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2

[node name="MarginContainer" type="MarginContainer" parent="HBoxContainer"]
custom_minimum_size = Vector2(40, 40)
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8

[node name="Panel" type="Panel" parent="HBoxContainer/MarginContainer"]
[node name="Panel" type="Panel" parent="."]
unique_name_in_owner = true
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_eogpc")

[node name="Label" type="Label" parent="HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Example"
theme_override_styles/panel = SubResource("StyleBoxFlat_w0e7p")

[node name="Button" type="Button" parent="."]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 4
tooltip_text = "Example"
mouse_default_cursor_shape = 2
theme_override_styles/normal = SubResource("StyleBoxEmpty_ousiv")
theme_override_styles/focus = SubResource("StyleBoxEmpty_dgecf")
theme_override_styles/hover = SubResource("StyleBoxFlat_fyk0j")
theme_override_styles/pressed = SubResource("StyleBoxFlat_ha83k")
theme_override_styles/focus = SubResource("StyleBoxEmpty_dgecf")
theme_override_styles/normal = SubResource("StyleBoxEmpty_ousiv")
icon = ExtResource("2_0c1ke")
icon_alignment = 1

[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
23 changes: 23 additions & 0 deletions addons/block_code/ui/picker/categories/icons/communication.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://d0agg8648xht3"
path="res://.godot/imported/communication.svg-1c0c83fe5e428cef3e6d7d530d940e5a.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}

[deps]

source_file="res://addons/block_code/ui/picker/categories/icons/communication.svg"
dest_files=["res://.godot/imported/communication.svg-1c0c83fe5e428cef3e6d7d530d940e5a.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=false
23 changes: 23 additions & 0 deletions addons/block_code/ui/picker/categories/icons/file_broken.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://g10ct6m5goi6"
path="res://.godot/imported/file_broken.svg-b3a1f0e4d54ed488e76a2c99c48cdeac.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}

[deps]

source_file="res://addons/block_code/ui/picker/categories/icons/file_broken.svg"
dest_files=["res://.godot/imported/file_broken.svg-b3a1f0e4d54ed488e76a2c99c48cdeac.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=false
23 changes: 23 additions & 0 deletions addons/block_code/ui/picker/categories/icons/graphics.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions addons/block_code/ui/picker/categories/icons/graphics.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bfvq21qp2l363"
path="res://.godot/imported/graphics.svg-cb4f23d8db2eb8b1314d97d84a9d0f87.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}

[deps]

source_file="res://addons/block_code/ui/picker/categories/icons/graphics.svg"
dest_files=["res://.godot/imported/graphics.svg-cb4f23d8db2eb8b1314d97d84a9d0f87.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=false
23 changes: 23 additions & 0 deletions addons/block_code/ui/picker/categories/icons/info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions addons/block_code/ui/picker/categories/icons/info.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bw76iiilnqfsn"
path="res://.godot/imported/info.svg-ea93806d088f2cc7be28fcec5db89f8b.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}

[deps]

source_file="res://addons/block_code/ui/picker/categories/icons/info.svg"
dest_files=["res://.godot/imported/info.svg-ea93806d088f2cc7be28fcec5db89f8b.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=false
23 changes: 23 additions & 0 deletions addons/block_code/ui/picker/categories/icons/input.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9d10248

Please sign in to comment.