Skip to content

Commit

Permalink
Add shrink option that allow change default shrink
Browse files Browse the repository at this point in the history
Shrink option allow to scale the godot application. This path enable
dynamic change of this value in the options.
  • Loading branch information
gschwind committed Nov 7, 2020
1 parent 320f1a4 commit 774f7df
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Autoload/Global.gd
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,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
Expand Down
3 changes: 3 additions & 0 deletions src/Main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ func setup_application_window_size() -> void:
return
# 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(1024,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"):
Expand Down
12 changes: 12 additions & 0 deletions src/Preferences/PreferencesDialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -35,6 +36,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:
Expand Down Expand Up @@ -171,3 +173,13 @@ 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))
51 changes: 46 additions & 5 deletions src/Preferences/PreferencesDialog.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -912,6 +951,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"]

0 comments on commit 774f7df

Please sign in to comment.