Skip to content

Commit 55acc2d

Browse files
authored
Merge pull request #188 from endlessm/zoom-label-enhancements
Zoom label enhancements
2 parents a5d1373 + 06aa75d commit 55acc2d

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

addons/block_code/ui/block_canvas/block_canvas.gd

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ const ZOOM_FACTOR: float = 1.1
3131
@onready var _open_scene_icon = _open_scene_button.get_theme_icon("Load", "EditorIcons")
3232

3333
@onready var _mouse_override: Control = %MouseOverride
34-
@onready var _zoom_label: Label = %ZoomLabel
34+
@onready var _zoom_button: Button = %ZoomButton
3535

3636
var _current_block_script: BlockScriptSerialization
3737
var _block_scenes_by_class = {}
3838
var _panning := false
3939
var zoom: float:
4040
set(value):
4141
_window.scale = Vector2(value, value)
42-
_zoom_label.text = "%.1fx" % value
42+
_zoom_button.text = "%.1fx" % value
4343
get:
4444
return _window.scale.x
4545

@@ -106,7 +106,7 @@ func block_script_selected(block_script: BlockScriptSerialization):
106106
zoom = 1
107107

108108
_window.visible = false
109-
_zoom_label.visible = false
109+
_zoom_button.visible = false
110110

111111
_empty_box.visible = false
112112
_selected_node_box.visible = false
@@ -118,7 +118,7 @@ func block_script_selected(block_script: BlockScriptSerialization):
118118
if block_script != null:
119119
_load_block_script(block_script)
120120
_window.visible = true
121-
_zoom_label.visible = true
121+
_zoom_button.visible = true
122122

123123
if block_script != _current_block_script:
124124
reset_window_position()
@@ -322,3 +322,8 @@ func set_mouse_override(override: bool):
322322
func generate_script_from_current_window(block_script: BlockScriptSerialization) -> String:
323323
# TODO: implement multiple windows
324324
return BlockTreeUtil.generate_script_from_nodes(_window.get_children(), block_script)
325+
326+
327+
func _on_zoom_button_pressed():
328+
zoom = 1.0
329+
reset_window_position()

addons/block_code/ui/block_canvas/block_canvas.tscn

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,12 @@ theme_override_constants/margin_top = 4
5858
theme_override_constants/margin_right = 4
5959
theme_override_constants/margin_bottom = 4
6060

61-
[node name="ZoomLabel" type="Label" parent="WindowContainer/Overlay/MarginContainer"]
61+
[node name="ZoomButton" type="Button" parent="WindowContainer/Overlay/MarginContainer"]
6262
unique_name_in_owner = true
63+
modulate = Color(1, 1, 1, 0.470588)
6364
layout_mode = 2
64-
theme_override_colors/font_color = Color(1, 1, 1, 0.196078)
65+
focus_mode = 0
6566
theme_override_font_sizes/font_size = 24
66-
text = "1x"
67-
horizontal_alignment = 2
6867

6968
[node name="MouseOverride" type="MarginContainer" parent="."]
7069
unique_name_in_owner = true
@@ -139,6 +138,7 @@ theme_type_variation = &"InspectorActionButton"
139138
text = "Override Block Code"
140139
icon = ExtResource("2_710vn")
141140

141+
[connection signal="pressed" from="WindowContainer/Overlay/MarginContainer/ZoomButton" to="." method="_on_zoom_button_pressed"]
142142
[connection signal="pressed" from="SelectedNodeBox/ButtonsBox/AddBlockCodeButton" to="." method="_on_add_block_code_button_pressed"]
143143
[connection signal="pressed" from="SelectedNodeWithBlockCodeBox/ButtonsBox/OpenSceneButton" to="." method="_on_open_scene_button_pressed"]
144144
[connection signal="pressed" from="SelectedNodeWithBlockCodeBox/ButtonsBox/ReplaceBlockCodeButton" to="." method="_on_replace_block_code_button_pressed"]

0 commit comments

Comments
 (0)