Skip to content

Commit c2f327c

Browse files
Improve SettingsMenu for mobile (#14)
- Adjusted settings menu layout to better support mobile screens. - Fixed horizontal overflow issues. - Removed the **Shortcuts** tab as it is not essential for mobile users. - It could be useful for those using a keyboard, so I'll reconsider its inclusion. - Removed UI scaling options (temporarily)
1 parent ff06151 commit c2f327c

File tree

4 files changed

+67
-71
lines changed

4 files changed

+67
-71
lines changed

src/autoload/HandlerGUI.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func _add_control(new_control: Control) -> void:
6868
menu_stack.append(overlay_ref)
6969
get_tree().root.add_child(overlay_ref)
7070
overlay_ref.add_child(new_control)
71-
new_control.set_anchors_and_offsets_preset(Control.PRESET_CENTER)
71+
new_control.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
7272
new_control.tree_exiting.connect(_remove_control.bind(overlay_ref))
7373

7474
func _remove_control(overlay_ref: ColorRect = null) -> void:

src/ui_parts/settings_menu.gd

Lines changed: 54 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ extends PanelContainer
22

33
const PaletteConfigWidget = preload("res://src/ui_widgets/palette_config.tscn")
44
const ShortcutConfigWidget = preload("res://src/ui_widgets/setting_shortcut.tscn")
5-
const ShortcutShowcaseWidget = preload("res://src/ui_widgets/presented_shortcut.tscn")
5+
#const ShortcutShowcaseWidget = preload("res://src/ui_widgets/presented_shortcut.tscn")
66
const SettingFrame = preload("res://src/ui_widgets/setting_frame.tscn")
77
const ProfileFrame = preload("res://src/ui_widgets/profile_frame.tscn")
88

@@ -46,7 +46,8 @@ func setup_tabs() -> void:
4646
var button_group := ButtonGroup.new()
4747
add_tab("formatting", Translator.translate("Formatting"), button_group)
4848
add_tab("palettes", Translator.translate("Palettes"), button_group)
49-
add_tab("shortcuts", Translator.translate("Shortcuts"), button_group)
49+
# Removing shortcuts tab as this is not really needed for mobile port.
50+
#add_tab("shortcuts", Translator.translate("Shortcuts"), button_group)
5051
add_tab("theming", Translator.translate("Theming"), button_group)
5152
add_tab("other", Translator.translate("Other"), button_group)
5253

@@ -113,32 +114,32 @@ func setup_content() -> void:
113114
vbox.size_flags_horizontal = Control.SIZE_EXPAND_FILL
114115
content_container.add_child(vbox)
115116
rebuild_palettes()
116-
"shortcuts":
117-
advice_panel.hide()
118-
var vbox := VBoxContainer.new()
119-
vbox.size_flags_horizontal = Control.SIZE_EXPAND_FILL
120-
vbox.add_theme_constant_override("separation", 6)
121-
content_container.add_child(vbox)
122-
var categories := HFlowContainer.new()
123-
var button_group := ButtonGroup.new()
124-
for tab_idx in shortcut_tab_names:
125-
var btn := Button.new()
126-
btn.toggle_mode = true
127-
btn.button_group = button_group
128-
btn.pressed.connect(show_shortcuts.bind(tab_idx))
129-
btn.text = get_translated_shortcut_tab(tab_idx)
130-
btn.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
131-
btn.focus_mode = Control.FOCUS_NONE
132-
btn.action_mode = BaseButton.ACTION_MODE_BUTTON_PRESS
133-
categories.add_child(btn)
134-
vbox.add_child(categories)
135-
var shortcuts := VBoxContainer.new()
136-
shortcuts.add_theme_constant_override("separation", 3)
137-
shortcuts.size_flags_horizontal = Control.SIZE_EXPAND_FILL
138-
shortcuts.size_flags_vertical = Control.SIZE_EXPAND_FILL
139-
vbox.add_child(shortcuts)
140-
categories.get_child(0).button_pressed = true
141-
categories.get_child(0).pressed.emit()
117+
#"shortcuts":
118+
#advice_panel.hide()
119+
#var vbox := VBoxContainer.new()
120+
#vbox.size_flags_horizontal = Control.SIZE_EXPAND_FILL
121+
#vbox.add_theme_constant_override("separation", 6)
122+
#content_container.add_child(vbox)
123+
#var categories := HFlowContainer.new()
124+
#var button_group := ButtonGroup.new()
125+
#for tab_idx in shortcut_tab_names:
126+
#var btn := Button.new()
127+
#btn.toggle_mode = true
128+
#btn.button_group = button_group
129+
#btn.pressed.connect(show_shortcuts.bind(tab_idx))
130+
#btn.text = get_translated_shortcut_tab(tab_idx)
131+
#btn.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
132+
#btn.focus_mode = Control.FOCUS_NONE
133+
#btn.action_mode = BaseButton.ACTION_MODE_BUTTON_PRESS
134+
#categories.add_child(btn)
135+
#vbox.add_child(categories)
136+
#var shortcuts := VBoxContainer.new()
137+
#shortcuts.add_theme_constant_override("separation", 3)
138+
#shortcuts.size_flags_horizontal = Control.SIZE_EXPAND_FILL
139+
#shortcuts.size_flags_vertical = Control.SIZE_EXPAND_FILL
140+
#vbox.add_child(shortcuts)
141+
#categories.get_child(0).button_pressed = true
142+
#categories.get_child(0).pressed.emit()
142143
"theming":
143144
advice_panel.hide()
144145
create_setting_container()
@@ -220,16 +221,18 @@ func setup_content() -> void:
220221
SaveData.HANDLE_SIZE_MIN, SaveData.HANDLE_SIZE_MAX)
221222
add_advice(Translator.translate(
222223
"Changes the visual size and grabbing area of handles."))
223-
current_setup_setting = "ui_scale"
224-
add_number_dropdown(Translator.translate("UI scale"),
225-
[0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0], false, false,
226-
SaveData.UI_SCALE_MIN, SaveData.UI_SCALE_MAX)
227-
add_advice(Translator.translate(
228-
"Changes the scale of the visual user interface."))
229-
current_setup_setting = "auto_ui_scale"
230-
add_checkbox(Translator.translate("Auto UI scale"))
231-
add_advice(Translator.translate(
232-
"Scales the user interface based on the screen size."))
224+
225+
# Temporarily hiding settings to change scale.
226+
#current_setup_setting = "ui_scale"
227+
#add_number_dropdown(Translator.translate("UI scale"),
228+
#[0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 4.0], false, false,
229+
#SaveData.UI_SCALE_MIN, SaveData.UI_SCALE_MAX)
230+
#add_advice(Translator.translate(
231+
#"Changes the scale of the visual user interface."))
232+
#current_setup_setting = "auto_ui_scale"
233+
#add_checkbox(Translator.translate("Auto UI scale"))
234+
#add_advice(Translator.translate(
235+
#"Scales the user interface based on the screen size."))
233236

234237
# Disable mouse wrap if not available.
235238
if not DisplayServer.has_feature(DisplayServer.FEATURE_MOUSE_WARP):
@@ -573,19 +576,19 @@ func show_formatter(category: String) -> void:
573576
add_checkbox(Translator.translate("Remove unnecessary parameters"))
574577

575578

576-
func show_shortcuts(category: String) -> void:
577-
var shortcuts_container := content_container.get_child(-1).get_child(-1)
578-
for child in shortcuts_container.get_children():
579-
child.queue_free()
580-
581-
for action in ShortcutUtils.get_shortcuts(category):
582-
var shortcut_config := ShortcutConfigWidget.instantiate() if\
583-
ShortcutUtils.is_shortcut_modifiable(action) else\
584-
ShortcutShowcaseWidget.instantiate()
585-
586-
shortcuts_container.add_child(shortcut_config)
587-
shortcut_config.label.text = TranslationUtils.get_shortcut_description(action)
588-
shortcut_config.setup(action)
579+
#func show_shortcuts(category: String) -> void:
580+
#var shortcuts_container := content_container.get_child(-1).get_child(-1)
581+
#for child in shortcuts_container.get_children():
582+
#child.queue_free()
583+
#
584+
#for action in ShortcutUtils.get_shortcuts(category):
585+
#var shortcut_config := ShortcutConfigWidget.instantiate() if\
586+
#ShortcutUtils.is_shortcut_modifiable(action) else\
587+
#ShortcutShowcaseWidget.instantiate()
588+
#
589+
#shortcuts_container.add_child(shortcut_config)
590+
#shortcut_config.label.text = TranslationUtils.get_shortcut_description(action)
591+
#shortcut_config.setup(action)
589592

590593
func create_setting_container() -> void:
591594
setting_container = VBoxContainer.new()

src/ui_parts/settings_menu.tscn

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
[gd_scene load_steps=3 format=3 uid="uid://1rylg17uwltw"]
22

3-
[ext_resource type="Script" path="res://src/ui_parts/settings_menu.gd" id="1_1gf4m"]
3+
[ext_resource type="Script" uid="uid://1rjr3yrqwueu" path="res://src/ui_parts/settings_menu.gd" id="1_1gf4m"]
44
[ext_resource type="Texture2D" uid="uid://c528knojuxbw6" path="res://assets/icons/Languages.svg" id="2_ndyp7"]
55

66
[node name="SettingsMenu" type="PanelContainer"]
7-
custom_minimum_size = Vector2(640, 400)
8-
anchors_preset = 8
9-
anchor_left = 0.5
10-
anchor_top = 0.5
11-
anchor_right = 0.5
12-
anchor_bottom = 0.5
13-
offset_left = -180.0
14-
offset_top = -128.0
15-
offset_right = 180.0
16-
offset_bottom = 128.0
7+
anchors_preset = 15
8+
anchor_right = 1.0
9+
anchor_bottom = 1.0
1710
grow_horizontal = 2
1811
grow_vertical = 2
1912
theme_type_variation = &"OverlayPanel"
@@ -30,29 +23,29 @@ focus_mode = 0
3023
mouse_default_cursor_shape = 2
3124
icon = ExtResource("2_ndyp7")
3225

33-
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
26+
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer"]
3427
layout_mode = 2
3528
size_flags_vertical = 3
3629
theme_override_constants/separation = 0
3730

38-
[node name="ContentPicker" type="PanelContainer" parent="VBoxContainer/HBoxContainer"]
39-
custom_minimum_size = Vector2(160, 0)
31+
[node name="ContentPicker" type="PanelContainer" parent="VBoxContainer/VBoxContainer"]
32+
custom_minimum_size = Vector2(0, 100)
4033
layout_mode = 2
4134
theme_type_variation = &"SideTabBar"
4235

43-
[node name="Tabs" type="VBoxContainer" parent="VBoxContainer/HBoxContainer/ContentPicker"]
36+
[node name="Tabs" type="VBoxContainer" parent="VBoxContainer/VBoxContainer/ContentPicker"]
4437
unique_name_in_owner = true
4538
layout_mode = 2
4639
size_flags_horizontal = 3
4740
theme_override_constants/separation = 0
4841

49-
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer/HBoxContainer"]
42+
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer/VBoxContainer"]
5043
layout_mode = 2
51-
size_flags_horizontal = 3
44+
size_flags_vertical = 3
5245
mouse_filter = 1
5346
theme_type_variation = &"SideBarContent"
5447

55-
[node name="ContentContainer" type="ScrollContainer" parent="VBoxContainer/HBoxContainer/PanelContainer"]
48+
[node name="ContentContainer" type="ScrollContainer" parent="VBoxContainer/VBoxContainer/PanelContainer"]
5649
unique_name_in_owner = true
5750
custom_minimum_size = Vector2(0, 120)
5851
layout_mode = 2

src/ui_widgets/setting_shortcut.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[gd_scene load_steps=3 format=3 uid="uid://b7fw7bodu5fbb"]
22

3-
[ext_resource type="Script" path="res://src/ui_widgets/setting_shortcut.gd" id="1_4c8oc"]
3+
[ext_resource type="Script" uid="uid://ds386q8jgqkr2" path="res://src/ui_widgets/setting_shortcut.gd" id="1_4c8oc"]
44
[ext_resource type="Texture2D" uid="uid://cvh3kwbucf2n1" path="res://assets/icons/Reload.svg" id="2_n8e0s"]
55

66
[node name="SettingShortcut" type="PanelContainer"]

0 commit comments

Comments
 (0)