-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from endlessm/scratch-like-categories
Scratch-like category UI
- Loading branch information
Showing
9 changed files
with
211 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
addons/block_code/ui/picker/categories/block_category_button.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@tool | ||
class_name BlockCategoryButton | ||
extends MarginContainer | ||
|
||
signal selected | ||
|
||
var category: BlockCategory | ||
|
||
@onready var _panel := %Panel | ||
@onready var _label := %Label | ||
|
||
|
||
func _ready(): | ||
if not category: | ||
category = BlockCategory.new("Example", Color.RED) | ||
|
||
var new_stylebox: StyleBoxFlat = _panel.get_theme_stylebox("panel").duplicate() | ||
new_stylebox.bg_color = category.color | ||
|
||
_panel.add_theme_stylebox_override("panel", new_stylebox) | ||
|
||
_label.text = category.name | ||
|
||
|
||
func _on_button_pressed(): | ||
selected.emit(category) |
57 changes: 57 additions & 0 deletions
57
addons/block_code/ui/picker/categories/block_category_button.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
[gd_scene load_steps=7 format=3 uid="uid://bdtetj0gs45hv"] | ||
|
||
[ext_resource type="Script" path="res://addons/block_code/ui/picker/categories/block_category_button.gd" id="1_pxxnl"] | ||
|
||
[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="StyleBoxEmpty" id="StyleBoxEmpty_ousiv"] | ||
|
||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_fyk0j"] | ||
bg_color = Color(1, 1, 1, 0.196078) | ||
|
||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ha83k"] | ||
bg_color = Color(1, 1, 1, 0.392157) | ||
|
||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_dgecf"] | ||
|
||
[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"] | ||
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" | ||
|
||
[node name="Button" type="Button" parent="."] | ||
layout_mode = 2 | ||
mouse_default_cursor_shape = 2 | ||
theme_override_styles/normal = SubResource("StyleBoxEmpty_ousiv") | ||
theme_override_styles/hover = SubResource("StyleBoxFlat_fyk0j") | ||
theme_override_styles/pressed = SubResource("StyleBoxFlat_ha83k") | ||
theme_override_styles/focus = SubResource("StyleBoxEmpty_dgecf") | ||
|
||
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.