2019-08-18 09:28:38 +00:00
|
|
|
|
extends Node
|
|
|
|
|
|
2020-05-31 15:03:44 +00:00
|
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
|
enum GridTypes {CARTESIAN, ISOMETRIC, ALL}
|
|
|
|
|
enum PressureSensitivity {NONE, ALPHA, SIZE, ALPHA_AND_SIZE}
|
2020-05-31 13:04:33 +00:00
|
|
|
|
enum Direction {UP, DOWN, LEFT, RIGHT}
|
2021-01-20 14:59:42 +00:00
|
|
|
|
enum ThemeTypes {DARK, BLUE, CARAMEL, LIGHT}
|
|
|
|
|
enum TileMode {NONE, BOTH, X_AXIS, Y_AXIS}
|
2021-03-06 13:59:26 +00:00
|
|
|
|
enum PanelLayout {AUTO, WIDESCREEN, TALLSCREEN}
|
2020-04-13 07:55:01 +00:00
|
|
|
|
# Stuff for arrowkey-based canvas movements nyaa ^.^
|
|
|
|
|
const low_speed_move_rate := 150.0
|
|
|
|
|
const medium_speed_move_rate := 750.0
|
|
|
|
|
const high_speed_move_rate := 3750.0
|
|
|
|
|
|
2020-05-31 13:04:33 +00:00
|
|
|
|
var root_directory := "."
|
|
|
|
|
var window_title := "" setget title_changed # Why doesn't Godot have get_window_title()?
|
|
|
|
|
var config_cache := ConfigFile.new()
|
|
|
|
|
var XDGDataPaths = preload("res://src/XDGDataPaths.gd")
|
|
|
|
|
var directory_module : Reference
|
2020-04-13 07:55:01 +00:00
|
|
|
|
|
2020-06-04 18:05:36 +00:00
|
|
|
|
var projects := [] # Array of Projects
|
|
|
|
|
var current_project : Project
|
|
|
|
|
var current_project_index := 0 setget project_changed
|
|
|
|
|
|
2020-10-26 20:51:55 +00:00
|
|
|
|
var recent_projects := []
|
2021-03-06 13:59:26 +00:00
|
|
|
|
var panel_layout = PanelLayout.AUTO
|
2020-10-26 20:51:55 +00:00
|
|
|
|
|
2020-04-13 07:55:01 +00:00
|
|
|
|
# Indices are as in the Direction enum
|
2020-04-13 13:39:18 +00:00
|
|
|
|
# This is the total time the key for
|
2020-04-13 07:55:01 +00:00
|
|
|
|
# that direction has been pressed.
|
|
|
|
|
var key_move_press_time := [0.0, 0.0, 0.0, 0.0]
|
|
|
|
|
|
2019-12-25 19:42:01 +00:00
|
|
|
|
# Canvas related stuff
|
2020-04-06 15:35:54 +00:00
|
|
|
|
var layers_changed_skip := false
|
2019-08-18 09:28:38 +00:00
|
|
|
|
var can_draw := false
|
2019-10-03 16:37:31 +00:00
|
|
|
|
var has_focus := false
|
2020-05-05 00:53:58 +00:00
|
|
|
|
var cursor_image = preload("res://assets/graphics/cursor_icons/cursor.png")
|
2020-07-09 12:22:17 +00:00
|
|
|
|
var left_cursor_tool_texture := ImageTexture.new()
|
|
|
|
|
var right_cursor_tool_texture := ImageTexture.new()
|
2020-04-24 21:42:02 +00:00
|
|
|
|
|
2019-12-05 23:48:29 +00:00
|
|
|
|
var image_clipboard : Image
|
2020-04-11 17:10:07 +00:00
|
|
|
|
var play_only_tags := true
|
2020-07-16 02:05:40 +00:00
|
|
|
|
var show_x_symmetry_axis := false
|
|
|
|
|
var show_y_symmetry_axis := false
|
2020-08-18 14:03:49 +00:00
|
|
|
|
var default_clear_color := Color.gray
|
2020-02-11 22:38:35 +00:00
|
|
|
|
|
2020-06-04 20:20:20 +00:00
|
|
|
|
# Preferences
|
2021-01-20 14:59:42 +00:00
|
|
|
|
var pressure_sensitivity_mode = PressureSensitivity.NONE
|
2020-07-28 22:54:15 +00:00
|
|
|
|
var open_last_project := false
|
2020-11-07 01:57:35 +00:00
|
|
|
|
var shrink := 1.0
|
2021-03-17 17:28:01 +00:00
|
|
|
|
var dim_on_popup := true
|
2020-07-28 22:54:15 +00:00
|
|
|
|
var smooth_zoom := true
|
2021-01-20 14:59:42 +00:00
|
|
|
|
var theme_type : int = ThemeTypes.DARK
|
2020-01-10 22:29:29 +00:00
|
|
|
|
var default_image_width := 64
|
|
|
|
|
var default_image_height := 64
|
2020-01-10 19:24:07 +00:00
|
|
|
|
var default_fill_color := Color(0, 0, 0, 0)
|
2021-01-20 14:59:42 +00:00
|
|
|
|
var grid_type = GridTypes.CARTESIAN
|
2021-01-16 18:24:46 +00:00
|
|
|
|
var grid_width := 2
|
|
|
|
|
var grid_height := 2
|
2021-01-18 20:59:26 +00:00
|
|
|
|
var grid_isometric_cell_bounds_width := 16
|
|
|
|
|
var grid_isometric_cell_bounds_height := 8
|
2021-01-20 00:17:33 +00:00
|
|
|
|
var grid_offset_x := 0
|
|
|
|
|
var grid_offset_y := 0
|
|
|
|
|
var grid_draw_over_tile_mode := false
|
2019-12-07 17:34:54 +00:00
|
|
|
|
var grid_color := Color.black
|
2021-01-16 18:24:46 +00:00
|
|
|
|
var pixel_grid_show_at_zoom := 1500.0 # percentage
|
|
|
|
|
var pixel_grid_color := Color("91212121")
|
2019-12-27 00:28:36 +00:00
|
|
|
|
var guide_color := Color.purple
|
2020-04-18 07:03:18 +00:00
|
|
|
|
var checker_size := 10
|
2020-05-03 00:42:44 +00:00
|
|
|
|
var checker_color_1 := Color(0.47, 0.47, 0.47, 1)
|
|
|
|
|
var checker_color_2 := Color(0.34, 0.35, 0.34, 1)
|
2020-08-17 19:30:58 +00:00
|
|
|
|
var checker_follow_movement := false
|
|
|
|
|
var checker_follow_scale := false
|
2020-10-25 23:10:14 +00:00
|
|
|
|
var tilemode_opacity := 1.0
|
2021-01-05 18:01:50 +00:00
|
|
|
|
var fps_limit_focus := true
|
|
|
|
|
var fps_limit := 0
|
2019-12-05 23:48:29 +00:00
|
|
|
|
|
2020-07-29 00:16:02 +00:00
|
|
|
|
var autosave_interval := 1.0
|
2020-05-31 20:04:59 +00:00
|
|
|
|
var enable_autosave := true
|
|
|
|
|
|
2019-12-25 19:42:01 +00:00
|
|
|
|
# Tools & options
|
2020-01-13 11:26:06 +00:00
|
|
|
|
var show_left_tool_icon := true
|
|
|
|
|
var show_right_tool_icon := true
|
2019-12-05 23:48:29 +00:00
|
|
|
|
var left_square_indicator_visible := true
|
|
|
|
|
var right_square_indicator_visible := false
|
2020-04-24 21:42:02 +00:00
|
|
|
|
|
2019-12-25 19:42:01 +00:00
|
|
|
|
# View menu options
|
2020-11-23 16:53:21 +00:00
|
|
|
|
var mirror_view := false
|
2019-09-09 22:57:46 +00:00
|
|
|
|
var draw_grid := false
|
2021-01-16 18:24:46 +00:00
|
|
|
|
var draw_pixel_grid := false
|
2019-12-03 00:30:38 +00:00
|
|
|
|
var show_rulers := true
|
|
|
|
|
var show_guides := true
|
2020-02-15 01:30:40 +00:00
|
|
|
|
var show_animation_timeline := true
|
2019-12-05 23:48:29 +00:00
|
|
|
|
|
2019-12-25 19:42:01 +00:00
|
|
|
|
# Onion skinning options
|
2020-03-26 18:56:30 +00:00
|
|
|
|
var onion_skinning := false
|
2020-05-01 17:47:10 +00:00
|
|
|
|
var onion_skinning_past_rate := 1.0
|
|
|
|
|
var onion_skinning_future_rate := 1.0
|
2019-12-05 23:48:29 +00:00
|
|
|
|
var onion_skinning_blue_red := false
|
|
|
|
|
|
2019-12-25 19:42:01 +00:00
|
|
|
|
# Palettes
|
2019-12-15 03:11:32 +00:00
|
|
|
|
var palettes := {}
|
|
|
|
|
|
2019-12-25 19:42:01 +00:00
|
|
|
|
# Nodes
|
2019-11-13 13:45:55 +00:00
|
|
|
|
var control : Node
|
2019-12-18 23:18:57 +00:00
|
|
|
|
var top_menu_container : Panel
|
2019-12-10 17:56:16 +00:00
|
|
|
|
var left_cursor : Sprite
|
|
|
|
|
var right_cursor : Sprite
|
2019-08-18 09:28:38 +00:00
|
|
|
|
var canvas : Canvas
|
2020-06-04 23:48:38 +00:00
|
|
|
|
var tabs : Tabs
|
2019-11-19 21:23:43 +00:00
|
|
|
|
var main_viewport : ViewportContainer
|
2019-09-25 19:59:48 +00:00
|
|
|
|
var second_viewport : ViewportContainer
|
2020-06-11 23:27:21 +00:00
|
|
|
|
var small_preview_viewport : ViewportContainer
|
2019-09-09 22:57:46 +00:00
|
|
|
|
var camera : Camera2D
|
2019-09-25 19:59:48 +00:00
|
|
|
|
var camera2 : Camera2D
|
2019-12-05 14:49:27 +00:00
|
|
|
|
var camera_preview : Camera2D
|
2019-12-03 00:30:38 +00:00
|
|
|
|
var horizontal_ruler : BaseButton
|
2019-11-20 22:11:21 +00:00
|
|
|
|
var vertical_ruler : BaseButton
|
2020-04-20 16:12:22 +00:00
|
|
|
|
var transparent_checker : ColorRect
|
2019-09-14 19:55:33 +00:00
|
|
|
|
|
2019-12-05 23:48:29 +00:00
|
|
|
|
var cursor_position_label : Label
|
|
|
|
|
var zoom_level_label : Label
|
2019-12-03 16:36:28 +00:00
|
|
|
|
|
2021-03-06 13:59:26 +00:00
|
|
|
|
var tool_panel : Panel
|
|
|
|
|
var right_panel : Panel
|
|
|
|
|
var tabs_container : PanelContainer
|
|
|
|
|
|
2020-10-26 20:51:55 +00:00
|
|
|
|
var recent_projects_submenu : PopupMenu
|
2020-11-13 18:12:20 +00:00
|
|
|
|
var tile_mode_submenu : PopupMenu
|
2021-02-02 15:29:19 +00:00
|
|
|
|
var window_transparency_submenu : PopupMenu
|
2021-03-06 13:59:26 +00:00
|
|
|
|
var panel_layout_submenu : PopupMenu
|
2020-10-26 20:51:55 +00:00
|
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
|
var new_image_dialog : ConfirmationDialog
|
2020-06-09 17:19:55 +00:00
|
|
|
|
var open_sprites_dialog : FileDialog
|
|
|
|
|
var save_sprites_dialog : FileDialog
|
2020-06-30 17:25:43 +00:00
|
|
|
|
var save_sprites_html5_dialog : ConfirmationDialog
|
2020-05-03 15:47:13 +00:00
|
|
|
|
var export_dialog : AcceptDialog
|
2020-05-28 00:41:28 +00:00
|
|
|
|
var preferences_dialog : AcceptDialog
|
2020-06-05 14:50:52 +00:00
|
|
|
|
var unsaved_changes_dialog : ConfirmationDialog
|
2019-12-28 16:35:53 +00:00
|
|
|
|
|
2020-04-25 19:24:20 +00:00
|
|
|
|
var color_switch_button : BaseButton
|
2020-04-15 18:52:20 +00:00
|
|
|
|
|
2019-12-05 23:48:29 +00:00
|
|
|
|
var brushes_popup : Popup
|
2020-04-24 21:42:02 +00:00
|
|
|
|
var patterns_popup : Popup
|
2019-12-03 16:36:28 +00:00
|
|
|
|
|
2020-01-15 20:01:43 +00:00
|
|
|
|
var animation_timeline : Panel
|
2019-12-05 23:48:29 +00:00
|
|
|
|
|
2020-01-15 20:01:43 +00:00
|
|
|
|
var animation_timer : Timer
|
2020-10-19 14:57:40 +00:00
|
|
|
|
var frame_properties : ConfirmationDialog
|
2020-01-18 19:06:47 +00:00
|
|
|
|
var frame_ids : HBoxContainer
|
2020-05-23 21:22:06 +00:00
|
|
|
|
var current_frame_mark_label : Label
|
2020-04-03 12:34:16 +00:00
|
|
|
|
var onion_skinning_button : BaseButton
|
2019-11-19 21:23:43 +00:00
|
|
|
|
var loop_animation_button : BaseButton
|
|
|
|
|
var play_forward : BaseButton
|
|
|
|
|
var play_backwards : BaseButton
|
2020-01-18 22:56:30 +00:00
|
|
|
|
var layers_container : VBoxContainer
|
|
|
|
|
var frames_container : VBoxContainer
|
2020-04-02 00:29:14 +00:00
|
|
|
|
var tag_container : Control
|
2020-04-05 22:07:28 +00:00
|
|
|
|
var tag_dialog : AcceptDialog
|
2019-12-05 23:48:29 +00:00
|
|
|
|
|
2020-05-03 15:17:12 +00:00
|
|
|
|
var remove_frame_button : BaseButton
|
2020-10-04 23:37:55 +00:00
|
|
|
|
var move_left_frame_button : BaseButton
|
|
|
|
|
var move_right_frame_button : BaseButton
|
2020-05-03 15:17:12 +00:00
|
|
|
|
|
2019-11-19 21:23:43 +00:00
|
|
|
|
var remove_layer_button : BaseButton
|
|
|
|
|
var move_up_layer_button : BaseButton
|
|
|
|
|
var move_down_layer_button : BaseButton
|
|
|
|
|
var merge_down_layer_button : BaseButton
|
2019-12-24 21:51:08 +00:00
|
|
|
|
var layer_opacity_slider : HSlider
|
2019-12-24 22:23:45 +00:00
|
|
|
|
var layer_opacity_spinbox : SpinBox
|
2019-09-25 19:59:48 +00:00
|
|
|
|
|
2020-08-01 21:59:00 +00:00
|
|
|
|
var preview_zoom_slider : VSlider
|
2021-04-16 18:09:03 +00:00
|
|
|
|
var palette_panel : PalettePanel
|
2020-08-01 21:59:00 +00:00
|
|
|
|
|
2019-12-17 01:23:18 +00:00
|
|
|
|
var error_dialog : AcceptDialog
|
2020-06-13 14:59:57 +00:00
|
|
|
|
var quit_dialog : ConfirmationDialog
|
|
|
|
|
var quit_and_save_dialog : ConfirmationDialog
|
2019-12-15 03:11:32 +00:00
|
|
|
|
|
2020-05-03 21:04:00 +00:00
|
|
|
|
onready var current_version : String = ProjectSettings.get_setting("application/config/Version")
|
|
|
|
|
|
2020-04-24 21:42:02 +00:00
|
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
|
func _ready() -> void:
|
2019-12-26 19:36:56 +00:00
|
|
|
|
randomize()
|
2020-12-06 00:10:40 +00:00
|
|
|
|
if OS.get_name() == "OSX":
|
|
|
|
|
use_osx_shortcuts()
|
2020-02-09 23:23:33 +00:00
|
|
|
|
if OS.has_feature("standalone"):
|
|
|
|
|
root_directory = OS.get_executable_path().get_base_dir()
|
2019-12-20 14:36:23 +00:00
|
|
|
|
# Load settings from the config file
|
|
|
|
|
config_cache.load("user://cache.ini")
|
2020-10-27 21:03:43 +00:00
|
|
|
|
|
2020-10-26 20:51:55 +00:00
|
|
|
|
recent_projects = config_cache.get_value("data", "recent_projects", [])
|
2021-03-06 13:59:26 +00:00
|
|
|
|
panel_layout = config_cache.get_value("window", "panel_layout", PanelLayout.AUTO)
|
2020-04-12 22:40:26 +00:00
|
|
|
|
|
2020-04-11 06:58:58 +00:00
|
|
|
|
# The fact that root_dir is set earlier than this is important
|
|
|
|
|
# XDGDataDirs depends on it nyaa
|
|
|
|
|
directory_module = XDGDataPaths.new()
|
2019-12-05 23:48:29 +00:00
|
|
|
|
image_clipboard = Image.new()
|
New selection system (#474)
* Basic move tool
* Added marching ants effect on the selection borders
* Rename SelectionRectangle to SelectionShape, make it have non-rectangular shape and multiple SelectionShapes can exist
- Create multiple selection rectangles
- Merge them together if they intersect
- Move the selections (without contents as of right now)
- Gizmos are being drawn but they are not functional yet
Code is very ugly.
* Sort vectors counter-clockwise to be used as polygon borders
I did this, no idea if it works properly, probably won't be used but I thought I'd keep it saved somewhere
* More experiments I may or may not need
Trying to generate a polygon from the individual selected pixels
* Change default rectangle select behavior and ability to clip polygons using Control
* Fix rectangle selection clipping
* Split polygon into two with selection subtracting
* Move selection with contents with the move tool
Code is still a mess, don't bother looking.
* Move some methods from SelectionShape.gd to Selection.gd
The purpose of this is to generalize some selection code, so that it applies to all polygons, the entire selection. More will follow.
* UndoRedo for border moving
Nothing else in the selections system works properly in UndoRedo right now. Needs:
- UR support for creating selections
- UR support for modifying selections (merging and cutting selections together)
- UR support for removing selection
- UR support for moving content
& for all the rest of the remaining features
* Moving all of the selection shape logic to Selection.gd
Handle all of the polygons there instead of having them as individual nodes. Should be easier to handle undo/redo this way. This commit probably breaks move tool + selection tool and undo/redo. Code is still a mess. For your sanity, I hope you are not reading this. I promise I will clean up.
* Move tool works again
Buggy and messy, of course.
* Remove unneeded code and restore selection move undoredo logic
* Made Selection.gd have one big preview_image for when moving content, instead of each polygon having its own image
Could be further optimized for some specific cases. We could also remove selected_pixels from SelectionPolygon.
* UndoRedo support for creating, deleting, merging and clipping selections
UndoRedo support for moving content not added in this commit. Should work but needs more testing. This PR also removes selected_pixels from the SelectionPolygon class.
* Confirm & cancel selection movement, should support undoredo properly too
Press Enter or do any editing to confirm movement, Escape to cancel. I will most likely add UI buttons for confirm and cancel too.
* Mirror View affects selection
* Restore Cut, Copy, Paste and Clear Selection
Pasting now no longer requires a pre-existing selection and instead copies the selections themselves too.
* Created a new Select menu, which has Select All and Clear Selection as options
Clear Selection now also confirms content moving. TopMenuContainer code has changed to no longer rely on Global for the menu buttons.
* Draw gizmos as rectangles
No functionality yet. They may need to be turned to nodes, so that they can easily resize based on zoom level and check for mouse enter/exit events.
* Made gizmos get drawn in the sides and corners of the big bounding rectangle instead of individual selection parts
Still no functionality yet.
* Restore label text
* Minor optimization when clipping selections
This will execute the for loop less times
* Made a Gizmo class, cursor change on hover, has_focus = false on mouse click
Now I should actually make them resize when dragged, aye?
* Very basic gizmo resizing, still a WIP, does not work properly yet
* Start replacing the array of selected pixels with a BitMap
This should optimize the selection making a lot, and it also allows for easy border drawing without having to deal with polygons, thanks to the MarchingAntsOutline.shader
Still commit is still a WIP, image effects and brushes may not work properly yet.
Because the BitMap has a fixed size, the size of the project, moving the selection outside of canvas boundaries has proven to be a bit tricky. I did implement a hacky way of handling it, but it may be buggy and problematic. I'm still unsure whether this is the best way to handle the situation.
* Selection works with mirror view
* Draw a black rectangle when the user is making a rectangular selection
After they release the mouse, the black rectangle becomes the selection
* Make Selection.gd update when undoing/redoing
* Fix brushes not working properly with non-rectangular selections
* Added invert selection
* Cache has_selection as a variable for a speedup
* Fix conflict issues with the shape tools
* Made the bitmap image squared so the marching ants effect will be the same on both dimensions
There may be a better way to fix the issue, perhaps inside the shader itself.
* Some optimizations to call selection_bitmap_changed() less times
* Restored almost all of the image effects
Left to do:
- Change gradient's behavior. Unsure of how it will work with non-rectangular selections yet, but it should not generate pixels outside of the selection.
- Restore rotation
- Resize bitmap on image resize
- Remove the `pixels` array from the ImageEffect
* Fix Selection.gd not updating when changing project
* Resize the selection bitmap along with image resize
* Restored rotation's old behavior and finally got rid of the selected_pixels array
The rotation does not yet work properly with selections, but at least it now "works".
* Resize selection too when using gizmos
Left to do for gizmos:
- Proper cancel transformation
- Begin transformation
(currently named move_content_start but it should be renamed to something more general) when resizing gizmos
- Keep the original image and selection in memory and resize them. Meaning, gizmos should not resize the already resized data, but only resize the original. This is less destructive as there is no danger of data loss.
- Always resize on InputEventMouseMotion. This is going to be worse for performance, but it will look better for the user.
* Image and bitmap resizing now uses the original data and begin transformation on gizmo click
No matter how many times the user resizes on the current transformation, the original data will not be lost until they either confirm or cancel, so there is no data loss before confirmation/cancel.
* Cancel transformation now works properly when the selection has been resized
* Made gizmos resize on mouse motion, fix issues with negative bounding rectangle and when combined with the move tool
* Resizing can now get out of positive bounds, clearing and inverting now gets limited to the canvas bounds
Resizing currently does not work properly with negative (left & up) canvas boundaries
* Flip image when resizing and the bounding rectangle gets flipped
* Call move_content_confirm() when inverting selection
* Attempt to implement selection resizing that goes outside of the canvas boundaries (not working properly yet)
* Flip selection when resizing to negative bounding rectangle sizes
And fix preview_image vertical flipping
* Fix rotation so that it works (almost) properly with selections
Rotation algorithms now accept and only work with a given image, and the pivot has been added as a parameter
* Experimental gizmo rotation - does not work properly yet
Transforming the selection outside of the canvas is still broken.
* Fix some issues with moving selection out of canvas bounds
* Fix more issues with selection getting resized outside of canvas bounds
* Update marching ants effect properly when switching between projects
And make sure the frequency of the marching ants effect always looks roughly the same on all project sizes
* Made the rotation gizmo part of the gizmos array and resize them based on camera zoom
* Remove unneeded parameter from move_bitmap_values()
* Remove more unneeded parameters
* Move the selection only if the cursor is above it and neither shift nor control are currently pressed
* Gradient generation now works on non-rectangular selections
Although this behavior might not be the intended one
* Copy/paste marching ants effect offset
Useful for when the selection is in negative coords
* Fix issue with clear selection & UndoRedo
* Restore the ability to move selection when it's in negative coords
* Made the marching ants offset a Project variable
This fixes the issue of project switching and keeping the previous project's offset. Again, this is only relevant for when the selection is in negative coords.
* Made the "from current selection" palette preset work with the new selection system
* Fix out of bounds error when using the rectangular select tool on negative coords
* Some code cleanup
* Comment out the rotation gizmo for now, since it does not work properly
* Update marching ants shader params and gizmo sizes when the bitmap changes
* Move some methods around in Selection.gd
2021-04-17 18:30:12 +00:00
|
|
|
|
Input.set_custom_mouse_cursor(cursor_image, Input.CURSOR_CROSS, Vector2(15, 15))
|
2020-04-12 22:40:26 +00:00
|
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
|
var root = get_tree().get_root()
|
2019-11-13 13:45:55 +00:00
|
|
|
|
control = find_node_by_name(root, "Control")
|
2021-03-06 13:59:26 +00:00
|
|
|
|
|
2019-12-18 23:18:57 +00:00
|
|
|
|
top_menu_container = find_node_by_name(control, "TopMenuContainer")
|
2019-12-10 17:56:16 +00:00
|
|
|
|
left_cursor = find_node_by_name(root, "LeftCursor")
|
|
|
|
|
right_cursor = find_node_by_name(root, "RightCursor")
|
2019-08-18 09:28:38 +00:00
|
|
|
|
canvas = find_node_by_name(root, "Canvas")
|
2020-06-25 15:18:20 +00:00
|
|
|
|
|
2020-06-04 23:48:38 +00:00
|
|
|
|
tabs = find_node_by_name(root, "Tabs")
|
2019-11-19 21:23:43 +00:00
|
|
|
|
main_viewport = find_node_by_name(root, "ViewportContainer")
|
2019-09-25 19:59:48 +00:00
|
|
|
|
second_viewport = find_node_by_name(root, "ViewportContainer2")
|
2020-06-11 23:27:21 +00:00
|
|
|
|
small_preview_viewport = find_node_by_name(root, "PreviewViewportContainer")
|
2020-06-02 23:14:24 +00:00
|
|
|
|
camera = find_node_by_name(main_viewport, "Camera2D")
|
2019-11-19 21:23:43 +00:00
|
|
|
|
camera2 = find_node_by_name(root, "Camera2D2")
|
2019-12-05 14:49:27 +00:00
|
|
|
|
camera_preview = find_node_by_name(root, "CameraPreview")
|
2019-12-03 00:30:38 +00:00
|
|
|
|
horizontal_ruler = find_node_by_name(root, "HorizontalRuler")
|
2019-11-20 22:11:21 +00:00
|
|
|
|
vertical_ruler = find_node_by_name(root, "VerticalRuler")
|
2020-04-20 16:12:22 +00:00
|
|
|
|
transparent_checker = find_node_by_name(root, "TransparentChecker")
|
2019-10-29 21:22:38 +00:00
|
|
|
|
|
2019-12-05 23:48:29 +00:00
|
|
|
|
cursor_position_label = find_node_by_name(root, "CursorPosition")
|
|
|
|
|
zoom_level_label = find_node_by_name(root, "ZoomLevel")
|
2020-10-27 21:03:43 +00:00
|
|
|
|
|
2021-03-06 13:59:26 +00:00
|
|
|
|
tool_panel = control.get_node("MenuAndUI/UI/ToolPanel")
|
|
|
|
|
right_panel = control.get_node("MenuAndUI/UI/RightPanel")
|
|
|
|
|
tabs_container = control.get_node("MenuAndUI/UI/CanvasAndTimeline/ViewportAndRulers/TabsContainer")
|
|
|
|
|
|
2020-10-27 21:03:43 +00:00
|
|
|
|
recent_projects_submenu = PopupMenu.new()
|
2020-10-26 20:51:55 +00:00
|
|
|
|
recent_projects_submenu.set_name("recent_projects_submenu")
|
2019-12-03 16:36:28 +00:00
|
|
|
|
|
2020-11-13 18:12:20 +00:00
|
|
|
|
tile_mode_submenu = PopupMenu.new()
|
|
|
|
|
tile_mode_submenu.set_name("tile_mode_submenu")
|
2021-01-20 14:59:42 +00:00
|
|
|
|
tile_mode_submenu.add_radio_check_item("None", TileMode.NONE)
|
|
|
|
|
tile_mode_submenu.set_item_checked(TileMode.NONE, true)
|
|
|
|
|
tile_mode_submenu.add_radio_check_item("Tiled In Both Axis", TileMode.BOTH)
|
|
|
|
|
tile_mode_submenu.add_radio_check_item("Tiled In X Axis", TileMode.X_AXIS)
|
|
|
|
|
tile_mode_submenu.add_radio_check_item("Tiled In Y Axis", TileMode.Y_AXIS)
|
2020-11-13 18:12:20 +00:00
|
|
|
|
tile_mode_submenu.hide_on_checkable_item_selection = false
|
|
|
|
|
|
2021-02-02 15:29:19 +00:00
|
|
|
|
window_transparency_submenu = PopupMenu.new()
|
|
|
|
|
window_transparency_submenu.set_name("set value")
|
|
|
|
|
window_transparency_submenu.add_radio_check_item("100%")
|
|
|
|
|
window_transparency_submenu.add_radio_check_item("90%")
|
|
|
|
|
window_transparency_submenu.add_radio_check_item("80%")
|
|
|
|
|
window_transparency_submenu.add_radio_check_item("70%")
|
|
|
|
|
window_transparency_submenu.add_radio_check_item("60%")
|
|
|
|
|
window_transparency_submenu.add_radio_check_item("50%")
|
|
|
|
|
window_transparency_submenu.add_radio_check_item("40%")
|
|
|
|
|
window_transparency_submenu.add_radio_check_item("30%")
|
|
|
|
|
window_transparency_submenu.add_radio_check_item("20%")
|
|
|
|
|
window_transparency_submenu.add_radio_check_item("10%")
|
|
|
|
|
window_transparency_submenu.add_radio_check_item("0%")
|
|
|
|
|
window_transparency_submenu.set_item_checked(10, true)
|
|
|
|
|
window_transparency_submenu.hide_on_checkable_item_selection = false
|
|
|
|
|
|
2021-03-06 13:59:26 +00:00
|
|
|
|
panel_layout_submenu = PopupMenu.new()
|
|
|
|
|
panel_layout_submenu.set_name("panel_layout_submenu")
|
|
|
|
|
panel_layout_submenu.add_radio_check_item("Auto", PanelLayout.AUTO)
|
|
|
|
|
panel_layout_submenu.add_radio_check_item("Widescreen", PanelLayout.WIDESCREEN)
|
|
|
|
|
panel_layout_submenu.add_radio_check_item("Tallscreen", PanelLayout.TALLSCREEN)
|
|
|
|
|
panel_layout_submenu.hide_on_checkable_item_selection = false
|
|
|
|
|
panel_layout_submenu.set_item_checked(panel_layout, true)
|
|
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
|
new_image_dialog = find_node_by_name(root, "CreateNewImage")
|
2020-06-09 17:19:55 +00:00
|
|
|
|
open_sprites_dialog = find_node_by_name(root, "OpenSprite")
|
|
|
|
|
save_sprites_dialog = find_node_by_name(root, "SaveSprite")
|
2020-06-30 17:25:43 +00:00
|
|
|
|
save_sprites_html5_dialog = find_node_by_name(root, "SaveSpriteHTML5")
|
2020-05-03 15:47:13 +00:00
|
|
|
|
export_dialog = find_node_by_name(root, "ExportDialog")
|
2020-05-28 00:41:28 +00:00
|
|
|
|
preferences_dialog = find_node_by_name(root, "PreferencesDialog")
|
2020-06-05 14:50:52 +00:00
|
|
|
|
unsaved_changes_dialog = find_node_by_name(root, "UnsavedCanvasDialog")
|
2019-12-28 16:35:53 +00:00
|
|
|
|
|
2020-04-15 18:52:20 +00:00
|
|
|
|
color_switch_button = find_node_by_name(root, "ColorSwitch")
|
2019-12-03 16:36:28 +00:00
|
|
|
|
|
2019-12-05 23:48:29 +00:00
|
|
|
|
brushes_popup = find_node_by_name(root, "BrushesPopup")
|
2020-04-24 21:42:02 +00:00
|
|
|
|
patterns_popup = find_node_by_name(root, "PatternsPopup")
|
2019-12-03 16:36:28 +00:00
|
|
|
|
|
2020-01-15 20:01:43 +00:00
|
|
|
|
animation_timeline = find_node_by_name(root, "AnimationTimeline")
|
2020-10-20 00:27:38 +00:00
|
|
|
|
frame_properties = find_node_by_name(root, "FrameProperties")
|
2019-12-05 23:48:29 +00:00
|
|
|
|
|
2020-01-18 22:56:30 +00:00
|
|
|
|
layers_container = find_node_by_name(animation_timeline, "LayersContainer")
|
|
|
|
|
frames_container = find_node_by_name(animation_timeline, "FramesContainer")
|
2020-01-15 20:01:43 +00:00
|
|
|
|
animation_timer = find_node_by_name(animation_timeline, "AnimationTimer")
|
2020-01-18 19:06:47 +00:00
|
|
|
|
frame_ids = find_node_by_name(animation_timeline, "FrameIDs")
|
2020-05-23 21:22:06 +00:00
|
|
|
|
current_frame_mark_label = find_node_by_name(control, "CurrentFrameMark")
|
2020-04-03 12:34:16 +00:00
|
|
|
|
onion_skinning_button = find_node_by_name(animation_timeline, "OnionSkinning")
|
2020-01-15 20:01:43 +00:00
|
|
|
|
loop_animation_button = find_node_by_name(animation_timeline, "LoopAnim")
|
|
|
|
|
play_forward = find_node_by_name(animation_timeline, "PlayForward")
|
|
|
|
|
play_backwards = find_node_by_name(animation_timeline, "PlayBackwards")
|
2020-04-02 00:29:14 +00:00
|
|
|
|
tag_container = find_node_by_name(animation_timeline, "TagContainer")
|
2020-04-05 21:51:46 +00:00
|
|
|
|
tag_dialog = find_node_by_name(animation_timeline, "FrameTagDialog")
|
2019-11-29 22:41:34 +00:00
|
|
|
|
|
2020-05-03 15:17:12 +00:00
|
|
|
|
remove_frame_button = find_node_by_name(animation_timeline, "DeleteFrame")
|
2020-10-04 23:37:55 +00:00
|
|
|
|
move_left_frame_button = find_node_by_name(animation_timeline, "MoveLeft")
|
|
|
|
|
move_right_frame_button = find_node_by_name(animation_timeline, "MoveRight")
|
2020-05-03 15:17:12 +00:00
|
|
|
|
|
2020-01-18 19:06:47 +00:00
|
|
|
|
remove_layer_button = find_node_by_name(animation_timeline, "RemoveLayer")
|
|
|
|
|
move_up_layer_button = find_node_by_name(animation_timeline, "MoveUpLayer")
|
2020-03-26 01:24:25 +00:00
|
|
|
|
move_down_layer_button = find_node_by_name(animation_timeline, "MoveDownLayer")
|
2020-01-18 19:06:47 +00:00
|
|
|
|
merge_down_layer_button = find_node_by_name(animation_timeline, "MergeDownLayer")
|
|
|
|
|
|
|
|
|
|
layer_opacity_slider = find_node_by_name(animation_timeline, "OpacitySlider")
|
|
|
|
|
layer_opacity_spinbox = find_node_by_name(animation_timeline, "OpacitySpinBox")
|
2019-12-15 11:44:53 +00:00
|
|
|
|
|
2020-08-01 21:59:00 +00:00
|
|
|
|
preview_zoom_slider = find_node_by_name(root, "PreviewZoomSlider")
|
|
|
|
|
|
2021-04-16 18:09:03 +00:00
|
|
|
|
palette_panel = find_node_by_name(root, "PalettePanel")
|
2019-12-17 01:23:18 +00:00
|
|
|
|
|
|
|
|
|
error_dialog = find_node_by_name(root, "ErrorDialog")
|
2020-06-13 14:59:57 +00:00
|
|
|
|
quit_dialog = find_node_by_name(root, "QuitDialog")
|
|
|
|
|
quit_and_save_dialog = find_node_by_name(root, "QuitAndSaveDialog")
|
2019-08-18 09:28:38 +00:00
|
|
|
|
|
2020-06-04 23:48:38 +00:00
|
|
|
|
projects.append(Project.new())
|
2020-06-05 15:54:11 +00:00
|
|
|
|
projects[0].layers.append(Layer.new())
|
2020-06-04 23:48:38 +00:00
|
|
|
|
current_project = projects[0]
|
|
|
|
|
|
2020-04-02 00:29:14 +00:00
|
|
|
|
|
2019-12-28 01:07:48 +00:00
|
|
|
|
# Thanks to https://godotengine.org/qa/17524/how-to-find-an-instanced-scene-by-its-name
|
2020-06-01 13:42:53 +00:00
|
|
|
|
func find_node_by_name(root : Node, node_name : String) -> Node:
|
2019-10-29 21:22:38 +00:00
|
|
|
|
if root.get_name() == node_name:
|
2019-08-18 09:28:38 +00:00
|
|
|
|
return root
|
|
|
|
|
for child in root.get_children():
|
|
|
|
|
if child.get_name() == node_name:
|
|
|
|
|
return child
|
|
|
|
|
var found = find_node_by_name(child, node_name)
|
2019-10-29 21:22:38 +00:00
|
|
|
|
if found:
|
2019-08-18 09:28:38 +00:00
|
|
|
|
return found
|
2019-09-09 22:57:46 +00:00
|
|
|
|
return null
|
|
|
|
|
|
2020-04-19 21:09:48 +00:00
|
|
|
|
|
2019-11-13 13:45:55 +00:00
|
|
|
|
func notification_label(text : String) -> void:
|
2020-05-01 22:19:01 +00:00
|
|
|
|
var notification : Label = load("res://src/UI/NotificationLabel.tscn").instance()
|
2019-12-08 01:12:34 +00:00
|
|
|
|
notification.text = tr(text)
|
2020-10-29 14:46:58 +00:00
|
|
|
|
notification.rect_position = Vector2(70, OS.window_size.y - animation_timeline.rect_size.y - 20)
|
2020-03-01 15:56:34 +00:00
|
|
|
|
notification.theme = control.theme
|
2019-11-13 13:45:55 +00:00
|
|
|
|
get_tree().get_root().add_child(notification)
|
|
|
|
|
|
2020-04-19 18:17:33 +00:00
|
|
|
|
|
2020-07-24 00:41:10 +00:00
|
|
|
|
func general_undo(project : Project = current_project) -> void:
|
|
|
|
|
project.undos -= 1
|
|
|
|
|
var action_name : String = project.undo_redo.get_current_action_name()
|
2020-04-19 18:17:33 +00:00
|
|
|
|
notification_label("Undo: %s" % action_name)
|
|
|
|
|
|
|
|
|
|
|
2020-07-24 00:41:10 +00:00
|
|
|
|
func general_redo(project : Project = current_project) -> void:
|
|
|
|
|
if project.undos < project.undo_redo.get_version(): # If we did undo and then redo
|
|
|
|
|
project.undos = project.undo_redo.get_version()
|
2020-04-19 18:17:33 +00:00
|
|
|
|
if control.redone:
|
2020-07-24 00:41:10 +00:00
|
|
|
|
var action_name : String = project.undo_redo.get_current_action_name()
|
2020-04-19 18:17:33 +00:00
|
|
|
|
notification_label("Redo: %s" % action_name)
|
|
|
|
|
|
|
|
|
|
|
2020-07-24 00:41:10 +00:00
|
|
|
|
func undo(_frame_index := -1, _layer_index := -1, project : Project = current_project) -> void:
|
|
|
|
|
general_undo(project)
|
|
|
|
|
var action_name : String = project.undo_redo.get_current_action_name()
|
New selection system (#474)
* Basic move tool
* Added marching ants effect on the selection borders
* Rename SelectionRectangle to SelectionShape, make it have non-rectangular shape and multiple SelectionShapes can exist
- Create multiple selection rectangles
- Merge them together if they intersect
- Move the selections (without contents as of right now)
- Gizmos are being drawn but they are not functional yet
Code is very ugly.
* Sort vectors counter-clockwise to be used as polygon borders
I did this, no idea if it works properly, probably won't be used but I thought I'd keep it saved somewhere
* More experiments I may or may not need
Trying to generate a polygon from the individual selected pixels
* Change default rectangle select behavior and ability to clip polygons using Control
* Fix rectangle selection clipping
* Split polygon into two with selection subtracting
* Move selection with contents with the move tool
Code is still a mess, don't bother looking.
* Move some methods from SelectionShape.gd to Selection.gd
The purpose of this is to generalize some selection code, so that it applies to all polygons, the entire selection. More will follow.
* UndoRedo for border moving
Nothing else in the selections system works properly in UndoRedo right now. Needs:
- UR support for creating selections
- UR support for modifying selections (merging and cutting selections together)
- UR support for removing selection
- UR support for moving content
& for all the rest of the remaining features
* Moving all of the selection shape logic to Selection.gd
Handle all of the polygons there instead of having them as individual nodes. Should be easier to handle undo/redo this way. This commit probably breaks move tool + selection tool and undo/redo. Code is still a mess. For your sanity, I hope you are not reading this. I promise I will clean up.
* Move tool works again
Buggy and messy, of course.
* Remove unneeded code and restore selection move undoredo logic
* Made Selection.gd have one big preview_image for when moving content, instead of each polygon having its own image
Could be further optimized for some specific cases. We could also remove selected_pixels from SelectionPolygon.
* UndoRedo support for creating, deleting, merging and clipping selections
UndoRedo support for moving content not added in this commit. Should work but needs more testing. This PR also removes selected_pixels from the SelectionPolygon class.
* Confirm & cancel selection movement, should support undoredo properly too
Press Enter or do any editing to confirm movement, Escape to cancel. I will most likely add UI buttons for confirm and cancel too.
* Mirror View affects selection
* Restore Cut, Copy, Paste and Clear Selection
Pasting now no longer requires a pre-existing selection and instead copies the selections themselves too.
* Created a new Select menu, which has Select All and Clear Selection as options
Clear Selection now also confirms content moving. TopMenuContainer code has changed to no longer rely on Global for the menu buttons.
* Draw gizmos as rectangles
No functionality yet. They may need to be turned to nodes, so that they can easily resize based on zoom level and check for mouse enter/exit events.
* Made gizmos get drawn in the sides and corners of the big bounding rectangle instead of individual selection parts
Still no functionality yet.
* Restore label text
* Minor optimization when clipping selections
This will execute the for loop less times
* Made a Gizmo class, cursor change on hover, has_focus = false on mouse click
Now I should actually make them resize when dragged, aye?
* Very basic gizmo resizing, still a WIP, does not work properly yet
* Start replacing the array of selected pixels with a BitMap
This should optimize the selection making a lot, and it also allows for easy border drawing without having to deal with polygons, thanks to the MarchingAntsOutline.shader
Still commit is still a WIP, image effects and brushes may not work properly yet.
Because the BitMap has a fixed size, the size of the project, moving the selection outside of canvas boundaries has proven to be a bit tricky. I did implement a hacky way of handling it, but it may be buggy and problematic. I'm still unsure whether this is the best way to handle the situation.
* Selection works with mirror view
* Draw a black rectangle when the user is making a rectangular selection
After they release the mouse, the black rectangle becomes the selection
* Make Selection.gd update when undoing/redoing
* Fix brushes not working properly with non-rectangular selections
* Added invert selection
* Cache has_selection as a variable for a speedup
* Fix conflict issues with the shape tools
* Made the bitmap image squared so the marching ants effect will be the same on both dimensions
There may be a better way to fix the issue, perhaps inside the shader itself.
* Some optimizations to call selection_bitmap_changed() less times
* Restored almost all of the image effects
Left to do:
- Change gradient's behavior. Unsure of how it will work with non-rectangular selections yet, but it should not generate pixels outside of the selection.
- Restore rotation
- Resize bitmap on image resize
- Remove the `pixels` array from the ImageEffect
* Fix Selection.gd not updating when changing project
* Resize the selection bitmap along with image resize
* Restored rotation's old behavior and finally got rid of the selected_pixels array
The rotation does not yet work properly with selections, but at least it now "works".
* Resize selection too when using gizmos
Left to do for gizmos:
- Proper cancel transformation
- Begin transformation
(currently named move_content_start but it should be renamed to something more general) when resizing gizmos
- Keep the original image and selection in memory and resize them. Meaning, gizmos should not resize the already resized data, but only resize the original. This is less destructive as there is no danger of data loss.
- Always resize on InputEventMouseMotion. This is going to be worse for performance, but it will look better for the user.
* Image and bitmap resizing now uses the original data and begin transformation on gizmo click
No matter how many times the user resizes on the current transformation, the original data will not be lost until they either confirm or cancel, so there is no data loss before confirmation/cancel.
* Cancel transformation now works properly when the selection has been resized
* Made gizmos resize on mouse motion, fix issues with negative bounding rectangle and when combined with the move tool
* Resizing can now get out of positive bounds, clearing and inverting now gets limited to the canvas bounds
Resizing currently does not work properly with negative (left & up) canvas boundaries
* Flip image when resizing and the bounding rectangle gets flipped
* Call move_content_confirm() when inverting selection
* Attempt to implement selection resizing that goes outside of the canvas boundaries (not working properly yet)
* Flip selection when resizing to negative bounding rectangle sizes
And fix preview_image vertical flipping
* Fix rotation so that it works (almost) properly with selections
Rotation algorithms now accept and only work with a given image, and the pivot has been added as a parameter
* Experimental gizmo rotation - does not work properly yet
Transforming the selection outside of the canvas is still broken.
* Fix some issues with moving selection out of canvas bounds
* Fix more issues with selection getting resized outside of canvas bounds
* Update marching ants effect properly when switching between projects
And make sure the frequency of the marching ants effect always looks roughly the same on all project sizes
* Made the rotation gizmo part of the gizmos array and resize them based on camera zoom
* Remove unneeded parameter from move_bitmap_values()
* Remove more unneeded parameters
* Move the selection only if the cursor is above it and neither shift nor control are currently pressed
* Gradient generation now works on non-rectangular selections
Although this behavior might not be the intended one
* Copy/paste marching ants effect offset
Useful for when the selection is in negative coords
* Fix issue with clear selection & UndoRedo
* Restore the ability to move selection when it's in negative coords
* Made the marching ants offset a Project variable
This fixes the issue of project switching and keeping the previous project's offset. Again, this is only relevant for when the selection is in negative coords.
* Made the "from current selection" palette preset work with the new selection system
* Fix out of bounds error when using the rectangular select tool on negative coords
* Some code cleanup
* Comment out the rotation gizmo for now, since it does not work properly
* Update marching ants shader params and gizmo sizes when the bitmap changes
* Move some methods around in Selection.gd
2021-04-17 18:30:12 +00:00
|
|
|
|
if action_name == "Draw" or action_name == "Draw Shape" or action_name == "Rectangle Select" or action_name == "Move Selection" or action_name == "Scale" or action_name == "Centralize" or action_name == "Merge Layer" or action_name == "Link Cel" or action_name == "Unlink Cel":
|
2020-06-02 23:14:24 +00:00
|
|
|
|
if _layer_index > -1 and _frame_index > -1:
|
2020-07-24 00:41:10 +00:00
|
|
|
|
canvas.update_texture(_layer_index, _frame_index, project)
|
2020-06-02 23:14:24 +00:00
|
|
|
|
else:
|
2020-07-24 00:41:10 +00:00
|
|
|
|
for i in project.frames.size():
|
|
|
|
|
for j in project.layers.size():
|
|
|
|
|
canvas.update_texture(j, i, project)
|
2020-06-02 23:14:24 +00:00
|
|
|
|
|
New selection system (#474)
* Basic move tool
* Added marching ants effect on the selection borders
* Rename SelectionRectangle to SelectionShape, make it have non-rectangular shape and multiple SelectionShapes can exist
- Create multiple selection rectangles
- Merge them together if they intersect
- Move the selections (without contents as of right now)
- Gizmos are being drawn but they are not functional yet
Code is very ugly.
* Sort vectors counter-clockwise to be used as polygon borders
I did this, no idea if it works properly, probably won't be used but I thought I'd keep it saved somewhere
* More experiments I may or may not need
Trying to generate a polygon from the individual selected pixels
* Change default rectangle select behavior and ability to clip polygons using Control
* Fix rectangle selection clipping
* Split polygon into two with selection subtracting
* Move selection with contents with the move tool
Code is still a mess, don't bother looking.
* Move some methods from SelectionShape.gd to Selection.gd
The purpose of this is to generalize some selection code, so that it applies to all polygons, the entire selection. More will follow.
* UndoRedo for border moving
Nothing else in the selections system works properly in UndoRedo right now. Needs:
- UR support for creating selections
- UR support for modifying selections (merging and cutting selections together)
- UR support for removing selection
- UR support for moving content
& for all the rest of the remaining features
* Moving all of the selection shape logic to Selection.gd
Handle all of the polygons there instead of having them as individual nodes. Should be easier to handle undo/redo this way. This commit probably breaks move tool + selection tool and undo/redo. Code is still a mess. For your sanity, I hope you are not reading this. I promise I will clean up.
* Move tool works again
Buggy and messy, of course.
* Remove unneeded code and restore selection move undoredo logic
* Made Selection.gd have one big preview_image for when moving content, instead of each polygon having its own image
Could be further optimized for some specific cases. We could also remove selected_pixels from SelectionPolygon.
* UndoRedo support for creating, deleting, merging and clipping selections
UndoRedo support for moving content not added in this commit. Should work but needs more testing. This PR also removes selected_pixels from the SelectionPolygon class.
* Confirm & cancel selection movement, should support undoredo properly too
Press Enter or do any editing to confirm movement, Escape to cancel. I will most likely add UI buttons for confirm and cancel too.
* Mirror View affects selection
* Restore Cut, Copy, Paste and Clear Selection
Pasting now no longer requires a pre-existing selection and instead copies the selections themselves too.
* Created a new Select menu, which has Select All and Clear Selection as options
Clear Selection now also confirms content moving. TopMenuContainer code has changed to no longer rely on Global for the menu buttons.
* Draw gizmos as rectangles
No functionality yet. They may need to be turned to nodes, so that they can easily resize based on zoom level and check for mouse enter/exit events.
* Made gizmos get drawn in the sides and corners of the big bounding rectangle instead of individual selection parts
Still no functionality yet.
* Restore label text
* Minor optimization when clipping selections
This will execute the for loop less times
* Made a Gizmo class, cursor change on hover, has_focus = false on mouse click
Now I should actually make them resize when dragged, aye?
* Very basic gizmo resizing, still a WIP, does not work properly yet
* Start replacing the array of selected pixels with a BitMap
This should optimize the selection making a lot, and it also allows for easy border drawing without having to deal with polygons, thanks to the MarchingAntsOutline.shader
Still commit is still a WIP, image effects and brushes may not work properly yet.
Because the BitMap has a fixed size, the size of the project, moving the selection outside of canvas boundaries has proven to be a bit tricky. I did implement a hacky way of handling it, but it may be buggy and problematic. I'm still unsure whether this is the best way to handle the situation.
* Selection works with mirror view
* Draw a black rectangle when the user is making a rectangular selection
After they release the mouse, the black rectangle becomes the selection
* Make Selection.gd update when undoing/redoing
* Fix brushes not working properly with non-rectangular selections
* Added invert selection
* Cache has_selection as a variable for a speedup
* Fix conflict issues with the shape tools
* Made the bitmap image squared so the marching ants effect will be the same on both dimensions
There may be a better way to fix the issue, perhaps inside the shader itself.
* Some optimizations to call selection_bitmap_changed() less times
* Restored almost all of the image effects
Left to do:
- Change gradient's behavior. Unsure of how it will work with non-rectangular selections yet, but it should not generate pixels outside of the selection.
- Restore rotation
- Resize bitmap on image resize
- Remove the `pixels` array from the ImageEffect
* Fix Selection.gd not updating when changing project
* Resize the selection bitmap along with image resize
* Restored rotation's old behavior and finally got rid of the selected_pixels array
The rotation does not yet work properly with selections, but at least it now "works".
* Resize selection too when using gizmos
Left to do for gizmos:
- Proper cancel transformation
- Begin transformation
(currently named move_content_start but it should be renamed to something more general) when resizing gizmos
- Keep the original image and selection in memory and resize them. Meaning, gizmos should not resize the already resized data, but only resize the original. This is less destructive as there is no danger of data loss.
- Always resize on InputEventMouseMotion. This is going to be worse for performance, but it will look better for the user.
* Image and bitmap resizing now uses the original data and begin transformation on gizmo click
No matter how many times the user resizes on the current transformation, the original data will not be lost until they either confirm or cancel, so there is no data loss before confirmation/cancel.
* Cancel transformation now works properly when the selection has been resized
* Made gizmos resize on mouse motion, fix issues with negative bounding rectangle and when combined with the move tool
* Resizing can now get out of positive bounds, clearing and inverting now gets limited to the canvas bounds
Resizing currently does not work properly with negative (left & up) canvas boundaries
* Flip image when resizing and the bounding rectangle gets flipped
* Call move_content_confirm() when inverting selection
* Attempt to implement selection resizing that goes outside of the canvas boundaries (not working properly yet)
* Flip selection when resizing to negative bounding rectangle sizes
And fix preview_image vertical flipping
* Fix rotation so that it works (almost) properly with selections
Rotation algorithms now accept and only work with a given image, and the pivot has been added as a parameter
* Experimental gizmo rotation - does not work properly yet
Transforming the selection outside of the canvas is still broken.
* Fix some issues with moving selection out of canvas bounds
* Fix more issues with selection getting resized outside of canvas bounds
* Update marching ants effect properly when switching between projects
And make sure the frequency of the marching ants effect always looks roughly the same on all project sizes
* Made the rotation gizmo part of the gizmos array and resize them based on camera zoom
* Remove unneeded parameter from move_bitmap_values()
* Remove more unneeded parameters
* Move the selection only if the cursor is above it and neither shift nor control are currently pressed
* Gradient generation now works on non-rectangular selections
Although this behavior might not be the intended one
* Copy/paste marching ants effect offset
Useful for when the selection is in negative coords
* Fix issue with clear selection & UndoRedo
* Restore the ability to move selection when it's in negative coords
* Made the marching ants offset a Project variable
This fixes the issue of project switching and keeping the previous project's offset. Again, this is only relevant for when the selection is in negative coords.
* Made the "from current selection" palette preset work with the new selection system
* Fix out of bounds error when using the rectangular select tool on negative coords
* Some code cleanup
* Comment out the rotation gizmo for now, since it does not work properly
* Update marching ants shader params and gizmo sizes when the bitmap changes
* Move some methods around in Selection.gd
2021-04-17 18:30:12 +00:00
|
|
|
|
canvas.selection.update()
|
2020-06-02 23:14:24 +00:00
|
|
|
|
if action_name == "Scale":
|
|
|
|
|
canvas.camera_zoom()
|
New selection system (#474)
* Basic move tool
* Added marching ants effect on the selection borders
* Rename SelectionRectangle to SelectionShape, make it have non-rectangular shape and multiple SelectionShapes can exist
- Create multiple selection rectangles
- Merge them together if they intersect
- Move the selections (without contents as of right now)
- Gizmos are being drawn but they are not functional yet
Code is very ugly.
* Sort vectors counter-clockwise to be used as polygon borders
I did this, no idea if it works properly, probably won't be used but I thought I'd keep it saved somewhere
* More experiments I may or may not need
Trying to generate a polygon from the individual selected pixels
* Change default rectangle select behavior and ability to clip polygons using Control
* Fix rectangle selection clipping
* Split polygon into two with selection subtracting
* Move selection with contents with the move tool
Code is still a mess, don't bother looking.
* Move some methods from SelectionShape.gd to Selection.gd
The purpose of this is to generalize some selection code, so that it applies to all polygons, the entire selection. More will follow.
* UndoRedo for border moving
Nothing else in the selections system works properly in UndoRedo right now. Needs:
- UR support for creating selections
- UR support for modifying selections (merging and cutting selections together)
- UR support for removing selection
- UR support for moving content
& for all the rest of the remaining features
* Moving all of the selection shape logic to Selection.gd
Handle all of the polygons there instead of having them as individual nodes. Should be easier to handle undo/redo this way. This commit probably breaks move tool + selection tool and undo/redo. Code is still a mess. For your sanity, I hope you are not reading this. I promise I will clean up.
* Move tool works again
Buggy and messy, of course.
* Remove unneeded code and restore selection move undoredo logic
* Made Selection.gd have one big preview_image for when moving content, instead of each polygon having its own image
Could be further optimized for some specific cases. We could also remove selected_pixels from SelectionPolygon.
* UndoRedo support for creating, deleting, merging and clipping selections
UndoRedo support for moving content not added in this commit. Should work but needs more testing. This PR also removes selected_pixels from the SelectionPolygon class.
* Confirm & cancel selection movement, should support undoredo properly too
Press Enter or do any editing to confirm movement, Escape to cancel. I will most likely add UI buttons for confirm and cancel too.
* Mirror View affects selection
* Restore Cut, Copy, Paste and Clear Selection
Pasting now no longer requires a pre-existing selection and instead copies the selections themselves too.
* Created a new Select menu, which has Select All and Clear Selection as options
Clear Selection now also confirms content moving. TopMenuContainer code has changed to no longer rely on Global for the menu buttons.
* Draw gizmos as rectangles
No functionality yet. They may need to be turned to nodes, so that they can easily resize based on zoom level and check for mouse enter/exit events.
* Made gizmos get drawn in the sides and corners of the big bounding rectangle instead of individual selection parts
Still no functionality yet.
* Restore label text
* Minor optimization when clipping selections
This will execute the for loop less times
* Made a Gizmo class, cursor change on hover, has_focus = false on mouse click
Now I should actually make them resize when dragged, aye?
* Very basic gizmo resizing, still a WIP, does not work properly yet
* Start replacing the array of selected pixels with a BitMap
This should optimize the selection making a lot, and it also allows for easy border drawing without having to deal with polygons, thanks to the MarchingAntsOutline.shader
Still commit is still a WIP, image effects and brushes may not work properly yet.
Because the BitMap has a fixed size, the size of the project, moving the selection outside of canvas boundaries has proven to be a bit tricky. I did implement a hacky way of handling it, but it may be buggy and problematic. I'm still unsure whether this is the best way to handle the situation.
* Selection works with mirror view
* Draw a black rectangle when the user is making a rectangular selection
After they release the mouse, the black rectangle becomes the selection
* Make Selection.gd update when undoing/redoing
* Fix brushes not working properly with non-rectangular selections
* Added invert selection
* Cache has_selection as a variable for a speedup
* Fix conflict issues with the shape tools
* Made the bitmap image squared so the marching ants effect will be the same on both dimensions
There may be a better way to fix the issue, perhaps inside the shader itself.
* Some optimizations to call selection_bitmap_changed() less times
* Restored almost all of the image effects
Left to do:
- Change gradient's behavior. Unsure of how it will work with non-rectangular selections yet, but it should not generate pixels outside of the selection.
- Restore rotation
- Resize bitmap on image resize
- Remove the `pixels` array from the ImageEffect
* Fix Selection.gd not updating when changing project
* Resize the selection bitmap along with image resize
* Restored rotation's old behavior and finally got rid of the selected_pixels array
The rotation does not yet work properly with selections, but at least it now "works".
* Resize selection too when using gizmos
Left to do for gizmos:
- Proper cancel transformation
- Begin transformation
(currently named move_content_start but it should be renamed to something more general) when resizing gizmos
- Keep the original image and selection in memory and resize them. Meaning, gizmos should not resize the already resized data, but only resize the original. This is less destructive as there is no danger of data loss.
- Always resize on InputEventMouseMotion. This is going to be worse for performance, but it will look better for the user.
* Image and bitmap resizing now uses the original data and begin transformation on gizmo click
No matter how many times the user resizes on the current transformation, the original data will not be lost until they either confirm or cancel, so there is no data loss before confirmation/cancel.
* Cancel transformation now works properly when the selection has been resized
* Made gizmos resize on mouse motion, fix issues with negative bounding rectangle and when combined with the move tool
* Resizing can now get out of positive bounds, clearing and inverting now gets limited to the canvas bounds
Resizing currently does not work properly with negative (left & up) canvas boundaries
* Flip image when resizing and the bounding rectangle gets flipped
* Call move_content_confirm() when inverting selection
* Attempt to implement selection resizing that goes outside of the canvas boundaries (not working properly yet)
* Flip selection when resizing to negative bounding rectangle sizes
And fix preview_image vertical flipping
* Fix rotation so that it works (almost) properly with selections
Rotation algorithms now accept and only work with a given image, and the pivot has been added as a parameter
* Experimental gizmo rotation - does not work properly yet
Transforming the selection outside of the canvas is still broken.
* Fix some issues with moving selection out of canvas bounds
* Fix more issues with selection getting resized outside of canvas bounds
* Update marching ants effect properly when switching between projects
And make sure the frequency of the marching ants effect always looks roughly the same on all project sizes
* Made the rotation gizmo part of the gizmos array and resize them based on camera zoom
* Remove unneeded parameter from move_bitmap_values()
* Remove more unneeded parameters
* Move the selection only if the cursor is above it and neither shift nor control are currently pressed
* Gradient generation now works on non-rectangular selections
Although this behavior might not be the intended one
* Copy/paste marching ants effect offset
Useful for when the selection is in negative coords
* Fix issue with clear selection & UndoRedo
* Restore the ability to move selection when it's in negative coords
* Made the marching ants offset a Project variable
This fixes the issue of project switching and keeping the previous project's offset. Again, this is only relevant for when the selection is in negative coords.
* Made the "from current selection" palette preset work with the new selection system
* Fix out of bounds error when using the rectangular select tool on negative coords
* Some code cleanup
* Comment out the rotation gizmo for now, since it does not work properly
* Update marching ants shader params and gizmo sizes when the bitmap changes
* Move some methods around in Selection.gd
2021-04-17 18:30:12 +00:00
|
|
|
|
canvas.grid.update()
|
|
|
|
|
canvas.pixel_grid.update()
|
|
|
|
|
cursor_position_label.text = "[%s×%s]" % [project.size.x, project.size.y]
|
2020-06-02 23:14:24 +00:00
|
|
|
|
|
|
|
|
|
elif "Frame" in action_name:
|
|
|
|
|
# This actually means that frames.size is one, but it hasn't been updated yet
|
2020-07-24 00:41:10 +00:00
|
|
|
|
if project.frames.size() == 2: # Stop animating
|
2019-11-23 22:52:17 +00:00
|
|
|
|
play_forward.pressed = false
|
|
|
|
|
play_backwards.pressed = false
|
|
|
|
|
animation_timer.stop()
|
2019-11-10 01:25:25 +00:00
|
|
|
|
|
2021-01-29 20:00:48 +00:00
|
|
|
|
elif "Move Cels" == action_name:
|
|
|
|
|
project.frames = project.frames # to call frames_changed
|
|
|
|
|
|
2019-12-27 22:57:28 +00:00
|
|
|
|
canvas.update()
|
2020-07-24 00:41:10 +00:00
|
|
|
|
if !project.has_changed:
|
|
|
|
|
project.has_changed = true
|
|
|
|
|
if project == current_project:
|
|
|
|
|
self.window_title = window_title + "(*)"
|
2019-11-13 13:45:55 +00:00
|
|
|
|
|
2019-10-29 21:22:38 +00:00
|
|
|
|
|
2020-07-24 00:41:10 +00:00
|
|
|
|
func redo(_frame_index := -1, _layer_index := -1, project : Project = current_project) -> void:
|
|
|
|
|
general_redo(project)
|
|
|
|
|
var action_name : String = project.undo_redo.get_current_action_name()
|
New selection system (#474)
* Basic move tool
* Added marching ants effect on the selection borders
* Rename SelectionRectangle to SelectionShape, make it have non-rectangular shape and multiple SelectionShapes can exist
- Create multiple selection rectangles
- Merge them together if they intersect
- Move the selections (without contents as of right now)
- Gizmos are being drawn but they are not functional yet
Code is very ugly.
* Sort vectors counter-clockwise to be used as polygon borders
I did this, no idea if it works properly, probably won't be used but I thought I'd keep it saved somewhere
* More experiments I may or may not need
Trying to generate a polygon from the individual selected pixels
* Change default rectangle select behavior and ability to clip polygons using Control
* Fix rectangle selection clipping
* Split polygon into two with selection subtracting
* Move selection with contents with the move tool
Code is still a mess, don't bother looking.
* Move some methods from SelectionShape.gd to Selection.gd
The purpose of this is to generalize some selection code, so that it applies to all polygons, the entire selection. More will follow.
* UndoRedo for border moving
Nothing else in the selections system works properly in UndoRedo right now. Needs:
- UR support for creating selections
- UR support for modifying selections (merging and cutting selections together)
- UR support for removing selection
- UR support for moving content
& for all the rest of the remaining features
* Moving all of the selection shape logic to Selection.gd
Handle all of the polygons there instead of having them as individual nodes. Should be easier to handle undo/redo this way. This commit probably breaks move tool + selection tool and undo/redo. Code is still a mess. For your sanity, I hope you are not reading this. I promise I will clean up.
* Move tool works again
Buggy and messy, of course.
* Remove unneeded code and restore selection move undoredo logic
* Made Selection.gd have one big preview_image for when moving content, instead of each polygon having its own image
Could be further optimized for some specific cases. We could also remove selected_pixels from SelectionPolygon.
* UndoRedo support for creating, deleting, merging and clipping selections
UndoRedo support for moving content not added in this commit. Should work but needs more testing. This PR also removes selected_pixels from the SelectionPolygon class.
* Confirm & cancel selection movement, should support undoredo properly too
Press Enter or do any editing to confirm movement, Escape to cancel. I will most likely add UI buttons for confirm and cancel too.
* Mirror View affects selection
* Restore Cut, Copy, Paste and Clear Selection
Pasting now no longer requires a pre-existing selection and instead copies the selections themselves too.
* Created a new Select menu, which has Select All and Clear Selection as options
Clear Selection now also confirms content moving. TopMenuContainer code has changed to no longer rely on Global for the menu buttons.
* Draw gizmos as rectangles
No functionality yet. They may need to be turned to nodes, so that they can easily resize based on zoom level and check for mouse enter/exit events.
* Made gizmos get drawn in the sides and corners of the big bounding rectangle instead of individual selection parts
Still no functionality yet.
* Restore label text
* Minor optimization when clipping selections
This will execute the for loop less times
* Made a Gizmo class, cursor change on hover, has_focus = false on mouse click
Now I should actually make them resize when dragged, aye?
* Very basic gizmo resizing, still a WIP, does not work properly yet
* Start replacing the array of selected pixels with a BitMap
This should optimize the selection making a lot, and it also allows for easy border drawing without having to deal with polygons, thanks to the MarchingAntsOutline.shader
Still commit is still a WIP, image effects and brushes may not work properly yet.
Because the BitMap has a fixed size, the size of the project, moving the selection outside of canvas boundaries has proven to be a bit tricky. I did implement a hacky way of handling it, but it may be buggy and problematic. I'm still unsure whether this is the best way to handle the situation.
* Selection works with mirror view
* Draw a black rectangle when the user is making a rectangular selection
After they release the mouse, the black rectangle becomes the selection
* Make Selection.gd update when undoing/redoing
* Fix brushes not working properly with non-rectangular selections
* Added invert selection
* Cache has_selection as a variable for a speedup
* Fix conflict issues with the shape tools
* Made the bitmap image squared so the marching ants effect will be the same on both dimensions
There may be a better way to fix the issue, perhaps inside the shader itself.
* Some optimizations to call selection_bitmap_changed() less times
* Restored almost all of the image effects
Left to do:
- Change gradient's behavior. Unsure of how it will work with non-rectangular selections yet, but it should not generate pixels outside of the selection.
- Restore rotation
- Resize bitmap on image resize
- Remove the `pixels` array from the ImageEffect
* Fix Selection.gd not updating when changing project
* Resize the selection bitmap along with image resize
* Restored rotation's old behavior and finally got rid of the selected_pixels array
The rotation does not yet work properly with selections, but at least it now "works".
* Resize selection too when using gizmos
Left to do for gizmos:
- Proper cancel transformation
- Begin transformation
(currently named move_content_start but it should be renamed to something more general) when resizing gizmos
- Keep the original image and selection in memory and resize them. Meaning, gizmos should not resize the already resized data, but only resize the original. This is less destructive as there is no danger of data loss.
- Always resize on InputEventMouseMotion. This is going to be worse for performance, but it will look better for the user.
* Image and bitmap resizing now uses the original data and begin transformation on gizmo click
No matter how many times the user resizes on the current transformation, the original data will not be lost until they either confirm or cancel, so there is no data loss before confirmation/cancel.
* Cancel transformation now works properly when the selection has been resized
* Made gizmos resize on mouse motion, fix issues with negative bounding rectangle and when combined with the move tool
* Resizing can now get out of positive bounds, clearing and inverting now gets limited to the canvas bounds
Resizing currently does not work properly with negative (left & up) canvas boundaries
* Flip image when resizing and the bounding rectangle gets flipped
* Call move_content_confirm() when inverting selection
* Attempt to implement selection resizing that goes outside of the canvas boundaries (not working properly yet)
* Flip selection when resizing to negative bounding rectangle sizes
And fix preview_image vertical flipping
* Fix rotation so that it works (almost) properly with selections
Rotation algorithms now accept and only work with a given image, and the pivot has been added as a parameter
* Experimental gizmo rotation - does not work properly yet
Transforming the selection outside of the canvas is still broken.
* Fix some issues with moving selection out of canvas bounds
* Fix more issues with selection getting resized outside of canvas bounds
* Update marching ants effect properly when switching between projects
And make sure the frequency of the marching ants effect always looks roughly the same on all project sizes
* Made the rotation gizmo part of the gizmos array and resize them based on camera zoom
* Remove unneeded parameter from move_bitmap_values()
* Remove more unneeded parameters
* Move the selection only if the cursor is above it and neither shift nor control are currently pressed
* Gradient generation now works on non-rectangular selections
Although this behavior might not be the intended one
* Copy/paste marching ants effect offset
Useful for when the selection is in negative coords
* Fix issue with clear selection & UndoRedo
* Restore the ability to move selection when it's in negative coords
* Made the marching ants offset a Project variable
This fixes the issue of project switching and keeping the previous project's offset. Again, this is only relevant for when the selection is in negative coords.
* Made the "from current selection" palette preset work with the new selection system
* Fix out of bounds error when using the rectangular select tool on negative coords
* Some code cleanup
* Comment out the rotation gizmo for now, since it does not work properly
* Update marching ants shader params and gizmo sizes when the bitmap changes
* Move some methods around in Selection.gd
2021-04-17 18:30:12 +00:00
|
|
|
|
if action_name == "Draw" or action_name == "Draw Shape" or action_name == "Rectangle Select" or action_name == "Move Selection" or action_name == "Scale" or action_name == "Centralize" or action_name == "Merge Layer" or action_name == "Link Cel" or action_name == "Unlink Cel":
|
2020-06-02 23:14:24 +00:00
|
|
|
|
if _layer_index > -1 and _frame_index > -1:
|
2020-07-24 00:41:10 +00:00
|
|
|
|
canvas.update_texture(_layer_index, _frame_index, project)
|
2020-06-02 23:14:24 +00:00
|
|
|
|
else:
|
2020-07-24 00:41:10 +00:00
|
|
|
|
for i in project.frames.size():
|
|
|
|
|
for j in project.layers.size():
|
|
|
|
|
canvas.update_texture(j, i, project)
|
2020-06-02 23:14:24 +00:00
|
|
|
|
|
New selection system (#474)
* Basic move tool
* Added marching ants effect on the selection borders
* Rename SelectionRectangle to SelectionShape, make it have non-rectangular shape and multiple SelectionShapes can exist
- Create multiple selection rectangles
- Merge them together if they intersect
- Move the selections (without contents as of right now)
- Gizmos are being drawn but they are not functional yet
Code is very ugly.
* Sort vectors counter-clockwise to be used as polygon borders
I did this, no idea if it works properly, probably won't be used but I thought I'd keep it saved somewhere
* More experiments I may or may not need
Trying to generate a polygon from the individual selected pixels
* Change default rectangle select behavior and ability to clip polygons using Control
* Fix rectangle selection clipping
* Split polygon into two with selection subtracting
* Move selection with contents with the move tool
Code is still a mess, don't bother looking.
* Move some methods from SelectionShape.gd to Selection.gd
The purpose of this is to generalize some selection code, so that it applies to all polygons, the entire selection. More will follow.
* UndoRedo for border moving
Nothing else in the selections system works properly in UndoRedo right now. Needs:
- UR support for creating selections
- UR support for modifying selections (merging and cutting selections together)
- UR support for removing selection
- UR support for moving content
& for all the rest of the remaining features
* Moving all of the selection shape logic to Selection.gd
Handle all of the polygons there instead of having them as individual nodes. Should be easier to handle undo/redo this way. This commit probably breaks move tool + selection tool and undo/redo. Code is still a mess. For your sanity, I hope you are not reading this. I promise I will clean up.
* Move tool works again
Buggy and messy, of course.
* Remove unneeded code and restore selection move undoredo logic
* Made Selection.gd have one big preview_image for when moving content, instead of each polygon having its own image
Could be further optimized for some specific cases. We could also remove selected_pixels from SelectionPolygon.
* UndoRedo support for creating, deleting, merging and clipping selections
UndoRedo support for moving content not added in this commit. Should work but needs more testing. This PR also removes selected_pixels from the SelectionPolygon class.
* Confirm & cancel selection movement, should support undoredo properly too
Press Enter or do any editing to confirm movement, Escape to cancel. I will most likely add UI buttons for confirm and cancel too.
* Mirror View affects selection
* Restore Cut, Copy, Paste and Clear Selection
Pasting now no longer requires a pre-existing selection and instead copies the selections themselves too.
* Created a new Select menu, which has Select All and Clear Selection as options
Clear Selection now also confirms content moving. TopMenuContainer code has changed to no longer rely on Global for the menu buttons.
* Draw gizmos as rectangles
No functionality yet. They may need to be turned to nodes, so that they can easily resize based on zoom level and check for mouse enter/exit events.
* Made gizmos get drawn in the sides and corners of the big bounding rectangle instead of individual selection parts
Still no functionality yet.
* Restore label text
* Minor optimization when clipping selections
This will execute the for loop less times
* Made a Gizmo class, cursor change on hover, has_focus = false on mouse click
Now I should actually make them resize when dragged, aye?
* Very basic gizmo resizing, still a WIP, does not work properly yet
* Start replacing the array of selected pixels with a BitMap
This should optimize the selection making a lot, and it also allows for easy border drawing without having to deal with polygons, thanks to the MarchingAntsOutline.shader
Still commit is still a WIP, image effects and brushes may not work properly yet.
Because the BitMap has a fixed size, the size of the project, moving the selection outside of canvas boundaries has proven to be a bit tricky. I did implement a hacky way of handling it, but it may be buggy and problematic. I'm still unsure whether this is the best way to handle the situation.
* Selection works with mirror view
* Draw a black rectangle when the user is making a rectangular selection
After they release the mouse, the black rectangle becomes the selection
* Make Selection.gd update when undoing/redoing
* Fix brushes not working properly with non-rectangular selections
* Added invert selection
* Cache has_selection as a variable for a speedup
* Fix conflict issues with the shape tools
* Made the bitmap image squared so the marching ants effect will be the same on both dimensions
There may be a better way to fix the issue, perhaps inside the shader itself.
* Some optimizations to call selection_bitmap_changed() less times
* Restored almost all of the image effects
Left to do:
- Change gradient's behavior. Unsure of how it will work with non-rectangular selections yet, but it should not generate pixels outside of the selection.
- Restore rotation
- Resize bitmap on image resize
- Remove the `pixels` array from the ImageEffect
* Fix Selection.gd not updating when changing project
* Resize the selection bitmap along with image resize
* Restored rotation's old behavior and finally got rid of the selected_pixels array
The rotation does not yet work properly with selections, but at least it now "works".
* Resize selection too when using gizmos
Left to do for gizmos:
- Proper cancel transformation
- Begin transformation
(currently named move_content_start but it should be renamed to something more general) when resizing gizmos
- Keep the original image and selection in memory and resize them. Meaning, gizmos should not resize the already resized data, but only resize the original. This is less destructive as there is no danger of data loss.
- Always resize on InputEventMouseMotion. This is going to be worse for performance, but it will look better for the user.
* Image and bitmap resizing now uses the original data and begin transformation on gizmo click
No matter how many times the user resizes on the current transformation, the original data will not be lost until they either confirm or cancel, so there is no data loss before confirmation/cancel.
* Cancel transformation now works properly when the selection has been resized
* Made gizmos resize on mouse motion, fix issues with negative bounding rectangle and when combined with the move tool
* Resizing can now get out of positive bounds, clearing and inverting now gets limited to the canvas bounds
Resizing currently does not work properly with negative (left & up) canvas boundaries
* Flip image when resizing and the bounding rectangle gets flipped
* Call move_content_confirm() when inverting selection
* Attempt to implement selection resizing that goes outside of the canvas boundaries (not working properly yet)
* Flip selection when resizing to negative bounding rectangle sizes
And fix preview_image vertical flipping
* Fix rotation so that it works (almost) properly with selections
Rotation algorithms now accept and only work with a given image, and the pivot has been added as a parameter
* Experimental gizmo rotation - does not work properly yet
Transforming the selection outside of the canvas is still broken.
* Fix some issues with moving selection out of canvas bounds
* Fix more issues with selection getting resized outside of canvas bounds
* Update marching ants effect properly when switching between projects
And make sure the frequency of the marching ants effect always looks roughly the same on all project sizes
* Made the rotation gizmo part of the gizmos array and resize them based on camera zoom
* Remove unneeded parameter from move_bitmap_values()
* Remove more unneeded parameters
* Move the selection only if the cursor is above it and neither shift nor control are currently pressed
* Gradient generation now works on non-rectangular selections
Although this behavior might not be the intended one
* Copy/paste marching ants effect offset
Useful for when the selection is in negative coords
* Fix issue with clear selection & UndoRedo
* Restore the ability to move selection when it's in negative coords
* Made the marching ants offset a Project variable
This fixes the issue of project switching and keeping the previous project's offset. Again, this is only relevant for when the selection is in negative coords.
* Made the "from current selection" palette preset work with the new selection system
* Fix out of bounds error when using the rectangular select tool on negative coords
* Some code cleanup
* Comment out the rotation gizmo for now, since it does not work properly
* Update marching ants shader params and gizmo sizes when the bitmap changes
* Move some methods around in Selection.gd
2021-04-17 18:30:12 +00:00
|
|
|
|
canvas.selection.update()
|
2020-06-02 23:14:24 +00:00
|
|
|
|
if action_name == "Scale":
|
|
|
|
|
canvas.camera_zoom()
|
New selection system (#474)
* Basic move tool
* Added marching ants effect on the selection borders
* Rename SelectionRectangle to SelectionShape, make it have non-rectangular shape and multiple SelectionShapes can exist
- Create multiple selection rectangles
- Merge them together if they intersect
- Move the selections (without contents as of right now)
- Gizmos are being drawn but they are not functional yet
Code is very ugly.
* Sort vectors counter-clockwise to be used as polygon borders
I did this, no idea if it works properly, probably won't be used but I thought I'd keep it saved somewhere
* More experiments I may or may not need
Trying to generate a polygon from the individual selected pixels
* Change default rectangle select behavior and ability to clip polygons using Control
* Fix rectangle selection clipping
* Split polygon into two with selection subtracting
* Move selection with contents with the move tool
Code is still a mess, don't bother looking.
* Move some methods from SelectionShape.gd to Selection.gd
The purpose of this is to generalize some selection code, so that it applies to all polygons, the entire selection. More will follow.
* UndoRedo for border moving
Nothing else in the selections system works properly in UndoRedo right now. Needs:
- UR support for creating selections
- UR support for modifying selections (merging and cutting selections together)
- UR support for removing selection
- UR support for moving content
& for all the rest of the remaining features
* Moving all of the selection shape logic to Selection.gd
Handle all of the polygons there instead of having them as individual nodes. Should be easier to handle undo/redo this way. This commit probably breaks move tool + selection tool and undo/redo. Code is still a mess. For your sanity, I hope you are not reading this. I promise I will clean up.
* Move tool works again
Buggy and messy, of course.
* Remove unneeded code and restore selection move undoredo logic
* Made Selection.gd have one big preview_image for when moving content, instead of each polygon having its own image
Could be further optimized for some specific cases. We could also remove selected_pixels from SelectionPolygon.
* UndoRedo support for creating, deleting, merging and clipping selections
UndoRedo support for moving content not added in this commit. Should work but needs more testing. This PR also removes selected_pixels from the SelectionPolygon class.
* Confirm & cancel selection movement, should support undoredo properly too
Press Enter or do any editing to confirm movement, Escape to cancel. I will most likely add UI buttons for confirm and cancel too.
* Mirror View affects selection
* Restore Cut, Copy, Paste and Clear Selection
Pasting now no longer requires a pre-existing selection and instead copies the selections themselves too.
* Created a new Select menu, which has Select All and Clear Selection as options
Clear Selection now also confirms content moving. TopMenuContainer code has changed to no longer rely on Global for the menu buttons.
* Draw gizmos as rectangles
No functionality yet. They may need to be turned to nodes, so that they can easily resize based on zoom level and check for mouse enter/exit events.
* Made gizmos get drawn in the sides and corners of the big bounding rectangle instead of individual selection parts
Still no functionality yet.
* Restore label text
* Minor optimization when clipping selections
This will execute the for loop less times
* Made a Gizmo class, cursor change on hover, has_focus = false on mouse click
Now I should actually make them resize when dragged, aye?
* Very basic gizmo resizing, still a WIP, does not work properly yet
* Start replacing the array of selected pixels with a BitMap
This should optimize the selection making a lot, and it also allows for easy border drawing without having to deal with polygons, thanks to the MarchingAntsOutline.shader
Still commit is still a WIP, image effects and brushes may not work properly yet.
Because the BitMap has a fixed size, the size of the project, moving the selection outside of canvas boundaries has proven to be a bit tricky. I did implement a hacky way of handling it, but it may be buggy and problematic. I'm still unsure whether this is the best way to handle the situation.
* Selection works with mirror view
* Draw a black rectangle when the user is making a rectangular selection
After they release the mouse, the black rectangle becomes the selection
* Make Selection.gd update when undoing/redoing
* Fix brushes not working properly with non-rectangular selections
* Added invert selection
* Cache has_selection as a variable for a speedup
* Fix conflict issues with the shape tools
* Made the bitmap image squared so the marching ants effect will be the same on both dimensions
There may be a better way to fix the issue, perhaps inside the shader itself.
* Some optimizations to call selection_bitmap_changed() less times
* Restored almost all of the image effects
Left to do:
- Change gradient's behavior. Unsure of how it will work with non-rectangular selections yet, but it should not generate pixels outside of the selection.
- Restore rotation
- Resize bitmap on image resize
- Remove the `pixels` array from the ImageEffect
* Fix Selection.gd not updating when changing project
* Resize the selection bitmap along with image resize
* Restored rotation's old behavior and finally got rid of the selected_pixels array
The rotation does not yet work properly with selections, but at least it now "works".
* Resize selection too when using gizmos
Left to do for gizmos:
- Proper cancel transformation
- Begin transformation
(currently named move_content_start but it should be renamed to something more general) when resizing gizmos
- Keep the original image and selection in memory and resize them. Meaning, gizmos should not resize the already resized data, but only resize the original. This is less destructive as there is no danger of data loss.
- Always resize on InputEventMouseMotion. This is going to be worse for performance, but it will look better for the user.
* Image and bitmap resizing now uses the original data and begin transformation on gizmo click
No matter how many times the user resizes on the current transformation, the original data will not be lost until they either confirm or cancel, so there is no data loss before confirmation/cancel.
* Cancel transformation now works properly when the selection has been resized
* Made gizmos resize on mouse motion, fix issues with negative bounding rectangle and when combined with the move tool
* Resizing can now get out of positive bounds, clearing and inverting now gets limited to the canvas bounds
Resizing currently does not work properly with negative (left & up) canvas boundaries
* Flip image when resizing and the bounding rectangle gets flipped
* Call move_content_confirm() when inverting selection
* Attempt to implement selection resizing that goes outside of the canvas boundaries (not working properly yet)
* Flip selection when resizing to negative bounding rectangle sizes
And fix preview_image vertical flipping
* Fix rotation so that it works (almost) properly with selections
Rotation algorithms now accept and only work with a given image, and the pivot has been added as a parameter
* Experimental gizmo rotation - does not work properly yet
Transforming the selection outside of the canvas is still broken.
* Fix some issues with moving selection out of canvas bounds
* Fix more issues with selection getting resized outside of canvas bounds
* Update marching ants effect properly when switching between projects
And make sure the frequency of the marching ants effect always looks roughly the same on all project sizes
* Made the rotation gizmo part of the gizmos array and resize them based on camera zoom
* Remove unneeded parameter from move_bitmap_values()
* Remove more unneeded parameters
* Move the selection only if the cursor is above it and neither shift nor control are currently pressed
* Gradient generation now works on non-rectangular selections
Although this behavior might not be the intended one
* Copy/paste marching ants effect offset
Useful for when the selection is in negative coords
* Fix issue with clear selection & UndoRedo
* Restore the ability to move selection when it's in negative coords
* Made the marching ants offset a Project variable
This fixes the issue of project switching and keeping the previous project's offset. Again, this is only relevant for when the selection is in negative coords.
* Made the "from current selection" palette preset work with the new selection system
* Fix out of bounds error when using the rectangular select tool on negative coords
* Some code cleanup
* Comment out the rotation gizmo for now, since it does not work properly
* Update marching ants shader params and gizmo sizes when the bitmap changes
* Move some methods around in Selection.gd
2021-04-17 18:30:12 +00:00
|
|
|
|
canvas.grid.update()
|
|
|
|
|
canvas.pixel_grid.update()
|
|
|
|
|
cursor_position_label.text = "[%s×%s]" % [project.size.x, project.size.y]
|
2020-06-02 23:14:24 +00:00
|
|
|
|
|
|
|
|
|
elif "Frame" in action_name:
|
2020-07-24 00:41:10 +00:00
|
|
|
|
if project.frames.size() == 1: # Stop animating
|
2019-11-23 22:52:17 +00:00
|
|
|
|
play_forward.pressed = false
|
|
|
|
|
play_backwards.pressed = false
|
|
|
|
|
animation_timer.stop()
|
2019-11-10 01:25:25 +00:00
|
|
|
|
|
2021-01-29 20:00:48 +00:00
|
|
|
|
elif "Move Cels" == action_name:
|
|
|
|
|
project.frames = project.frames # to call frames_changed
|
|
|
|
|
|
2019-12-27 22:57:28 +00:00
|
|
|
|
canvas.update()
|
2020-07-24 00:41:10 +00:00
|
|
|
|
if !project.has_changed:
|
|
|
|
|
project.has_changed = true
|
|
|
|
|
if project == current_project:
|
|
|
|
|
self.window_title = window_title + "(*)"
|
2020-04-19 18:17:33 +00:00
|
|
|
|
|
2019-10-29 21:22:38 +00:00
|
|
|
|
|
2020-02-22 15:21:52 +00:00
|
|
|
|
func title_changed(value : String) -> void:
|
|
|
|
|
window_title = value
|
|
|
|
|
OS.set_window_title(value)
|
|
|
|
|
|
2020-04-19 18:17:33 +00:00
|
|
|
|
|
2020-06-04 18:05:36 +00:00
|
|
|
|
func project_changed(value : int) -> void:
|
New selection system (#474)
* Basic move tool
* Added marching ants effect on the selection borders
* Rename SelectionRectangle to SelectionShape, make it have non-rectangular shape and multiple SelectionShapes can exist
- Create multiple selection rectangles
- Merge them together if they intersect
- Move the selections (without contents as of right now)
- Gizmos are being drawn but they are not functional yet
Code is very ugly.
* Sort vectors counter-clockwise to be used as polygon borders
I did this, no idea if it works properly, probably won't be used but I thought I'd keep it saved somewhere
* More experiments I may or may not need
Trying to generate a polygon from the individual selected pixels
* Change default rectangle select behavior and ability to clip polygons using Control
* Fix rectangle selection clipping
* Split polygon into two with selection subtracting
* Move selection with contents with the move tool
Code is still a mess, don't bother looking.
* Move some methods from SelectionShape.gd to Selection.gd
The purpose of this is to generalize some selection code, so that it applies to all polygons, the entire selection. More will follow.
* UndoRedo for border moving
Nothing else in the selections system works properly in UndoRedo right now. Needs:
- UR support for creating selections
- UR support for modifying selections (merging and cutting selections together)
- UR support for removing selection
- UR support for moving content
& for all the rest of the remaining features
* Moving all of the selection shape logic to Selection.gd
Handle all of the polygons there instead of having them as individual nodes. Should be easier to handle undo/redo this way. This commit probably breaks move tool + selection tool and undo/redo. Code is still a mess. For your sanity, I hope you are not reading this. I promise I will clean up.
* Move tool works again
Buggy and messy, of course.
* Remove unneeded code and restore selection move undoredo logic
* Made Selection.gd have one big preview_image for when moving content, instead of each polygon having its own image
Could be further optimized for some specific cases. We could also remove selected_pixels from SelectionPolygon.
* UndoRedo support for creating, deleting, merging and clipping selections
UndoRedo support for moving content not added in this commit. Should work but needs more testing. This PR also removes selected_pixels from the SelectionPolygon class.
* Confirm & cancel selection movement, should support undoredo properly too
Press Enter or do any editing to confirm movement, Escape to cancel. I will most likely add UI buttons for confirm and cancel too.
* Mirror View affects selection
* Restore Cut, Copy, Paste and Clear Selection
Pasting now no longer requires a pre-existing selection and instead copies the selections themselves too.
* Created a new Select menu, which has Select All and Clear Selection as options
Clear Selection now also confirms content moving. TopMenuContainer code has changed to no longer rely on Global for the menu buttons.
* Draw gizmos as rectangles
No functionality yet. They may need to be turned to nodes, so that they can easily resize based on zoom level and check for mouse enter/exit events.
* Made gizmos get drawn in the sides and corners of the big bounding rectangle instead of individual selection parts
Still no functionality yet.
* Restore label text
* Minor optimization when clipping selections
This will execute the for loop less times
* Made a Gizmo class, cursor change on hover, has_focus = false on mouse click
Now I should actually make them resize when dragged, aye?
* Very basic gizmo resizing, still a WIP, does not work properly yet
* Start replacing the array of selected pixels with a BitMap
This should optimize the selection making a lot, and it also allows for easy border drawing without having to deal with polygons, thanks to the MarchingAntsOutline.shader
Still commit is still a WIP, image effects and brushes may not work properly yet.
Because the BitMap has a fixed size, the size of the project, moving the selection outside of canvas boundaries has proven to be a bit tricky. I did implement a hacky way of handling it, but it may be buggy and problematic. I'm still unsure whether this is the best way to handle the situation.
* Selection works with mirror view
* Draw a black rectangle when the user is making a rectangular selection
After they release the mouse, the black rectangle becomes the selection
* Make Selection.gd update when undoing/redoing
* Fix brushes not working properly with non-rectangular selections
* Added invert selection
* Cache has_selection as a variable for a speedup
* Fix conflict issues with the shape tools
* Made the bitmap image squared so the marching ants effect will be the same on both dimensions
There may be a better way to fix the issue, perhaps inside the shader itself.
* Some optimizations to call selection_bitmap_changed() less times
* Restored almost all of the image effects
Left to do:
- Change gradient's behavior. Unsure of how it will work with non-rectangular selections yet, but it should not generate pixels outside of the selection.
- Restore rotation
- Resize bitmap on image resize
- Remove the `pixels` array from the ImageEffect
* Fix Selection.gd not updating when changing project
* Resize the selection bitmap along with image resize
* Restored rotation's old behavior and finally got rid of the selected_pixels array
The rotation does not yet work properly with selections, but at least it now "works".
* Resize selection too when using gizmos
Left to do for gizmos:
- Proper cancel transformation
- Begin transformation
(currently named move_content_start but it should be renamed to something more general) when resizing gizmos
- Keep the original image and selection in memory and resize them. Meaning, gizmos should not resize the already resized data, but only resize the original. This is less destructive as there is no danger of data loss.
- Always resize on InputEventMouseMotion. This is going to be worse for performance, but it will look better for the user.
* Image and bitmap resizing now uses the original data and begin transformation on gizmo click
No matter how many times the user resizes on the current transformation, the original data will not be lost until they either confirm or cancel, so there is no data loss before confirmation/cancel.
* Cancel transformation now works properly when the selection has been resized
* Made gizmos resize on mouse motion, fix issues with negative bounding rectangle and when combined with the move tool
* Resizing can now get out of positive bounds, clearing and inverting now gets limited to the canvas bounds
Resizing currently does not work properly with negative (left & up) canvas boundaries
* Flip image when resizing and the bounding rectangle gets flipped
* Call move_content_confirm() when inverting selection
* Attempt to implement selection resizing that goes outside of the canvas boundaries (not working properly yet)
* Flip selection when resizing to negative bounding rectangle sizes
And fix preview_image vertical flipping
* Fix rotation so that it works (almost) properly with selections
Rotation algorithms now accept and only work with a given image, and the pivot has been added as a parameter
* Experimental gizmo rotation - does not work properly yet
Transforming the selection outside of the canvas is still broken.
* Fix some issues with moving selection out of canvas bounds
* Fix more issues with selection getting resized outside of canvas bounds
* Update marching ants effect properly when switching between projects
And make sure the frequency of the marching ants effect always looks roughly the same on all project sizes
* Made the rotation gizmo part of the gizmos array and resize them based on camera zoom
* Remove unneeded parameter from move_bitmap_values()
* Remove more unneeded parameters
* Move the selection only if the cursor is above it and neither shift nor control are currently pressed
* Gradient generation now works on non-rectangular selections
Although this behavior might not be the intended one
* Copy/paste marching ants effect offset
Useful for when the selection is in negative coords
* Fix issue with clear selection & UndoRedo
* Restore the ability to move selection when it's in negative coords
* Made the marching ants offset a Project variable
This fixes the issue of project switching and keeping the previous project's offset. Again, this is only relevant for when the selection is in negative coords.
* Made the "from current selection" palette preset work with the new selection system
* Fix out of bounds error when using the rectangular select tool on negative coords
* Some code cleanup
* Comment out the rotation gizmo for now, since it does not work properly
* Update marching ants shader params and gizmo sizes when the bitmap changes
* Move some methods around in Selection.gd
2021-04-17 18:30:12 +00:00
|
|
|
|
canvas.selection.move_content_confirm()
|
2020-06-04 18:05:36 +00:00
|
|
|
|
current_project_index = value
|
|
|
|
|
current_project = projects[value]
|
2020-06-05 01:30:31 +00:00
|
|
|
|
current_project.change_project()
|
2020-04-19 17:39:08 +00:00
|
|
|
|
|
2020-04-19 18:17:33 +00:00
|
|
|
|
|
2020-05-08 15:37:45 +00:00
|
|
|
|
func dialog_open(open : bool) -> void:
|
|
|
|
|
if open:
|
|
|
|
|
can_draw = false
|
2021-03-17 17:28:01 +00:00
|
|
|
|
if dim_on_popup:
|
|
|
|
|
control.get_node("ModulateTween").interpolate_property(control, "modulate", control.modulate, Color(0.5, 0.5, 0.5), 0.1, Tween.TRANS_LINEAR, Tween.EASE_OUT)
|
2020-05-08 15:37:45 +00:00
|
|
|
|
else:
|
|
|
|
|
can_draw = true
|
|
|
|
|
control.get_node("ModulateTween").interpolate_property(control, "modulate", control.modulate, Color.white, 0.1, Tween.TRANS_LINEAR, Tween.EASE_OUT)
|
|
|
|
|
|
|
|
|
|
control.get_node("ModulateTween").start()
|
|
|
|
|
|
|
|
|
|
|
2020-05-03 00:13:08 +00:00
|
|
|
|
func disable_button(button : BaseButton, disable : bool) -> void:
|
|
|
|
|
button.disabled = disable
|
|
|
|
|
if disable:
|
|
|
|
|
button.mouse_default_cursor_shape = Control.CURSOR_FORBIDDEN
|
|
|
|
|
else:
|
|
|
|
|
button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
|
|
|
|
|
|
|
|
|
if button is Button:
|
|
|
|
|
var theme := theme_type
|
2021-01-20 14:59:42 +00:00
|
|
|
|
if theme == ThemeTypes.CARAMEL:
|
|
|
|
|
theme = ThemeTypes.DARK
|
2020-05-03 00:13:08 +00:00
|
|
|
|
for c in button.get_children():
|
|
|
|
|
if c is TextureRect:
|
|
|
|
|
var normal_file_name = c.texture.resource_path.get_file().trim_suffix(".png").replace("_disabled", "")
|
|
|
|
|
if disable:
|
2020-05-06 12:56:44 +00:00
|
|
|
|
change_button_texturerect(c, "%s_disabled.png" % normal_file_name)
|
2020-05-03 00:13:08 +00:00
|
|
|
|
else:
|
2020-05-06 12:56:44 +00:00
|
|
|
|
change_button_texturerect(c, "%s.png" % normal_file_name)
|
2020-05-03 00:13:08 +00:00
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
2020-05-06 12:19:53 +00:00
|
|
|
|
func change_button_texturerect(texture_button : TextureRect, new_file_name : String) -> void:
|
|
|
|
|
var file_name := texture_button.texture.resource_path.get_basename().get_file()
|
|
|
|
|
var directory_path := texture_button.texture.resource_path.get_basename().replace(file_name, "")
|
|
|
|
|
texture_button.texture = load(directory_path.plus_file(new_file_name))
|
|
|
|
|
|
|
|
|
|
|
2020-04-11 21:08:45 +00:00
|
|
|
|
func update_hint_tooltips() -> void:
|
New selection system (#474)
* Basic move tool
* Added marching ants effect on the selection borders
* Rename SelectionRectangle to SelectionShape, make it have non-rectangular shape and multiple SelectionShapes can exist
- Create multiple selection rectangles
- Merge them together if they intersect
- Move the selections (without contents as of right now)
- Gizmos are being drawn but they are not functional yet
Code is very ugly.
* Sort vectors counter-clockwise to be used as polygon borders
I did this, no idea if it works properly, probably won't be used but I thought I'd keep it saved somewhere
* More experiments I may or may not need
Trying to generate a polygon from the individual selected pixels
* Change default rectangle select behavior and ability to clip polygons using Control
* Fix rectangle selection clipping
* Split polygon into two with selection subtracting
* Move selection with contents with the move tool
Code is still a mess, don't bother looking.
* Move some methods from SelectionShape.gd to Selection.gd
The purpose of this is to generalize some selection code, so that it applies to all polygons, the entire selection. More will follow.
* UndoRedo for border moving
Nothing else in the selections system works properly in UndoRedo right now. Needs:
- UR support for creating selections
- UR support for modifying selections (merging and cutting selections together)
- UR support for removing selection
- UR support for moving content
& for all the rest of the remaining features
* Moving all of the selection shape logic to Selection.gd
Handle all of the polygons there instead of having them as individual nodes. Should be easier to handle undo/redo this way. This commit probably breaks move tool + selection tool and undo/redo. Code is still a mess. For your sanity, I hope you are not reading this. I promise I will clean up.
* Move tool works again
Buggy and messy, of course.
* Remove unneeded code and restore selection move undoredo logic
* Made Selection.gd have one big preview_image for when moving content, instead of each polygon having its own image
Could be further optimized for some specific cases. We could also remove selected_pixels from SelectionPolygon.
* UndoRedo support for creating, deleting, merging and clipping selections
UndoRedo support for moving content not added in this commit. Should work but needs more testing. This PR also removes selected_pixels from the SelectionPolygon class.
* Confirm & cancel selection movement, should support undoredo properly too
Press Enter or do any editing to confirm movement, Escape to cancel. I will most likely add UI buttons for confirm and cancel too.
* Mirror View affects selection
* Restore Cut, Copy, Paste and Clear Selection
Pasting now no longer requires a pre-existing selection and instead copies the selections themselves too.
* Created a new Select menu, which has Select All and Clear Selection as options
Clear Selection now also confirms content moving. TopMenuContainer code has changed to no longer rely on Global for the menu buttons.
* Draw gizmos as rectangles
No functionality yet. They may need to be turned to nodes, so that they can easily resize based on zoom level and check for mouse enter/exit events.
* Made gizmos get drawn in the sides and corners of the big bounding rectangle instead of individual selection parts
Still no functionality yet.
* Restore label text
* Minor optimization when clipping selections
This will execute the for loop less times
* Made a Gizmo class, cursor change on hover, has_focus = false on mouse click
Now I should actually make them resize when dragged, aye?
* Very basic gizmo resizing, still a WIP, does not work properly yet
* Start replacing the array of selected pixels with a BitMap
This should optimize the selection making a lot, and it also allows for easy border drawing without having to deal with polygons, thanks to the MarchingAntsOutline.shader
Still commit is still a WIP, image effects and brushes may not work properly yet.
Because the BitMap has a fixed size, the size of the project, moving the selection outside of canvas boundaries has proven to be a bit tricky. I did implement a hacky way of handling it, but it may be buggy and problematic. I'm still unsure whether this is the best way to handle the situation.
* Selection works with mirror view
* Draw a black rectangle when the user is making a rectangular selection
After they release the mouse, the black rectangle becomes the selection
* Make Selection.gd update when undoing/redoing
* Fix brushes not working properly with non-rectangular selections
* Added invert selection
* Cache has_selection as a variable for a speedup
* Fix conflict issues with the shape tools
* Made the bitmap image squared so the marching ants effect will be the same on both dimensions
There may be a better way to fix the issue, perhaps inside the shader itself.
* Some optimizations to call selection_bitmap_changed() less times
* Restored almost all of the image effects
Left to do:
- Change gradient's behavior. Unsure of how it will work with non-rectangular selections yet, but it should not generate pixels outside of the selection.
- Restore rotation
- Resize bitmap on image resize
- Remove the `pixels` array from the ImageEffect
* Fix Selection.gd not updating when changing project
* Resize the selection bitmap along with image resize
* Restored rotation's old behavior and finally got rid of the selected_pixels array
The rotation does not yet work properly with selections, but at least it now "works".
* Resize selection too when using gizmos
Left to do for gizmos:
- Proper cancel transformation
- Begin transformation
(currently named move_content_start but it should be renamed to something more general) when resizing gizmos
- Keep the original image and selection in memory and resize them. Meaning, gizmos should not resize the already resized data, but only resize the original. This is less destructive as there is no danger of data loss.
- Always resize on InputEventMouseMotion. This is going to be worse for performance, but it will look better for the user.
* Image and bitmap resizing now uses the original data and begin transformation on gizmo click
No matter how many times the user resizes on the current transformation, the original data will not be lost until they either confirm or cancel, so there is no data loss before confirmation/cancel.
* Cancel transformation now works properly when the selection has been resized
* Made gizmos resize on mouse motion, fix issues with negative bounding rectangle and when combined with the move tool
* Resizing can now get out of positive bounds, clearing and inverting now gets limited to the canvas bounds
Resizing currently does not work properly with negative (left & up) canvas boundaries
* Flip image when resizing and the bounding rectangle gets flipped
* Call move_content_confirm() when inverting selection
* Attempt to implement selection resizing that goes outside of the canvas boundaries (not working properly yet)
* Flip selection when resizing to negative bounding rectangle sizes
And fix preview_image vertical flipping
* Fix rotation so that it works (almost) properly with selections
Rotation algorithms now accept and only work with a given image, and the pivot has been added as a parameter
* Experimental gizmo rotation - does not work properly yet
Transforming the selection outside of the canvas is still broken.
* Fix some issues with moving selection out of canvas bounds
* Fix more issues with selection getting resized outside of canvas bounds
* Update marching ants effect properly when switching between projects
And make sure the frequency of the marching ants effect always looks roughly the same on all project sizes
* Made the rotation gizmo part of the gizmos array and resize them based on camera zoom
* Remove unneeded parameter from move_bitmap_values()
* Remove more unneeded parameters
* Move the selection only if the cursor is above it and neither shift nor control are currently pressed
* Gradient generation now works on non-rectangular selections
Although this behavior might not be the intended one
* Copy/paste marching ants effect offset
Useful for when the selection is in negative coords
* Fix issue with clear selection & UndoRedo
* Restore the ability to move selection when it's in negative coords
* Made the marching ants offset a Project variable
This fixes the issue of project switching and keeping the previous project's offset. Again, this is only relevant for when the selection is in negative coords.
* Made the "from current selection" palette preset work with the new selection system
* Fix out of bounds error when using the rectangular select tool on negative coords
* Some code cleanup
* Comment out the rotation gizmo for now, since it does not work properly
* Update marching ants shader params and gizmo sizes when the bitmap changes
* Move some methods around in Selection.gd
2021-04-17 18:30:12 +00:00
|
|
|
|
var root = control
|
|
|
|
|
var tool_buttons = root.find_node("ToolButtons")
|
2020-04-11 21:08:45 +00:00
|
|
|
|
|
New selection system (#474)
* Basic move tool
* Added marching ants effect on the selection borders
* Rename SelectionRectangle to SelectionShape, make it have non-rectangular shape and multiple SelectionShapes can exist
- Create multiple selection rectangles
- Merge them together if they intersect
- Move the selections (without contents as of right now)
- Gizmos are being drawn but they are not functional yet
Code is very ugly.
* Sort vectors counter-clockwise to be used as polygon borders
I did this, no idea if it works properly, probably won't be used but I thought I'd keep it saved somewhere
* More experiments I may or may not need
Trying to generate a polygon from the individual selected pixels
* Change default rectangle select behavior and ability to clip polygons using Control
* Fix rectangle selection clipping
* Split polygon into two with selection subtracting
* Move selection with contents with the move tool
Code is still a mess, don't bother looking.
* Move some methods from SelectionShape.gd to Selection.gd
The purpose of this is to generalize some selection code, so that it applies to all polygons, the entire selection. More will follow.
* UndoRedo for border moving
Nothing else in the selections system works properly in UndoRedo right now. Needs:
- UR support for creating selections
- UR support for modifying selections (merging and cutting selections together)
- UR support for removing selection
- UR support for moving content
& for all the rest of the remaining features
* Moving all of the selection shape logic to Selection.gd
Handle all of the polygons there instead of having them as individual nodes. Should be easier to handle undo/redo this way. This commit probably breaks move tool + selection tool and undo/redo. Code is still a mess. For your sanity, I hope you are not reading this. I promise I will clean up.
* Move tool works again
Buggy and messy, of course.
* Remove unneeded code and restore selection move undoredo logic
* Made Selection.gd have one big preview_image for when moving content, instead of each polygon having its own image
Could be further optimized for some specific cases. We could also remove selected_pixels from SelectionPolygon.
* UndoRedo support for creating, deleting, merging and clipping selections
UndoRedo support for moving content not added in this commit. Should work but needs more testing. This PR also removes selected_pixels from the SelectionPolygon class.
* Confirm & cancel selection movement, should support undoredo properly too
Press Enter or do any editing to confirm movement, Escape to cancel. I will most likely add UI buttons for confirm and cancel too.
* Mirror View affects selection
* Restore Cut, Copy, Paste and Clear Selection
Pasting now no longer requires a pre-existing selection and instead copies the selections themselves too.
* Created a new Select menu, which has Select All and Clear Selection as options
Clear Selection now also confirms content moving. TopMenuContainer code has changed to no longer rely on Global for the menu buttons.
* Draw gizmos as rectangles
No functionality yet. They may need to be turned to nodes, so that they can easily resize based on zoom level and check for mouse enter/exit events.
* Made gizmos get drawn in the sides and corners of the big bounding rectangle instead of individual selection parts
Still no functionality yet.
* Restore label text
* Minor optimization when clipping selections
This will execute the for loop less times
* Made a Gizmo class, cursor change on hover, has_focus = false on mouse click
Now I should actually make them resize when dragged, aye?
* Very basic gizmo resizing, still a WIP, does not work properly yet
* Start replacing the array of selected pixels with a BitMap
This should optimize the selection making a lot, and it also allows for easy border drawing without having to deal with polygons, thanks to the MarchingAntsOutline.shader
Still commit is still a WIP, image effects and brushes may not work properly yet.
Because the BitMap has a fixed size, the size of the project, moving the selection outside of canvas boundaries has proven to be a bit tricky. I did implement a hacky way of handling it, but it may be buggy and problematic. I'm still unsure whether this is the best way to handle the situation.
* Selection works with mirror view
* Draw a black rectangle when the user is making a rectangular selection
After they release the mouse, the black rectangle becomes the selection
* Make Selection.gd update when undoing/redoing
* Fix brushes not working properly with non-rectangular selections
* Added invert selection
* Cache has_selection as a variable for a speedup
* Fix conflict issues with the shape tools
* Made the bitmap image squared so the marching ants effect will be the same on both dimensions
There may be a better way to fix the issue, perhaps inside the shader itself.
* Some optimizations to call selection_bitmap_changed() less times
* Restored almost all of the image effects
Left to do:
- Change gradient's behavior. Unsure of how it will work with non-rectangular selections yet, but it should not generate pixels outside of the selection.
- Restore rotation
- Resize bitmap on image resize
- Remove the `pixels` array from the ImageEffect
* Fix Selection.gd not updating when changing project
* Resize the selection bitmap along with image resize
* Restored rotation's old behavior and finally got rid of the selected_pixels array
The rotation does not yet work properly with selections, but at least it now "works".
* Resize selection too when using gizmos
Left to do for gizmos:
- Proper cancel transformation
- Begin transformation
(currently named move_content_start but it should be renamed to something more general) when resizing gizmos
- Keep the original image and selection in memory and resize them. Meaning, gizmos should not resize the already resized data, but only resize the original. This is less destructive as there is no danger of data loss.
- Always resize on InputEventMouseMotion. This is going to be worse for performance, but it will look better for the user.
* Image and bitmap resizing now uses the original data and begin transformation on gizmo click
No matter how many times the user resizes on the current transformation, the original data will not be lost until they either confirm or cancel, so there is no data loss before confirmation/cancel.
* Cancel transformation now works properly when the selection has been resized
* Made gizmos resize on mouse motion, fix issues with negative bounding rectangle and when combined with the move tool
* Resizing can now get out of positive bounds, clearing and inverting now gets limited to the canvas bounds
Resizing currently does not work properly with negative (left & up) canvas boundaries
* Flip image when resizing and the bounding rectangle gets flipped
* Call move_content_confirm() when inverting selection
* Attempt to implement selection resizing that goes outside of the canvas boundaries (not working properly yet)
* Flip selection when resizing to negative bounding rectangle sizes
And fix preview_image vertical flipping
* Fix rotation so that it works (almost) properly with selections
Rotation algorithms now accept and only work with a given image, and the pivot has been added as a parameter
* Experimental gizmo rotation - does not work properly yet
Transforming the selection outside of the canvas is still broken.
* Fix some issues with moving selection out of canvas bounds
* Fix more issues with selection getting resized outside of canvas bounds
* Update marching ants effect properly when switching between projects
And make sure the frequency of the marching ants effect always looks roughly the same on all project sizes
* Made the rotation gizmo part of the gizmos array and resize them based on camera zoom
* Remove unneeded parameter from move_bitmap_values()
* Remove more unneeded parameters
* Move the selection only if the cursor is above it and neither shift nor control are currently pressed
* Gradient generation now works on non-rectangular selections
Although this behavior might not be the intended one
* Copy/paste marching ants effect offset
Useful for when the selection is in negative coords
* Fix issue with clear selection & UndoRedo
* Restore the ability to move selection when it's in negative coords
* Made the marching ants offset a Project variable
This fixes the issue of project switching and keeping the previous project's offset. Again, this is only relevant for when the selection is in negative coords.
* Made the "from current selection" palette preset work with the new selection system
* Fix out of bounds error when using the rectangular select tool on negative coords
* Some code cleanup
* Comment out the rotation gizmo for now, since it does not work properly
* Update marching ants shader params and gizmo sizes when the bitmap changes
* Move some methods around in Selection.gd
2021-04-17 18:30:12 +00:00
|
|
|
|
var rect_select : BaseButton = tool_buttons.find_node("RectSelect")
|
2020-04-11 21:08:45 +00:00
|
|
|
|
rect_select.hint_tooltip = tr("""Rectangular Selection
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button
|
|
|
|
|
|
|
|
|
|
Press %s to move the content""") % [InputMap.get_action_list("left_rectangle_select_tool")[0].as_text(), InputMap.get_action_list("right_rectangle_select_tool")[0].as_text(), "Shift"]
|
|
|
|
|
|
New selection system (#474)
* Basic move tool
* Added marching ants effect on the selection borders
* Rename SelectionRectangle to SelectionShape, make it have non-rectangular shape and multiple SelectionShapes can exist
- Create multiple selection rectangles
- Merge them together if they intersect
- Move the selections (without contents as of right now)
- Gizmos are being drawn but they are not functional yet
Code is very ugly.
* Sort vectors counter-clockwise to be used as polygon borders
I did this, no idea if it works properly, probably won't be used but I thought I'd keep it saved somewhere
* More experiments I may or may not need
Trying to generate a polygon from the individual selected pixels
* Change default rectangle select behavior and ability to clip polygons using Control
* Fix rectangle selection clipping
* Split polygon into two with selection subtracting
* Move selection with contents with the move tool
Code is still a mess, don't bother looking.
* Move some methods from SelectionShape.gd to Selection.gd
The purpose of this is to generalize some selection code, so that it applies to all polygons, the entire selection. More will follow.
* UndoRedo for border moving
Nothing else in the selections system works properly in UndoRedo right now. Needs:
- UR support for creating selections
- UR support for modifying selections (merging and cutting selections together)
- UR support for removing selection
- UR support for moving content
& for all the rest of the remaining features
* Moving all of the selection shape logic to Selection.gd
Handle all of the polygons there instead of having them as individual nodes. Should be easier to handle undo/redo this way. This commit probably breaks move tool + selection tool and undo/redo. Code is still a mess. For your sanity, I hope you are not reading this. I promise I will clean up.
* Move tool works again
Buggy and messy, of course.
* Remove unneeded code and restore selection move undoredo logic
* Made Selection.gd have one big preview_image for when moving content, instead of each polygon having its own image
Could be further optimized for some specific cases. We could also remove selected_pixels from SelectionPolygon.
* UndoRedo support for creating, deleting, merging and clipping selections
UndoRedo support for moving content not added in this commit. Should work but needs more testing. This PR also removes selected_pixels from the SelectionPolygon class.
* Confirm & cancel selection movement, should support undoredo properly too
Press Enter or do any editing to confirm movement, Escape to cancel. I will most likely add UI buttons for confirm and cancel too.
* Mirror View affects selection
* Restore Cut, Copy, Paste and Clear Selection
Pasting now no longer requires a pre-existing selection and instead copies the selections themselves too.
* Created a new Select menu, which has Select All and Clear Selection as options
Clear Selection now also confirms content moving. TopMenuContainer code has changed to no longer rely on Global for the menu buttons.
* Draw gizmos as rectangles
No functionality yet. They may need to be turned to nodes, so that they can easily resize based on zoom level and check for mouse enter/exit events.
* Made gizmos get drawn in the sides and corners of the big bounding rectangle instead of individual selection parts
Still no functionality yet.
* Restore label text
* Minor optimization when clipping selections
This will execute the for loop less times
* Made a Gizmo class, cursor change on hover, has_focus = false on mouse click
Now I should actually make them resize when dragged, aye?
* Very basic gizmo resizing, still a WIP, does not work properly yet
* Start replacing the array of selected pixels with a BitMap
This should optimize the selection making a lot, and it also allows for easy border drawing without having to deal with polygons, thanks to the MarchingAntsOutline.shader
Still commit is still a WIP, image effects and brushes may not work properly yet.
Because the BitMap has a fixed size, the size of the project, moving the selection outside of canvas boundaries has proven to be a bit tricky. I did implement a hacky way of handling it, but it may be buggy and problematic. I'm still unsure whether this is the best way to handle the situation.
* Selection works with mirror view
* Draw a black rectangle when the user is making a rectangular selection
After they release the mouse, the black rectangle becomes the selection
* Make Selection.gd update when undoing/redoing
* Fix brushes not working properly with non-rectangular selections
* Added invert selection
* Cache has_selection as a variable for a speedup
* Fix conflict issues with the shape tools
* Made the bitmap image squared so the marching ants effect will be the same on both dimensions
There may be a better way to fix the issue, perhaps inside the shader itself.
* Some optimizations to call selection_bitmap_changed() less times
* Restored almost all of the image effects
Left to do:
- Change gradient's behavior. Unsure of how it will work with non-rectangular selections yet, but it should not generate pixels outside of the selection.
- Restore rotation
- Resize bitmap on image resize
- Remove the `pixels` array from the ImageEffect
* Fix Selection.gd not updating when changing project
* Resize the selection bitmap along with image resize
* Restored rotation's old behavior and finally got rid of the selected_pixels array
The rotation does not yet work properly with selections, but at least it now "works".
* Resize selection too when using gizmos
Left to do for gizmos:
- Proper cancel transformation
- Begin transformation
(currently named move_content_start but it should be renamed to something more general) when resizing gizmos
- Keep the original image and selection in memory and resize them. Meaning, gizmos should not resize the already resized data, but only resize the original. This is less destructive as there is no danger of data loss.
- Always resize on InputEventMouseMotion. This is going to be worse for performance, but it will look better for the user.
* Image and bitmap resizing now uses the original data and begin transformation on gizmo click
No matter how many times the user resizes on the current transformation, the original data will not be lost until they either confirm or cancel, so there is no data loss before confirmation/cancel.
* Cancel transformation now works properly when the selection has been resized
* Made gizmos resize on mouse motion, fix issues with negative bounding rectangle and when combined with the move tool
* Resizing can now get out of positive bounds, clearing and inverting now gets limited to the canvas bounds
Resizing currently does not work properly with negative (left & up) canvas boundaries
* Flip image when resizing and the bounding rectangle gets flipped
* Call move_content_confirm() when inverting selection
* Attempt to implement selection resizing that goes outside of the canvas boundaries (not working properly yet)
* Flip selection when resizing to negative bounding rectangle sizes
And fix preview_image vertical flipping
* Fix rotation so that it works (almost) properly with selections
Rotation algorithms now accept and only work with a given image, and the pivot has been added as a parameter
* Experimental gizmo rotation - does not work properly yet
Transforming the selection outside of the canvas is still broken.
* Fix some issues with moving selection out of canvas bounds
* Fix more issues with selection getting resized outside of canvas bounds
* Update marching ants effect properly when switching between projects
And make sure the frequency of the marching ants effect always looks roughly the same on all project sizes
* Made the rotation gizmo part of the gizmos array and resize them based on camera zoom
* Remove unneeded parameter from move_bitmap_values()
* Remove more unneeded parameters
* Move the selection only if the cursor is above it and neither shift nor control are currently pressed
* Gradient generation now works on non-rectangular selections
Although this behavior might not be the intended one
* Copy/paste marching ants effect offset
Useful for when the selection is in negative coords
* Fix issue with clear selection & UndoRedo
* Restore the ability to move selection when it's in negative coords
* Made the marching ants offset a Project variable
This fixes the issue of project switching and keeping the previous project's offset. Again, this is only relevant for when the selection is in negative coords.
* Made the "from current selection" palette preset work with the new selection system
* Fix out of bounds error when using the rectangular select tool on negative coords
* Some code cleanup
* Comment out the rotation gizmo for now, since it does not work properly
* Update marching ants shader params and gizmo sizes when the bitmap changes
* Move some methods around in Selection.gd
2021-04-17 18:30:12 +00:00
|
|
|
|
var move_select : BaseButton = tool_buttons.find_node("Move")
|
|
|
|
|
move_select.hint_tooltip = tr("""Move
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button""") % [InputMap.get_action_list("left_move_tool")[0].as_text(), InputMap.get_action_list("right_move_tool")[0].as_text()]
|
|
|
|
|
|
|
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
var zoom_tool : BaseButton = find_node_by_name(root, "Zoom")
|
|
|
|
|
zoom_tool.hint_tooltip = tr("""Zoom
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button""") % [InputMap.get_action_list("left_zoom_tool")[0].as_text(), InputMap.get_action_list("right_zoom_tool")[0].as_text()]
|
|
|
|
|
|
2020-12-23 18:41:42 +00:00
|
|
|
|
var pan_tool : BaseButton = find_node_by_name(root, "Pan")
|
|
|
|
|
pan_tool.hint_tooltip = tr("""Pan
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button""") % [InputMap.get_action_list("left_pan_tool")[0].as_text(), InputMap.get_action_list("right_pan_tool")[0].as_text()]
|
2020-04-13 02:07:52 +00:00
|
|
|
|
|
2020-04-11 21:08:45 +00:00
|
|
|
|
var color_picker : BaseButton = find_node_by_name(root, "ColorPicker")
|
|
|
|
|
color_picker.hint_tooltip = tr("""Color Picker
|
|
|
|
|
Select a color from a pixel of the sprite
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button""") % [InputMap.get_action_list("left_colorpicker_tool")[0].as_text(), InputMap.get_action_list("right_colorpicker_tool")[0].as_text()]
|
|
|
|
|
|
|
|
|
|
var pencil : BaseButton = find_node_by_name(root, "Pencil")
|
|
|
|
|
pencil.hint_tooltip = tr("""Pencil
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button
|
|
|
|
|
|
|
|
|
|
Hold %s to make a line""") % [InputMap.get_action_list("left_pencil_tool")[0].as_text(), InputMap.get_action_list("right_pencil_tool")[0].as_text(), "Shift"]
|
|
|
|
|
|
|
|
|
|
var eraser : BaseButton = find_node_by_name(root, "Eraser")
|
|
|
|
|
eraser.hint_tooltip = tr("""Eraser
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button
|
|
|
|
|
|
|
|
|
|
Hold %s to make a line""") % [InputMap.get_action_list("left_eraser_tool")[0].as_text(), InputMap.get_action_list("right_eraser_tool")[0].as_text(), "Shift"]
|
|
|
|
|
|
|
|
|
|
var bucket : BaseButton = find_node_by_name(root, "Bucket")
|
|
|
|
|
bucket.hint_tooltip = tr("""Bucket
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button""") % [InputMap.get_action_list("left_fill_tool")[0].as_text(), InputMap.get_action_list("right_fill_tool")[0].as_text()]
|
|
|
|
|
|
|
|
|
|
var ld : BaseButton = find_node_by_name(root, "LightenDarken")
|
|
|
|
|
ld.hint_tooltip = tr("""Lighten/Darken
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button""") % [InputMap.get_action_list("left_lightdark_tool")[0].as_text(), InputMap.get_action_list("right_lightdark_tool")[0].as_text()]
|
|
|
|
|
|
2021-03-30 17:07:13 +00:00
|
|
|
|
var recttool : BaseButton = find_node_by_name(root, "RectangleTool")
|
|
|
|
|
recttool.hint_tooltip = tr("""Rectangle Tool
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button
|
|
|
|
|
|
|
|
|
|
Hold %s to create a 1:1 shape
|
|
|
|
|
Hold %s to center the shape on the click origin""") % [InputMap.get_action_list("left_rectangletool_tool")[0].as_text(), InputMap.get_action_list("right_rectangletool_tool")[0].as_text(), "Shift", "Ctrl" ]
|
|
|
|
|
|
|
|
|
|
var ellipsetool : BaseButton = find_node_by_name(root, "EllipseTool")
|
|
|
|
|
ellipsetool.hint_tooltip = tr("""Ellipse Tool
|
|
|
|
|
|
|
|
|
|
%s for left mouse button
|
|
|
|
|
%s for right mouse button
|
|
|
|
|
|
|
|
|
|
Hold %s to create a 1:1 shape
|
|
|
|
|
Hold %s to center the shape on the click origin""") % [InputMap.get_action_list("left_ellipsetool_tool")[0].as_text(), InputMap.get_action_list("right_ellipsetool_tool")[0].as_text(), "Shift", "Ctrl" ]
|
|
|
|
|
|
2020-04-12 16:50:14 +00:00
|
|
|
|
var color_switch : BaseButton = find_node_by_name(root, "ColorSwitch")
|
|
|
|
|
color_switch.hint_tooltip = tr("""Switch left and right colors
|
2020-04-15 18:52:20 +00:00
|
|
|
|
(%s)""") % InputMap.get_action_list("switch_colors")[0].as_text()
|
2020-04-12 16:50:14 +00:00
|
|
|
|
|
|
|
|
|
var first_frame : BaseButton = find_node_by_name(root, "FirstFrame")
|
|
|
|
|
first_frame.hint_tooltip = tr("""Jump to the first frame
|
2020-06-27 13:01:17 +00:00
|
|
|
|
(%s)""") % InputMap.get_action_list("go_to_first_frame")[0].as_text()
|
2020-04-12 16:50:14 +00:00
|
|
|
|
|
|
|
|
|
var previous_frame : BaseButton = find_node_by_name(root, "PreviousFrame")
|
|
|
|
|
previous_frame.hint_tooltip = tr("""Go to the previous frame
|
2020-06-27 13:01:17 +00:00
|
|
|
|
(%s)""") % InputMap.get_action_list("go_to_previous_frame")[0].as_text()
|
2020-04-12 16:50:14 +00:00
|
|
|
|
|
|
|
|
|
play_backwards.hint_tooltip = tr("""Play the animation backwards (from end to beginning)
|
2020-06-27 13:01:17 +00:00
|
|
|
|
(%s)""") % InputMap.get_action_list("play_backwards")[0].as_text()
|
2020-04-12 16:50:14 +00:00
|
|
|
|
|
|
|
|
|
play_forward.hint_tooltip = tr("""Play the animation forward (from beginning to end)
|
2020-06-27 13:01:17 +00:00
|
|
|
|
(%s)""") % InputMap.get_action_list("play_forward")[0].as_text()
|
2020-04-12 16:50:14 +00:00
|
|
|
|
|
|
|
|
|
var next_frame : BaseButton = find_node_by_name(root, "NextFrame")
|
|
|
|
|
next_frame.hint_tooltip = tr("""Go to the next frame
|
2020-06-27 13:01:17 +00:00
|
|
|
|
(%s)""") % InputMap.get_action_list("go_to_next_frame")[0].as_text()
|
2020-04-12 16:50:14 +00:00
|
|
|
|
|
|
|
|
|
var last_frame : BaseButton = find_node_by_name(root, "LastFrame")
|
|
|
|
|
last_frame.hint_tooltip = tr("""Jump to the last frame
|
2020-06-27 13:01:17 +00:00
|
|
|
|
(%s)""") % InputMap.get_action_list("go_to_last_frame")[0].as_text()
|
2020-04-12 16:50:14 +00:00
|
|
|
|
|
2020-04-11 21:08:45 +00:00
|
|
|
|
|
2020-10-28 22:45:23 +00:00
|
|
|
|
func is_cjk(locale : String) -> bool:
|
2020-12-12 13:05:03 +00:00
|
|
|
|
return "zh" in locale or "ko" in locale or "ja" in locale
|
2020-10-28 22:45:23 +00:00
|
|
|
|
|
|
|
|
|
|
2019-12-12 22:19:28 +00:00
|
|
|
|
func _exit_tree() -> void:
|
2021-03-06 13:59:26 +00:00
|
|
|
|
config_cache.set_value("window", "panel_layout", panel_layout)
|
2019-12-18 16:12:44 +00:00
|
|
|
|
config_cache.set_value("window", "screen", OS.current_screen)
|
|
|
|
|
config_cache.set_value("window", "maximized", OS.window_maximized || OS.window_fullscreen)
|
|
|
|
|
config_cache.set_value("window", "position", OS.window_position)
|
|
|
|
|
config_cache.set_value("window", "size", OS.window_size)
|
|
|
|
|
config_cache.save("user://cache.ini")
|
|
|
|
|
|
2020-06-05 23:16:53 +00:00
|
|
|
|
var i := 0
|
2020-06-04 18:05:36 +00:00
|
|
|
|
for project in projects:
|
|
|
|
|
project.undo_redo.free()
|
2020-06-05 23:16:53 +00:00
|
|
|
|
OpenSave.remove_backup(i)
|
|
|
|
|
i += 1
|
2020-10-26 20:51:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func save_project_to_recent_list(path : String) -> void:
|
|
|
|
|
if path.get_file().substr(0, 7) == "backup-" or path == "":
|
|
|
|
|
return
|
2020-10-27 21:03:43 +00:00
|
|
|
|
|
2020-10-26 20:51:55 +00:00
|
|
|
|
if recent_projects.has(path):
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if recent_projects.size() >= 5:
|
|
|
|
|
recent_projects.pop_front()
|
|
|
|
|
recent_projects.push_back(path)
|
2020-10-27 21:03:43 +00:00
|
|
|
|
|
2020-10-26 20:51:55 +00:00
|
|
|
|
config_cache.set_value("data", "recent_projects", recent_projects)
|
|
|
|
|
|
|
|
|
|
recent_projects_submenu.clear()
|
|
|
|
|
update_recent_projects_submenu()
|
2020-10-27 21:03:43 +00:00
|
|
|
|
|
|
|
|
|
|
2020-10-26 20:51:55 +00:00
|
|
|
|
func update_recent_projects_submenu() -> void:
|
New selection system (#474)
* Basic move tool
* Added marching ants effect on the selection borders
* Rename SelectionRectangle to SelectionShape, make it have non-rectangular shape and multiple SelectionShapes can exist
- Create multiple selection rectangles
- Merge them together if they intersect
- Move the selections (without contents as of right now)
- Gizmos are being drawn but they are not functional yet
Code is very ugly.
* Sort vectors counter-clockwise to be used as polygon borders
I did this, no idea if it works properly, probably won't be used but I thought I'd keep it saved somewhere
* More experiments I may or may not need
Trying to generate a polygon from the individual selected pixels
* Change default rectangle select behavior and ability to clip polygons using Control
* Fix rectangle selection clipping
* Split polygon into two with selection subtracting
* Move selection with contents with the move tool
Code is still a mess, don't bother looking.
* Move some methods from SelectionShape.gd to Selection.gd
The purpose of this is to generalize some selection code, so that it applies to all polygons, the entire selection. More will follow.
* UndoRedo for border moving
Nothing else in the selections system works properly in UndoRedo right now. Needs:
- UR support for creating selections
- UR support for modifying selections (merging and cutting selections together)
- UR support for removing selection
- UR support for moving content
& for all the rest of the remaining features
* Moving all of the selection shape logic to Selection.gd
Handle all of the polygons there instead of having them as individual nodes. Should be easier to handle undo/redo this way. This commit probably breaks move tool + selection tool and undo/redo. Code is still a mess. For your sanity, I hope you are not reading this. I promise I will clean up.
* Move tool works again
Buggy and messy, of course.
* Remove unneeded code and restore selection move undoredo logic
* Made Selection.gd have one big preview_image for when moving content, instead of each polygon having its own image
Could be further optimized for some specific cases. We could also remove selected_pixels from SelectionPolygon.
* UndoRedo support for creating, deleting, merging and clipping selections
UndoRedo support for moving content not added in this commit. Should work but needs more testing. This PR also removes selected_pixels from the SelectionPolygon class.
* Confirm & cancel selection movement, should support undoredo properly too
Press Enter or do any editing to confirm movement, Escape to cancel. I will most likely add UI buttons for confirm and cancel too.
* Mirror View affects selection
* Restore Cut, Copy, Paste and Clear Selection
Pasting now no longer requires a pre-existing selection and instead copies the selections themselves too.
* Created a new Select menu, which has Select All and Clear Selection as options
Clear Selection now also confirms content moving. TopMenuContainer code has changed to no longer rely on Global for the menu buttons.
* Draw gizmos as rectangles
No functionality yet. They may need to be turned to nodes, so that they can easily resize based on zoom level and check for mouse enter/exit events.
* Made gizmos get drawn in the sides and corners of the big bounding rectangle instead of individual selection parts
Still no functionality yet.
* Restore label text
* Minor optimization when clipping selections
This will execute the for loop less times
* Made a Gizmo class, cursor change on hover, has_focus = false on mouse click
Now I should actually make them resize when dragged, aye?
* Very basic gizmo resizing, still a WIP, does not work properly yet
* Start replacing the array of selected pixels with a BitMap
This should optimize the selection making a lot, and it also allows for easy border drawing without having to deal with polygons, thanks to the MarchingAntsOutline.shader
Still commit is still a WIP, image effects and brushes may not work properly yet.
Because the BitMap has a fixed size, the size of the project, moving the selection outside of canvas boundaries has proven to be a bit tricky. I did implement a hacky way of handling it, but it may be buggy and problematic. I'm still unsure whether this is the best way to handle the situation.
* Selection works with mirror view
* Draw a black rectangle when the user is making a rectangular selection
After they release the mouse, the black rectangle becomes the selection
* Make Selection.gd update when undoing/redoing
* Fix brushes not working properly with non-rectangular selections
* Added invert selection
* Cache has_selection as a variable for a speedup
* Fix conflict issues with the shape tools
* Made the bitmap image squared so the marching ants effect will be the same on both dimensions
There may be a better way to fix the issue, perhaps inside the shader itself.
* Some optimizations to call selection_bitmap_changed() less times
* Restored almost all of the image effects
Left to do:
- Change gradient's behavior. Unsure of how it will work with non-rectangular selections yet, but it should not generate pixels outside of the selection.
- Restore rotation
- Resize bitmap on image resize
- Remove the `pixels` array from the ImageEffect
* Fix Selection.gd not updating when changing project
* Resize the selection bitmap along with image resize
* Restored rotation's old behavior and finally got rid of the selected_pixels array
The rotation does not yet work properly with selections, but at least it now "works".
* Resize selection too when using gizmos
Left to do for gizmos:
- Proper cancel transformation
- Begin transformation
(currently named move_content_start but it should be renamed to something more general) when resizing gizmos
- Keep the original image and selection in memory and resize them. Meaning, gizmos should not resize the already resized data, but only resize the original. This is less destructive as there is no danger of data loss.
- Always resize on InputEventMouseMotion. This is going to be worse for performance, but it will look better for the user.
* Image and bitmap resizing now uses the original data and begin transformation on gizmo click
No matter how many times the user resizes on the current transformation, the original data will not be lost until they either confirm or cancel, so there is no data loss before confirmation/cancel.
* Cancel transformation now works properly when the selection has been resized
* Made gizmos resize on mouse motion, fix issues with negative bounding rectangle and when combined with the move tool
* Resizing can now get out of positive bounds, clearing and inverting now gets limited to the canvas bounds
Resizing currently does not work properly with negative (left & up) canvas boundaries
* Flip image when resizing and the bounding rectangle gets flipped
* Call move_content_confirm() when inverting selection
* Attempt to implement selection resizing that goes outside of the canvas boundaries (not working properly yet)
* Flip selection when resizing to negative bounding rectangle sizes
And fix preview_image vertical flipping
* Fix rotation so that it works (almost) properly with selections
Rotation algorithms now accept and only work with a given image, and the pivot has been added as a parameter
* Experimental gizmo rotation - does not work properly yet
Transforming the selection outside of the canvas is still broken.
* Fix some issues with moving selection out of canvas bounds
* Fix more issues with selection getting resized outside of canvas bounds
* Update marching ants effect properly when switching between projects
And make sure the frequency of the marching ants effect always looks roughly the same on all project sizes
* Made the rotation gizmo part of the gizmos array and resize them based on camera zoom
* Remove unneeded parameter from move_bitmap_values()
* Remove more unneeded parameters
* Move the selection only if the cursor is above it and neither shift nor control are currently pressed
* Gradient generation now works on non-rectangular selections
Although this behavior might not be the intended one
* Copy/paste marching ants effect offset
Useful for when the selection is in negative coords
* Fix issue with clear selection & UndoRedo
* Restore the ability to move selection when it's in negative coords
* Made the marching ants offset a Project variable
This fixes the issue of project switching and keeping the previous project's offset. Again, this is only relevant for when the selection is in negative coords.
* Made the "from current selection" palette preset work with the new selection system
* Fix out of bounds error when using the rectangular select tool on negative coords
* Some code cleanup
* Comment out the rotation gizmo for now, since it does not work properly
* Update marching ants shader params and gizmo sizes when the bitmap changes
* Move some methods around in Selection.gd
2021-04-17 18:30:12 +00:00
|
|
|
|
for project in recent_projects:
|
2020-10-26 20:51:55 +00:00
|
|
|
|
recent_projects_submenu.add_item(project.get_file())
|
2020-12-06 00:10:40 +00:00
|
|
|
|
|
|
|
|
|
func use_osx_shortcuts() -> void:
|
2020-12-09 16:07:12 +00:00
|
|
|
|
var inputmap := InputMap
|
|
|
|
|
|
2020-12-06 00:10:40 +00:00
|
|
|
|
for action in inputmap.get_actions():
|
2020-12-09 16:07:12 +00:00
|
|
|
|
var event : InputEvent = inputmap.get_action_list(action)[0]
|
|
|
|
|
|
2020-12-06 00:10:40 +00:00
|
|
|
|
if event.control:
|
|
|
|
|
event.control = false
|
|
|
|
|
event.command = true
|