Added a slider for zoom.

This commit is contained in:
Relintai 2022-12-10 19:58:36 +01:00
parent 1fe8fb0469
commit d744445bb3
3 changed files with 38 additions and 8 deletions

View File

@ -31,3 +31,10 @@ func _notification(what: int) -> void:
hscrollbar = sc.get_h_scrollbar() hscrollbar = sc.get_h_scrollbar()
vscrollbar = sc.get_v_scrollbar() vscrollbar = sc.get_v_scrollbar()
func _on_ZoomSlider_value_changed(value: float) -> void:
if value < 0.00000001:
value = 0.00000001
rect_scale = Vector2(value, value)

View File

@ -10,6 +10,7 @@ var _gif_rect : TextureRect
var _error_label : Label var _error_label : Label
var _categories_ob : OptionButton var _categories_ob : OptionButton
var _sub_categories_ob : OptionButton var _sub_categories_ob : OptionButton
var _zoom_slider : VSlider
var _categories_popup : ConfirmationDialog var _categories_popup : ConfirmationDialog
var _categories_popup_line_edit : LineEdit var _categories_popup_line_edit : LineEdit
@ -127,6 +128,8 @@ func next_image() -> void:
else: else:
_gif_rect.show() _gif_rect.show()
_zoom_slider.value = 1
func evaluate_folders() -> void: func evaluate_folders() -> void:
_folders.clear() _folders.clear()
@ -293,9 +296,9 @@ func _on_NewSubCategoryPopup_confirmed() -> void:
func _notification(what: int) -> void: func _notification(what: int) -> void:
if what == NOTIFICATION_READY: if what == NOTIFICATION_READY:
_texture_rect = get_node("ScrollContainer/VBoxContainer/TextureRect") as TextureRect _texture_rect = get_node("HBoxContainer/ScrollContainer/VBoxContainer/TextureRect") as TextureRect
_gif_rect = get_node("ScrollContainer/VBoxContainer/GifRect") as TextureRect _gif_rect = get_node("HBoxContainer/ScrollContainer/VBoxContainer/GifRect") as TextureRect
_error_label = get_node("ScrollContainer/VBoxContainer/ErrorLabel") as Label _error_label = get_node("HBoxContainer/ScrollContainer/VBoxContainer/ErrorLabel") as Label
_categories_ob = get_node("Categories/Categories") as OptionButton _categories_ob = get_node("Categories/Categories") as OptionButton
_sub_categories_ob = get_node("SubCategoies/SubCategoies") as OptionButton _sub_categories_ob = get_node("SubCategoies/SubCategoies") as OptionButton
@ -305,6 +308,9 @@ func _notification(what: int) -> void:
_sub_categories_popup = get_node("Control/NewSubCategoryPopup") as ConfirmationDialog _sub_categories_popup = get_node("Control/NewSubCategoryPopup") as ConfirmationDialog
_sub_categories_popup_line_edit = get_node("Control/NewSubCategoryPopup/VBoxContainer/LineEdit") as LineEdit _sub_categories_popup_line_edit = get_node("Control/NewSubCategoryPopup/VBoxContainer/LineEdit") as LineEdit
_zoom_slider = get_node("HBoxContainer/ZoomSlider") as VSlider
_zoom_slider.value = 1
_texture_rect.texture = ImageTexture.new() _texture_rect.texture = ImageTexture.new()
elif what == NOTIFICATION_VISIBILITY_CHANGED: elif what == NOTIFICATION_VISIBILITY_CHANGED:
if is_visible_in_tree(): if is_visible_in_tree():

View File

@ -9,28 +9,44 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="ScrollContainer" type="ScrollContainer" parent="."] [node name="HBoxContainer" type="HBoxContainer" parent="."]
margin_right = 600.0 margin_right = 600.0
margin_bottom = 500.0 margin_bottom = 500.0
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
[node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer"] [node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer"]
margin_right = 580.0
margin_bottom = 500.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer/ScrollContainer"]
script = ExtResource( 3 ) script = ExtResource( 3 )
[node name="TextureRect" type="TextureRect" parent="ScrollContainer/VBoxContainer"] [node name="TextureRect" type="TextureRect" parent="HBoxContainer/ScrollContainer/VBoxContainer"]
[node name="GifRect" parent="ScrollContainer/VBoxContainer" instance=ExtResource( 2 )] [node name="GifRect" parent="HBoxContainer/ScrollContainer/VBoxContainer" instance=ExtResource( 2 )]
visible = false visible = false
margin_top = 4.0 margin_top = 4.0
margin_right = 0.0 margin_right = 0.0
margin_bottom = 4.0 margin_bottom = 4.0
[node name="ErrorLabel" type="Label" parent="ScrollContainer/VBoxContainer"] [node name="ErrorLabel" type="Label" parent="HBoxContainer/ScrollContainer/VBoxContainer"]
visible = false visible = false
margin_top = 4.0 margin_top = 4.0
margin_bottom = 18.0 margin_bottom = 18.0
[node name="ZoomSlider" type="VSlider" parent="HBoxContainer"]
margin_left = 584.0
margin_right = 600.0
margin_bottom = 500.0
max_value = 5.0
step = 0.0
value = 1.0
allow_greater = true
tick_count = 6
[node name="Categories" type="HBoxContainer" parent="."] [node name="Categories" type="HBoxContainer" parent="."]
margin_top = 504.0 margin_top = 504.0
margin_right = 600.0 margin_right = 600.0
@ -128,6 +144,7 @@ margin_top = 18.0
margin_right = 184.0 margin_right = 184.0
margin_bottom = 42.0 margin_bottom = 42.0
[connection signal="value_changed" from="HBoxContainer/ZoomSlider" to="HBoxContainer/ScrollContainer/VBoxContainer" method="_on_ZoomSlider_value_changed"]
[connection signal="item_selected" from="Categories/Categories" to="." method="_on_Categories_item_selected"] [connection signal="item_selected" from="Categories/Categories" to="." method="_on_Categories_item_selected"]
[connection signal="pressed" from="Categories/Add" to="." method="_on_Categories_Add_pressed"] [connection signal="pressed" from="Categories/Add" to="." method="_on_Categories_Add_pressed"]
[connection signal="item_selected" from="SubCategoies/SubCategoies" to="." method="_on_SubCategoies_item_selected"] [connection signal="item_selected" from="SubCategoies/SubCategoies" to="." method="_on_SubCategoies_item_selected"]