mirror of
https://github.com/Relintai/MemR.git
synced 2025-02-06 16:26:04 +01:00
Now the images are fitted into the image container.
This commit is contained in:
parent
9c0a752045
commit
1efd1926b2
@ -1,5 +1,7 @@
|
|||||||
extends PanelContainer
|
extends PanelContainer
|
||||||
|
|
||||||
|
export(NodePath) var zoom_slider_path : NodePath
|
||||||
|
|
||||||
var mouse_down : bool = false
|
var mouse_down : bool = false
|
||||||
var mouse_pointer : int = 0
|
var mouse_pointer : int = 0
|
||||||
|
|
||||||
@ -8,6 +10,22 @@ var vscrollbar : VScrollBar
|
|||||||
|
|
||||||
var zoom : float = 1
|
var zoom : float = 1
|
||||||
|
|
||||||
|
var _zoom_slider : VSlider
|
||||||
|
|
||||||
|
func update_zoom_to_fit_width() -> void:
|
||||||
|
var cs : Vector2 = get_tex_size()
|
||||||
|
|
||||||
|
if cs.x < 0.0000001 || cs.y < 0.0000001:
|
||||||
|
_zoom_slider.value = 1
|
||||||
|
return
|
||||||
|
|
||||||
|
var max_axis : int = cs.max_axis()
|
||||||
|
|
||||||
|
if max_axis == Vector2.AXIS_X:
|
||||||
|
_zoom_slider.value = get_parent().rect_size.x / cs.x
|
||||||
|
else:
|
||||||
|
_zoom_slider.value = get_parent().rect_size.y / cs.y
|
||||||
|
|
||||||
func _gui_input(event: InputEvent) -> void:
|
func _gui_input(event: InputEvent) -> void:
|
||||||
if event.is_echo():
|
if event.is_echo():
|
||||||
return
|
return
|
||||||
@ -36,6 +54,8 @@ 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()
|
||||||
|
|
||||||
|
_zoom_slider = get_node(zoom_slider_path)
|
||||||
|
|
||||||
func udpate_minimum_size() -> void:
|
func udpate_minimum_size() -> void:
|
||||||
var active_node : Control
|
var active_node : Control
|
||||||
for c in get_children():
|
for c in get_children():
|
||||||
@ -43,16 +63,28 @@ func udpate_minimum_size() -> void:
|
|||||||
active_node = c
|
active_node = c
|
||||||
break
|
break
|
||||||
|
|
||||||
|
var cs : Vector2 = get_tex_size()
|
||||||
|
|
||||||
|
cs.x *= zoom
|
||||||
|
cs.y *= zoom
|
||||||
|
|
||||||
|
rect_min_size = cs
|
||||||
|
|
||||||
|
func get_tex_size() -> Vector2:
|
||||||
|
var active_node : Control
|
||||||
|
for c in get_children():
|
||||||
|
if c.is_visible_in_tree():
|
||||||
|
active_node = c
|
||||||
|
break
|
||||||
|
|
||||||
var cs : Vector2 = Vector2(0, 0)
|
var cs : Vector2 = Vector2(0, 0)
|
||||||
|
|
||||||
if active_node is TextureRect:
|
if active_node is TextureRect:
|
||||||
var tr : TextureRect = active_node as TextureRect
|
var tr : TextureRect = active_node as TextureRect
|
||||||
|
|
||||||
cs = Vector2(tr.texture.get_width(), tr.texture.get_height())
|
cs = Vector2(tr.texture.get_width(), tr.texture.get_height())
|
||||||
cs.x *= zoom
|
|
||||||
cs.y *= zoom
|
|
||||||
|
|
||||||
rect_min_size = cs
|
return cs
|
||||||
|
|
||||||
func _on_ZoomSlider_value_changed(value: float) -> void:
|
func _on_ZoomSlider_value_changed(value: float) -> void:
|
||||||
if value < 0.00000001:
|
if value < 0.00000001:
|
||||||
|
@ -5,12 +5,12 @@ var target_folder : String
|
|||||||
|
|
||||||
var shell_script_name : String = "apply.sh"
|
var shell_script_name : String = "apply.sh"
|
||||||
|
|
||||||
|
var _texture_container : Control
|
||||||
var _texture_rect : TextureRect
|
var _texture_rect : TextureRect
|
||||||
var _gif_rect : TextureRect
|
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
|
||||||
@ -128,7 +128,8 @@ func next_image() -> void:
|
|||||||
else:
|
else:
|
||||||
_gif_rect.show()
|
_gif_rect.show()
|
||||||
|
|
||||||
_zoom_slider.value = 1
|
_texture_container.update_zoom_to_fit_width()
|
||||||
|
|
||||||
|
|
||||||
func evaluate_folders() -> void:
|
func evaluate_folders() -> void:
|
||||||
_folders.clear()
|
_folders.clear()
|
||||||
@ -296,6 +297,7 @@ func _on_NewSubCategoryPopup_confirmed() -> void:
|
|||||||
|
|
||||||
func _notification(what: int) -> void:
|
func _notification(what: int) -> void:
|
||||||
if what == NOTIFICATION_READY:
|
if what == NOTIFICATION_READY:
|
||||||
|
_texture_container = get_node("HBoxContainer/ScrollContainer/VBoxContainer") as Control
|
||||||
_texture_rect = get_node("HBoxContainer/ScrollContainer/VBoxContainer/TextureRect") as TextureRect
|
_texture_rect = get_node("HBoxContainer/ScrollContainer/VBoxContainer/TextureRect") as TextureRect
|
||||||
_gif_rect = get_node("HBoxContainer/ScrollContainer/VBoxContainer/GifRect") as TextureRect
|
_gif_rect = get_node("HBoxContainer/ScrollContainer/VBoxContainer/GifRect") as TextureRect
|
||||||
_error_label = get_node("HBoxContainer/ScrollContainer/VBoxContainer/ErrorLabel") as Label
|
_error_label = get_node("HBoxContainer/ScrollContainer/VBoxContainer/ErrorLabel") as Label
|
||||||
@ -308,8 +310,6 @@ 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
|
|
||||||
|
|
||||||
_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():
|
||||||
|
@ -10,14 +10,14 @@ anchor_bottom = 1.0
|
|||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||||
margin_right = 600.0
|
margin_right = 1024.0
|
||||||
margin_bottom = 500.0
|
margin_bottom = 700.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
|
||||||
[node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer"]
|
[node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer"]
|
||||||
margin_right = 580.0
|
margin_right = 1004.0
|
||||||
margin_bottom = 500.0
|
margin_bottom = 700.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
|
||||||
@ -25,6 +25,7 @@ size_flags_vertical = 3
|
|||||||
margin_right = 14.0
|
margin_right = 14.0
|
||||||
margin_bottom = 14.0
|
margin_bottom = 14.0
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
|
zoom_slider_path = NodePath("../../ZoomSlider")
|
||||||
|
|
||||||
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/ScrollContainer/VBoxContainer"]
|
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/ScrollContainer/VBoxContainer"]
|
||||||
visible = false
|
visible = false
|
||||||
@ -49,9 +50,9 @@ margin_top = 4.0
|
|||||||
margin_bottom = 18.0
|
margin_bottom = 18.0
|
||||||
|
|
||||||
[node name="ZoomSlider" type="VSlider" parent="HBoxContainer"]
|
[node name="ZoomSlider" type="VSlider" parent="HBoxContainer"]
|
||||||
margin_left = 584.0
|
margin_left = 1008.0
|
||||||
margin_right = 600.0
|
margin_right = 1024.0
|
||||||
margin_bottom = 500.0
|
margin_bottom = 700.0
|
||||||
max_value = 5.0
|
max_value = 5.0
|
||||||
step = 0.0
|
step = 0.0
|
||||||
value = 2.0
|
value = 2.0
|
||||||
@ -59,55 +60,55 @@ allow_greater = true
|
|||||||
tick_count = 6
|
tick_count = 6
|
||||||
|
|
||||||
[node name="Categories" type="HBoxContainer" parent="."]
|
[node name="Categories" type="HBoxContainer" parent="."]
|
||||||
margin_top = 504.0
|
margin_top = 704.0
|
||||||
margin_right = 600.0
|
margin_right = 1024.0
|
||||||
margin_bottom = 524.0
|
margin_bottom = 724.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
[node name="Categories" type="OptionButton" parent="Categories"]
|
[node name="Categories" type="OptionButton" parent="Categories"]
|
||||||
margin_right = 576.0
|
margin_right = 1000.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
[node name="Add" type="Button" parent="Categories"]
|
[node name="Add" type="Button" parent="Categories"]
|
||||||
margin_left = 580.0
|
margin_left = 1004.0
|
||||||
margin_right = 600.0
|
margin_right = 1024.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
text = "+"
|
text = "+"
|
||||||
|
|
||||||
[node name="SubCategoies" type="HBoxContainer" parent="."]
|
[node name="SubCategoies" type="HBoxContainer" parent="."]
|
||||||
margin_top = 528.0
|
margin_top = 728.0
|
||||||
margin_right = 600.0
|
margin_right = 1024.0
|
||||||
margin_bottom = 548.0
|
margin_bottom = 748.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
[node name="SubCategoies" type="OptionButton" parent="SubCategoies"]
|
[node name="SubCategoies" type="OptionButton" parent="SubCategoies"]
|
||||||
margin_right = 576.0
|
margin_right = 1000.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
[node name="Add" type="Button" parent="SubCategoies"]
|
[node name="Add" type="Button" parent="SubCategoies"]
|
||||||
margin_left = 580.0
|
margin_left = 1004.0
|
||||||
margin_right = 600.0
|
margin_right = 1024.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
text = "+"
|
text = "+"
|
||||||
|
|
||||||
[node name="Apply" type="Button" parent="."]
|
[node name="Apply" type="Button" parent="."]
|
||||||
margin_top = 552.0
|
margin_top = 752.0
|
||||||
margin_right = 600.0
|
margin_right = 1024.0
|
||||||
margin_bottom = 572.0
|
margin_bottom = 772.0
|
||||||
text = "Apply"
|
text = "Apply"
|
||||||
|
|
||||||
[node name="Skip" type="Button" parent="."]
|
[node name="Skip" type="Button" parent="."]
|
||||||
margin_top = 576.0
|
margin_top = 776.0
|
||||||
margin_right = 600.0
|
margin_right = 1024.0
|
||||||
margin_bottom = 596.0
|
margin_bottom = 796.0
|
||||||
text = "Skip"
|
text = "Skip"
|
||||||
|
|
||||||
[node name="Control" type="Control" parent="."]
|
[node name="Control" type="Control" parent="."]
|
||||||
margin_top = 600.0
|
margin_top = 800.0
|
||||||
margin_right = 600.0
|
margin_right = 1024.0
|
||||||
margin_bottom = 600.0
|
margin_bottom = 800.0
|
||||||
|
|
||||||
[node name="NewCategoryPopup" type="ConfirmationDialog" parent="Control"]
|
[node name="NewCategoryPopup" type="ConfirmationDialog" parent="Control"]
|
||||||
margin_left = 291.0
|
margin_left = 291.0
|
||||||
|
Loading…
Reference in New Issue
Block a user