Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ env:
# Which godot version to use for exporting.
GODOT_VERSION: 4.5
# Which godot release to use for exporting. (stable/rc/beta/alpha)
GODOT_RELEASE: beta2
GODOT_RELEASE: beta4
# Used in the editor config file name. Do not change this for patch releases.
GODOT_FEATURE_VERSION: 4.5
# Commit hash
GODOT_COMMIT_HASH: e1b4101e3
GODOT_COMMIT_HASH: 2d113cc22
PROJECT_NAME: GodSVG Mobile
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
GODOT_REPO: https://github.com/godotengine/godot.git
Expand Down
8 changes: 7 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ mouse_cursor/tooltip_position_offset=Vector2(0, 10)

[editor_plugins]

enabled=PackedStringArray()
text_editor/appearance/guidelines/line_length_guideline_soft_column=160
text_editor/behavior/indent/type=0
text_editor/behavior/files/trim_trailing_whitespace_on_save=false
text_editor/completion/add_type_hints=true
text_editor/completion/add_node_path_literals=true
text_editor/completion/add_string_name_literals=false
text_editor/appearance/guidelines/line_length_guideline_hard_column=160

[filesystem]

Expand Down
12 changes: 5 additions & 7 deletions src/ui_parts/export_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,13 @@ func get_dimensions_text(sides: Vector2, integer := false) -> String:
Utils.num_simple(sides.y, precision)]


func _input(event: InputEvent) -> void:
func _unhandled_input(event: InputEvent) -> void:
if not visible:
return

if ShortcutUtils.is_action_pressed(event, "ui_redo"):
if undo_redo.has_redo():
undo_redo.redo()
if ShortcutUtils.is_action_pressed(event, "ui_undo"):
undo_redo.undo()
accept_event()
elif ShortcutUtils.is_action_pressed(event, "ui_undo"):
if undo_redo.has_undo():
undo_redo.undo()
elif ShortcutUtils.is_action_pressed(event, "ui_redo"):
undo_redo.redo()
accept_event()
10 changes: 4 additions & 6 deletions src/ui_widgets/BetterTextEdit.gd
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,11 @@ func _gui_input(event: InputEvent) -> void:
set_caret_column(click_pos.x, false)
else:
# Set these inputs as handled, so the default UndoRedo doesn't eat them.
if ShortcutUtils.is_action_pressed(event, "ui_redo"):
if has_redo():
redo()
if ShortcutUtils.is_action_pressed(event, "ui_undo"):
undo()
accept_event()
elif ShortcutUtils.is_action_pressed(event, "ui_undo"):
if has_undo():
undo()
elif ShortcutUtils.is_action_pressed(event, "ui_redo"):
redo()
accept_event()


Expand Down
162 changes: 53 additions & 109 deletions src/ui_widgets/ContextPopup.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ func _init() -> void:
theme_type_variation = "OutlinedPanel"


static func create_shortcut_button(action: String, disabled := false,
custom_text := "", custom_icon: Texture2D = null) -> Button:
static func create_shortcut_button(action: String, disabled := false, custom_text := "", custom_icon: Texture2D = null) -> Button:
if not InputMap.has_action(action):
push_error("Non-existent shortcut was passed.")
return
Expand All @@ -26,11 +25,11 @@ custom_text := "", custom_icon: Texture2D = null) -> Button:
var shortcut_obj := Shortcut.new()
shortcut_obj.events = shortcut_events
btn.shortcut = shortcut_obj
btn.shortcut_in_tooltip = false
btn.shortcut_feedback = false
return btn

static func create_shortcut_button_without_icon(action: String, disabled := false,
custom_text := "") -> Button:
static func create_shortcut_button_without_icon(action: String, disabled := false, custom_text := "") -> Button:
if not InputMap.has_action(action):
push_error("Non-existent shortcut was passed.")
return
Expand All @@ -45,147 +44,92 @@ custom_text := "") -> Button:
var shortcut_obj := Shortcut.new()
shortcut_obj.events = shortcut_events
btn.shortcut = shortcut_obj
btn.shortcut_in_tooltip = false
btn.shortcut_feedback = false

return btn

static func create_button(text: String, press_callback: Callable, disabled := false,
icon: Texture2D = null, dim_text := "") -> Button:
static func create_button(text: String, press_callback: Callable, disabled := false, icon: Texture2D = null, dim_text := "") -> Button:
# Create main button.
var main_button := Button.new()
main_button.theme_type_variation = "ContextButton"
main_button.focus_mode = Control.FOCUS_NONE
if disabled:
main_button.disabled = true
else:
main_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND

main_button.text = text
if is_instance_valid(icon):
main_button.add_theme_constant_override("icon_max_width", 16)
main_button.icon = icon


if press_callback.is_valid():
main_button.pressed.connect(press_callback)
main_button.pressed.connect(HandlerGUI.remove_popup)

if not dim_text.is_empty():
# Add button with dim text.
var ret_button := Button.new()
ret_button.theme_type_variation = "ContextButton"
ret_button.focus_mode = Control.FOCUS_NONE
ret_button.shortcut_in_tooltip = false
if disabled:
main_button.disabled = true
ret_button.disabled = true
else:
ret_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND

const CONST_ARR: PackedStringArray = ["normal", "hover", "pressed", "disabled"]
main_button.begin_bulk_theme_override()
for theme_type in CONST_ARR:
main_button.add_theme_stylebox_override(theme_type,
main_button.get_theme_stylebox("normal", "ContextButton"))
main_button.end_bulk_theme_override()
var font := main_button.get_theme_font("font")
var font_size := main_button.get_theme_font_size("font_size")
var dim_text_width := font.get_string_size(dim_text, HORIZONTAL_ALIGNMENT_RIGHT, -1, font_size).x

var internal_hbox := HBoxContainer.new()
main_button.mouse_filter = Control.MOUSE_FILTER_IGNORE # Unpressable.
internal_hbox.add_theme_constant_override("separation", 12)
main_button.add_theme_color_override("icon_normal_color",
ret_button.get_theme_color("icon_normal_color", "ContextButton"))
var label_margin := MarginContainer.new()
label_margin.add_theme_constant_override("margin_right",
int(ret_button.get_theme_stylebox("normal").content_margin_right))
var label := Label.new()
label.text = dim_text
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
var shortcut_text_color := ThemeUtils.subtle_text_color
if disabled:
shortcut_text_color.a *= 0.75
label.add_theme_color_override("font_color", shortcut_text_color)
label.add_theme_font_size_override("font_size",
main_button.get_theme_font_size("font_size"))

ret_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
internal_hbox.set_anchors_and_offsets_preset(Control.PRESET_TOP_WIDE)
label_margin.size_flags_horizontal = Control.SIZE_EXPAND_FILL
label.size_flags_horizontal = Control.SIZE_FILL
internal_hbox.add_child(main_button)
label_margin.add_child(label)
internal_hbox.add_child(label_margin)
ret_button.add_child(internal_hbox)
ret_button.pressed.connect(press_callback)
ret_button.pressed.connect(HandlerGUI.remove_popup)
return ret_button
# Finish setting up the main button and return it if there's no shortcut.
main_button.theme_type_variation = "ContextButton"
main_button.focus_mode = Control.FOCUS_NONE
if disabled:
main_button.disabled = true
else:
main_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
if press_callback.is_valid():
main_button.pressed.connect(press_callback)
main_button.pressed.connect(HandlerGUI.remove_popup)
var CONST_ARR: PackedStringArray = ["normal", "hover", "pressed"]
for theme_style in CONST_ARR:
var sb := main_button.get_theme_stylebox(theme_style, "ContextButton").duplicate()
sb.content_margin_right += dim_text_width + 8
main_button.add_theme_stylebox_override(theme_style, sb)

var on_main_button_draw := func() -> void:
var sb := ThemeDB.get_default_theme().get_stylebox("normal", "ContextButton")
font.draw_string(main_button.get_canvas_item(), Vector2(0, sb.content_margin_top + font.get_ascent(font_size)), dim_text,
HORIZONTAL_ALIGNMENT_RIGHT, main_button.size.x - sb.content_margin_right, font_size, shortcut_text_color)
main_button.draw.connect(on_main_button_draw)

return main_button


static func create_shortcut_checkbox(action: String, start_pressed: bool,
custom_text := "") -> CheckBox:
static func create_shortcut_checkbox(action: String, start_pressed: bool) -> CheckBox:
if not InputMap.has_action(action):
push_error("Non-existent shortcut was passed.")
return

if custom_text.is_empty():
custom_text = TranslationUtils.get_action_description(action, true)

return create_checkbox(custom_text, HandlerGUI.throw_action_event.bind(action),
return create_checkbox(TranslationUtils.get_action_description(action, true),
HandlerGUI.throw_action_event.bind(action),
start_pressed, ShortcutUtils.get_action_showcase_text(action))

static func create_checkbox(text: String, toggle_action: Callable,
start_pressed: bool, dim_text := "") -> CheckBox:
# Create main checkbox.
var checkbox := CheckBox.new()
checkbox.focus_mode = Control.FOCUS_NONE
checkbox.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND

checkbox.text = text
checkbox.button_pressed = start_pressed
checkbox.toggled.connect(toggle_action.unbind(1))

if not dim_text.is_empty():
# Add button with dim text.
var ret_button := Button.new()
ret_button.theme_type_variation = "ContextButton"
ret_button.focus_mode = Control.FOCUS_NONE
ret_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
ret_button.shortcut_in_tooltip = false

checkbox.begin_bulk_theme_override()
const CONST_ARR: PackedStringArray = ["normal", "pressed"]
for theme_type in CONST_ARR:
checkbox.add_theme_stylebox_override(theme_type,
checkbox.get_theme_stylebox("normal", "ContextButton"))
checkbox.end_bulk_theme_override()

var internal_hbox := HBoxContainer.new()
checkbox.mouse_filter = Control.MOUSE_FILTER_IGNORE # Unpressable.
internal_hbox.add_theme_constant_override("separation", 12)
checkbox.add_theme_color_override("icon_normal_color",
ret_button.get_theme_color("icon_normal_color", "ContextButton"))
var label_margin := MarginContainer.new()
label_margin.add_theme_constant_override("margin_right",
int(ret_button.get_theme_stylebox("normal").content_margin_right))
var label := Label.new()
label.text = dim_text
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
var font := checkbox.get_theme_font("font")
var font_size := checkbox.get_theme_font_size("font_size")
var dim_text_width := font.get_string_size(dim_text, HORIZONTAL_ALIGNMENT_RIGHT, -1, font_size).x
var shortcut_text_color := ThemeUtils.subtle_text_color
#if disabled:
#shortcut_text_color.a *= 0.75
label.add_theme_color_override("font_color", shortcut_text_color)
label.add_theme_font_size_override("font_size",
checkbox.get_theme_font_size("font_size"))

ret_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
internal_hbox.set_anchors_and_offsets_preset(Control.PRESET_TOP_WIDE)
label_margin.size_flags_horizontal = Control.SIZE_EXPAND_FILL
label.size_flags_horizontal = Control.SIZE_FILL
internal_hbox.add_child(checkbox)
label_margin.add_child(label)
internal_hbox.add_child(label_margin)
ret_button.add_child(internal_hbox)
ret_button.pressed.connect(
func() -> void: checkbox.button_pressed = not checkbox.button_pressed)
return ret_button
# Finish setting up the checkbox and return it if there's no shortcut.
checkbox.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
checkbox.focus_mode = Control.FOCUS_NONE
var CONST_ARR: PackedStringArray = ["normal", "hover", "pressed"]
for theme_style in CONST_ARR:
var sb := checkbox.get_theme_stylebox(theme_style, "CheckBox").duplicate()
sb.content_margin_right += dim_text_width + 8
checkbox.add_theme_stylebox_override(theme_style, sb)

var on_shortcut_draw := func() -> void:
var sb := ThemeDB.get_default_theme().get_stylebox("normal", "CheckBox")
font.draw_string(checkbox.get_canvas_item(), Vector2(0, sb.content_margin_top + font.get_ascent(font_size)), dim_text,
HORIZONTAL_ALIGNMENT_RIGHT, checkbox.size.x - sb.content_margin_right, font_size, shortcut_text_color)
checkbox.draw.connect(on_shortcut_draw)

return checkbox

func _setup_button(btn: Button, align_left: bool) -> Button:
Expand Down
4 changes: 2 additions & 2 deletions src/ui_widgets/PanelGrid.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func _draw() -> void:
if item_count == 0:
return

var inner_color := ThemeUtils.tab_container_panel_inner_color.lerp(ThemeUtils.desaturated_color, 0.35)
var border_color := ThemeUtils.tab_container_panel_inner_color.lerp(ThemeUtils.desaturated_color, 0.85)
var inner_color := ThemeUtils.basic_panel_inner_color.lerp(ThemeUtils.desaturated_color, 0.35)
var border_color := ThemeUtils.basic_panel_inner_color.lerp(ThemeUtils.desaturated_color, 0.85)

var effective_columns := clampi(columns, 1, item_count)
var text_color := get_theme_color("font_color", "Label")
Expand Down
17 changes: 9 additions & 8 deletions src/ui_widgets/good_color_picker.gd
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,13 @@ func sync_color_space_buttons() -> void:
btn.button_group = color_space_button_group
btn.toggle_mode = true
btn.action_mode = BaseButton.ACTION_MODE_BUTTON_PRESS
slider_mode_changed.connect(func() -> void:

var on_slider_mode_changed := func() -> void:
btn.mouse_default_cursor_shape = Control.CURSOR_ARROW if\
slider_mode == color_space else Control.CURSOR_POINTING_HAND
)

slider_mode_changed.connect(on_slider_mode_changed)
btn.tree_exiting.connect(slider_mode_changed.disconnect.bind(on_slider_mode_changed))
if color_space == Configs.savedata.color_picker_slider_mode:
btn.button_pressed = true
btn.pressed.connect(change_slider_mode.bind(color_space))
Expand Down Expand Up @@ -531,13 +534,11 @@ func _unhandled_input(event: InputEvent) -> void:
if not visible:
return

if ShortcutUtils.is_action_pressed(event, "ui_redo"):
if undo_redo.has_redo():
undo_redo.redo()
if ShortcutUtils.is_action_pressed(event, "ui_undo"):
undo_redo.undo()
accept_event()
elif ShortcutUtils.is_action_pressed(event, "ui_undo"):
if undo_redo.has_undo():
undo_redo.undo()
elif ShortcutUtils.is_action_pressed(event, "ui_redo"):
undo_redo.redo()
accept_event()


Expand Down
2 changes: 1 addition & 1 deletion src/ui_widgets/palette_config.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ func sync_theming() -> void:
stylebox.content_margin_bottom -= 2.0
stylebox.content_margin_left += 1.0
palette_button.add_theme_stylebox_override(theme_type, stylebox)
palette_button.end_bulk_theme_override()
var panel_stylebox := get_theme_stylebox("panel").duplicate()
panel_stylebox.content_margin_top = panel_stylebox.content_margin_bottom
add_theme_stylebox_override("panel", panel_stylebox)
palette_button.end_bulk_theme_override()


# Used to setup a palette for this element.
Expand Down
17 changes: 13 additions & 4 deletions src/ui_widgets/presented_shortcut.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@ extends PanelContainer

var action: String

func setup(new_action: String) -> void:
action = new_action
var events := InputMap.action_get_events(new_action)
func _ready() -> void:
Configs.language_changed.connect(sync_localization)
sync_localization()
Configs.language_changed.connect(sync)
Configs.shortcuts_changed.connect(check_shortcuts_validity)
sync()

func sync_localization() -> void:
label.text = TranslationUtils.get_action_description(action)

func sync() -> void:
var events := InputMap.action_get_events(action)
# Clear the existing buttons.
for button in shortcut_container.get_children():
shortcut_container.remove_child(button)
button.queue_free()
# Create new ones.
for i in events.size():
Expand All @@ -26,7 +36,6 @@ func setup(new_action: String) -> void:
new_btn.disabled = true
new_btn.text = events[i].as_text_keycode()
shortcut_container.add_child(new_btn)
Configs.shortcuts_changed.connect(check_shortcuts_validity)
check_shortcuts_validity()

func check_shortcuts_validity() -> void:
Expand Down
Loading