Skip to content

Commit 9863db4

Browse files
Update to Godot 4.5 beta4 and misc changes (#51)
1 parent a624f86 commit 9863db4

27 files changed

Lines changed: 4440 additions & 4482 deletions

‎.github/workflows/build.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ env:
1111
# Which godot version to use for exporting.
1212
GODOT_VERSION: 4.5
1313
# Which godot release to use for exporting. (stable/rc/beta/alpha)
14-
GODOT_RELEASE: beta2
14+
GODOT_RELEASE: beta4
1515
# Used in the editor config file name. Do not change this for patch releases.
1616
GODOT_FEATURE_VERSION: 4.5
1717
# Commit hash
18-
GODOT_COMMIT_HASH: e1b4101e3
18+
GODOT_COMMIT_HASH: 2d113cc22
1919
PROJECT_NAME: GodSVG Mobile
2020
BUILD_OPTIONS: target=template_release lto=full production=yes deprecated=no minizip=no brotli=no vulkan=no openxr=no use_volk=no disable_3d=yes disable_physics_2d=yes disable_navigation_2d=yes modules_enabled_by_default=no module_freetype_enabled=yes module_gdscript_enabled=yes module_svg_enabled=yes module_jpg_enabled=yes module_text_server_adv_enabled=yes graphite=no module_webp_enabled=yes module_mbedtls_enabled=yes swappy=no build_profile=../godsvg/.github/disabled_classes.build
2121
GODOT_REPO: https://github.com/godotengine/godot.git

‎project.godot‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ mouse_cursor/tooltip_position_offset=Vector2(0, 10)
4141

4242
[editor_plugins]
4343

44-
enabled=PackedStringArray()
44+
text_editor/appearance/guidelines/line_length_guideline_soft_column=160
45+
text_editor/behavior/indent/type=0
46+
text_editor/behavior/files/trim_trailing_whitespace_on_save=false
47+
text_editor/completion/add_type_hints=true
48+
text_editor/completion/add_node_path_literals=true
49+
text_editor/completion/add_string_name_literals=false
50+
text_editor/appearance/guidelines/line_length_guideline_hard_column=160
4551

4652
[filesystem]
4753

‎src/ui_parts/export_menu.gd‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,13 @@ func get_dimensions_text(sides: Vector2, integer := false) -> String:
170170
Utils.num_simple(sides.y, precision)]
171171

172172

173-
func _input(event: InputEvent) -> void:
173+
func _unhandled_input(event: InputEvent) -> void:
174174
if not visible:
175175
return
176176

177-
if ShortcutUtils.is_action_pressed(event, "ui_redo"):
178-
if undo_redo.has_redo():
179-
undo_redo.redo()
177+
if ShortcutUtils.is_action_pressed(event, "ui_undo"):
178+
undo_redo.undo()
180179
accept_event()
181-
elif ShortcutUtils.is_action_pressed(event, "ui_undo"):
182-
if undo_redo.has_undo():
183-
undo_redo.undo()
180+
elif ShortcutUtils.is_action_pressed(event, "ui_redo"):
181+
undo_redo.redo()
184182
accept_event()

‎src/ui_widgets/BetterTextEdit.gd‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,11 @@ func _gui_input(event: InputEvent) -> void:
225225
set_caret_column(click_pos.x, false)
226226
else:
227227
# Set these inputs as handled, so the default UndoRedo doesn't eat them.
228-
if ShortcutUtils.is_action_pressed(event, "ui_redo"):
229-
if has_redo():
230-
redo()
228+
if ShortcutUtils.is_action_pressed(event, "ui_undo"):
229+
undo()
231230
accept_event()
232-
elif ShortcutUtils.is_action_pressed(event, "ui_undo"):
233-
if has_undo():
234-
undo()
231+
elif ShortcutUtils.is_action_pressed(event, "ui_redo"):
232+
redo()
235233
accept_event()
236234

237235

‎src/ui_widgets/ContextPopup.gd‎

Lines changed: 53 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ func _init() -> void:
88
theme_type_variation = "OutlinedPanel"
99

1010

11-
static func create_shortcut_button(action: String, disabled := false,
12-
custom_text := "", custom_icon: Texture2D = null) -> Button:
11+
static func create_shortcut_button(action: String, disabled := false, custom_text := "", custom_icon: Texture2D = null) -> Button:
1312
if not InputMap.has_action(action):
1413
push_error("Non-existent shortcut was passed.")
1514
return
@@ -26,11 +25,11 @@ custom_text := "", custom_icon: Texture2D = null) -> Button:
2625
var shortcut_obj := Shortcut.new()
2726
shortcut_obj.events = shortcut_events
2827
btn.shortcut = shortcut_obj
28+
btn.shortcut_in_tooltip = false
2929
btn.shortcut_feedback = false
3030
return btn
3131

32-
static func create_shortcut_button_without_icon(action: String, disabled := false,
33-
custom_text := "") -> Button:
32+
static func create_shortcut_button_without_icon(action: String, disabled := false, custom_text := "") -> Button:
3433
if not InputMap.has_action(action):
3534
push_error("Non-existent shortcut was passed.")
3635
return
@@ -45,147 +44,92 @@ custom_text := "") -> Button:
4544
var shortcut_obj := Shortcut.new()
4645
shortcut_obj.events = shortcut_events
4746
btn.shortcut = shortcut_obj
47+
btn.shortcut_in_tooltip = false
4848
btn.shortcut_feedback = false
4949

5050
return btn
5151

52-
static func create_button(text: String, press_callback: Callable, disabled := false,
53-
icon: Texture2D = null, dim_text := "") -> Button:
52+
static func create_button(text: String, press_callback: Callable, disabled := false, icon: Texture2D = null, dim_text := "") -> Button:
5453
# Create main button.
5554
var main_button := Button.new()
55+
main_button.theme_type_variation = "ContextButton"
56+
main_button.focus_mode = Control.FOCUS_NONE
57+
if disabled:
58+
main_button.disabled = true
59+
else:
60+
main_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
61+
5662
main_button.text = text
5763
if is_instance_valid(icon):
5864
main_button.add_theme_constant_override("icon_max_width", 16)
5965
main_button.icon = icon
60-
66+
67+
if press_callback.is_valid():
68+
main_button.pressed.connect(press_callback)
69+
main_button.pressed.connect(HandlerGUI.remove_popup)
70+
6171
if not dim_text.is_empty():
62-
# Add button with dim text.
63-
var ret_button := Button.new()
64-
ret_button.theme_type_variation = "ContextButton"
65-
ret_button.focus_mode = Control.FOCUS_NONE
66-
ret_button.shortcut_in_tooltip = false
67-
if disabled:
68-
main_button.disabled = true
69-
ret_button.disabled = true
70-
else:
71-
ret_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
72-
73-
const CONST_ARR: PackedStringArray = ["normal", "hover", "pressed", "disabled"]
74-
main_button.begin_bulk_theme_override()
75-
for theme_type in CONST_ARR:
76-
main_button.add_theme_stylebox_override(theme_type,
77-
main_button.get_theme_stylebox("normal", "ContextButton"))
78-
main_button.end_bulk_theme_override()
72+
var font := main_button.get_theme_font("font")
73+
var font_size := main_button.get_theme_font_size("font_size")
74+
var dim_text_width := font.get_string_size(dim_text, HORIZONTAL_ALIGNMENT_RIGHT, -1, font_size).x
7975

80-
var internal_hbox := HBoxContainer.new()
81-
main_button.mouse_filter = Control.MOUSE_FILTER_IGNORE # Unpressable.
82-
internal_hbox.add_theme_constant_override("separation", 12)
83-
main_button.add_theme_color_override("icon_normal_color",
84-
ret_button.get_theme_color("icon_normal_color", "ContextButton"))
85-
var label_margin := MarginContainer.new()
86-
label_margin.add_theme_constant_override("margin_right",
87-
int(ret_button.get_theme_stylebox("normal").content_margin_right))
88-
var label := Label.new()
89-
label.text = dim_text
90-
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
9176
var shortcut_text_color := ThemeUtils.subtle_text_color
9277
if disabled:
9378
shortcut_text_color.a *= 0.75
94-
label.add_theme_color_override("font_color", shortcut_text_color)
95-
label.add_theme_font_size_override("font_size",
96-
main_button.get_theme_font_size("font_size"))
9779

98-
ret_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
99-
internal_hbox.set_anchors_and_offsets_preset(Control.PRESET_TOP_WIDE)
100-
label_margin.size_flags_horizontal = Control.SIZE_EXPAND_FILL
101-
label.size_flags_horizontal = Control.SIZE_FILL
102-
internal_hbox.add_child(main_button)
103-
label_margin.add_child(label)
104-
internal_hbox.add_child(label_margin)
105-
ret_button.add_child(internal_hbox)
106-
ret_button.pressed.connect(press_callback)
107-
ret_button.pressed.connect(HandlerGUI.remove_popup)
108-
return ret_button
109-
# Finish setting up the main button and return it if there's no shortcut.
110-
main_button.theme_type_variation = "ContextButton"
111-
main_button.focus_mode = Control.FOCUS_NONE
112-
if disabled:
113-
main_button.disabled = true
114-
else:
115-
main_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
116-
if press_callback.is_valid():
117-
main_button.pressed.connect(press_callback)
118-
main_button.pressed.connect(HandlerGUI.remove_popup)
80+
var CONST_ARR: PackedStringArray = ["normal", "hover", "pressed"]
81+
for theme_style in CONST_ARR:
82+
var sb := main_button.get_theme_stylebox(theme_style, "ContextButton").duplicate()
83+
sb.content_margin_right += dim_text_width + 8
84+
main_button.add_theme_stylebox_override(theme_style, sb)
85+
86+
var on_main_button_draw := func() -> void:
87+
var sb := ThemeDB.get_default_theme().get_stylebox("normal", "ContextButton")
88+
font.draw_string(main_button.get_canvas_item(), Vector2(0, sb.content_margin_top + font.get_ascent(font_size)), dim_text,
89+
HORIZONTAL_ALIGNMENT_RIGHT, main_button.size.x - sb.content_margin_right, font_size, shortcut_text_color)
90+
main_button.draw.connect(on_main_button_draw)
91+
11992
return main_button
12093

12194

122-
static func create_shortcut_checkbox(action: String, start_pressed: bool,
123-
custom_text := "") -> CheckBox:
95+
static func create_shortcut_checkbox(action: String, start_pressed: bool) -> CheckBox:
12496
if not InputMap.has_action(action):
12597
push_error("Non-existent shortcut was passed.")
12698
return
12799

128-
if custom_text.is_empty():
129-
custom_text = TranslationUtils.get_action_description(action, true)
130-
131-
return create_checkbox(custom_text, HandlerGUI.throw_action_event.bind(action),
100+
return create_checkbox(TranslationUtils.get_action_description(action, true),
101+
HandlerGUI.throw_action_event.bind(action),
132102
start_pressed, ShortcutUtils.get_action_showcase_text(action))
133103

134104
static func create_checkbox(text: String, toggle_action: Callable,
135105
start_pressed: bool, dim_text := "") -> CheckBox:
136106
# Create main checkbox.
137107
var checkbox := CheckBox.new()
108+
checkbox.focus_mode = Control.FOCUS_NONE
109+
checkbox.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
110+
138111
checkbox.text = text
139112
checkbox.button_pressed = start_pressed
140113
checkbox.toggled.connect(toggle_action.unbind(1))
141114

142115
if not dim_text.is_empty():
143-
# Add button with dim text.
144-
var ret_button := Button.new()
145-
ret_button.theme_type_variation = "ContextButton"
146-
ret_button.focus_mode = Control.FOCUS_NONE
147-
ret_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
148-
ret_button.shortcut_in_tooltip = false
149-
150-
checkbox.begin_bulk_theme_override()
151-
const CONST_ARR: PackedStringArray = ["normal", "pressed"]
152-
for theme_type in CONST_ARR:
153-
checkbox.add_theme_stylebox_override(theme_type,
154-
checkbox.get_theme_stylebox("normal", "ContextButton"))
155-
checkbox.end_bulk_theme_override()
156-
157-
var internal_hbox := HBoxContainer.new()
158-
checkbox.mouse_filter = Control.MOUSE_FILTER_IGNORE # Unpressable.
159-
internal_hbox.add_theme_constant_override("separation", 12)
160-
checkbox.add_theme_color_override("icon_normal_color",
161-
ret_button.get_theme_color("icon_normal_color", "ContextButton"))
162-
var label_margin := MarginContainer.new()
163-
label_margin.add_theme_constant_override("margin_right",
164-
int(ret_button.get_theme_stylebox("normal").content_margin_right))
165-
var label := Label.new()
166-
label.text = dim_text
167-
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
116+
var font := checkbox.get_theme_font("font")
117+
var font_size := checkbox.get_theme_font_size("font_size")
118+
var dim_text_width := font.get_string_size(dim_text, HORIZONTAL_ALIGNMENT_RIGHT, -1, font_size).x
168119
var shortcut_text_color := ThemeUtils.subtle_text_color
169-
#if disabled:
170-
#shortcut_text_color.a *= 0.75
171-
label.add_theme_color_override("font_color", shortcut_text_color)
172-
label.add_theme_font_size_override("font_size",
173-
checkbox.get_theme_font_size("font_size"))
174120

175-
ret_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
176-
internal_hbox.set_anchors_and_offsets_preset(Control.PRESET_TOP_WIDE)
177-
label_margin.size_flags_horizontal = Control.SIZE_EXPAND_FILL
178-
label.size_flags_horizontal = Control.SIZE_FILL
179-
internal_hbox.add_child(checkbox)
180-
label_margin.add_child(label)
181-
internal_hbox.add_child(label_margin)
182-
ret_button.add_child(internal_hbox)
183-
ret_button.pressed.connect(
184-
func() -> void: checkbox.button_pressed = not checkbox.button_pressed)
185-
return ret_button
186-
# Finish setting up the checkbox and return it if there's no shortcut.
187-
checkbox.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
188-
checkbox.focus_mode = Control.FOCUS_NONE
121+
var CONST_ARR: PackedStringArray = ["normal", "hover", "pressed"]
122+
for theme_style in CONST_ARR:
123+
var sb := checkbox.get_theme_stylebox(theme_style, "CheckBox").duplicate()
124+
sb.content_margin_right += dim_text_width + 8
125+
checkbox.add_theme_stylebox_override(theme_style, sb)
126+
127+
var on_shortcut_draw := func() -> void:
128+
var sb := ThemeDB.get_default_theme().get_stylebox("normal", "CheckBox")
129+
font.draw_string(checkbox.get_canvas_item(), Vector2(0, sb.content_margin_top + font.get_ascent(font_size)), dim_text,
130+
HORIZONTAL_ALIGNMENT_RIGHT, checkbox.size.x - sb.content_margin_right, font_size, shortcut_text_color)
131+
checkbox.draw.connect(on_shortcut_draw)
132+
189133
return checkbox
190134

191135
func _setup_button(btn: Button, align_left: bool) -> Button:

‎src/ui_widgets/PanelGrid.gd‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ func _draw() -> void:
1717
if item_count == 0:
1818
return
1919

20-
var inner_color := ThemeUtils.tab_container_panel_inner_color.lerp(ThemeUtils.desaturated_color, 0.35)
21-
var border_color := ThemeUtils.tab_container_panel_inner_color.lerp(ThemeUtils.desaturated_color, 0.85)
20+
var inner_color := ThemeUtils.basic_panel_inner_color.lerp(ThemeUtils.desaturated_color, 0.35)
21+
var border_color := ThemeUtils.basic_panel_inner_color.lerp(ThemeUtils.desaturated_color, 0.85)
2222

2323
var effective_columns := clampi(columns, 1, item_count)
2424
var text_color := get_theme_color("font_color", "Label")

‎src/ui_widgets/good_color_picker.gd‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,13 @@ func sync_color_space_buttons() -> void:
120120
btn.button_group = color_space_button_group
121121
btn.toggle_mode = true
122122
btn.action_mode = BaseButton.ACTION_MODE_BUTTON_PRESS
123-
slider_mode_changed.connect(func() -> void:
123+
124+
var on_slider_mode_changed := func() -> void:
124125
btn.mouse_default_cursor_shape = Control.CURSOR_ARROW if\
125126
slider_mode == color_space else Control.CURSOR_POINTING_HAND
126-
)
127+
128+
slider_mode_changed.connect(on_slider_mode_changed)
129+
btn.tree_exiting.connect(slider_mode_changed.disconnect.bind(on_slider_mode_changed))
127130
if color_space == Configs.savedata.color_picker_slider_mode:
128131
btn.button_pressed = true
129132
btn.pressed.connect(change_slider_mode.bind(color_space))
@@ -531,13 +534,11 @@ func _unhandled_input(event: InputEvent) -> void:
531534
if not visible:
532535
return
533536

534-
if ShortcutUtils.is_action_pressed(event, "ui_redo"):
535-
if undo_redo.has_redo():
536-
undo_redo.redo()
537+
if ShortcutUtils.is_action_pressed(event, "ui_undo"):
538+
undo_redo.undo()
537539
accept_event()
538-
elif ShortcutUtils.is_action_pressed(event, "ui_undo"):
539-
if undo_redo.has_undo():
540-
undo_redo.undo()
540+
elif ShortcutUtils.is_action_pressed(event, "ui_redo"):
541+
undo_redo.redo()
541542
accept_event()
542543

543544

‎src/ui_widgets/palette_config.gd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ func sync_theming() -> void:
2626
stylebox.content_margin_bottom -= 2.0
2727
stylebox.content_margin_left += 1.0
2828
palette_button.add_theme_stylebox_override(theme_type, stylebox)
29-
palette_button.end_bulk_theme_override()
3029
var panel_stylebox := get_theme_stylebox("panel").duplicate()
3130
panel_stylebox.content_margin_top = panel_stylebox.content_margin_bottom
3231
add_theme_stylebox_override("panel", panel_stylebox)
32+
palette_button.end_bulk_theme_override()
3333

3434

3535
# Used to setup a palette for this element.

‎src/ui_widgets/presented_shortcut.gd‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,21 @@ extends PanelContainer
55

66
var action: String
77

8-
func setup(new_action: String) -> void:
9-
action = new_action
10-
var events := InputMap.action_get_events(new_action)
8+
func _ready() -> void:
9+
Configs.language_changed.connect(sync_localization)
10+
sync_localization()
11+
Configs.language_changed.connect(sync)
12+
Configs.shortcuts_changed.connect(check_shortcuts_validity)
13+
sync()
14+
15+
func sync_localization() -> void:
16+
label.text = TranslationUtils.get_action_description(action)
17+
18+
func sync() -> void:
19+
var events := InputMap.action_get_events(action)
1120
# Clear the existing buttons.
1221
for button in shortcut_container.get_children():
22+
shortcut_container.remove_child(button)
1323
button.queue_free()
1424
# Create new ones.
1525
for i in events.size():
@@ -26,7 +36,6 @@ func setup(new_action: String) -> void:
2636
new_btn.disabled = true
2737
new_btn.text = events[i].as_text_keycode()
2838
shortcut_container.add_child(new_btn)
29-
Configs.shortcuts_changed.connect(check_shortcuts_validity)
3039
check_shortcuts_validity()
3140

3241
func check_shortcuts_validity() -> void:

0 commit comments

Comments
 (0)