mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Implement shrink option (#376)
* Add shrink option that allow change default shrink Shrink option allow to scale the godot application. This path enable dynamic change of this value in the options. * Fix the computation of cursor location For an unknown reason the function get_local_mouse_position return incorrect current_pixel when shrink is not 1. This path compute the transformation manually and povide correct values for any shrink value.
This commit is contained in:
parent
613dc9f0c8
commit
279228daba
|
@ -45,6 +45,7 @@ var default_clear_color := Color.gray
|
|||
# Preferences
|
||||
var pressure_sensitivity_mode = Pressure_Sensitivity.NONE
|
||||
var open_last_project := false
|
||||
var shrink := 1.0
|
||||
var smooth_zoom := true
|
||||
var theme_type : int = Theme_Types.DARK
|
||||
var default_image_width := 64
|
||||
|
|
|
@ -67,6 +67,9 @@ func setup_application_window_size() -> void:
|
|||
# Set a minimum window size to prevent UI elements from collapsing on each other.
|
||||
OS.min_window_size = Vector2(1024, 576)
|
||||
|
||||
get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_DISABLED,
|
||||
SceneTree.STRETCH_ASPECT_IGNORE, Vector2(1014,576), Global.shrink)
|
||||
|
||||
# Restore the window position/size if values are present in the configuration cache
|
||||
if Global.config_cache.has_section_key("window", "screen"):
|
||||
OS.current_screen = Global.config_cache.get_value("window", "screen")
|
||||
|
|
|
@ -3,6 +3,7 @@ extends AcceptDialog
|
|||
# Preferences table: [Prop name in Global, relative node path, value type, default value]
|
||||
var preferences = [
|
||||
["open_last_project", "Startup/StartupContainer/OpenLastProject", "pressed", Global.open_last_project],
|
||||
["shrink", "Startup/ShrinkContainer/ShrinkHSlider", "value", Global.shrink],
|
||||
["smooth_zoom", "Canvas/ZoomOptions/SmoothZoom", "pressed", Global.smooth_zoom],
|
||||
["pressure_sensitivity_mode", "Startup/PressureSentivity/PressureSensitivityOptionButton", "selected", Global.pressure_sensitivity_mode],
|
||||
["show_left_tool_icon", "Indicators/IndicatorsContainer/LeftToolIconCheckbox", "pressed", Global.show_left_tool_icon],
|
||||
|
@ -36,6 +37,7 @@ onready var list : ItemList = $HSplitContainer/List
|
|||
onready var right_side : VBoxContainer = $HSplitContainer/ScrollContainer/VBoxContainer
|
||||
onready var autosave_interval : SpinBox = $HSplitContainer/ScrollContainer/VBoxContainer/Backup/AutosaveContainer/AutosaveInterval
|
||||
onready var restore_default_button_scene = preload("res://src/Preferences/RestoreDefaultButton.tscn")
|
||||
onready var shrink_label : Label = $HSplitContainer/ScrollContainer/VBoxContainer/Startup/ShrinkContainer/ShrinkLabel
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
@ -172,3 +174,15 @@ func _on_List_item_selected(index : int) -> void:
|
|||
if OS.get_name() == "HTML5":
|
||||
content_list.erase("Startup")
|
||||
child.visible = child.name == content_list[index]
|
||||
|
||||
|
||||
func _on_HSlider_value_changed(value):
|
||||
shrink_label.text = str(value)
|
||||
|
||||
|
||||
func _on_ShrinkApplyButton_pressed():
|
||||
get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_DISABLED,
|
||||
SceneTree.STRETCH_ASPECT_IGNORE, Vector2(1014,576), Global.shrink)
|
||||
Global.preferences_dialog.popup_centered(Vector2(400, 280))
|
||||
Global.camera.zoom_100()
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
[sub_resource type="ButtonGroup" id=1]
|
||||
|
||||
[node name="PreferencesDialog" type="AcceptDialog"]
|
||||
visible = true
|
||||
margin_left = -3.0
|
||||
margin_top = 9.0
|
||||
margin_right = 419.0
|
||||
|
@ -51,12 +52,12 @@ size_flags_horizontal = 3
|
|||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/ScrollContainer"]
|
||||
margin_right = 498.0
|
||||
margin_bottom = 24.0
|
||||
margin_bottom = 48.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Startup" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
||||
margin_right = 498.0
|
||||
margin_bottom = 24.0
|
||||
margin_bottom = 48.0
|
||||
|
||||
[node name="StartupContainer" type="HBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Startup"]
|
||||
margin_right = 498.0
|
||||
|
@ -78,9 +79,9 @@ text = "On"
|
|||
|
||||
[node name="PressureSentivity" type="HBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Startup"]
|
||||
visible = false
|
||||
margin_top = 100.0
|
||||
margin_right = 506.0
|
||||
margin_bottom = 120.0
|
||||
margin_top = 28.0
|
||||
margin_right = 498.0
|
||||
margin_bottom = 48.0
|
||||
|
||||
[node name="PressureSensitivityLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Startup/PressureSentivity"]
|
||||
margin_top = 3.0
|
||||
|
@ -96,6 +97,44 @@ text = "Affect Brush's Alpha"
|
|||
items = [ "None", null, false, 0, null, "Affect Brush's Alpha", null, false, 1, null ]
|
||||
selected = 1
|
||||
|
||||
[node name="ShrinkContainer" type="HBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer/Startup"]
|
||||
margin_top = 28.0
|
||||
margin_right = 498.0
|
||||
margin_bottom = 48.0
|
||||
|
||||
[node name="Label" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Startup/ShrinkContainer"]
|
||||
margin_top = 3.0
|
||||
margin_right = 68.0
|
||||
margin_bottom = 17.0
|
||||
text = "Shrink GUI"
|
||||
|
||||
[node name="ShrinkLabel" type="Label" parent="HSplitContainer/ScrollContainer/VBoxContainer/Startup/ShrinkContainer"]
|
||||
margin_left = 72.0
|
||||
margin_top = 3.0
|
||||
margin_right = 122.0
|
||||
margin_bottom = 17.0
|
||||
rect_min_size = Vector2( 50, 0 )
|
||||
text = "1"
|
||||
align = 2
|
||||
|
||||
[node name="ShrinkHSlider" type="HSlider" parent="HSplitContainer/ScrollContainer/VBoxContainer/Startup/ShrinkContainer"]
|
||||
margin_left = 126.0
|
||||
margin_right = 446.0
|
||||
margin_bottom = 16.0
|
||||
size_flags_horizontal = 3
|
||||
min_value = 1.0
|
||||
max_value = 4.0
|
||||
step = 0.5
|
||||
value = 1.0
|
||||
tick_count = 7
|
||||
ticks_on_borders = true
|
||||
|
||||
[node name="ShrinkApplyButton" type="Button" parent="HSplitContainer/ScrollContainer/VBoxContainer/Startup/ShrinkContainer"]
|
||||
margin_left = 450.0
|
||||
margin_right = 498.0
|
||||
margin_bottom = 20.0
|
||||
text = "Apply"
|
||||
|
||||
[node name="Languages" type="VBoxContainer" parent="HSplitContainer/ScrollContainer/VBoxContainer"]
|
||||
visible = false
|
||||
margin_top = 184.0
|
||||
|
@ -939,6 +978,8 @@ __meta__ = {
|
|||
[connection signal="about_to_show" from="." to="." method="_on_PreferencesDialog_about_to_show"]
|
||||
[connection signal="popup_hide" from="." to="." method="_on_PreferencesDialog_popup_hide"]
|
||||
[connection signal="item_selected" from="HSplitContainer/List" to="." method="_on_List_item_selected"]
|
||||
[connection signal="value_changed" from="HSplitContainer/ScrollContainer/VBoxContainer/Startup/ShrinkContainer/ShrinkHSlider" to="." method="_on_HSlider_value_changed"]
|
||||
[connection signal="pressed" from="HSplitContainer/ScrollContainer/VBoxContainer/Startup/ShrinkContainer/ShrinkApplyButton" to="." method="_on_ShrinkApplyButton_pressed"]
|
||||
[connection signal="item_selected" from="HSplitContainer/ScrollContainer/VBoxContainer/Shortcuts/HBoxContainer/PresetOptionButton" to="HSplitContainer/ScrollContainer/VBoxContainer/Shortcuts" method="_on_PresetOptionButton_item_selected"]
|
||||
[connection signal="confirmed" from="Popups/ShortcutSelector" to="HSplitContainer/ScrollContainer/VBoxContainer/Shortcuts" method="_on_ShortcutSelector_confirmed"]
|
||||
[connection signal="popup_hide" from="Popups/ShortcutSelector" to="HSplitContainer/ScrollContainer/VBoxContainer/Shortcuts" method="_on_ShortcutSelector_popup_hide"]
|
||||
|
|
|
@ -50,7 +50,10 @@ func _input(event : InputEvent) -> void:
|
|||
# elif not get_viewport_rect().has_point(event.position):
|
||||
# return
|
||||
|
||||
current_pixel = get_local_mouse_position() + location
|
||||
#current_pixel = get_local_mouse_position() + location
|
||||
var tmp_transform = get_canvas_transform().affine_inverse()
|
||||
var tmp_position = Global.main_viewport.get_local_mouse_position()
|
||||
current_pixel = tmp_transform.basis_xform(tmp_position)+tmp_transform.origin
|
||||
|
||||
if Global.has_focus:
|
||||
update()
|
||||
|
|
Loading…
Reference in a new issue