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
2 changes: 1 addition & 1 deletion assets/icons/Snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/backgrounds/CheckerboardMini.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/element/circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/element/ellipse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/element/g.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/element/line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/element/linearGradient.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/element/path.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/element/polygon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/element/stop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/element/svg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/element/unrecognized.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/icons/element/use.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions assets/icons/element/use.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://c1k88bqfhsvp5"
path="res://.godot/imported/use.svg-7ae354a656abf9c2d947f0f7d986cf9a.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/icons/element/use.svg"
dest_files=["res://.godot/imported/use.svg-7ae354a656abf9c2d947f0f7d986cf9a.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
2 changes: 1 addition & 1 deletion assets/icons/foreign_logos/GithubLogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/foreign_logos/KoFiLogo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/icons/theme/GuiToggleChecked.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 29 additions & 9 deletions godot_only/scripts/tests.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
extends EditorScript

func _run() -> void:
var pathdata_test_passed := pathdata_tests()
if pathdata_test_passed:
print("All tests passed!")
pathdata_tests()
transform_list_tests()


func pathdata_tests(print_success := false) -> bool:
func pathdata_tests() -> void:
const tests: Dictionary[String, Array] = {
"Jerky": [],
"M 3s 6 h 6 v 3 z": [],
Expand All @@ -31,13 +30,34 @@ func pathdata_tests(print_success := false) -> bool:
"M1 6.9e-1": [["M", 1.0, 0.69]],
}

var tests_passed := true
for test in tests:
var result := AttributePathdata.pathdata_to_arrays(test)
var expected: Array = tests[test]
if result != expected:
tests_passed = false
print('"' + test + '" generated ' + str(result) + ', expected ' + str(expected))
elif print_success:
print('"' + test + '" generated ' + str(result) + ' (SUCCESS)')
return tests_passed

func transform_list_tests() -> void:
var tests: Dictionary[String, Array] = {
"Jerky": [],
"matrix(1, 0, 0, 5, 0, 3)": [Transform.TransformMatrix.new(1, 0, 0, 5, 0, 3)],
"matrix(1 0 0 5 0 3)": [Transform.TransformMatrix.new(1, 0, 0, 5, 0, 3)],
}

for test in tests:
var test_passed := true
var result := AttributeTransformList.text_to_transform_list(test)
var expected := tests[test]
if expected.size() != result.size():
test_passed = false
else:
for i in expected.size():
if expected[i] is Transform.TransformMatrix and\
(not result[i] is Transform.TransformMatrix or\
expected[i].x1 != result[i].x1 or expected[i].x2 != result[i].x2 or\
expected[i].y1 != result[i].y1 or expected[i].y2 != result[i].y2 or\
expected[i].o1 != result[i].o1 or expected[i].o2 != result[i].o2):
test_passed = false
break

if not test_passed:
print('"' + test + '" generated ' + str(result))
10 changes: 9 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ close_all_other_tabs={
"deadzone": 0.2,
"events": []
}
close_empty_tabs={
"deadzone": 0.2,
"events": []
}
close_saved_tabs={
"deadzone": 0.2,
"events": []
}
new_tab={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"command_or_control_autoremap":true,"alt_pressed":false,"shift_pressed":false,"pressed":false,"keycode":84,"physical_keycode":0,"key_label":0,"unicode":116,"location":0,"echo":false,"script":null)
Expand Down Expand Up @@ -358,7 +366,7 @@ pen_tablet/driver.windows="dummy"
[internationalization]

rendering/root_node_auto_translate=false
locale/translations=PackedStringArray("res://translations/bg.po", "res://translations/de.po", "res://translations/et.po", "res://translations/en.po", "res://translations/fr.po", "res://translations/nl.po", "res://translations/pt_BR.po", "res://translations/ru.po", "res://translations/uk.po", "res://translations/zh_CN.po")
locale/translations=PackedStringArray("res://translations/bg.po", "res://translations/de.po", "res://translations/es.po", "res://translations/et.po", "res://translations/en.po", "res://translations/fr.po", "res://translations/nl.po", "res://translations/pt_BR.po", "res://translations/ru.po", "res://translations/uk.po", "res://translations/zh_CN.po")

[physics]

Expand Down
14 changes: 9 additions & 5 deletions src/autoload/Configs.gd
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ func load_config() -> void:
reset_settings()
return

savedata.get_active_tab().activate()
change_background_color()
change_locale()
post_load()


func reset_settings() -> void:
Expand All @@ -78,6 +76,12 @@ func reset_settings() -> void:
savedata.set_shortcut_panel_slots({ 0: "ui_undo", 1: "ui_redo", 2: "duplicate", 3: "save" })
savedata.set_palettes([Palette.new("Pure", Palette.Preset.PURE)])
save()
post_load()

func post_load() -> void:
savedata.get_active_tab().activate()
sync_background_color()
sync_locale()


func generate_highlighter() -> SVGHighlighter:
Expand All @@ -95,10 +99,10 @@ func generate_highlighter() -> SVGHighlighter:

# Global effects from settings. Some of them should also be used on launch.

func change_background_color() -> void:
func sync_background_color() -> void:
RenderingServer.set_default_clear_color(savedata.background_color)

func change_locale() -> void:
func sync_locale() -> void:
if not savedata.language in TranslationServer.get_loaded_locales():
savedata.language = "en"
else:
Expand Down
23 changes: 18 additions & 5 deletions src/autoload/HandlerGUI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func _notification(what: int) -> void:
# Drag-and-drop of files.
func _on_files_dropped(files: PackedStringArray) -> void:
if menu_stack.is_empty():
FileUtils.apply_svg_from_path(files[0])
FileUtils.apply_svgs_from_paths(files)


func add_menu(new_menu: Control) -> void:
Expand Down Expand Up @@ -263,15 +263,21 @@ func _unhandled_input(event: InputEvent) -> void:
"save": FileUtils.save_svg()
"save_as": FileUtils.save_svg_as()
"close_tab": FileUtils.close_tabs(Configs.savedata.get_active_tab_index())
"close_all_other_tabs": FileUtils.close_tabs(
Configs.savedata.get_active_tab_index(),
FileUtils.TabCloseMode.ALL_OTHERS)
"close_tabs_to_left": FileUtils.close_tabs(
Configs.savedata.get_active_tab_index(),
FileUtils.TabCloseMode.TO_LEFT)
"close_tabs_to_right": FileUtils.close_tabs(
Configs.savedata.get_active_tab_index(),
FileUtils.TabCloseMode.TO_RIGHT)
"close_all_other_tabs": FileUtils.close_tabs(
"close_empty_tabs": FileUtils.close_tabs(
Configs.savedata.get_active_tab_index(),
FileUtils.TabCloseMode.ALL_OTHERS)
FileUtils.TabCloseMode.EMPTY)
"close_saved_tabs": FileUtils.close_tabs(
Configs.savedata.get_active_tab_index(),
FileUtils.TabCloseMode.SAVED)
"new_tab": Configs.savedata.add_empty_tab()
"select_next_tab": Configs.savedata.set_active_tab_index(
posmod(Configs.savedata.get_active_tab_index() + 1,
Expand Down Expand Up @@ -359,7 +365,7 @@ func get_max_ui_scale() -> float:
var window_default_size := get_window_default_size()
# How much can the default size be increased before it takes all usable screen space.
var max_expansion := Vector2(usable_screen_size) / Vector2(window_default_size)
return clampf(snappedf(minf(max_expansion.x, max_expansion.y) - 0.025, 0.05), 0.75, 4.0)
return clampf(snappedf(minf(max_expansion.x, max_expansion.y) - 0.005, 0.01), 0.75, 4.0)

func get_min_ui_scale() -> float:
return maxf(snappedf(get_max_ui_scale() / 2.0 - 0.125, 0.25), 0.75)
Expand Down Expand Up @@ -519,7 +525,14 @@ func throw_mouse_motion_event() -> void:
var mm_event := InputEventMouseMotion.new()
var window := get_window()
# Must multiply by the final transform because the InputEvent is not yet parsed.
mm_event.position = window.get_mouse_position() * window.get_final_transform()
var mouse_position = window.get_mouse_position()
# TODO This is a workaround because the returned mouse position is sometimes (0, 0),
# likely a Godot issue. This has been reproduced on Android and on Web.
# Reproducing on web is especially easy with zoom at something like 110% on Web.
if mouse_position == Vector2.ZERO:
return

mm_event.position = mouse_position * window.get_final_transform()
Input.parse_input_event.call_deferred(mm_event)

# Trigger a shortcut automatically.
Expand Down
13 changes: 3 additions & 10 deletions src/autoload/State.gd
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,9 @@ func _enter_tree() -> void:
cmdline_args.remove_at(0)

if cmdline_args.size() >= 1:
# Need to wait a frame so the import warnings panel can be added.
# Need to wait a frame so the import warnings panel becomes available.
await get_tree().process_frame

var used_tab_paths := PackedStringArray()
for tab in Configs.savedata.get_tabs():
used_tab_paths.append(tab.svg_file_path)

for path in cmdline_args:
if path.get_extension() == "svg" and not path in used_tab_paths:
FileUtils.apply_svg_from_path(path)
FileUtils.apply_svgs_from_paths(cmdline_args)

func setup_from_tab() -> void:
var active_tab := Configs.savedata.get_active_tab()
Expand All @@ -91,7 +84,7 @@ func setup_from_tab() -> void:
return

if not new_text.is_empty():
apply_svg_text(new_text)
apply_svg_text(new_text, false)
return

if active_tab.fully_loaded and not active_tab.empty_unsaved and\
Expand Down
Loading