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
1 change: 1 addition & 0 deletions assets/icons/CodeEditor.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/CodeEditor.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://drl587rrnbwo3"
path="res://.godot/imported/CodeEditor.svg-0e7e65ddead32356f4603181bf8c379c.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/icons/CodeEditor.svg"
dest_files=["res://.godot/imported/CodeEditor.svg-0e7e65ddead32356f4603181bf8c379c.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
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://oha0oauf4kup"
path="res://.godot/imported/ViewInList.svg-e0595b44695503f2072a608f260e2171.ctex"
path="res://.godot/imported/Inspector.svg-16dc105bb2fde5191bb55e4179b50443.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/icons/ViewInList.svg"
dest_files=["res://.godot/imported/ViewInList.svg-e0595b44695503f2072a608f260e2171.ctex"]
source_file="res://assets/icons/Inspector.svg"
dest_files=["res://.godot/imported/Inspector.svg-16dc105bb2fde5191bb55e4179b50443.ctex"]

[params]

Expand Down
1 change: 1 addition & 0 deletions assets/icons/Layouts.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/Layouts.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://b6mqp088ef65"
path="res://.godot/imported/Layouts.svg-1c07a3528e532f1c03ca36a1edac552d.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/icons/Layouts.svg"
dest_files=["res://.godot/imported/Layouts.svg-1c07a3528e532f1c03ca36a1edac552d.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
1 change: 1 addition & 0 deletions assets/icons/Viewport.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/Viewport.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://baxqpqub1hxmr"
path="res://.godot/imported/Viewport.svg-f8c0ca66b45914e279c67a6c13d5852c.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/icons/Viewport.svg"
dest_files=["res://.godot/imported/Viewport.svg-f8c0ca66b45914e279c67a6c13d5852c.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 export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ architectures/arm64-v8a=true
architectures/x86=false
architectures/x86_64=false
version/code=1
version/name="1.0-alpha1"
version/name="1.0-alpha2"
package/unique_name="com.godsvg.mobile"
package/name="GodSVG Mobile"
package/signed=true
Expand Down
2 changes: 1 addition & 1 deletion godot_only/scripts/tests.gd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func pathdata_tests(print_success := false) -> bool:
}

var tests_passed := true
for test in tests.keys():
for test in tests:
var result := AttributePathdata.pathdata_to_arrays(test)
var expected: Array = tests[test]
if result != expected:
Expand Down
2 changes: 2 additions & 0 deletions src/autoload/Configs.gd
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ signal active_tab_reference_changed
signal active_tab_changed
@warning_ignore("unused_signal")
signal tabs_changed
@warning_ignore("unused_signal")
signal layout_changed

const savedata_path = "user://savedata.tres"
var savedata: SaveData:
Expand Down
16 changes: 7 additions & 9 deletions src/autoload/State.gd
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,7 @@ func insert_point_after_selection() -> void:
queue_svg_save()


enum Context {VIEWPORT, LIST}

func get_selection_context(popup_method: Callable, context: Context) -> ContextPopup:
func get_selection_context(popup_method: Callable, context: Utils.LayoutPart) -> ContextPopup:
var btn_arr: Array[Button] = []

if not selected_xids.is_empty():
Expand All @@ -761,10 +759,10 @@ func get_selection_context(popup_method: Callable, context: Context) -> ContextP
can_move_up = true
if not can_move_down and base_xid[-1] < parent_child_count - filtered_count:
can_move_down = true
if context == Context.VIEWPORT:
btn_arr.append(ContextPopup.create_button(Translator.translate("View in List"),
if context == Utils.LayoutPart.VIEWPORT:
btn_arr.append(ContextPopup.create_button(Translator.translate("View in Inspector"),
view_in_list.bind(selected_xids[0]), false,
load("res://assets/icons/ViewInList.svg")))
load("res://assets/icons/Inspector.svg")))

btn_arr.append(ContextPopup.create_shortcut_button("duplicate"))

Expand All @@ -787,14 +785,14 @@ func get_selection_context(popup_method: Callable, context: Context) -> ContextP
elif not inner_selections.is_empty() and not semi_selected_xid.is_empty():
var element_ref := root_element.get_xnode(semi_selected_xid)

if context == Context.VIEWPORT:
if context == Utils.LayoutPart.VIEWPORT:
var inner_idx := inner_selections[0]
for idx in inner_selections:
if idx < inner_idx:
inner_idx = idx
btn_arr.append(ContextPopup.create_button(Translator.translate("View in List"),
btn_arr.append(ContextPopup.create_button(Translator.translate("View in Inspector"),
view_in_list.bind(semi_selected_xid, inner_idx), false,
load("res://assets/icons/ViewInList.svg")))
load("res://assets/icons/Inspector.svg")))
match element_ref.name:
"path":
if inner_selections.size() == 1:
Expand Down
113 changes: 110 additions & 3 deletions src/config_classes/SaveData.gd
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ func validate() -> void:
export_formatter = Formatter.new(Formatter.Preset.COMPACT)
if _active_tab_index >= _tabs.size() or _active_tab_index < 0:
_active_tab_index = _active_tab_index # Run the setter.

# End of the method, would need to be rewritten if more things need validation.
for location in [LayoutLocation.TOP_LEFT, LayoutLocation.BOTTOM_LEFT]:
if _layout.has(location) and not _layout[location].is_empty():
return
_layout = {
LayoutLocation.TOP_LEFT: [Utils.LayoutPart.CODE_EDITOR, Utils.LayoutPart.INSPECTOR]
}


const CURRENT_VERSION = 1
Expand Down Expand Up @@ -239,9 +247,10 @@ const HANDLE_SIZE_MAX = 4.0
@export var handle_size := 1.0:
set(new_value):
# Validation
new_value = clampf(new_value, HANDLE_SIZE_MIN, HANDLE_SIZE_MAX)
if is_nan(new_value):
new_value = get_setting_default("handle_size")
else:
new_value = clampf(new_value, HANDLE_SIZE_MIN, HANDLE_SIZE_MAX)
# Main part
if handle_size != new_value:
handle_size = new_value
Expand All @@ -267,9 +276,10 @@ const MAX_SNAP = 16384
@export var snap := -0.5: # Negative when disabled.
set(new_value):
# Validation
new_value = clampf(new_value, -MAX_SNAP, MAX_SNAP)
if is_nan(new_value):
new_value = -0.5
else:
new_value = clampf(new_value, -MAX_SNAP, MAX_SNAP)
# Main part
if snap != new_value:
snap = new_value
Expand Down Expand Up @@ -595,9 +605,10 @@ const MAX_TABS = 50
if _tabs.is_empty():
_add_new_tab()

new_value = clampi(new_value, 0, _tabs.size() - 1)
if is_nan(new_value):
new_value = 0
else:
new_value = clampi(new_value, 0, _tabs.size() - 1)
# Main part
if _active_tab_index != new_value:
_active_tab_index = new_value
Expand Down Expand Up @@ -738,6 +749,102 @@ func move_tab(old_idx: int, new_idx: int) -> void:
Configs.tabs_changed.emit()


enum LayoutLocation {NONE, EXCLUDED, TOP_LEFT, BOTTOM_LEFT}

@export var _layout: Dictionary[LayoutLocation, Array]: # Array[Utils.LayoutPart]
set(new_value):
# Validation
for key in new_value:
# Ensure keys correspond to layout locations.
if key < 0 or key >= LayoutLocation.size() or key == LayoutLocation.NONE:
new_value.erase(key)
else:
# Ensure arrays correspond to layout parts.
var arr := new_value[key]
for i in range(arr.size() - 1, -1, -1):
if not arr[i] is Utils.LayoutPart or arr[i] < 0 or\
arr[i] >= Utils.LayoutPart.size():
arr.remove_at(i)
# Ensure non-duplicate layout parts and no empty arrays.
var used_layout_parts: Array[Utils.LayoutPart] = []
for location in LayoutLocation.size():
if new_value.has(location):
var arr := new_value[location]
for i in range(arr.size() - 1, -1, -1):
if arr[i] in used_layout_parts:
arr.remove_at(i)
else:
used_layout_parts.append(arr[i])
if arr.is_empty():
new_value.erase(location)
# Put all layout parts that aren't listed in excluded.
used_layout_parts += [Utils.LayoutPart.NONE, Utils.LayoutPart.VIEWPORT]
for part in Utils.LayoutPart.size():
if not part in used_layout_parts:
if not new_value.has(LayoutLocation.EXCLUDED):
new_value[LayoutLocation.EXCLUDED] = []
new_value[LayoutLocation.EXCLUDED].append(part)
# Main part
if _layout != new_value:
_layout = new_value
emit_changed()

func set_layout_parts(location: LayoutLocation, parts: Array[Utils.LayoutPart],
notify_layout_changed := true) -> void:
if (_layout.has(location) and parts == _layout[location]) or\
(not _layout.has(location) and parts.is_empty()):
return

if parts.is_empty():
_layout.erase(location)
else:
_layout[location] = parts
emit_changed()
if notify_layout_changed:
Configs.layout_changed.emit()

func get_layout_parts(location: LayoutLocation) -> Array[Utils.LayoutPart]:
if _layout.has(location):
var output: Array[Utils.LayoutPart] = []
output.assign(_layout[location])
return output
else:
return []

func get_layout_part_location(part: Utils.LayoutPart) -> LayoutLocation:
for location in _layout:
if _layout[location].has(part):
return location
return LayoutLocation.NONE

func get_layout_part_index(part: Utils.LayoutPart) -> int:
for location in _layout:
if _layout[location].has(part):
return _layout[location].find(part)
return -1


@export var main_splitter_offset := -180:
set(new_value):
# Validation
if is_nan(new_value):
new_value = 0
# Main part
if main_splitter_offset != new_value:
main_splitter_offset = new_value
emit_changed()

@export var top_vertical_splitter_offset := -240:
set(new_value):
# Validation
if is_nan(new_value):
new_value = 0
# Main part
if top_vertical_splitter_offset != new_value:
top_vertical_splitter_offset = new_value
emit_changed()


# Utility

func get_validity_color(error_condition: bool, warning_condition := false) -> Color:
Expand Down
2 changes: 1 addition & 1 deletion src/data_classes/DB.gd
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static func is_child_element_valid(parent_name: String, child_name: String) -> b

static func get_valid_parents(child_name: String) -> PackedStringArray:
var valid_parents := PackedStringArray()
for parent_name in _valid_children.keys():
for parent_name in _valid_children:
if child_name in _valid_children[parent_name]:
valid_parents.append(parent_name)
return valid_parents
Expand Down
2 changes: 1 addition & 1 deletion src/data_classes/SVGParser.gd
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static func _xnode_to_export_text(xnode: XNode) -> String:

enum ParseError {OK, ERR_NOT_SVG, ERR_IMPROPER_NESTING}

class ParseResult extends RefCounted:
class ParseResult:
var error: SVGParser.ParseError
var svg: ElementRoot

Expand Down
2 changes: 1 addition & 1 deletion src/ui_parts/code_editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ extends VBoxContainer
@onready var code_edit: TextEdit = $ScriptEditor/SVGCodeEdit
@onready var error_bar: PanelContainer = $ScriptEditor/ErrorBar
@onready var error_label: RichTextLabel = $ScriptEditor/ErrorBar/Label

@onready var options_button: Button = %MetaActions/OptionsButton

func _ready() -> void:
Expand All @@ -15,6 +14,7 @@ func _ready() -> void:
update_syntax_highlighter()
code_edit.clear_undo_history()
State.svg_changed.connect(auto_update_text)
auto_update_text()


func auto_update_text() -> void:
Expand Down
Loading