Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crop Tool #830

Merged
merged 24 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
84eb41b
Added intial crop tool
Mar 9, 2023
3b11efc
[skip ci] Removed unneeeded LINE_WIDTH constant from CropRect
Mar 9, 2023
37b5483
Added DimensionsLabel
Mar 9, 2023
1892aed
Cleaned up CropRect._draw
Mar 9, 2023
4765a02
Hide the CropRect after switching to a different tool
Mar 10, 2023
1c5aab5
Sets the crop values to the entire canvas size on setup
Mar 10, 2023
aef3b94
[skip ci] Added crop tool tooltip
Mar 10, 2023
d05370f
Made Crop tools synced with eachother by placing the crop settings on…
Mar 10, 2023
f15e79c
Added new modes, refactored, added rule of thirds lines and darkened …
Mar 11, 2023
0c05a1f
[skip ci] reset optimization
Mar 11, 2023
dc7a422
Renames
Mar 11, 2023
0489fdf
[skip ci] Tweaked the darkened background
Mar 11, 2023
ec097dd
Fixed bug with top/bottom/left/right sliders after rect refactor
Mar 12, 2023
0f5897b
Changing width/height on locked aspect ratio bug
Mar 12, 2023
e62fa01
Aspect ratio sliders rounding/setting a min of 1 px height/width
Mar 12, 2023
f55196d
Fixed bugs with drawing the crop rect, especially with locked aspect …
Mar 12, 2023
93da955
Save the mode to config_cache
Mar 12, 2023
b5b6dda
Added size lock and renamed mode
Mar 13, 2023
5842051
Added tooltip for size lock. Not sure if I did the translation file r…
Mar 13, 2023
45bcf3e
removed signal that wasn't used
Mar 13, 2023
1acb255
Formatting
Mar 13, 2023
020f350
Removed old TODO comment from one of my previous PRs that isn't true …
Mar 13, 2023
df985fc
Fixed definition order for linter
Mar 13, 2023
aeb14d8
Changed locked size modes moving to offset by @Variable-ind, reordere…
Mar 14, 2023
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
38 changes: 38 additions & 0 deletions Translations/Translations.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2122,3 +2122,41 @@ msgstr ""

msgid "Reference Images"
msgstr ""

msgid "Crop"
msgstr ""

msgid "Resize the canvas"
msgstr ""

msgid "Margins"
msgstr ""

msgid "Position + Size"
msgstr ""

msgid "Locked Aspect Ratio"
msgstr ""

msgid "Margins:"
msgstr ""

msgid "Aspect Ratio:"
msgstr ""

msgid "Top:"
msgstr ""

msgid "Bottom:"
msgstr ""

msgid "Left:"
msgstr ""

msgid "Right:"
msgstr ""

msgid "Locked size\n\n"
"When enabled using the tool on the canvas will only move the cropping rectangle.\n\n"
"When disabled using the tool on the canvas will draw the rectangle."
msgstr ""
Binary file added assets/graphics/misc/locked_size.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions assets/graphics/misc/locked_size.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/locked_size.png-05ec97950456a9ee42557d3414337309.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/graphics/misc/locked_size.png"
dest_files=[ "res://.import/locked_size.png-05ec97950456a9ee42557d3414337309.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
Binary file added assets/graphics/misc/unlocked_size.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions assets/graphics/misc/unlocked_size.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/unlocked_size.png-bd224f1987da9100f208bda51349ff67.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/graphics/misc/unlocked_size.png"
dest_files=[ "res://.import/unlocked_size.png-bd224f1987da9100f208bda51349ff67.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
Binary file added assets/graphics/tools/crop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions assets/graphics/tools/crop.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/crop.png-b117b864c2b96dd1998350bff3c06cf8.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/graphics/tools/crop.png"
dest_files=[ "res://.import/crop.png-b117b864c2b96dd1998350bff3c06cf8.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
Binary file added assets/graphics/tools/cursors/crop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions assets/graphics/tools/cursors/crop.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/crop.png-b1dd939167138aaa21a7eeec94aed6bc.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/graphics/tools/cursors/crop.png"
dest_files=[ "res://.import/crop.png-b1dd939167138aaa21a7eeec94aed6bc.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
6 changes: 6 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://src/UI/Nodes/CollapsibleContainer.gd"
}, {
"base": "Node2D",
"class": "CropRect",
"language": "GDScript",
"path": "res://src/UI/Canvas/CropRect.gd"
}, {
"base": "Reference",
"class": "Drawer",
"language": "GDScript",
Expand Down Expand Up @@ -244,6 +249,7 @@ _global_script_class_icons={
"Brushes": "",
"Canvas": "",
"CollapsibleContainer": "",
"CropRect": "",
"Drawer": "",
"Frame": "",
"GIFAnimationExporter": "",
Expand Down
6 changes: 6 additions & 0 deletions src/Autoload/Global.gd
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ var onion_skinning_blue_red := false
# Palettes
var palettes := {}

# Crop Options:
var crop_top := 0
var crop_bottom := 0
var crop_left := 0
var crop_right := 0

# Nodes
var pixel_layer_button_node: PackedScene = preload("res://src/UI/Timeline/PixelLayerButton.tscn")
var group_layer_button_node: PackedScene = preload("res://src/UI/Timeline/GroupLayerButton.tscn")
Expand Down
2 changes: 2 additions & 0 deletions src/Autoload/Tools.gd
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ var tools := {
preload("res://src/Tools/ColorPicker.tscn"),
"Select a color from a pixel of the sprite"
),
"Crop":
Tool.new("Crop", "Crop", "crop", preload("res://src/Tools/CropTool.tscn"), "Resize the canvas"),
"Pencil":
Tool.new(
"Pencil",
Expand Down
1 change: 1 addition & 0 deletions src/Classes/Project.gd
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ func _size_changed(value: Vector2) -> void:
tiles.tile_size = value
tiles.reset_mask()
size = value
Global.canvas.crop_rect.reset()


func change_cel(new_frame: int, new_layer := -1) -> void:
Expand Down
Loading