mirror of
https://github.com/Relintai/MemR.git
synced 2024-11-12 10:25:05 +01:00
Better zoom implementation.
This commit is contained in:
parent
d744445bb3
commit
13ab0f1723
@ -7,26 +7,26 @@ anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
margin_right = 1024.0
|
||||
margin_right = 600.0
|
||||
margin_bottom = 600.0
|
||||
custom_constants/separation = 24
|
||||
alignment = 1
|
||||
|
||||
[node name="Sort" type="Button" parent="VBoxContainer"]
|
||||
margin_top = 246.0
|
||||
margin_right = 1024.0
|
||||
margin_right = 600.0
|
||||
margin_bottom = 266.0
|
||||
text = "Sort"
|
||||
|
||||
[node name="Settings" type="Button" parent="VBoxContainer"]
|
||||
margin_top = 290.0
|
||||
margin_right = 1024.0
|
||||
margin_right = 600.0
|
||||
margin_bottom = 310.0
|
||||
text = "Settings"
|
||||
|
||||
[node name="Exit" type="Button" parent="VBoxContainer"]
|
||||
margin_top = 334.0
|
||||
margin_right = 1024.0
|
||||
margin_right = 600.0
|
||||
margin_bottom = 354.0
|
||||
text = "Exit"
|
||||
script = ExtResource( 1 )
|
||||
|
@ -1,4 +1,4 @@
|
||||
extends VBoxContainer
|
||||
extends PanelContainer
|
||||
|
||||
var mouse_down : bool = false
|
||||
var mouse_pointer : int = 0
|
||||
@ -6,6 +6,8 @@ var mouse_pointer : int = 0
|
||||
var hscrollbar : HScrollBar
|
||||
var vscrollbar : VScrollBar
|
||||
|
||||
var zoom : float = 1
|
||||
|
||||
func _gui_input(event: InputEvent) -> void:
|
||||
if event.is_echo():
|
||||
return
|
||||
@ -15,6 +17,7 @@ func _gui_input(event: InputEvent) -> void:
|
||||
|
||||
mouse_down = iemb.pressed
|
||||
mouse_pointer == event.device
|
||||
accept_event()
|
||||
|
||||
elif event is InputEventMouseMotion:
|
||||
var iemm : InputEventMouseMotion = event
|
||||
@ -24,6 +27,7 @@ func _gui_input(event: InputEvent) -> void:
|
||||
|
||||
hscrollbar.value -= iemm.relative.x
|
||||
vscrollbar.value -= iemm.relative.y
|
||||
accept_event()
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
if what == NOTIFICATION_READY:
|
||||
@ -31,10 +35,28 @@ func _notification(what: int) -> void:
|
||||
|
||||
hscrollbar = sc.get_h_scrollbar()
|
||||
vscrollbar = sc.get_v_scrollbar()
|
||||
|
||||
func udpate_minimum_size() -> void:
|
||||
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)
|
||||
|
||||
if active_node is TextureRect:
|
||||
var tr : TextureRect = active_node as TextureRect
|
||||
|
||||
cs = Vector2(tr.texture.get_width(), tr.texture.get_height())
|
||||
cs.x *= zoom
|
||||
cs.y *= zoom
|
||||
|
||||
rect_min_size = cs
|
||||
|
||||
func _on_ZoomSlider_value_changed(value: float) -> void:
|
||||
if value < 0.00000001:
|
||||
value = 0.00000001
|
||||
|
||||
rect_scale = Vector2(value, value)
|
||||
zoom = value
|
||||
udpate_minimum_size()
|
||||
|
@ -309,7 +309,6 @@ func _notification(what: int) -> void:
|
||||
_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()
|
||||
elif what == NOTIFICATION_VISIBILITY_CHANGED:
|
||||
|
@ -21,16 +21,27 @@ margin_bottom = 500.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="HBoxContainer/ScrollContainer"]
|
||||
[node name="VBoxContainer" type="PanelContainer" parent="HBoxContainer/ScrollContainer"]
|
||||
margin_right = 14.0
|
||||
margin_bottom = 14.0
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="HBoxContainer/ScrollContainer/VBoxContainer"]
|
||||
visible = false
|
||||
margin_left = 7.0
|
||||
margin_top = 7.0
|
||||
margin_right = 7.0
|
||||
margin_bottom = 7.0
|
||||
expand = true
|
||||
stretch_mode = 1
|
||||
|
||||
[node name="GifRect" parent="HBoxContainer/ScrollContainer/VBoxContainer" instance=ExtResource( 2 )]
|
||||
visible = false
|
||||
margin_top = 4.0
|
||||
margin_right = 0.0
|
||||
margin_bottom = 4.0
|
||||
expand = true
|
||||
stretch_mode = 1
|
||||
|
||||
[node name="ErrorLabel" type="Label" parent="HBoxContainer/ScrollContainer/VBoxContainer"]
|
||||
visible = false
|
||||
@ -43,7 +54,7 @@ margin_right = 600.0
|
||||
margin_bottom = 500.0
|
||||
max_value = 5.0
|
||||
step = 0.0
|
||||
value = 1.0
|
||||
value = 2.0
|
||||
allow_greater = true
|
||||
tick_count = 6
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user