2020-06-13 14:59:57 +00:00
|
|
|
extends Panel
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
enum FileMenuId { NEW, OPEN, OPEN_LAST_PROJECT, SAVE, SAVE_AS, EXPORT, EXPORT_AS, QUIT }
|
|
|
|
enum EditMenuId { UNDO, REDO, COPY, CUT, PASTE, DELETE, NEW_BRUSH, PREFERENCES }
|
|
|
|
enum ViewMenuId {
|
|
|
|
TILE_MODE,
|
2022-02-11 22:47:26 +00:00
|
|
|
GREYSCALE_VIEW,
|
2021-11-25 12:48:30 +00:00
|
|
|
MIRROR_VIEW,
|
|
|
|
SHOW_GRID,
|
|
|
|
SHOW_PIXEL_GRID,
|
|
|
|
SHOW_RULERS,
|
|
|
|
SHOW_GUIDES,
|
|
|
|
}
|
2022-02-16 22:54:09 +00:00
|
|
|
enum WindowMenuId { WINDOW_OPACITY, PANELS, LAYOUTS, EDIT_MODE, ZEN_MODE, FULLSCREEN_MODE }
|
2021-11-25 12:48:30 +00:00
|
|
|
enum ImageMenuId {
|
|
|
|
SCALE_IMAGE,
|
|
|
|
CENTRALIZE_IMAGE,
|
|
|
|
CROP_IMAGE,
|
|
|
|
RESIZE_CANVAS,
|
|
|
|
FLIP,
|
|
|
|
ROTATE,
|
|
|
|
INVERT_COLORS,
|
|
|
|
DESATURATION,
|
|
|
|
OUTLINE,
|
|
|
|
HSV,
|
|
|
|
GRADIENT,
|
|
|
|
SHADER
|
|
|
|
}
|
|
|
|
enum SelectMenuId { SELECT_ALL, CLEAR_SELECTION, INVERT }
|
|
|
|
enum HelpMenuId {
|
|
|
|
VIEW_SPLASH_SCREEN,
|
|
|
|
ONLINE_DOCS,
|
|
|
|
ISSUE_TRACKER,
|
|
|
|
OPEN_LOGS_FOLDER,
|
|
|
|
CHANGELOG,
|
|
|
|
ABOUT_PIXELORAMA
|
|
|
|
}
|
|
|
|
|
|
|
|
var file_menu: PopupMenu
|
|
|
|
var view_menu: PopupMenu
|
2022-02-16 22:54:09 +00:00
|
|
|
var window_menu: PopupMenu
|
2021-11-23 00:36:22 +00:00
|
|
|
var recent_projects := []
|
2022-02-01 00:31:13 +00:00
|
|
|
var layouts := [
|
|
|
|
["Default", preload("res://assets/layouts/default.tres")],
|
|
|
|
["Tallscreen", preload("res://assets/layouts/tallscreen.tres")],
|
|
|
|
]
|
2022-03-01 22:41:22 +00:00
|
|
|
var selected_layout := 0
|
2022-02-01 00:31:13 +00:00
|
|
|
var zen_mode := false
|
2021-11-23 00:36:22 +00:00
|
|
|
|
2022-01-29 22:47:25 +00:00
|
|
|
onready var ui_elements: Array = Global.control.find_node("DockableContainer").get_children()
|
2021-11-25 12:48:30 +00:00
|
|
|
onready var file_menu_button: MenuButton = find_node("FileMenu")
|
|
|
|
onready var edit_menu_button: MenuButton = find_node("EditMenu")
|
|
|
|
onready var view_menu_button: MenuButton = find_node("ViewMenu")
|
2022-02-16 22:54:09 +00:00
|
|
|
onready var window_menu_button: MenuButton = find_node("WindowMenu")
|
2021-11-25 12:48:30 +00:00
|
|
|
onready var image_menu_button: MenuButton = find_node("ImageMenu")
|
|
|
|
onready var select_menu_button: MenuButton = find_node("SelectMenu")
|
|
|
|
onready var help_menu_button: MenuButton = find_node("HelpMenu")
|
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
|
|
|
|
2022-02-14 23:42:20 +00:00
|
|
|
onready var ui: Container = Global.control.find_node("DockableContainer")
|
2021-11-25 12:48:30 +00:00
|
|
|
onready var new_image_dialog: ConfirmationDialog = Global.control.find_node("CreateNewImage")
|
|
|
|
onready var window_opacity_dialog: AcceptDialog = Global.control.find_node("WindowOpacityDialog")
|
2021-11-23 00:36:22 +00:00
|
|
|
onready var tile_mode_submenu := PopupMenu.new()
|
2022-02-06 23:18:19 +00:00
|
|
|
onready var panels_submenu := PopupMenu.new()
|
2022-02-01 00:31:13 +00:00
|
|
|
onready var layouts_submenu := PopupMenu.new()
|
2021-11-23 00:36:22 +00:00
|
|
|
onready var recent_projects_submenu := PopupMenu.new()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
2022-02-05 23:49:54 +00:00
|
|
|
var dir := Directory.new()
|
|
|
|
dir.make_dir("user://layouts")
|
2021-11-29 15:12:30 +00:00
|
|
|
_setup_file_menu()
|
|
|
|
_setup_edit_menu()
|
|
|
|
_setup_view_menu()
|
2022-02-16 22:54:09 +00:00
|
|
|
_setup_window_menu()
|
2021-11-29 15:12:30 +00:00
|
|
|
_setup_image_menu()
|
|
|
|
_setup_select_menu()
|
|
|
|
_setup_help_menu()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _setup_file_menu() -> void:
|
2021-11-25 12:48:30 +00:00
|
|
|
var file_menu_items := { # order as in FileMenuId enum
|
|
|
|
"New...": InputMap.get_action_list("new_file")[0].get_scancode_with_modifiers(),
|
|
|
|
"Open...": InputMap.get_action_list("open_file")[0].get_scancode_with_modifiers(),
|
|
|
|
"Open last project...": 0,
|
2020-10-29 20:33:15 +00:00
|
|
|
"Recent projects": 0,
|
2021-11-25 12:48:30 +00:00
|
|
|
"Save...": InputMap.get_action_list("save_file")[0].get_scancode_with_modifiers(),
|
|
|
|
"Save as...": InputMap.get_action_list("save_file_as")[0].get_scancode_with_modifiers(),
|
|
|
|
"Export...": InputMap.get_action_list("export_file")[0].get_scancode_with_modifiers(),
|
|
|
|
"Export as...": InputMap.get_action_list("export_file_as")[0].get_scancode_with_modifiers(),
|
|
|
|
"Quit": InputMap.get_action_list("quit")[0].get_scancode_with_modifiers(),
|
|
|
|
}
|
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
|
|
|
file_menu = file_menu_button.get_popup()
|
2020-06-13 14:59:57 +00:00
|
|
|
var i := 0
|
|
|
|
|
|
|
|
for item in file_menu_items.keys():
|
2020-10-26 20:51:55 +00:00
|
|
|
if item == "Recent projects":
|
2021-11-29 15:12:30 +00:00
|
|
|
_setup_recent_projects_submenu(item)
|
2020-10-26 20:51:55 +00:00
|
|
|
else:
|
|
|
|
file_menu.add_item(item, i, file_menu_items[item])
|
|
|
|
i += 1
|
2020-10-27 21:03:43 +00:00
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
file_menu.connect("id_pressed", self, "file_menu_id_pressed")
|
2020-10-27 21:03:43 +00:00
|
|
|
|
2020-07-15 15:36:46 +00:00
|
|
|
if OS.get_name() == "HTML5":
|
2021-01-20 14:59:42 +00:00
|
|
|
file_menu.set_item_disabled(FileMenuId.OPEN_LAST_PROJECT, true)
|
|
|
|
file_menu.set_item_disabled(FileMenuId.SAVE, true)
|
2020-07-15 15:36:46 +00:00
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _setup_recent_projects_submenu(item: String) -> void:
|
2021-11-22 15:37:06 +00:00
|
|
|
recent_projects = Global.config_cache.get_value("data", "recent_projects", [])
|
2021-11-29 15:12:30 +00:00
|
|
|
recent_projects_submenu.connect("id_pressed", self, "_on_recent_projects_submenu_id_pressed")
|
2021-11-22 15:37:06 +00:00
|
|
|
update_recent_projects_submenu()
|
2020-10-27 21:03:43 +00:00
|
|
|
|
2021-11-23 00:36:22 +00:00
|
|
|
file_menu.add_child(recent_projects_submenu)
|
|
|
|
file_menu.add_submenu_item(item, recent_projects_submenu.get_name())
|
2020-10-26 20:51:55 +00:00
|
|
|
|
|
|
|
|
2021-11-22 15:37:06 +00:00
|
|
|
func update_recent_projects_submenu() -> void:
|
|
|
|
for project in recent_projects:
|
2021-11-23 00:36:22 +00:00
|
|
|
recent_projects_submenu.add_item(project.get_file())
|
2021-11-22 15:37:06 +00:00
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _setup_edit_menu() -> void:
|
2021-11-25 12:48:30 +00:00
|
|
|
var edit_menu_items := { # order as in EditMenuId enum
|
|
|
|
"Undo": InputMap.get_action_list("undo")[0].get_scancode_with_modifiers(),
|
|
|
|
"Redo": InputMap.get_action_list("redo")[0].get_scancode_with_modifiers(),
|
|
|
|
"Copy": InputMap.get_action_list("copy")[0].get_scancode_with_modifiers(),
|
|
|
|
"Cut": InputMap.get_action_list("cut")[0].get_scancode_with_modifiers(),
|
|
|
|
"Paste": InputMap.get_action_list("paste")[0].get_scancode_with_modifiers(),
|
|
|
|
"Delete": InputMap.get_action_list("delete")[0].get_scancode_with_modifiers(),
|
|
|
|
"New Brush": InputMap.get_action_list("new_brush")[0].get_scancode_with_modifiers(),
|
|
|
|
"Preferences": 0
|
|
|
|
}
|
|
|
|
var edit_menu: PopupMenu = edit_menu_button.get_popup()
|
2020-06-13 14:59:57 +00:00
|
|
|
var i := 0
|
|
|
|
|
|
|
|
for item in edit_menu_items.keys():
|
|
|
|
edit_menu.add_item(item, i, edit_menu_items[item])
|
|
|
|
i += 1
|
|
|
|
|
2021-11-06 15:19:20 +00:00
|
|
|
edit_menu.set_item_disabled(6, true)
|
2020-06-13 14:59:57 +00:00
|
|
|
edit_menu.connect("id_pressed", self, "edit_menu_id_pressed")
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _setup_view_menu() -> void:
|
2021-11-25 12:48:30 +00:00
|
|
|
var view_menu_items := { # order as in ViewMenuId enum
|
|
|
|
"Tile Mode": 0,
|
2022-02-11 22:47:26 +00:00
|
|
|
"Greyscale View": 0,
|
2021-11-25 12:48:30 +00:00
|
|
|
"Mirror View": InputMap.get_action_list("mirror_view")[0].get_scancode_with_modifiers(),
|
|
|
|
"Show Grid": InputMap.get_action_list("show_grid")[0].get_scancode_with_modifiers(),
|
|
|
|
"Show Pixel Grid":
|
|
|
|
InputMap.get_action_list("show_pixel_grid")[0].get_scancode_with_modifiers(),
|
|
|
|
"Show Rulers": InputMap.get_action_list("show_rulers")[0].get_scancode_with_modifiers(),
|
|
|
|
"Show Guides": InputMap.get_action_list("show_guides")[0].get_scancode_with_modifiers(),
|
|
|
|
}
|
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
|
|
|
view_menu = view_menu_button.get_popup()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
var i := 0
|
|
|
|
for item in view_menu_items.keys():
|
2020-11-13 18:12:20 +00:00
|
|
|
if item == "Tile Mode":
|
2021-11-29 15:12:30 +00:00
|
|
|
_setup_tile_mode_submenu(item)
|
2020-11-13 18:12:20 +00:00
|
|
|
else:
|
|
|
|
view_menu.add_check_item(item, i, view_menu_items[item])
|
2020-06-13 14:59:57 +00:00
|
|
|
i += 1
|
2021-01-20 14:59:42 +00:00
|
|
|
view_menu.set_item_checked(ViewMenuId.SHOW_RULERS, true)
|
|
|
|
view_menu.set_item_checked(ViewMenuId.SHOW_GUIDES, true)
|
2020-06-13 14:59:57 +00:00
|
|
|
view_menu.hide_on_checkable_item_selection = false
|
|
|
|
view_menu.connect("id_pressed", self, "view_menu_id_pressed")
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _setup_tile_mode_submenu(item: String) -> void:
|
2021-11-22 14:15:36 +00:00
|
|
|
tile_mode_submenu.set_name("tile_mode_submenu")
|
|
|
|
tile_mode_submenu.add_radio_check_item("None", Global.TileMode.NONE)
|
|
|
|
tile_mode_submenu.set_item_checked(Global.TileMode.NONE, true)
|
|
|
|
tile_mode_submenu.add_radio_check_item("Tiled In Both Axis", Global.TileMode.BOTH)
|
|
|
|
tile_mode_submenu.add_radio_check_item("Tiled In X Axis", Global.TileMode.X_AXIS)
|
|
|
|
tile_mode_submenu.add_radio_check_item("Tiled In Y Axis", Global.TileMode.Y_AXIS)
|
|
|
|
tile_mode_submenu.hide_on_checkable_item_selection = false
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
tile_mode_submenu.connect("id_pressed", self, "_tile_mode_submenu_id_pressed")
|
2021-11-22 14:15:36 +00:00
|
|
|
view_menu.add_child(tile_mode_submenu)
|
|
|
|
view_menu.add_submenu_item(item, tile_mode_submenu.get_name())
|
2020-11-13 18:12:20 +00:00
|
|
|
|
|
|
|
|
2022-02-16 22:54:09 +00:00
|
|
|
func _setup_window_menu() -> void:
|
|
|
|
var window_menu_items := { # order as in WindowMenuId enum
|
|
|
|
"Window Opacity": 0,
|
|
|
|
"Panels": 0,
|
|
|
|
"Layouts": 0,
|
|
|
|
"Edit Mode": InputMap.get_action_list("edit_mode")[0].get_scancode_with_modifiers(),
|
|
|
|
"Zen Mode": InputMap.get_action_list("zen_mode")[0].get_scancode_with_modifiers(),
|
|
|
|
"Fullscreen Mode":
|
|
|
|
InputMap.get_action_list("toggle_fullscreen")[0].get_scancode_with_modifiers(),
|
|
|
|
}
|
|
|
|
window_menu = window_menu_button.get_popup()
|
|
|
|
|
|
|
|
var i := 0
|
|
|
|
for item in window_menu_items.keys():
|
|
|
|
if item == "Panels":
|
|
|
|
_setup_panels_submenu(item)
|
|
|
|
elif item == "Layouts":
|
|
|
|
_setup_layouts_submenu(item)
|
|
|
|
elif item == "Window Opacity":
|
|
|
|
window_menu.add_item(item, i, window_menu_items[item])
|
|
|
|
else:
|
|
|
|
window_menu.add_check_item(item, i, window_menu_items[item])
|
|
|
|
i += 1
|
|
|
|
window_menu.hide_on_checkable_item_selection = false
|
|
|
|
window_menu.connect("id_pressed", self, "window_menu_id_pressed")
|
|
|
|
# Disable window opacity item if per pixel transparency is not allowed
|
|
|
|
window_menu.set_item_disabled(
|
|
|
|
WindowMenuId.WINDOW_OPACITY,
|
|
|
|
!ProjectSettings.get_setting("display/window/per_pixel_transparency/allowed")
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-02-06 23:18:19 +00:00
|
|
|
func _setup_panels_submenu(item: String) -> void:
|
|
|
|
panels_submenu.set_name("panels_submenu")
|
|
|
|
panels_submenu.hide_on_checkable_item_selection = false
|
2022-01-29 22:47:25 +00:00
|
|
|
for element in ui_elements:
|
2022-02-06 23:18:19 +00:00
|
|
|
panels_submenu.add_check_item(element.name)
|
2022-02-14 23:42:20 +00:00
|
|
|
var is_hidden: bool = ui.is_control_hidden(element)
|
|
|
|
panels_submenu.set_item_checked(ui_elements.find(element), !is_hidden)
|
2021-11-22 14:15:36 +00:00
|
|
|
|
2022-02-06 23:18:19 +00:00
|
|
|
panels_submenu.connect("id_pressed", self, "_panels_submenu_id_pressed")
|
2022-02-16 22:54:09 +00:00
|
|
|
window_menu.add_child(panels_submenu)
|
|
|
|
window_menu.add_submenu_item(item, panels_submenu.get_name())
|
2021-03-06 13:59:26 +00:00
|
|
|
|
|
|
|
|
2022-02-01 00:31:13 +00:00
|
|
|
func _setup_layouts_submenu(item: String) -> void:
|
2022-02-05 23:49:54 +00:00
|
|
|
var dir := Directory.new()
|
|
|
|
var path := "user://layouts"
|
|
|
|
if dir.open(path) == OK:
|
|
|
|
dir.list_dir_begin()
|
|
|
|
var file_name = dir.get_next()
|
|
|
|
while file_name != "":
|
|
|
|
if !dir.current_is_dir():
|
|
|
|
var file_name_no_tres: String = file_name.get_basename()
|
|
|
|
layouts.append([file_name_no_tres, ResourceLoader.load(path.plus_file(file_name))])
|
|
|
|
file_name = dir.get_next()
|
|
|
|
|
2022-02-01 00:31:13 +00:00
|
|
|
layouts_submenu.set_name("layouts_submenu")
|
|
|
|
layouts_submenu.hide_on_checkable_item_selection = false
|
2022-02-05 23:49:54 +00:00
|
|
|
populate_layouts_submenu()
|
2022-02-01 00:31:13 +00:00
|
|
|
layouts_submenu.set_item_checked(0, true)
|
|
|
|
|
|
|
|
layouts_submenu.connect("id_pressed", self, "_layouts_submenu_id_pressed")
|
2022-02-16 22:54:09 +00:00
|
|
|
window_menu.add_child(layouts_submenu)
|
|
|
|
window_menu.add_submenu_item(item, layouts_submenu.get_name())
|
2022-02-01 00:31:13 +00:00
|
|
|
|
2022-03-01 22:41:22 +00:00
|
|
|
var saved_layout = Global.config_cache.get_value("window", "layout", 0)
|
|
|
|
set_layout(saved_layout)
|
|
|
|
|
2022-02-01 00:31:13 +00:00
|
|
|
|
2022-02-05 23:49:54 +00:00
|
|
|
func populate_layouts_submenu() -> void:
|
|
|
|
layouts_submenu.clear() # Does not do anything if it's called for the first time
|
|
|
|
for layout in layouts:
|
|
|
|
layouts_submenu.add_radio_check_item(layout[0])
|
|
|
|
|
|
|
|
layouts_submenu.add_item("Manage Layouts")
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _setup_image_menu() -> void:
|
2021-11-25 12:48:30 +00:00
|
|
|
var image_menu_items := { # order as in ImageMenuId enum
|
|
|
|
"Scale Image": 0,
|
|
|
|
"Centralize Image": 0,
|
|
|
|
"Crop Image": 0,
|
|
|
|
"Resize Canvas": 0,
|
|
|
|
"Flip": 0,
|
|
|
|
"Rotate Image": 0,
|
|
|
|
"Invert Colors": 0,
|
|
|
|
"Desaturation": 0,
|
|
|
|
"Outline": 0,
|
|
|
|
"Adjust Hue/Saturation/Value": 0,
|
|
|
|
"Gradient": 0,
|
2020-09-05 10:39:32 +00:00
|
|
|
# "Shader" : 0
|
2021-11-25 12:48:30 +00:00
|
|
|
}
|
|
|
|
var image_menu: PopupMenu = image_menu_button.get_popup()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
var i := 0
|
|
|
|
for item in image_menu_items.keys():
|
|
|
|
image_menu.add_item(item, i, image_menu_items[item])
|
2021-01-20 14:59:42 +00:00
|
|
|
if i == ImageMenuId.RESIZE_CANVAS:
|
2020-06-13 14:59:57 +00:00
|
|
|
image_menu.add_separator()
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
image_menu.connect("id_pressed", self, "image_menu_id_pressed")
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _setup_select_menu() -> void:
|
2021-11-25 12:48:30 +00:00
|
|
|
var select_menu_items := { # order as in EditMenuId enum
|
|
|
|
"All": InputMap.get_action_list("select_all")[0].get_scancode_with_modifiers(),
|
|
|
|
"Clear": InputMap.get_action_list("clear_selection")[0].get_scancode_with_modifiers(),
|
|
|
|
"Invert": InputMap.get_action_list("invert_selection")[0].get_scancode_with_modifiers(),
|
|
|
|
}
|
|
|
|
var select_menu: PopupMenu = select_menu_button.get_popup()
|
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 i := 0
|
|
|
|
|
|
|
|
for item in select_menu_items.keys():
|
|
|
|
select_menu.add_item(item, i, select_menu_items[item])
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
select_menu.connect("id_pressed", self, "select_menu_id_pressed")
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _setup_help_menu() -> void:
|
2021-11-25 12:48:30 +00:00
|
|
|
var help_menu_items := { # order as in HelpMenuId enum
|
|
|
|
"View Splash Screen": 0,
|
|
|
|
"Online Docs": InputMap.get_action_list("open_docs")[0].get_scancode_with_modifiers(),
|
|
|
|
"Issue Tracker": 0,
|
|
|
|
"Open Logs Folder": 0,
|
|
|
|
"Changelog": 0,
|
|
|
|
"About Pixelorama": 0
|
|
|
|
}
|
|
|
|
var help_menu: PopupMenu = help_menu_button.get_popup()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
var i := 0
|
|
|
|
for item in help_menu_items.keys():
|
|
|
|
help_menu.add_item(item, i, help_menu_items[item])
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
help_menu.connect("id_pressed", self, "help_menu_id_pressed")
|
|
|
|
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func file_menu_id_pressed(id: int) -> void:
|
2020-06-13 14:59:57 +00:00
|
|
|
match id:
|
2021-01-20 14:59:42 +00:00
|
|
|
FileMenuId.NEW:
|
2021-11-29 15:12:30 +00:00
|
|
|
_on_new_project_file_menu_option_pressed()
|
2021-01-20 14:59:42 +00:00
|
|
|
FileMenuId.OPEN:
|
2021-11-29 15:12:30 +00:00
|
|
|
_open_project_file()
|
2021-01-20 14:59:42 +00:00
|
|
|
FileMenuId.OPEN_LAST_PROJECT:
|
2021-11-29 15:12:30 +00:00
|
|
|
_on_open_last_project_file_menu_option_pressed()
|
2021-01-20 14:59:42 +00:00
|
|
|
FileMenuId.SAVE:
|
2021-11-29 15:12:30 +00:00
|
|
|
_save_project_file()
|
2021-01-20 14:59:42 +00:00
|
|
|
FileMenuId.SAVE_AS:
|
2021-11-29 15:12:30 +00:00
|
|
|
_save_project_file_as()
|
2021-01-20 14:59:42 +00:00
|
|
|
FileMenuId.EXPORT:
|
2021-11-29 15:12:30 +00:00
|
|
|
_export_file()
|
2021-01-20 14:59:42 +00:00
|
|
|
FileMenuId.EXPORT_AS:
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.export_dialog.popup_centered()
|
|
|
|
Global.dialog_open(true)
|
2021-01-20 14:59:42 +00:00
|
|
|
FileMenuId.QUIT:
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.control.show_quit_dialog()
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _on_new_project_file_menu_option_pressed() -> void:
|
2021-11-23 00:36:22 +00:00
|
|
|
new_image_dialog.popup_centered()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _open_project_file() -> void:
|
2020-06-30 19:29:24 +00:00
|
|
|
if OS.get_name() == "HTML5":
|
|
|
|
Html5FileExchange.load_image()
|
|
|
|
else:
|
|
|
|
Global.open_sprites_dialog.popup_centered()
|
|
|
|
Global.dialog_open(true)
|
|
|
|
Global.control.opensprite_file_selected = false
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _on_open_last_project_file_menu_option_pressed() -> void:
|
2020-06-13 14:59:57 +00:00
|
|
|
if Global.config_cache.has_section_key("preferences", "last_project_path"):
|
|
|
|
Global.control.load_last_project()
|
2021-11-25 12:48:30 +00:00
|
|
|
else:
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.error_dialog.set_text("You haven't saved or opened any project in Pixelorama yet!")
|
|
|
|
Global.error_dialog.popup_centered()
|
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _save_project_file() -> void:
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.control.is_quitting_on_save = false
|
2020-06-30 17:25:43 +00:00
|
|
|
var path = OpenSave.current_save_paths[Global.current_project_index]
|
|
|
|
if path == "":
|
|
|
|
if OS.get_name() == "HTML5":
|
2021-11-25 12:48:30 +00:00
|
|
|
var save_dialog: ConfirmationDialog = Global.save_sprites_html5_dialog
|
|
|
|
var save_filename = save_dialog.get_node("FileNameContainer/FileNameLineEdit")
|
|
|
|
save_dialog.popup_centered()
|
|
|
|
save_filename.text = Global.current_project.name
|
2020-06-30 17:25:43 +00:00
|
|
|
else:
|
|
|
|
Global.save_sprites_dialog.popup_centered()
|
2021-05-24 14:03:56 +00:00
|
|
|
Global.save_sprites_dialog.current_file = Global.current_project.name
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|
|
|
|
else:
|
2021-11-25 12:48:30 +00:00
|
|
|
Global.control.save_project(path)
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _save_project_file_as() -> void:
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.control.is_quitting_on_save = false
|
2020-06-30 17:25:43 +00:00
|
|
|
if OS.get_name() == "HTML5":
|
2021-11-25 12:48:30 +00:00
|
|
|
var save_dialog: ConfirmationDialog = Global.save_sprites_html5_dialog
|
|
|
|
var save_filename = save_dialog.get_node("FileNameContainer/FileNameLineEdit")
|
|
|
|
save_dialog.popup_centered()
|
|
|
|
save_filename.text = Global.current_project.name
|
2020-06-30 17:25:43 +00:00
|
|
|
else:
|
|
|
|
Global.save_sprites_dialog.popup_centered()
|
2021-05-24 14:03:56 +00:00
|
|
|
Global.save_sprites_dialog.current_file = Global.current_project.name
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _export_file() -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
if Export.was_exported == false:
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.export_dialog.popup_centered()
|
|
|
|
Global.dialog_open(true)
|
|
|
|
else:
|
2020-08-28 15:05:49 +00:00
|
|
|
Export.external_export()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _on_recent_projects_submenu_id_pressed(id: int) -> void:
|
2021-11-22 15:37:06 +00:00
|
|
|
Global.control.load_recent_project_file(recent_projects[id])
|
2020-10-26 20:51:55 +00:00
|
|
|
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func edit_menu_id_pressed(id: int) -> void:
|
2020-06-13 14:59:57 +00:00
|
|
|
match id:
|
2021-01-20 14:59:42 +00:00
|
|
|
EditMenuId.UNDO:
|
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
|
|
|
Global.current_project.commit_undo()
|
2021-01-20 14:59:42 +00:00
|
|
|
EditMenuId.REDO:
|
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
|
|
|
Global.current_project.commit_redo()
|
2021-01-20 14:59:42 +00:00
|
|
|
EditMenuId.COPY:
|
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
|
|
|
Global.canvas.selection.copy()
|
2021-01-20 14:59:42 +00:00
|
|
|
EditMenuId.CUT:
|
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
|
|
|
Global.canvas.selection.cut()
|
2021-01-20 14:59:42 +00:00
|
|
|
EditMenuId.PASTE:
|
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
|
|
|
Global.canvas.selection.paste()
|
2021-01-20 14:59:42 +00:00
|
|
|
EditMenuId.DELETE:
|
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
|
|
|
Global.canvas.selection.delete()
|
2021-05-25 19:48:37 +00:00
|
|
|
EditMenuId.NEW_BRUSH:
|
|
|
|
Global.canvas.selection.new_brush()
|
2021-01-20 14:59:42 +00:00
|
|
|
EditMenuId.PREFERENCES:
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.preferences_dialog.popup_centered(Vector2(400, 280))
|
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func view_menu_id_pressed(id: int) -> void:
|
2020-06-13 14:59:57 +00:00
|
|
|
match id:
|
2022-02-11 22:47:26 +00:00
|
|
|
ViewMenuId.GREYSCALE_VIEW:
|
|
|
|
_toggle_greyscale_view()
|
2021-01-20 14:59:42 +00:00
|
|
|
ViewMenuId.MIRROR_VIEW:
|
2021-11-29 15:12:30 +00:00
|
|
|
_toggle_mirror_view()
|
2021-01-20 14:59:42 +00:00
|
|
|
ViewMenuId.SHOW_GRID:
|
2021-11-29 15:12:30 +00:00
|
|
|
_toggle_show_grid()
|
2021-01-20 14:59:42 +00:00
|
|
|
ViewMenuId.SHOW_PIXEL_GRID:
|
2021-11-29 15:12:30 +00:00
|
|
|
_toggle_show_pixel_grid()
|
2021-01-20 14:59:42 +00:00
|
|
|
ViewMenuId.SHOW_RULERS:
|
2021-11-29 15:12:30 +00:00
|
|
|
_toggle_show_rulers()
|
2021-01-20 14:59:42 +00:00
|
|
|
ViewMenuId.SHOW_GUIDES:
|
2021-11-29 15:12:30 +00:00
|
|
|
_toggle_show_guides()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.canvas.update()
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _tile_mode_submenu_id_pressed(id: int) -> void:
|
2021-01-16 18:24:46 +00:00
|
|
|
Global.current_project.tile_mode = id
|
2021-01-28 19:21:48 +00:00
|
|
|
Global.transparent_checker.fit_rect(Global.current_project.get_tile_mode_rect())
|
2021-01-20 14:59:42 +00:00
|
|
|
for i in Global.TileMode.values():
|
2021-11-22 14:15:36 +00:00
|
|
|
tile_mode_submenu.set_item_checked(i, i == id)
|
2020-11-13 18:12:20 +00:00
|
|
|
Global.canvas.tile_mode.update()
|
2021-01-16 18:24:46 +00:00
|
|
|
Global.canvas.pixel_grid.update()
|
2021-01-18 20:59:26 +00:00
|
|
|
Global.canvas.grid.update()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
2022-02-16 22:54:09 +00:00
|
|
|
func window_menu_id_pressed(id: int) -> void:
|
|
|
|
match id:
|
|
|
|
WindowMenuId.WINDOW_OPACITY:
|
|
|
|
window_opacity_dialog.popup_centered()
|
|
|
|
Global.dialog_open(true)
|
|
|
|
WindowMenuId.EDIT_MODE:
|
|
|
|
ui.tabs_visible = !ui.tabs_visible
|
|
|
|
window_menu.set_item_checked(WindowMenuId.EDIT_MODE, ui.tabs_visible)
|
|
|
|
WindowMenuId.ZEN_MODE:
|
|
|
|
_toggle_zen_mode()
|
|
|
|
WindowMenuId.FULLSCREEN_MODE:
|
|
|
|
_toggle_fullscreen()
|
|
|
|
|
|
|
|
|
2022-02-06 23:18:19 +00:00
|
|
|
func _panels_submenu_id_pressed(id: int) -> void:
|
2022-01-29 22:47:25 +00:00
|
|
|
if zen_mode:
|
|
|
|
return
|
2022-02-06 23:18:19 +00:00
|
|
|
var element_visible = panels_submenu.is_item_checked(id)
|
2022-02-14 23:42:20 +00:00
|
|
|
ui.set_control_hidden(ui_elements[id], element_visible)
|
2022-02-06 23:18:19 +00:00
|
|
|
panels_submenu.set_item_checked(id, !element_visible)
|
2021-03-06 13:59:26 +00:00
|
|
|
|
|
|
|
|
2022-02-01 00:31:13 +00:00
|
|
|
func _layouts_submenu_id_pressed(id: int) -> void:
|
2022-02-05 23:49:54 +00:00
|
|
|
if id < layouts.size():
|
|
|
|
set_layout(id)
|
|
|
|
else:
|
|
|
|
Global.control.get_node("Dialogs/ManageLayouts").popup_centered()
|
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
|
|
|
func set_layout(id: int) -> void:
|
2022-03-01 22:41:22 +00:00
|
|
|
if id >= layouts.size():
|
|
|
|
id = 0
|
|
|
|
selected_layout = id
|
|
|
|
ui.layout = layouts[id][1].clone() # Clone is needed to avoid modifying premade layouts
|
2022-02-01 00:31:13 +00:00
|
|
|
for i in layouts.size():
|
|
|
|
layouts_submenu.set_item_checked(i, i == id)
|
|
|
|
|
|
|
|
for i in ui_elements.size():
|
2022-02-14 23:42:20 +00:00
|
|
|
var is_hidden: bool = ui.is_control_hidden(ui_elements[i])
|
|
|
|
panels_submenu.set_item_checked(i, !is_hidden)
|
2022-02-01 00:31:13 +00:00
|
|
|
|
2022-03-01 22:41:22 +00:00
|
|
|
# Turn zen mode off
|
|
|
|
if zen_mode:
|
|
|
|
Global.control.find_node("TabsContainer").visible = true
|
|
|
|
zen_mode = false
|
|
|
|
window_menu.set_item_checked(WindowMenuId.ZEN_MODE, false)
|
2022-02-02 00:51:43 +00:00
|
|
|
|
2022-02-01 00:31:13 +00:00
|
|
|
|
2022-02-11 22:47:26 +00:00
|
|
|
func _toggle_greyscale_view() -> void:
|
|
|
|
Global.greyscale_view = !Global.greyscale_view
|
|
|
|
Global.greyscale_vision.visible = Global.greyscale_view
|
|
|
|
view_menu.set_item_checked(ViewMenuId.GREYSCALE_VIEW, Global.greyscale_view)
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _toggle_mirror_view() -> void:
|
2020-11-23 16:53:21 +00:00
|
|
|
Global.mirror_view = !Global.mirror_view
|
2021-11-25 12:48:30 +00:00
|
|
|
var marching_ants_outline: Sprite = Global.canvas.selection.marching_ants_outline
|
|
|
|
marching_ants_outline.scale.x = -marching_ants_outline.scale.x
|
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 Global.mirror_view:
|
2021-11-25 12:48:30 +00:00
|
|
|
marching_ants_outline.position.x = (
|
|
|
|
marching_ants_outline.position.x
|
|
|
|
+ Global.current_project.size.x
|
|
|
|
)
|
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
|
|
|
else:
|
|
|
|
Global.canvas.selection.marching_ants_outline.position.x = 0
|
|
|
|
Global.canvas.selection.update()
|
2021-01-20 14:59:42 +00:00
|
|
|
view_menu.set_item_checked(ViewMenuId.MIRROR_VIEW, Global.mirror_view)
|
2020-11-23 16:53:21 +00:00
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _toggle_show_grid() -> void:
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.draw_grid = !Global.draw_grid
|
2021-01-20 14:59:42 +00:00
|
|
|
view_menu.set_item_checked(ViewMenuId.SHOW_GRID, Global.draw_grid)
|
2020-08-17 19:54:33 +00:00
|
|
|
Global.canvas.grid.update()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _toggle_show_pixel_grid() -> void:
|
2021-01-16 18:24:46 +00:00
|
|
|
Global.draw_pixel_grid = !Global.draw_pixel_grid
|
2021-01-20 14:59:42 +00:00
|
|
|
view_menu.set_item_checked(ViewMenuId.SHOW_PIXEL_GRID, Global.draw_pixel_grid)
|
2021-01-16 18:24:46 +00:00
|
|
|
Global.canvas.pixel_grid.update()
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _toggle_show_rulers() -> void:
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.show_rulers = !Global.show_rulers
|
2021-01-20 14:59:42 +00:00
|
|
|
view_menu.set_item_checked(ViewMenuId.SHOW_RULERS, Global.show_rulers)
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.horizontal_ruler.visible = Global.show_rulers
|
|
|
|
Global.vertical_ruler.visible = Global.show_rulers
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _toggle_show_guides() -> void:
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.show_guides = !Global.show_guides
|
2021-01-20 14:59:42 +00:00
|
|
|
view_menu.set_item_checked(ViewMenuId.SHOW_GUIDES, Global.show_guides)
|
2020-06-13 14:59:57 +00:00
|
|
|
for guide in Global.canvas.get_children():
|
2020-07-16 02:05:40 +00:00
|
|
|
if guide is Guide and guide in Global.current_project.guides:
|
2020-06-13 14:59:57 +00:00
|
|
|
guide.visible = Global.show_guides
|
2020-07-16 02:05:40 +00:00
|
|
|
if guide is SymmetryGuide:
|
|
|
|
if guide.type == Guide.Types.HORIZONTAL:
|
|
|
|
guide.visible = Global.show_x_symmetry_axis and Global.show_guides
|
|
|
|
else:
|
|
|
|
guide.visible = Global.show_y_symmetry_axis and Global.show_guides
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _toggle_zen_mode() -> void:
|
2022-03-01 22:01:28 +00:00
|
|
|
for i in ui_elements.size():
|
|
|
|
if ui_elements[i].name == "Main Canvas":
|
|
|
|
continue
|
|
|
|
if !panels_submenu.is_item_checked(i):
|
|
|
|
continue
|
|
|
|
ui.set_control_hidden(ui_elements[i], !zen_mode)
|
2021-11-23 00:36:22 +00:00
|
|
|
Global.control.find_node("TabsContainer").visible = zen_mode
|
2020-06-13 14:59:57 +00:00
|
|
|
zen_mode = !zen_mode
|
2022-02-16 22:54:09 +00:00
|
|
|
window_menu.set_item_checked(WindowMenuId.ZEN_MODE, zen_mode)
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _toggle_fullscreen() -> void:
|
2020-07-21 19:11:25 +00:00
|
|
|
OS.window_fullscreen = !OS.window_fullscreen
|
2022-02-16 22:54:09 +00:00
|
|
|
window_menu.set_item_checked(WindowMenuId.FULLSCREEN_MODE, OS.window_fullscreen)
|
2021-11-25 12:48:30 +00:00
|
|
|
if OS.window_fullscreen: # If window is fullscreen then reset transparency
|
|
|
|
window_opacity_dialog.set_window_opacity(1.0)
|
2020-07-21 19:11:25 +00:00
|
|
|
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func image_menu_id_pressed(id: int) -> void:
|
2020-06-13 14:59:57 +00:00
|
|
|
match id:
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.SCALE_IMAGE:
|
2021-11-29 15:12:30 +00:00
|
|
|
_show_scale_image_popup()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
2021-01-26 14:03:38 +00:00
|
|
|
ImageMenuId.CENTRALIZE_IMAGE:
|
|
|
|
DrawingAlgos.centralize()
|
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.CROP_IMAGE:
|
2021-07-20 18:30:27 +00:00
|
|
|
DrawingAlgos.crop_image()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.RESIZE_CANVAS:
|
2021-11-29 15:12:30 +00:00
|
|
|
_show_resize_canvas_popup()
|
2020-06-13 17:22:25 +00:00
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.FLIP:
|
2020-07-29 21:01:04 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/FlipImageDialog").popup_centered()
|
|
|
|
Global.dialog_open(true)
|
2020-06-13 14:59:57 +00:00
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.ROTATE:
|
2021-11-29 15:12:30 +00:00
|
|
|
_show_rotate_image_popup()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.INVERT_COLORS:
|
2020-07-31 00:39:46 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/InvertColorsDialog").popup_centered()
|
|
|
|
Global.dialog_open(true)
|
2020-06-13 14:59:57 +00:00
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.DESATURATION:
|
2020-08-01 01:24:11 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/DesaturateDialog").popup_centered()
|
|
|
|
Global.dialog_open(true)
|
2020-06-13 14:59:57 +00:00
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.OUTLINE:
|
2021-11-29 15:12:30 +00:00
|
|
|
_show_add_outline_popup()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.HSV:
|
2021-11-29 15:12:30 +00:00
|
|
|
_show_hsv_configuration_popup()
|
2020-07-29 21:01:04 +00:00
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.GRADIENT:
|
2020-07-23 01:15:18 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/GradientDialog").popup_centered()
|
2020-07-18 14:23:36 +00:00
|
|
|
Global.dialog_open(true)
|
2020-07-29 21:01:04 +00:00
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.SHADER:
|
2020-07-25 13:26:57 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/ShaderEffect").popup_centered()
|
|
|
|
Global.dialog_open(true)
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _show_scale_image_popup() -> void:
|
2020-07-23 01:15:18 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/ScaleImage").popup_centered()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _show_resize_canvas_popup() -> void:
|
2020-07-23 01:15:18 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/ResizeCanvas").popup_centered()
|
2020-06-13 17:22:25 +00:00
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _show_rotate_image_popup() -> void:
|
2020-07-23 01:15:18 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/RotateImage").popup_centered()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _show_add_outline_popup() -> void:
|
2020-07-23 01:15:18 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/OutlineDialog").popup_centered()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
2021-11-29 15:12:30 +00:00
|
|
|
func _show_hsv_configuration_popup() -> void:
|
2020-07-23 01:15:18 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/HSVDialog").popup_centered()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func select_menu_id_pressed(id: 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
|
|
|
match id:
|
|
|
|
SelectMenuId.SELECT_ALL:
|
|
|
|
Global.canvas.selection.select_all()
|
|
|
|
SelectMenuId.CLEAR_SELECTION:
|
|
|
|
Global.canvas.selection.clear_selection(true)
|
|
|
|
SelectMenuId.INVERT:
|
|
|
|
Global.canvas.selection.invert()
|
|
|
|
|
|
|
|
|
2021-11-25 12:48:30 +00:00
|
|
|
func help_menu_id_pressed(id: int) -> void:
|
2020-06-13 14:59:57 +00:00
|
|
|
match id:
|
2021-01-20 14:59:42 +00:00
|
|
|
HelpMenuId.VIEW_SPLASH_SCREEN:
|
2020-07-17 23:27:47 +00:00
|
|
|
Global.control.get_node("Dialogs/SplashDialog").popup_centered()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|
2021-01-20 14:59:42 +00:00
|
|
|
HelpMenuId.ONLINE_DOCS:
|
2020-06-13 14:59:57 +00:00
|
|
|
OS.shell_open("https://orama-interactive.github.io/Pixelorama-Docs/")
|
2021-01-20 14:59:42 +00:00
|
|
|
HelpMenuId.ISSUE_TRACKER:
|
2020-06-13 14:59:57 +00:00
|
|
|
OS.shell_open("https://github.com/Orama-Interactive/Pixelorama/issues")
|
2021-10-05 20:37:16 +00:00
|
|
|
HelpMenuId.OPEN_LOGS_FOLDER:
|
|
|
|
var dir = Directory.new()
|
2021-12-12 15:11:25 +00:00
|
|
|
dir.make_dir_recursive("user://logs") # In case someone deleted it
|
2021-10-05 20:37:16 +00:00
|
|
|
OS.shell_open(ProjectSettings.globalize_path("user://logs"))
|
2021-01-20 14:59:42 +00:00
|
|
|
HelpMenuId.CHANGELOG:
|
2021-11-25 12:48:30 +00:00
|
|
|
OS.shell_open(
|
2022-01-21 14:03:53 +00:00
|
|
|
"https://github.com/Orama-Interactive/Pixelorama/blob/master/CHANGELOG.md#v092---2022-01-21"
|
2021-11-25 12:48:30 +00:00
|
|
|
)
|
2021-01-20 14:59:42 +00:00
|
|
|
HelpMenuId.ABOUT_PIXELORAMA:
|
2020-07-17 23:27:47 +00:00
|
|
|
Global.control.get_node("Dialogs/AboutDialog").popup_centered()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|